Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit 3092b95

Browse files
committed
added logs to ui
1 parent 771b45b commit 3092b95

File tree

7 files changed

+52
-2
lines changed

7 files changed

+52
-2
lines changed

controller/static/app/app.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ angular.module('shipyard', [
1010
'shipyard.directives',
1111
'angular-flash.service',
1212
'angular-flash.flash-alert-directive',
13-
'angles'
13+
'angles',
14+
'ansiToHtml'
1415
])
1516
.config(['$routeProvider', '$httpProvider', '$provide', 'flashProvider',
1617
function ($routeProvider, $httpProvider, $provide, flashProvider) {
@@ -38,6 +39,10 @@ angular.module('shipyard', [
3839
templateUrl: 'templates/container_details.html',
3940
controller: 'ContainerDetailsController'
4041
});
42+
$routeProvider.when('/containers/:id/logs', {
43+
templateUrl: 'templates/container_logs.html',
44+
controller: 'ContainerLogsController'
45+
});
4146
$routeProvider.when('/engines', {
4247
templateUrl: 'templates/engines.html',
4348
controller: 'EnginesController'

controller/static/app/controllers.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,16 @@ angular.module('shipyard.controllers', ['ngCookies'])
284284
};
285285
});
286286
})
287+
.controller('ContainerLogsController', function($scope, $location, $routeParams, $http, flash, Container, ansi2html) {
288+
$scope.template = 'templates/container_logs.html';
289+
290+
$http.get('/api/containers/' + $routeParams.id + "/logs").success(function(data){
291+
$scope.logs = ansi2html.toHtml(data.replace(/\n/g, '<br/>'));
292+
});
293+
Container.query({id: $routeParams.id}, function(data){
294+
$scope.container = data;
295+
});
296+
})
287297
.controller('EnginesController', function($scope, Engines) {
288298
$scope.template = 'templates/engines.html';
289299
Engines.query(function(data){

controller/static/app/filters.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ angular.module('shipyard.filters', [])
3737
return s + " MB";
3838
};
3939
})
40+
.filter('unsafe', function ($sce) {
41+
return function(val) {
42+
return $sce.trustAsHtml(val);
43+
};
44+
})
4045
.filter('formatEvent', function () {
4146
return function (e) {
4247
var evt = "";

controller/static/bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"angular-loader": "~1.2.23",
3030
"angular-cookies": "~1.2.23",
3131
"angular-flash": "~0.1.13",
32-
"angles": "*"
32+
"angles": "*",
33+
"ansi-to-html": "jorgeecardona/ansi-to-html"
3334
}
3435
}

controller/static/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<script src="bower_components/angular-flash/dist/angular-flash.min.js"></script>
3030
<script src="bower_components/chartjs/Chart.min.js"></script>
3131
<script src="bower_components/angles/angles.js"></script>
32+
<script src="bower_components/ansi-to-html/ansi2html.js"></script>
3233
<script src="app/app.js"></script>
3334
<script src="app/services.js"></script>
3435
<script src="app/controllers.js"></script>

controller/static/templates/container_details.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
<div class="ui breadcrumb">
2+
<a href="/#/containers" class="section">containers</a>
3+
<div class="divider"> / </div>
4+
<div class="active section">{{container.id | limitTo:12}}</div>
5+
</div>
6+
17
<div class="ui basic small modal removeContainer">
28
<div class="header">
39
Destroy Container
@@ -62,6 +68,8 @@
6268
</div>
6369
</div>
6470

71+
<div></div>
72+
6573
<div class="ui icon buttons toolbar">
6674
<a ng-click="showRestartContainerDialog()" class="ui button mini green">
6775
<i class="refresh icon"></i>
@@ -86,6 +94,12 @@
8694
Scale
8795
</a>
8896
</div>
97+
<div class="ui icon buttons toolbar">
98+
<a href="/#/containers/{{container.id}}/logs" class="ui button mini black">
99+
<i class="text file outline icon"></i>
100+
Logs
101+
</a>
102+
</div>
89103

90104
<div class="ui small message red" flash-alert="error" ng-show="flash.message" duration="0">
91105
<i class="close icon"></i>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<div class="ui breadcrumb">
2+
<a href="/#/containers" class="section">containers</a>
3+
<div class="divider"> / </div>
4+
<a href="/#/containers/{{container.id}}" class="section">{{container.id | limitTo:12}}</a>
5+
<div class="divider"> / </div>
6+
<div class="active section">logs</div>
7+
</div>
8+
<div class="ui small message red" flash-alert="error" ng-show="flash.message" duration="0">
9+
<i class="close icon"></i>
10+
{{flash.message}}
11+
</div>
12+
<div class="ui segment">
13+
<div ng-bind-html="logs|unsafe"></div>
14+
</div>

0 commit comments

Comments
 (0)