Better handling of refresh time in the web ui

This commit is contained in:
Floran Brutel 2019-04-20 11:51:56 +02:00
parent 68d10873bb
commit e408a2a202
No known key found for this signature in database
GPG Key ID: 0A61C46D590F5999
7 changed files with 24 additions and 19 deletions

View File

@ -7,5 +7,8 @@ import template from "./view.html";
export default angular.module("glancesApp").component("glances", {
controller: GlancesController,
controllerAs: 'vm',
templateUrl: template,
bindings: {
refreshTime: "<"
},
templateUrl: template
});

View File

@ -4,6 +4,10 @@ export default function GlancesController($scope, GlancesStats, hotkeys, ARGUMEN
vm.dataLoaded = false;
vm.arguments = ARGUMENTS;
vm.$onInit = function () {
GlancesStats.init(vm.refreshTime);
};
$scope.$on('data_refreshed', function (event, data) {
vm.hasGpu = data.stats.gpu.length > 0;
vm.dataLoaded = true;

View File

@ -2,7 +2,7 @@
import angular from "angular";
import "angular-hotkeys";
export default angular.module("glancesApp", ["glances.config", "cfp.hotkeys"])
export default angular.module("glancesApp", ["cfp.hotkeys"])
.value("CONFIG", {})
.value("ARGUMENTS", {})
@ -18,6 +18,4 @@ export default angular.module("glancesApp", ["glances.config", "cfp.hotkeys"])
$rootScope.$on("data_refreshed", function (event, data) {
$rootScope.title = `${data.stats.system.hostname} - Glances`;
});
GlancesStats.init();
});

View File

@ -1,7 +1,7 @@
import angular from "angular";
function GlancesStats ($http, $q, $rootScope, $timeout, GlancesPluginHelper, REFRESH_TIME, CONFIG, ARGUMENTS) {
function GlancesStats ($http, $q, $rootScope, $timeout, GlancesPluginHelper, CONFIG, ARGUMENTS) {
var _data = false;
@ -10,7 +10,7 @@ function GlancesStats ($http, $q, $rootScope, $timeout, GlancesPluginHelper, REF
}
// load config/limit/arguments and execute stats/views auto refresh
this.init = function () {
this.init = function (REFRESH_TIME) {
var refreshData = function () {
return $q.all([
getAllStats(),

View File

@ -829,7 +829,7 @@ module.exports = __webpack_require__.p + "9a360c92ce9bda60a8da6389741dcfbf.png";
/* unused harmony default export */ var _unused_webpack_default_export = (__WEBPACK_IMPORTED_MODULE_0_angular___default.a.module("glancesApp", ["glances.config", "cfp.hotkeys"])
/* unused harmony default export */ var _unused_webpack_default_export = (__WEBPACK_IMPORTED_MODULE_0_angular___default.a.module("glancesApp", ["cfp.hotkeys"])
.value("CONFIG", {})
.value("ARGUMENTS", {})
@ -845,8 +845,6 @@ module.exports = __webpack_require__.p + "9a360c92ce9bda60a8da6389741dcfbf.png";
$rootScope.$on("data_refreshed", function (event, data) {
$rootScope.title = `${data.stats.system.hostname} - Glances`;
});
GlancesStats.init();
}));
@ -38764,7 +38762,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;/*!
function GlancesStats ($http, $q, $rootScope, $timeout, GlancesPluginHelper, REFRESH_TIME, CONFIG, ARGUMENTS) {
function GlancesStats ($http, $q, $rootScope, $timeout, GlancesPluginHelper, CONFIG, ARGUMENTS) {
var _data = false;
@ -38773,7 +38771,7 @@ function GlancesStats ($http, $q, $rootScope, $timeout, GlancesPluginHelper, REF
}
// load config/limit/arguments and execute stats/views auto refresh
this.init = function () {
this.init = function (REFRESH_TIME) {
var refreshData = function () {
return $q.all([
getAllStats(),
@ -39874,7 +39872,10 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
/* unused harmony default export */ var _unused_webpack_default_export = (__WEBPACK_IMPORTED_MODULE_0_angular___default.a.module("glancesApp").component("glances", {
controller: __WEBPACK_IMPORTED_MODULE_1__controller__["a" /* default */],
controllerAs: 'vm',
templateUrl: __WEBPACK_IMPORTED_MODULE_2__view_html___default.a,
bindings: {
refreshTime: "<"
},
templateUrl: __WEBPACK_IMPORTED_MODULE_2__view_html___default.a
}));
@ -39890,6 +39891,10 @@ function GlancesController($scope, GlancesStats, hotkeys, ARGUMENTS) {
vm.dataLoaded = false;
vm.arguments = ARGUMENTS;
vm.$onInit = function () {
GlancesStats.init(vm.refreshTime);
};
$scope.$on('data_refreshed', function (event, data) {
vm.hasGpu = data.stats.gpu.length > 0;
vm.dataLoaded = true;

File diff suppressed because one or more lines are too long

View File

@ -8,14 +8,9 @@
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<script type="text/javascript" src="glances.js"></script>
<script>
angular
.module('glances.config', [])
.constant('REFRESH_TIME', {{ refresh_time }});
</script>
</head>
<body>
<glances></glances>
<glances refresh-time="{{ refresh_time }}"></glances>
</body>
</html>