From ca6fd5faf131fc234bc2f67bdf62589bea0333be Mon Sep 17 00:00:00 2001 From: Tieu-Philippe KHIM Date: Tue, 13 Feb 2018 17:43:43 +0100 Subject: [PATCH] update root js --- glances/outputs/static/js/app.js | 23 ++++---------- glances/outputs/static/js/directives.js | 5 ++- glances/outputs/static/js/filters.js | 42 ++++++++++++++++--------- glances/outputs/static/js/module.js | 23 ++++++++++++++ 4 files changed, 61 insertions(+), 32 deletions(-) create mode 100644 glances/outputs/static/js/module.js diff --git a/glances/outputs/static/js/app.js b/glances/outputs/static/js/app.js index 6bf44656..a7b56bd1 100644 --- a/glances/outputs/static/js/app.js +++ b/glances/outputs/static/js/app.js @@ -1,19 +1,8 @@ -var glancesApp = angular.module('glancesApp', ['glances.config', 'cfp.hotkeys']) -.value('CONFIG', {}) -.value('ARGUMENTS', {}) +import 'bootstrap/dist/css/bootstrap.min.css'; +import '../css/style.css'; -.config(function (hotkeysProvider) { - hotkeysProvider.useNgRoute = false; - hotkeysProvider.includeCheatSheet = false; -}) - -.run(function ($rootScope, GlancesStats) { - $rootScope.title = "Glances"; - - $rootScope.$on('data_refreshed', function (event, data) { - $rootScope.title = data.stats.system.hostname + ' - Glances'; - }); - - GlancesStats.init(); -}); +import './module'; +import './services'; +import './components'; +import './filters'; \ No newline at end of file diff --git a/glances/outputs/static/js/directives.js b/glances/outputs/static/js/directives.js index a50cb54d..151a3581 100644 --- a/glances/outputs/static/js/directives.js +++ b/glances/outputs/static/js/directives.js @@ -1,4 +1,7 @@ -glancesApp.directive("sortableTh", function () { + +// import angular from 'angular'; + +export default angular.module('glancesApp').directive("sortableTh", function () { return { restrict: 'A', scope: { diff --git a/glances/outputs/static/js/filters.js b/glances/outputs/static/js/filters.js index 300350e6..507caf32 100644 --- a/glances/outputs/static/js/filters.js +++ b/glances/outputs/static/js/filters.js @@ -1,4 +1,17 @@ -glancesApp.filter('min_size', function () { + +import _ from 'lodash'; +// import angular from 'angular'; + +export default angular.module('glancesApp') + .filter('min_size', min_size_filter) + .filter('exclamation', exclamation_filter) + .filter('bytes', bytes_filter) + .filter('bits', bits_filter) + .filter('leftPad', leftPad_filter) + .filter('timemillis', timemillis_filter) + .filter('timedelta', timedelta_filter); + +function min_size_filter() { return function (input, max) { var max = max || 8; if (input.length > max) { @@ -6,17 +19,18 @@ glancesApp.filter('min_size', function () { } return input }; -}); -glancesApp.filter('exclamation', function () { +} + +function exclamation_filter() { return function (input) { if (input === undefined || input === '') { return '?'; } return input; }; -}); +} -glancesApp.filter('bytes', function () { +function bytes_filter() { return function (bytes, low_precision) { low_precision = low_precision || false; if (isNaN(parseFloat(bytes)) || !isFinite(bytes) || bytes == 0) { @@ -68,24 +82,24 @@ glancesApp.filter('bytes', function () { return bytes.toFixed(0); } -}); +} -glancesApp.filter('bits', function ($filter) { +function bits_filter($filter) { return function (bits, low_precision) { bits = Math.round(bits) * 8; return $filter('bytes')(bits, low_precision) + 'b'; } -}); +} -glancesApp.filter('leftPad', function () { +function leftPad_filter() { return function (value, length, chars) { length = length || 0; chars = chars || ' '; return _.padStart(value, length, chars); } -}); +} -glancesApp.filter('timemillis', function () { +function timemillis_filter() { return function (array) { var sum = 0.0; for (var i = 0; i < array.length; i++) { @@ -93,9 +107,9 @@ glancesApp.filter('timemillis', function () { } return sum; } -}); +} -glancesApp.filter('timedelta', function ($filter) { +function timedelta_filter($filter) { return function (value) { var sum = $filter('timemillis')(value); var d = new Date(sum); @@ -107,4 +121,4 @@ glancesApp.filter('timedelta', function ($filter) { milliseconds: parseInt("" + d.getUTCMilliseconds() / 10) }; } -}); +} diff --git a/glances/outputs/static/js/module.js b/glances/outputs/static/js/module.js new file mode 100644 index 00000000..76c99206 --- /dev/null +++ b/glances/outputs/static/js/module.js @@ -0,0 +1,23 @@ + +import angular from 'angular'; +import 'angular-hotkeys'; + +export default angular.module('glancesApp', ['glances.config', 'cfp.hotkeys']) + +.value('CONFIG', {}) +.value('ARGUMENTS', {}) + +.config(function (hotkeysProvider) { + hotkeysProvider.useNgRoute = false; + hotkeysProvider.includeCheatSheet = false; +}) + +.run(function ($rootScope, GlancesStats) { + $rootScope.title = "Glances"; + + $rootScope.$on('data_refreshed', function (event, data) { + $rootScope.title = data.stats.system.hostname + ' - Glances'; + }); + + GlancesStats.init(); +});