update root js

pull/1237/head
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', {})
.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';

View File

@ -1,4 +1,7 @@
glancesApp.directive("sortableTh", function () {
// import angular from 'angular';
export default angular.module('glancesApp').directive("sortableTh", function () {
return {
restrict: 'A',
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) {
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)
};
}
});
}

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