[pve-devel] r5807 - in pve-manager/pve2/www/new: . data grid tree
svn-commits at proxmox.com
svn-commits at proxmox.com
Tue Apr 12 08:18:16 CEST 2011
Author: dietmar
Date: 2011-04-12 08:18:15 +0200 (Tue, 12 Apr 2011)
New Revision: 5807
Modified:
pve-manager/pve2/www/new/PVEUtils.js
pve-manager/pve2/www/new/data/ResourceStore.js
pve-manager/pve2/www/new/grid/ResourceGrid.js
pve-manager/pve2/www/new/tree/ResourceTree.js
Log:
cleanups
Modified: pve-manager/pve2/www/new/PVEUtils.js
===================================================================
--- pve-manager/pve2/www/new/PVEUtils.js 2011-04-11 10:03:23 UTC (rev 5806)
+++ pve-manager/pve2/www/new/PVEUtils.js 2011-04-12 06:18:15 UTC (rev 5807)
@@ -249,7 +249,7 @@
if (uptime <= 0)
return '-';
- return PVE.PVE.Utils.format_duration_long(uptime);
+ return PVE.Utils.format_duration_long(uptime);
},
render_upid: function(value, metaData, record) {
Modified: pve-manager/pve2/www/new/data/ResourceStore.js
===================================================================
--- pve-manager/pve2/www/new/data/ResourceStore.js 2011-04-11 10:03:23 UTC (rev 5806)
+++ pve-manager/pve2/www/new/data/ResourceStore.js 2011-04-12 06:18:15 UTC (rev 5807)
@@ -11,31 +11,45 @@
header: 'Type',
type: 'text',
renderer: PVE.Utils.render_itype,
+ sortable: true,
+ hideable: false,
width: 50
},
id: {
header: 'ID',
hidden: true,
+ sortable: true,
type: 'text'
},
+ text: {
+ header: 'Text',
+ type: 'text',
+ sortable: true,
+ width: 200
+ },
vmid: {
header: 'VMID',
hidden: true,
+ sortable: true,
type: 'integer'
},
name: {
header: 'Name',
+ hidden: true,
+ sortable: true,
type: 'text'
},
disk: {
header: 'Disk',
type: 'integer',
renderer: PVE.Utils.render_disk,
+ sortable: true,
width: 60
},
maxdisk: {
header: 'maxdisk',
type: 'integer',
+ sortable: true,
hidden: true,
width: 60
},
@@ -43,51 +57,84 @@
header: 'Memory',
type: 'integer',
renderer: PVE.Utils.render_mem,
+ sortable: true,
width: 60
},
maxmem: {
header: 'maxmem',
type:'integer',
hidden: true,
+ sortable: true,
width: 60
},
cpu: {
header: 'CPU',
type: 'float',
renderer: PVE.Utils.render_cpu,
+ sortable: true,
width: 85
},
maxcpu: {
header: 'maxcpu',
type: 'integer',
hidden: true,
+ sortable: true,
width: 60
},
uptime: {
header: 'Uptime',
type: 'integer',
renderer: PVE.Utils.render_uptime,
+ sortable: true,
width: 110
},
node: {
header: 'Node',
type: 'text',
hidden: true,
+ sortable: true,
width: 110
},
storage: {
header: 'Storage',
type: 'text',
hidden: true,
+ sortable: true,
width: 110
}
};
var fields = [];
Ext.Object.each(field_defaults, function(key, value) {
- fields.push({name: key, type: value.type});
+ if (name !== 'text')
+ fields.push({name: key, type: value.type});
});
+ fields.push({
+ name: 'text',
+ type: 'text',
+ convert: function(value, record) {
+ var info = record.data;
+ var text;
+
+ if (value)
+ return value;
+
+ if (info.type === 'node') {
+ text = info.node;
+ } else if (info.type === 'storage') {
+ text = info.storage + ' (' + info.node + ')';
+ } else if (info.type === 'qemu' || info.type === 'openvz') {
+ text = info.vmid;
+ if (info.name)
+ text += " (" + info.name + ')';
+ } else {
+ text = info.id;
+ }
+ return text;
+ }
+ });
+
Ext.regModel('PVEResources', {
fields: fields,
proxy: {
@@ -104,7 +151,18 @@
var config = Ext.apply({}, {
storeid: 'PVEResources',
model: 'PVEResources',
- autoDestory: false
+ autoDestory: false,
+ defaultColums: function() {
+
+ var res = [];
+ for (field in field_defaults) {
+ var info = field_defaults[field];
+ var fi = Ext.apply({ dataIndex: field }, info);
+ res.push(fi);
+ }
+
+ return res;
+ }
});
self.callParent([config]);
Modified: pve-manager/pve2/www/new/grid/ResourceGrid.js
===================================================================
--- pve-manager/pve2/www/new/grid/ResourceGrid.js 2011-04-11 10:03:23 UTC (rev 5806)
+++ pve-manager/pve2/www/new/grid/ResourceGrid.js 2011-04-12 06:18:15 UTC (rev 5807)
@@ -17,6 +17,8 @@
var rstore = PVE.data.ResourceStore;
+ var coldef = rstore.defaultColums();
+
var store = Ext.create('Ext.data.BufferStore', {
pageSize: 50,
purgePageCount: 0,
@@ -133,17 +135,7 @@
rstore.un("load", updateGrid)
}
},
- columns:[
- { text: 'ID', dataIndex: 'id', sortable: true },
- { text: 'Type', dataIndex: 'type', sortable: true,
- renderer: PVE.Utils.render_itype },
- {
- text: 'CPU',
- dataIndex: 'cpu',
- sortable: true,
- renderer: PVE.Utils.render_cpu
- },
- ]
+ columns: coldef
});
me.callParent();
Modified: pve-manager/pve2/www/new/tree/ResourceTree.js
===================================================================
--- pve-manager/pve2/www/new/tree/ResourceTree.js 2011-04-11 10:03:23 UTC (rev 5806)
+++ pve-manager/pve2/www/new/tree/ResourceTree.js 2011-04-12 06:18:15 UTC (rev 5807)
@@ -87,24 +87,14 @@
if (defaults && defaults.iconCls)
info.iconCls = defaults.iconCls;
- if (info.type === 'node') {
- info.text = info.node;
- } else if (info.type === 'storage') {
- info.text = info.storage + ' (' + info.node + ')';
- } else if (info.type === 'qemu' || info.type === 'openvz') {
- info.text = info.vmid;
- if (info.name)
- info.text += " (" + info.name + ')';
- } else if (info.type === 'type') {
- defaults = statics.typeDefaults[info.groupbyid];
- if (defaults && defaults.text)
- info.text = defaults.text;
- else
- info.text = info.groupbyid;
- } else {
- info.text = info.id;
+ if (info.groupbyid) {
+ info.text = info.groupbyid;
+ if (info.type === 'type') {
+ defaults = statics.typeDefaults[info.groupbyid];
+ if (defaults && defaults.text)
+ info.text = defaults.text;
+ }
}
-
var child = Ext.ModelMgr.create(info, 'PVETree', info.id);
var cs = node.childNodes;
More information about the pve-devel
mailing list