mirror of
https://github.com/nicolargo/glances.git
synced 2025-01-03 07:03:40 +03:00
Change the polling system of the api in the webui
This commit is contained in:
parent
7b2cac0f2f
commit
f415f8e511
@ -1,13 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
function GlancesController($interval, GlancesStats, REFRESH_TIME, Hotkeys) {
|
||||
function GlancesController($timeout, GlancesStats, REFRESH_TIME, Hotkeys) {
|
||||
var vm = this;
|
||||
|
||||
vm.dataLoaded = false;
|
||||
vm.stats = {};
|
||||
vm.refreshData = function () {
|
||||
GlancesStats.getData().then(function (data) {
|
||||
|
||||
var refreshDataSuccess = function (data) {
|
||||
data.isBsd = data.stats['system']['os_name'] === 'FreeBSD';
|
||||
data.isLinux = data.stats['system']['os_name'] === 'Linux';
|
||||
data.isMac = data.stats['system']['os_name'] === 'Darwin';
|
||||
@ -16,15 +15,31 @@ function GlancesController($interval, GlancesStats, REFRESH_TIME, Hotkeys) {
|
||||
vm.stats = data;
|
||||
vm.is_disconnected = false;
|
||||
vm.dataLoaded = true;
|
||||
}, function() {
|
||||
|
||||
data = undefined;
|
||||
nextLoad();
|
||||
};
|
||||
|
||||
var refreshDataError = function() {
|
||||
vm.is_disconnected = true;
|
||||
});
|
||||
nextLoad();
|
||||
};
|
||||
|
||||
vm.refreshData = function () {
|
||||
GlancesStats.getData().then(refreshDataSuccess, refreshDataError);
|
||||
};
|
||||
|
||||
var loadPromise;
|
||||
var cancelNextLoad = function() {
|
||||
$timeout.cancel(loadPromise);
|
||||
};
|
||||
|
||||
var nextLoad = function() {
|
||||
cancelNextLoad();
|
||||
loadPromise = $timeout(vm.refreshData, REFRESH_TIME * 1000); // in milliseconds
|
||||
};
|
||||
|
||||
vm.refreshData();
|
||||
$interval(function () {
|
||||
vm.refreshData();
|
||||
}, REFRESH_TIME * 1000); // in milliseconds
|
||||
|
||||
Hotkeys.registerHotkey(Hotkeys.createHotkey({
|
||||
key: 'm',
|
||||
@ -32,6 +47,4 @@ function GlancesController($interval, GlancesStats, REFRESH_TIME, Hotkeys) {
|
||||
console.log('Sort processes by MEM%');
|
||||
}
|
||||
}));
|
||||
|
||||
Hotkeys.registerHotkey( hotkey);
|
||||
}
|
||||
|
335
glances/outputs/static/public/js/main.min.js
vendored
335
glances/outputs/static/public/js/main.min.js
vendored
@ -315,14 +315,13 @@ glancesApp.component('glances', {
|
||||
|
||||
'use strict';
|
||||
|
||||
function GlancesController($interval, GlancesStats, REFRESH_TIME, Hotkeys) {
|
||||
function GlancesController($timeout, GlancesStats, REFRESH_TIME, Hotkeys) {
|
||||
var vm = this;
|
||||
|
||||
vm.dataLoaded = false;
|
||||
vm.stats = {};
|
||||
vm.refreshData = function () {
|
||||
GlancesStats.getData().then(function (data) {
|
||||
|
||||
var refreshDataSuccess = function (data) {
|
||||
data.isBsd = data.stats['system']['os_name'] === 'FreeBSD';
|
||||
data.isLinux = data.stats['system']['os_name'] === 'Linux';
|
||||
data.isMac = data.stats['system']['os_name'] === 'Darwin';
|
||||
@ -331,15 +330,31 @@ function GlancesController($interval, GlancesStats, REFRESH_TIME, Hotkeys) {
|
||||
vm.stats = data;
|
||||
vm.is_disconnected = false;
|
||||
vm.dataLoaded = true;
|
||||
}, function() {
|
||||
|
||||
data = undefined;
|
||||
nextLoad();
|
||||
};
|
||||
|
||||
var refreshDataError = function() {
|
||||
vm.is_disconnected = true;
|
||||
});
|
||||
nextLoad();
|
||||
};
|
||||
|
||||
vm.refreshData = function () {
|
||||
GlancesStats.getData().then(refreshDataSuccess, refreshDataError);
|
||||
};
|
||||
|
||||
var loadPromise;
|
||||
var cancelNextLoad = function() {
|
||||
$timeout.cancel(loadPromise);
|
||||
};
|
||||
|
||||
var nextLoad = function() {
|
||||
cancelNextLoad();
|
||||
loadPromise = $timeout(vm.refreshData, REFRESH_TIME * 1000); // in milliseconds
|
||||
};
|
||||
|
||||
vm.refreshData();
|
||||
$interval(function () {
|
||||
vm.refreshData();
|
||||
}, REFRESH_TIME * 1000); // in milliseconds
|
||||
|
||||
Hotkeys.registerHotkey(Hotkeys.createHotkey({
|
||||
key: 'm',
|
||||
@ -347,8 +362,26 @@ function GlancesController($interval, GlancesStats, REFRESH_TIME, Hotkeys) {
|
||||
console.log('Sort processes by MEM%');
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
Hotkeys.registerHotkey( hotkey);
|
||||
'use strict';
|
||||
|
||||
glancesApp.component('glancesHelp', {
|
||||
controller: GlancesHelpController,
|
||||
controllerAs: 'vm',
|
||||
bindings: {
|
||||
},
|
||||
templateUrl: 'components/help/view.html'
|
||||
});
|
||||
|
||||
'use strict';
|
||||
|
||||
function GlancesHelpController(GlancesStats) {
|
||||
var vm = this;
|
||||
|
||||
GlancesStats.getHelp().then(function(help) {
|
||||
vm.help = help;
|
||||
});
|
||||
}
|
||||
|
||||
'use strict';
|
||||
@ -438,22 +471,38 @@ function GlancesPluginAlertController(favicoService) {
|
||||
|
||||
'use strict';
|
||||
|
||||
glancesApp.component('glancesHelp', {
|
||||
controller: GlancesHelpController,
|
||||
glancesApp.component('glancesPluginCloud', {
|
||||
controller: GlancesPluginCloudController,
|
||||
controllerAs: 'vm',
|
||||
bindings: {
|
||||
stats: '<'
|
||||
},
|
||||
templateUrl: 'components/help/view.html'
|
||||
templateUrl: 'components/plugin-cloud/view.html'
|
||||
});
|
||||
|
||||
'use strict';
|
||||
|
||||
function GlancesHelpController(GlancesStats) {
|
||||
function GlancesPluginCloudController() {
|
||||
var vm = this;
|
||||
|
||||
GlancesStats.getHelp().then(function(help) {
|
||||
vm.help = help;
|
||||
});
|
||||
vm.provider = null;
|
||||
vm.instance = null;
|
||||
|
||||
vm.$onChanges = function (changes) {
|
||||
var stats = changes.stats.currentValue;
|
||||
if (stats === undefined || stats.stats === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
var data = stats.stats['cloud'];
|
||||
|
||||
if (data['ami-id'] !== undefined) {
|
||||
vm.provider = 'AWS EC2';
|
||||
vm.instance = data['instance-type'] + ' instance ' + data['instance-id'] + ' (' + data['region'] + ')';
|
||||
}
|
||||
|
||||
data = undefined;
|
||||
};
|
||||
}
|
||||
|
||||
'use strict';
|
||||
@ -586,42 +635,6 @@ function GlancesPluginDiskioController($filter) {
|
||||
|
||||
'use strict';
|
||||
|
||||
glancesApp.component('glancesPluginCloud', {
|
||||
controller: GlancesPluginCloudController,
|
||||
controllerAs: 'vm',
|
||||
bindings: {
|
||||
stats: '<'
|
||||
},
|
||||
templateUrl: 'components/plugin-cloud/view.html'
|
||||
});
|
||||
|
||||
'use strict';
|
||||
|
||||
function GlancesPluginCloudController() {
|
||||
var vm = this;
|
||||
|
||||
vm.provider = null;
|
||||
vm.instance = null;
|
||||
|
||||
vm.$onChanges = function (changes) {
|
||||
var stats = changes.stats.currentValue;
|
||||
if (stats === undefined || stats.stats === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
var data = stats.stats['cloud'];
|
||||
|
||||
if (data['ami-id'] !== undefined) {
|
||||
vm.provider = 'AWS EC2';
|
||||
vm.instance = data['instance-type'] + ' instance ' + data['instance-id'] + ' (' + data['region'] + ')';
|
||||
}
|
||||
|
||||
data = undefined;
|
||||
};
|
||||
}
|
||||
|
||||
'use strict';
|
||||
|
||||
glancesApp.component('glancesPluginFs', {
|
||||
controller: GlancesPluginFsController,
|
||||
controllerAs: 'vm',
|
||||
@ -860,6 +873,54 @@ function GlancesPluginMemMoreController() {
|
||||
|
||||
'use strict';
|
||||
|
||||
glancesApp.component('glancesPluginMemswap', {
|
||||
controller: GlancesPluginMemswapController,
|
||||
controllerAs: 'vm',
|
||||
bindings: {
|
||||
stats: '<'
|
||||
},
|
||||
templateUrl: 'components/plugin-memswap/view.html'
|
||||
});
|
||||
|
||||
'use strict';
|
||||
|
||||
function GlancesPluginMemswapController() {
|
||||
var vm = this;
|
||||
var _view = {};
|
||||
|
||||
vm.percent = null;
|
||||
vm.total = null;
|
||||
vm.used = null;
|
||||
vm.free = null;
|
||||
|
||||
vm.$onChanges = function (changes) {
|
||||
var stats = changes.stats.currentValue;
|
||||
if (stats === undefined || stats.stats === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
var data = stats.stats['memswap'];
|
||||
_view = stats.view['memswap'];
|
||||
|
||||
vm.percent = data['percent'];
|
||||
vm.total = data['total'];
|
||||
vm.used = data['used'];
|
||||
vm.free = data['free'];
|
||||
|
||||
data = undefined;
|
||||
};
|
||||
|
||||
this.getDecoration = function (value) {
|
||||
if (_view[value] === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
return _view[value].decoration.toLowerCase();
|
||||
};
|
||||
}
|
||||
|
||||
'use strict';
|
||||
|
||||
glancesApp.component('glancesPluginNetwork', {
|
||||
controller: GlancesPluginNetworkController,
|
||||
controllerAs: 'vm',
|
||||
@ -911,54 +972,6 @@ function GlancesPluginNetworkController($filter) {
|
||||
|
||||
'use strict';
|
||||
|
||||
glancesApp.component('glancesPluginMemswap', {
|
||||
controller: GlancesPluginMemswapController,
|
||||
controllerAs: 'vm',
|
||||
bindings: {
|
||||
stats: '<'
|
||||
},
|
||||
templateUrl: 'components/plugin-memswap/view.html'
|
||||
});
|
||||
|
||||
'use strict';
|
||||
|
||||
function GlancesPluginMemswapController() {
|
||||
var vm = this;
|
||||
var _view = {};
|
||||
|
||||
vm.percent = null;
|
||||
vm.total = null;
|
||||
vm.used = null;
|
||||
vm.free = null;
|
||||
|
||||
vm.$onChanges = function (changes) {
|
||||
var stats = changes.stats.currentValue;
|
||||
if (stats === undefined || stats.stats === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
var data = stats.stats['memswap'];
|
||||
_view = stats.view['memswap'];
|
||||
|
||||
vm.percent = data['percent'];
|
||||
vm.total = data['total'];
|
||||
vm.used = data['used'];
|
||||
vm.free = data['free'];
|
||||
|
||||
data = undefined;
|
||||
};
|
||||
|
||||
this.getDecoration = function (value) {
|
||||
if (_view[value] === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
return _view[value].decoration.toLowerCase();
|
||||
};
|
||||
}
|
||||
|
||||
'use strict';
|
||||
|
||||
glancesApp.component('glancesPluginPercpu', {
|
||||
controller: GlancesPluginPercpuController,
|
||||
controllerAs: 'vm',
|
||||
@ -1062,6 +1075,39 @@ function GlancesPluginPortsController() {
|
||||
|
||||
'use strict';
|
||||
|
||||
glancesApp.component('glancesPluginProcess', {
|
||||
controller: GlancesPluginProcessController,
|
||||
controllerAs: 'vm',
|
||||
bindings: {
|
||||
stats: '<',
|
||||
arguments: '<'
|
||||
},
|
||||
templateUrl: 'components/plugin-process/view.html'
|
||||
});
|
||||
|
||||
'use strict';
|
||||
|
||||
function GlancesPluginProcessController() {
|
||||
var vm = this;
|
||||
|
||||
vm.sorter = {
|
||||
column: "cpu_percent",
|
||||
auto: true,
|
||||
isReverseColumn: function (column) {
|
||||
return !(column === 'username' || column === 'name');
|
||||
},
|
||||
getColumnLabel: function (column) {
|
||||
if (_.isEqual(column, ['io_read', 'io_write'])) {
|
||||
return 'io_counters';
|
||||
} else {
|
||||
return column;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
'use strict';
|
||||
|
||||
glancesApp.component('glancesPluginProcesscount', {
|
||||
controller: GlancesPluginProcesscountController,
|
||||
controllerAs: 'vm',
|
||||
@ -1103,39 +1149,6 @@ function GlancesPluginProcesscountController() {
|
||||
|
||||
'use strict';
|
||||
|
||||
glancesApp.component('glancesPluginProcess', {
|
||||
controller: GlancesPluginProcessController,
|
||||
controllerAs: 'vm',
|
||||
bindings: {
|
||||
stats: '<',
|
||||
arguments: '<'
|
||||
},
|
||||
templateUrl: 'components/plugin-process/view.html'
|
||||
});
|
||||
|
||||
'use strict';
|
||||
|
||||
function GlancesPluginProcessController() {
|
||||
var vm = this;
|
||||
|
||||
vm.sorter = {
|
||||
column: "cpu_percent",
|
||||
auto: true,
|
||||
isReverseColumn: function (column) {
|
||||
return !(column === 'username' || column === 'name');
|
||||
},
|
||||
getColumnLabel: function (column) {
|
||||
if (_.isEqual(column, ['io_read', 'io_write'])) {
|
||||
return 'io_counters';
|
||||
} else {
|
||||
return column;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
'use strict';
|
||||
|
||||
glancesApp.component('glancesPluginProcesslist', {
|
||||
controller: GlancesPluginProcesslistController,
|
||||
controllerAs: 'vm',
|
||||
@ -1287,34 +1300,6 @@ function GlancesPluginQuicklookController() {
|
||||
|
||||
'use strict';
|
||||
|
||||
glancesApp.component('glancesPluginUptime', {
|
||||
controller: GlancesPluginUptimeController,
|
||||
controllerAs: 'vm',
|
||||
bindings: {
|
||||
stats: '<'
|
||||
},
|
||||
templateUrl: 'components/plugin-uptime/view.html'
|
||||
});
|
||||
|
||||
'use strict';
|
||||
|
||||
function GlancesPluginUptimeController() {
|
||||
var vm = this;
|
||||
|
||||
vm.value = null;
|
||||
|
||||
vm.$onChanges = function (changes) {
|
||||
var stats = changes.stats.currentValue;
|
||||
if (stats === undefined || stats.stats === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
vm.value = stats.stats['uptime'];
|
||||
};
|
||||
}
|
||||
|
||||
'use strict';
|
||||
|
||||
glancesApp.component('glancesPluginSystem', {
|
||||
controller: GlancesPluginSystemController,
|
||||
controllerAs: 'vm',
|
||||
@ -1358,6 +1343,34 @@ function GlancesPluginSystemController() {
|
||||
|
||||
'use strict';
|
||||
|
||||
glancesApp.component('glancesPluginUptime', {
|
||||
controller: GlancesPluginUptimeController,
|
||||
controllerAs: 'vm',
|
||||
bindings: {
|
||||
stats: '<'
|
||||
},
|
||||
templateUrl: 'components/plugin-uptime/view.html'
|
||||
});
|
||||
|
||||
'use strict';
|
||||
|
||||
function GlancesPluginUptimeController() {
|
||||
var vm = this;
|
||||
|
||||
vm.value = null;
|
||||
|
||||
vm.$onChanges = function (changes) {
|
||||
var stats = changes.stats.currentValue;
|
||||
if (stats === undefined || stats.stats === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
vm.value = stats.stats['uptime'];
|
||||
};
|
||||
}
|
||||
|
||||
'use strict';
|
||||
|
||||
glancesApp.component('glancesPluginWifi', {
|
||||
controller: GlancesPluginWifiController,
|
||||
controllerAs: 'vm',
|
||||
|
File diff suppressed because one or more lines are too long
@ -6471,7 +6471,7 @@ function $BrowserProvider() {
|
||||
<input ng-model="newCacheValue" placeholder="Value">
|
||||
<button ng-click="put(newCacheKey, newCacheValue)">Cache</button>
|
||||
|
||||
<p ng-if="keys.length">Cached Values</p>
|
||||
<p ng-show="keys.length">Cached Values</p>
|
||||
<div ng-repeat="key in keys">
|
||||
<span ng-bind="key"></span>
|
||||
<span>: </span>
|
||||
@ -27211,11 +27211,11 @@ forEach(
|
||||
* element is added to the DOM tree.
|
||||
*
|
||||
* @example
|
||||
<example module="ngAnimate" deps="angular-animate.js" animations="true" name="ng-if">
|
||||
<example module="ngAnimate" deps="angular-animate.js" animations="true" name="ng-show">
|
||||
<file name="index.html">
|
||||
<label>Click me: <input type="checkbox" ng-model="checked" ng-init="checked=true" /></label><br/>
|
||||
Show when checked:
|
||||
<span ng-if="checked" class="animate-if">
|
||||
<span ng-show="checked" class="animate-if">
|
||||
This is removed when the checkbox is unchecked.
|
||||
</span>
|
||||
</file>
|
||||
@ -30566,7 +30566,7 @@ var ngPluralizeDirective = ['$locale', '$interpolate', '$log', function($locale,
|
||||
<li class="animate-repeat" ng-repeat="friend in friends | filter:q as results">
|
||||
[{{$index + 1}}] {{friend.name}} who is {{friend.age}} years old.
|
||||
</li>
|
||||
<li class="animate-repeat" ng-if="results.length === 0">
|
||||
<li class="animate-repeat" ng-show="results.length === 0">
|
||||
<strong>No results found...</strong>
|
||||
</li>
|
||||
</ul>
|
||||
|
Loading…
Reference in New Issue
Block a user