update root js

This commit is contained in:
Tieu-Philippe KHIM 2018-02-13 17:43:43 +01:00
parent 3e33056e7c
commit ca6fd5faf1
4 changed files with 61 additions and 32 deletions

View File

@ -1,19 +1,8 @@
var glancesApp = angular.module('glancesApp', ['glances.config', 'cfp.hotkeys'])
.value('CONFIG', {}) import 'bootstrap/dist/css/bootstrap.min.css';
.value('ARGUMENTS', {}) import '../css/style.css';
.config(function (hotkeysProvider) { import './module';
hotkeysProvider.useNgRoute = false; import './services';
hotkeysProvider.includeCheatSheet = false; import './components';
}) import './filters';
.run(function ($rootScope, GlancesStats) {
$rootScope.title = "Glances";
$rootScope.$on('data_refreshed', function (event, data) {
$rootScope.title = data.stats.system.hostname + ' - Glances';
});
GlancesStats.init();
});

View File

@ -1,4 +1,7 @@
glancesApp.directive("sortableTh", function () {
// import angular from 'angular';
export default angular.module('glancesApp').directive("sortableTh", function () {
return { return {
restrict: 'A', restrict: 'A',
scope: { scope: {

View File

@ -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) { return function (input, max) {
var max = max || 8; var max = max || 8;
if (input.length > max) { if (input.length > max) {
@ -6,17 +19,18 @@ glancesApp.filter('min_size', function () {
} }
return input return input
}; };
}); }
glancesApp.filter('exclamation', function () {
function exclamation_filter() {
return function (input) { return function (input) {
if (input === undefined || input === '') { if (input === undefined || input === '') {
return '?'; return '?';
} }
return input; return input;
}; };
}); }
glancesApp.filter('bytes', function () { function bytes_filter() {
return function (bytes, low_precision) { return function (bytes, low_precision) {
low_precision = low_precision || false; low_precision = low_precision || false;
if (isNaN(parseFloat(bytes)) || !isFinite(bytes) || bytes == 0) { if (isNaN(parseFloat(bytes)) || !isFinite(bytes) || bytes == 0) {
@ -68,24 +82,24 @@ glancesApp.filter('bytes', function () {
return bytes.toFixed(0); return bytes.toFixed(0);
} }
}); }
glancesApp.filter('bits', function ($filter) { function bits_filter($filter) {
return function (bits, low_precision) { return function (bits, low_precision) {
bits = Math.round(bits) * 8; bits = Math.round(bits) * 8;
return $filter('bytes')(bits, low_precision) + 'b'; return $filter('bytes')(bits, low_precision) + 'b';
} }
}); }
glancesApp.filter('leftPad', function () { function leftPad_filter() {
return function (value, length, chars) { return function (value, length, chars) {
length = length || 0; length = length || 0;
chars = chars || ' '; chars = chars || ' ';
return _.padStart(value, length, chars); return _.padStart(value, length, chars);
} }
}); }
glancesApp.filter('timemillis', function () { function timemillis_filter() {
return function (array) { return function (array) {
var sum = 0.0; var sum = 0.0;
for (var i = 0; i < array.length; i++) { for (var i = 0; i < array.length; i++) {
@ -93,9 +107,9 @@ glancesApp.filter('timemillis', function () {
} }
return sum; return sum;
} }
}); }
glancesApp.filter('timedelta', function ($filter) { function timedelta_filter($filter) {
return function (value) { return function (value) {
var sum = $filter('timemillis')(value); var sum = $filter('timemillis')(value);
var d = new Date(sum); var d = new Date(sum);
@ -107,4 +121,4 @@ glancesApp.filter('timedelta', function ($filter) {
milliseconds: parseInt("" + d.getUTCMilliseconds() / 10) milliseconds: parseInt("" + d.getUTCMilliseconds() / 10)
}; };
} }
}); }

View File

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