diff --git a/.eslintignore b/.eslintignore index 3d9cd50..d872a66 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1 @@ -client/bower_components +client/bower_components/** diff --git a/bower.json b/bower.json index fed1f2d..6c2defc 100644 --- a/bower.json +++ b/bower.json @@ -13,11 +13,13 @@ ], "dependencies": { "angular": "~1.3.0", + "angular-moment": "~0.10.3", "angular-route": "~1.3.0", "angular-sanitize": "~1.3.0", "bootstrap": "~3.2.0", "foundation": "~5.4.6", "foundation-icons": "*", - "jquery": "~2.1.3" + "jquery": "~2.1.3", + "moment": "~2.10.6" } } diff --git a/client/static/assets/scripts/app.js b/client/static/assets/scripts/app.js index 78c4107..3a4eef1 100644 --- a/client/static/assets/scripts/app.js +++ b/client/static/assets/scripts/app.js @@ -1,3 +1,3 @@ 'use strict'; -angular.module('LoadsApp', ['ngRoute', 'ngSanitize']); +angular.module('LoadsApp', ['ngRoute', 'ngSanitize', 'angularMoment']); diff --git a/client/static/assets/scripts/filters.js b/client/static/assets/scripts/filters.js index cfe9e78..c16c71d 100644 --- a/client/static/assets/scripts/filters.js +++ b/client/static/assets/scripts/filters.js @@ -9,4 +9,15 @@ angular.module('LoadsApp') return function (bool) { return bool ? 'success' : 'danger'; }; + }).filter('statusToText', function () { + // Converts status states to an output-friendly format. + return function (status) { + var STATUSES = [ + 'INITIALIZING', + 'RUNNING', + 'TERMINATING', + 'COMPLETED' + ]; + return STATUSES[status] || 'UNKNOWN'; + }; }); diff --git a/client/static/assets/scripts/services.js b/client/static/assets/scripts/services.js index 30e1927..481a182 100644 --- a/client/static/assets/scripts/services.js +++ b/client/static/assets/scripts/services.js @@ -1,43 +1,11 @@ 'use strict'; angular.module('LoadsApp') - .factory('RunsService', function ($rootScope, WEBSOCKET_URL) { - var cleanData = function (arr) { - return arr.map(function (result) { - var data = { - date: result[0], - name: result[1], - runId: result[2], - details: result[3] - }; - data.success = (data.details.metadata.style === 'green'); - data.cssClass = (data.success) ? 'success' : 'danger'; - data.iconClass = (data.success) ? 'checkmark' : 'remove'; - return data; - }); - }; + .factory('RunsService', function ($rootScope, $http) { - var ws = new WebSocket(WEBSOCKET_URL); - ws.onopen = function () { - console.log('Socket has been opened to %s', WEBSOCKET_URL); // eslint-disable-line no-console - }; - ws.onmessage = function (message) { - $rootScope.$apply(function () { - try { - var data = angular.fromJson(message.data); - $rootScope.runs = { - active: cleanData(data.active), - inactive: cleanData(data.inactive), - hasActive: (data.active.length !== 0), - hasInactive: (data.inactive.length !== 0), - lastSync: new Date() - }; - } catch (err) { - console.error(err); // eslint-disable-line no-console - console.log(message); // eslint-disable-line no-console - } + return $http.get('/api') + .then(function (res) { + $rootScope.runs = res.data.runs; + $rootScope.lastSync = Date.now(); }); - }; - - return ws; }); diff --git a/client/static/assets/views/_partials/footer-nav.html b/client/static/assets/views/_partials/footer-nav.html index c4b6d27..ba93fcf 100644 --- a/client/static/assets/views/_partials/footer-nav.html +++ b/client/static/assets/views/_partials/footer-nav.html @@ -5,8 +5,6 @@