未验证 提交 bf7267ba 编写于 作者: N Nicolas Hennion 提交者: GitHub

Merge pull request #1473 from notFloran/webui-rewrite-refresh-time

Better method to pass "refresh time" from glances to the WebUI
......@@ -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
});
......@@ -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;
......
......@@ -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();
});
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(),
......
......@@ -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>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册