Hi all !
I'm trying to tweak the omv graphs and dev a plugin for that after.
I want to show multiple CPU graphs on the same page, side by side.
At the moment, I'm stuck with a stupid thing and I cannot find the way it works in IOMV Framework.
I just created a /var/www/openmediavault/js/omv/workspace/panel/RrdGraph2.js (almost the same as RrdGraph.js but with the HTML code to have 2 CPU core) with that code.
Code
/**
* This file is part of OpenMediaVault.
*
* @license http://www.gnu.org/licenses/gpl.html GPL Version 3
* @author Volker Theile <volker.theile@openmediavault.org>
* @copyright Copyright (c) 2009-2018 Volker Theile
*
* OpenMediaVault is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* OpenMediaVault is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenMediaVault. If not, see <http://www.gnu.org/licenses/>.
*/
// require("js/omv/workspace/panel/Panel.js")
// require("js/omv/Rpc.js")
// require("js/omv/window/MessageBox.js")
/**
* @ingroup webgui
* @class OMV.workspace.panel.RrdGraph2
* @derived OMV.workspace.panel.Panel
* Panel that is displaying RRD graphs.
* @param rrdGraphName1 (required) The name of the RRD graph file. Such a
* file looks like xxxxx-(hour|day|week|month|year).png.
* @param rrdGraphName2 (required) The name of the RRD graph file. Such a
* file looks like xxxxx-(hour|day|week|month|year).png.
*/
Ext.define("OMV.workspace.panel.RrdGraph2", {
extend: "OMV.workspace.panel.Panel",
requires: [
"OMV.Rpc",
"OMV.window.MessageBox"
],
uses: [
"Ext.XTemplate"
],
hideTopToolbar: false,
autoLoadData: false,
initComponent: function() {
var me = this;
var tpl = me.getTemplate();
Ext.apply(me, {
html: tpl.apply({
name1: me.rrdGraphName1,
name2: me.rrdGraphName2,
time: Ext.Date.now()
})
});
me.callParent(arguments);
},
getTemplate: function() {
return Ext.create("Ext.XTemplate",
'<div class="x-panel-rrdgraph">',
' <img src="rrd.php?name={name1}-hour.png&time={time}" alt="RRD graph - by hour"/> <img src="rrd.php?name={name2}-hour.png&time={time}" alt="RRD graph - by hour"/><br/>',
' <img src="rrd.php?name={name1}-day.png&time={time}" alt="RRD graph - by day"/> <img src="rrd.php?name={name2}-day.png&time={time}" alt="RRD graph - by day"/><br/>',
' <img src="rrd.php?name={name1}-week.png&time={time}" alt="RRD graph - by week"/> <img src="rrd.php?name={name2}-week.png&time={time}" alt="RRD graph - by week"/><br/>',
' <img src="rrd.php?name={name1}-month.png&time={time}" alt="RRD graph - by month"/> <img src="rrd.php?name={name2}-month.png&time={time}" alt="RRD graph - by month"/><br/>',
' <img src="rrd.php?name={name1}-year.png&time={time}" alt="RRD graph - by year"/> <img src="rrd.php?name={name2}-year.png&time={time}" alt="RRD graph - by year"/>',
'</div>');
},
doLoad: function() {
var me = this;
OMV.RpcObserver.request({
msg: _("Generating graphs ..."),
rpcDelay: 1000,
rpcData: {
service: "Rrd",
method: "generate"
},
scope: me,
finish: function() {
var tpl = this.getTemplate();
this.update(tpl.apply({
name1: this.rrdGraphName1,
name2: this.rrdGraphName2,
time: Ext.Date.now()
}));
}
});
}
});
Alles anzeigen
I'd like to have 2 string var passed to it, with "cpu-0" and "cpu-1" for both core of my CPU.
So I tried to call it with a modified /var/www/openmediavault/js/omv/module/admin/diagnostic/system/Cpu.js
Code
/**
* This file is part of OpenMediaVault.
*
* @license http://www.gnu.org/licenses/gpl.html GPL Version 3
* @author Volker Theile <volker.theile@openmediavault.org>
* @copyright Copyright (c) 2009-2018 Volker Theile
*
* OpenMediaVault is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* OpenMediaVault is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenMediaVault. If not, see <http://www.gnu.org/licenses/>.
*/
// require("js/omv/workspace/panel/RrdGraph2.js")
/**
* @class OMV.module.admin.diagnostic.system.plugin.Cpu
* @derived OMV.workspace.panel.RrdGraph2
*/
Ext.define("OMV.module.admin.diagnostic.system.plugin.Cpu", {
extend: "OMV.workspace.panel.RrdGraph2",
alias: "omv.plugin.diagnostic.system.cpu",
title: _("CPU usage"),
rrdGraphName1: "cpu-0",
rrdGraphName2: "cpu-1"
});
Alles anzeigen
That doesn't work. I must missed something but I cannot find what...
Any help is welcome.
Thanks