mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-09 10:39:41 +00:00
accept type 'node' for NotesView and refactor it
so that we can use it for the notes of a node, also changes the configuration to a static declaration, this adds an 'edit' button for the node panel Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
abbf0eb74f
commit
9db54b1f76
@ -7,6 +7,30 @@ Ext.define('PVE.panel.NotesView', {
|
|||||||
bodyPadding: 10,
|
bodyPadding: 10,
|
||||||
scrollable: true,
|
scrollable: true,
|
||||||
|
|
||||||
|
tbar: {
|
||||||
|
itemId: 'tbar',
|
||||||
|
hidden: true,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: gettext('Edit'),
|
||||||
|
handler: function() {
|
||||||
|
var me = this.up('panel');
|
||||||
|
me.run_editor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
run_editor: function() {
|
||||||
|
var me = this;
|
||||||
|
var win = Ext.create('PVE.window.NotesEdit', {
|
||||||
|
pveSelNode: me.pveSelNode,
|
||||||
|
url: me.url
|
||||||
|
});
|
||||||
|
win.show();
|
||||||
|
win.on('destroy', me.load, me);
|
||||||
|
},
|
||||||
|
|
||||||
load: function() {
|
load: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
@ -23,6 +47,20 @@ Ext.define('PVE.panel.NotesView', {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
listeners: {
|
||||||
|
render: function(c) {
|
||||||
|
var me = this;
|
||||||
|
me.getEl().on('dblclick', me.run_editor, me);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
tools: [{
|
||||||
|
type: 'gear',
|
||||||
|
handler: function() {
|
||||||
|
me.run_editor();
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
|
||||||
initComponent : function() {
|
initComponent : function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
@ -31,49 +69,29 @@ Ext.define('PVE.panel.NotesView', {
|
|||||||
throw "no node name specified";
|
throw "no node name specified";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var type = me.pveSelNode.data.type;
|
||||||
|
if (!Ext.Array.contains(['node', 'qemu', 'lxc'], type)) {
|
||||||
|
throw 'invalid type specified';
|
||||||
|
}
|
||||||
|
|
||||||
var vmid = me.pveSelNode.data.vmid;
|
var vmid = me.pveSelNode.data.vmid;
|
||||||
if (!vmid) {
|
if (!vmid && type !== 'node') {
|
||||||
throw "no VM ID specified";
|
throw "no VM ID specified";
|
||||||
}
|
}
|
||||||
|
|
||||||
var vmtype = me.pveSelNode.data.type;
|
me.url = '/api2/extjs/nodes/' + nodename + '/';
|
||||||
var url;
|
|
||||||
|
|
||||||
if (vmtype === 'qemu') {
|
// add the type specific path if qemu/lxc
|
||||||
me.url = '/api2/extjs/nodes/' + nodename + '/qemu/' + vmid + '/config';
|
if (type === 'qemu' || type === 'lxc') {
|
||||||
} else if (vmtype === 'lxc') {
|
me.url += type + '/' + vmid + '/';
|
||||||
me.url = '/api2/extjs/nodes/' + nodename + '/lxc/' + vmid + '/config';
|
|
||||||
} else {
|
|
||||||
throw "unknown vm type '" + vmtype + "'";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ext.apply(me, {
|
me.url += 'config';
|
||||||
listeners: {
|
|
||||||
render: function(c) {
|
|
||||||
c.el.on('dblclick', function() {
|
|
||||||
var win = Ext.create('PVE.window.NotesEdit', {
|
|
||||||
pveSelNode: me.pveSelNode,
|
|
||||||
url: me.url
|
|
||||||
});
|
|
||||||
win.show();
|
|
||||||
win.on('destroy', me.load, me);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
tools: [{
|
|
||||||
type: 'gear',
|
|
||||||
handler: function() {
|
|
||||||
var win = Ext.create('PVE.window.NotesEdit', {
|
|
||||||
pveSelNode: me.pveSelNode,
|
|
||||||
url: me.url
|
|
||||||
});
|
|
||||||
win.show();
|
|
||||||
win.on('destroy', me.load, me);
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
|
|
||||||
me.callParent();
|
me.callParent();
|
||||||
|
if (type === 'node') {
|
||||||
|
me.down('#tbar').setVisible(true);
|
||||||
|
}
|
||||||
me.load();
|
me.load();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user