Switch to ngOboe, for DI and promise interface.

pull/2/head
Kevan Ahlquist 2015-04-18 23:06:58 -07:00
parent 2514672c35
commit 6012453d2d
4 changed files with 21 additions and 8 deletions

View File

@ -1,5 +1,5 @@
angular.module('events', [])
.controller('EventsController', ['Settings', '$scope', function(Settings, $scope) {
angular.module('events', ['ngOboe'])
.controller('EventsController', ['Settings', '$scope', 'Oboe', 'Messages', '$timeout', function(Settings, $scope, oboe, Messages, $timeout) {
$scope.updateEvents = function() {
$scope.dockerEvents = [];
@ -15,10 +15,21 @@ angular.module('events', [])
url += 'until=' + untilSecs;
}
oboe(url)
.done(function(node) {
oboe({
url: url,
pattern: '{id status time}'
})
.then(function(node) {
// finished loading
$timeout(function() {
$scope.$apply();
});
}, function(error) {
// handle errors
Messages.error("Failure", error.data);
}, function(node) {
// node received
$scope.dockerEvents.push(node);
$scope.$apply();
});
};

1
assets/js/angular-oboe.min.js vendored Normal file
View File

@ -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}}}]);

View File

@ -87,7 +87,8 @@ module.exports = function (grunt) {
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-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'
}
},

View File

@ -19,7 +19,7 @@ describe('ContainerController', function () {
}));
function expectGetContainer() {
$httpBackend.expectGET('dockerapi/containers/json?').respond({
$httpBackend.expectGET('dockerapi/containers/json').respond({
'Created': 1421817232,
'id': 'b17882378cee8ec0136f482681b764cca430befd52a9bfd1bde031f49b8bba9f',
'Image': 'dockerui:latest',
@ -41,7 +41,7 @@ describe('ContainerController', function () {
var newContainerName = "newName";
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').
respond({