mirror of https://github.com/portainer/portainer
Switch to ngOboe, for DI and promise interface.
parent
2514672c35
commit
6012453d2d
|
@ -1,5 +1,5 @@
|
||||||
angular.module('events', [])
|
angular.module('events', ['ngOboe'])
|
||||||
.controller('EventsController', ['Settings', '$scope', function(Settings, $scope) {
|
.controller('EventsController', ['Settings', '$scope', 'Oboe', 'Messages', '$timeout', function(Settings, $scope, oboe, Messages, $timeout) {
|
||||||
$scope.updateEvents = function() {
|
$scope.updateEvents = function() {
|
||||||
$scope.dockerEvents = [];
|
$scope.dockerEvents = [];
|
||||||
|
|
||||||
|
@ -15,11 +15,22 @@ angular.module('events', [])
|
||||||
url += 'until=' + untilSecs;
|
url += 'until=' + untilSecs;
|
||||||
}
|
}
|
||||||
|
|
||||||
oboe(url)
|
oboe({
|
||||||
.done(function(node) {
|
url: url,
|
||||||
$scope.dockerEvents.push(node);
|
pattern: '{id status time}'
|
||||||
|
})
|
||||||
|
.then(function(node) {
|
||||||
|
// finished loading
|
||||||
|
$timeout(function() {
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
});
|
});
|
||||||
|
}, function(error) {
|
||||||
|
// handle errors
|
||||||
|
Messages.error("Failure", error.data);
|
||||||
|
}, function(node) {
|
||||||
|
// node received
|
||||||
|
$scope.dockerEvents.push(node);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
"use strict";angular.module("ngOboe",[]).service("Oboe",["OboeStream",function(a){return function(b){return a.get(b)}}]).factory("OboeStream",["$q",function(a){return{get:function(b){var c=a.defer();return oboe(b).start(function(){}).node(b.pattern||".",function(a){return c.notify(a),oboe.drop}).done(function(){return oboe.drop}),c.promise}}}]);
|
|
@ -87,7 +87,8 @@ module.exports = function (grunt) {
|
||||||
src:['assets/js/angularjs/1.3.15/angular.min.js',
|
src:['assets/js/angularjs/1.3.15/angular.min.js',
|
||||||
'assets/js/angularjs/1.3.15/angular-route.min.js',
|
'assets/js/angularjs/1.3.15/angular-route.min.js',
|
||||||
'assets/js/angularjs/1.3.15/angular-resource.min.js',
|
'assets/js/angularjs/1.3.15/angular-resource.min.js',
|
||||||
'assets/js/ui-bootstrap/ui-bootstrap-custom-tpls-0.12.0.min.js'],
|
'assets/js/ui-bootstrap/ui-bootstrap-custom-tpls-0.12.0.min.js',
|
||||||
|
'assets/js/angular-oboe.min.js'],
|
||||||
dest: '<%= distdir %>/angular.js'
|
dest: '<%= distdir %>/angular.js'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -19,7 +19,7 @@ describe('ContainerController', function () {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function expectGetContainer() {
|
function expectGetContainer() {
|
||||||
$httpBackend.expectGET('dockerapi/containers/json?').respond({
|
$httpBackend.expectGET('dockerapi/containers/json').respond({
|
||||||
'Created': 1421817232,
|
'Created': 1421817232,
|
||||||
'id': 'b17882378cee8ec0136f482681b764cca430befd52a9bfd1bde031f49b8bba9f',
|
'id': 'b17882378cee8ec0136f482681b764cca430befd52a9bfd1bde031f49b8bba9f',
|
||||||
'Image': 'dockerui:latest',
|
'Image': 'dockerui:latest',
|
||||||
|
@ -41,7 +41,7 @@ describe('ContainerController', function () {
|
||||||
var newContainerName = "newName";
|
var newContainerName = "newName";
|
||||||
expectGetContainer();
|
expectGetContainer();
|
||||||
|
|
||||||
$httpBackend.expectGET('dockerapi/containers/changes?').respond([{"Kind": 1, "Path": "/docker.sock"}]);
|
$httpBackend.expectGET('dockerapi/containers/changes').respond([{"Kind": 1, "Path": "/docker.sock"}]);
|
||||||
|
|
||||||
$httpBackend.expectPOST('dockerapi/containers/' + $routeParams.id + '/rename?name=newName').
|
$httpBackend.expectPOST('dockerapi/containers/' + $routeParams.id + '/rename?name=newName').
|
||||||
respond({
|
respond({
|
||||||
|
|
Loading…
Reference in New Issue