[pve-devel] [PATCH manager 1/3] Rewrite Log Panel and Task Panel with declarative synthax
Emmanuel Kasper
e.kasper at proxmox.com
Wed Aug 30 16:15:09 CEST 2017
No functional changes
---
www/manager6/dc/Log.js | 130 +++++++++++++++----------------
www/manager6/dc/Tasks.js | 195 +++++++++++++++++++++++------------------------
2 files changed, 161 insertions(+), 164 deletions(-)
diff --git a/www/manager6/dc/Log.js b/www/manager6/dc/Log.js
index 62370eca..4a47f18e 100644
--- a/www/manager6/dc/Log.js
+++ b/www/manager6/dc/Log.js
@@ -4,12 +4,75 @@
Ext.define('PVE.dc.Log', {
extend: 'Ext.grid.GridPanel',
-
alias: ['widget.pveClusterLog'],
+ stateful: false,
+ sortableColumns: false,
+
+ viewConfig: {
+ trackOver: false,
+ stripeRows: true,
+ getRowClass: function(record, index) {
+ var pri = record.get('pri');
+ if (pri && pri <= 3) {
+ return "pve-invalid-row";
+ }
+ }
+ },
+ columns: [
+ {
+ header: gettext("Time"),
+ dataIndex: 'time',
+ width: 150,
+ renderer: function(value) {
+ return Ext.Date.format(value, "M d H:i:s");
+ }
+ },
+ {
+ header: gettext("Node"),
+ dataIndex: 'node',
+ width: 150
+ },
+ {
+ header: gettext("Service"),
+ dataIndex: 'tag',
+ width: 100
+ },
+ {
+ header: "PID",
+ dataIndex: 'pid',
+ width: 100
+ },
+ {
+ header: gettext("User name"),
+ dataIndex: 'user',
+ width: 150
+ },
+ {
+ header: gettext("Severity"),
+ dataIndex: 'pri',
+ renderer: PVE.Utils.render_serverity,
+ width: 100
+ },
+ {
+ header: gettext("Message"),
+ dataIndex: 'msg',
+ flex: 1
+ }
+ ],
+ listeners: {
+ activate: function() {
+ this.getStore().rstore.startUpdate();
+ },
+ deactivate: function() {
+ this.getStore().rstore.stopUpdate();
+ },
+ destroy: function() {
+ this.getStore().rstore.stopUpdate();
+ }
+ },
initComponent : function() {
var me = this;
-
var logstore = new PVE.data.UpdateStore({
storeid: 'pve-cluster-log',
model: 'pve-cluster-log',
@@ -25,68 +88,7 @@ Ext.define('PVE.dc.Log', {
});
Ext.apply(me, {
- store: store,
- stateful: false,
-
- viewConfig: {
- trackOver: false,
- stripeRows: true,
-
- getRowClass: function(record, index) {
- var pri = record.get('pri');
-
- if (pri && pri <= 3) {
- return "pve-invalid-row";
- }
- }
- },
- sortableColumns: false,
- columns: [
- {
- header: gettext("Time"),
- dataIndex: 'time',
- width: 150,
- renderer: function(value) {
- return Ext.Date.format(value, "M d H:i:s");
- }
- },
- {
- header: gettext("Node"),
- dataIndex: 'node',
- width: 150
- },
- {
- header: gettext("Service"),
- dataIndex: 'tag',
- width: 100
- },
- {
- header: "PID",
- dataIndex: 'pid',
- width: 100
- },
- {
- header: gettext("User name"),
- dataIndex: 'user',
- width: 150
- },
- {
- header: gettext("Severity"),
- dataIndex: 'pri',
- renderer: PVE.Utils.render_serverity,
- width: 100
- },
- {
- header: gettext("Message"),
- dataIndex: 'msg',
- flex: 1
- }
- ],
- listeners: {
- activate: logstore.startUpdate,
- deactivate: logstore.stopUpdate,
- destroy: logstore.stopUpdate
- }
+ store: store
});
me.callParent();
diff --git a/www/manager6/dc/Tasks.js b/www/manager6/dc/Tasks.js
index 5d65bd2e..b5727bc1 100644
--- a/www/manager6/dc/Tasks.js
+++ b/www/manager6/dc/Tasks.js
@@ -1,11 +1,102 @@
/* This class defines the "Tasks" tab of the bottom status panel
* Tasks are jobs with a start, end and log output
*/
-
Ext.define('PVE.dc.Tasks', {
extend: 'Ext.grid.GridPanel',
-
alias: ['widget.pveClusterTasks'],
+ stateful: false,
+ sortableColumns: false,
+
+ viewConfig: {
+ trackOver: false,
+ stripeRows: true,
+ getRowClass: function(record, index) {
+ var status = record.get('status');
+ if (status && status != 'OK') {
+ return "pve-invalid-row";
+ }
+ }
+ },
+ columns: [
+ {
+ header: gettext("Start Time"),
+ dataIndex: 'starttime',
+ width: 150,
+ renderer: function(value) {
+ return Ext.Date.format(value, "M d H:i:s");
+ }
+ },
+ {
+ header: gettext("End Time"),
+ dataIndex: 'endtime',
+ width: 150,
+ renderer: function(value, metaData, record) {
+ if (record.data.pid) {
+ if (record.data.type == "vncproxy" ||
+ record.data.type == "vncshell" ||
+ record.data.type == "spiceproxy") {
+ metaData.tdCls = "x-grid-row-console";
+ } else {
+ metaData.tdCls = "x-grid-row-loading";
+ }
+ return "";
+ }
+ return Ext.Date.format(value, "M d H:i:s");
+ }
+ },
+ {
+ header: gettext("Node"),
+ dataIndex: 'node',
+ width: 100
+ },
+ {
+ header: gettext("User name"),
+ dataIndex: 'user',
+ width: 150
+ },
+ {
+ header: gettext("Description"),
+ dataIndex: 'upid',
+ flex: 1,
+ renderer: PVE.Utils.render_upid
+ },
+ {
+ header: gettext("Status"),
+ dataIndex: 'status',
+ width: 200,
+ renderer: function(value, metaData, record) {
+ if (record.data.pid) {
+ if (record.data.type != "vncproxy") {
+ metaData.tdCls = "x-grid-row-loading";
+ }
+ return "";
+ }
+ if (value == 'OK') {
+ return 'OK';
+ }
+ // metaData.attr = 'style="color:red;"';
+ return PVE.Utils.errorText + ': ' + value;
+ }
+ }
+ ],
+ listeners: {
+ show: function() {
+ this.getStore().rstore.startUpdate();
+ },
+ itemdblclick: function() {
+ var sm = this.getSelectionModel();
+ var rec = sm.getSelection()[0];
+ if (!rec) {
+ return;
+ }
+ Ext.create('PVE.window.TaskViewer', {
+ upid: rec.data.upid
+ }).show();
+ },
+ destroy: function() {
+ this.getStore().rstore.stopUpdate();
+ }
+ },
initComponent : function() {
var me = this;
@@ -33,108 +124,12 @@ Ext.define('PVE.dc.Tasks', {
direction: 'DESC'
}
]
-
});
- var run_task_viewer = function() {
- var sm = me.getSelectionModel();
- var rec = sm.getSelection()[0];
- if (!rec) {
- return;
- }
-
- var win = Ext.create('PVE.window.TaskViewer', {
- upid: rec.data.upid
- });
- win.show();
- };
-
Ext.apply(me, {
- store: store,
- stateful: false,
-
- viewConfig: {
- trackOver: false,
- stripeRows: true, // does not work with getRowClass()
-
- getRowClass: function(record, index) {
- var status = record.get('status');
-
- if (status && status != 'OK') {
- return "pve-invalid-row";
- }
- }
- },
- sortableColumns: false,
- columns: [
- {
- header: gettext("Start Time"),
- dataIndex: 'starttime',
- width: 150,
- renderer: function(value) {
- return Ext.Date.format(value, "M d H:i:s");
- }
- },
- {
- header: gettext("End Time"),
- dataIndex: 'endtime',
- width: 150,
- renderer: function(value, metaData, record) {
- if (record.data.pid) {
- if (record.data.type == "vncproxy" ||
- record.data.type == "vncshell" ||
- record.data.type == "spiceproxy") {
- metaData.tdCls = "x-grid-row-console";
- } else {
- metaData.tdCls = "x-grid-row-loading";
- }
- return "";
- }
- return Ext.Date.format(value, "M d H:i:s");
- }
- },
- {
- header: gettext("Node"),
- dataIndex: 'node',
- width: 100
- },
- {
- header: gettext("User name"),
- dataIndex: 'user',
- width: 150
- },
- {
- header: gettext("Description"),
- dataIndex: 'upid',
- flex: 1,
- renderer: PVE.Utils.render_upid
- },
- {
- header: gettext("Status"),
- dataIndex: 'status',
- width: 200,
- renderer: function(value, metaData, record) {
- if (record.data.pid) {
- if (record.data.type != "vncproxy") {
- metaData.tdCls = "x-grid-row-loading";
- }
- return "";
- }
- if (value == 'OK') {
- return 'OK';
- }
- // metaData.attr = 'style="color:red;"';
- return PVE.Utils.errorText + ': ' + value;
- }
- }
- ],
- listeners: {
- itemdblclick: run_task_viewer,
- show: taskstore.startUpdate,
- destroy: taskstore.stopUpdate
- }
+ store: store
});
me.callParent();
}
-});
+});
\ No newline at end of file
--
2.11.0
More information about the pve-devel
mailing list