Commit a9a1e2f2 authored by Dietmar Maurer's avatar Dietmar Maurer

GUI rework

parent 2b8c2281
...@@ -160,34 +160,24 @@ Ext.define('PVE.ConsoleWorkspace', { ...@@ -160,34 +160,24 @@ Ext.define('PVE.ConsoleWorkspace', {
Ext.define('PVE.StdWorkspace', { Ext.define('PVE.StdWorkspace', {
extend: 'PVE.Workspace', extend: 'PVE.Workspace',
requires: [
'Ext.History',
'Ext.state.*',
'Ext.selection.*',
'PVE.form.ViewSelector',
'PVE.data.ResourceStore',
'PVE.tree.ResourceTree'
],
alias: ['widget.pveStdWorkspace'], alias: ['widget.pveStdWorkspace'],
// private // private
defaultContent: {
title: 'Nothing selected',
region: 'center'
},
setContent: function(comp) { setContent: function(comp) {
var me = this; var me = this;
if (!comp) {
comp = me.defaultContent;
}
var cont = me.child('#content'); var cont = me.child('#content');
cont.removeAll(true); cont.removeAll(true);
if (comp) {
cont.setLoading(false);
comp.border = false;
cont.add(comp); cont.add(comp);
cont.doLayout(); cont.doLayout();
} else {
cont.setLoading('nothing selected');
}
}, },
selectById: function(nodeid) { selectById: function(nodeid) {
...@@ -231,26 +221,11 @@ Ext.define('PVE.StdWorkspace', { ...@@ -231,26 +221,11 @@ Ext.define('PVE.StdWorkspace', {
Ext.History.init(); Ext.History.init();
Ext.state.Manager.setProvider(Ext.create('PVE.StateProvider')); Ext.state.Manager.setProvider(Ext.create('PVE.StateProvider'));
//document.title = ; var selview = new PVE.form.ViewSelector({});
var selview = new PVE.form.ViewSelector({
listeners: {
select: function(combo, records) {
if (records && records.length) {
var view = combo.getViewFilter();
combo.up('pveResourceTree').setViewFilter(view);
}
}
}
});
var rtree = Ext.createWidget('pveResourceTree', { var rtree = Ext.createWidget('pveResourceTree', {
width: 200,
region: 'west',
margins: '0 0 0 5',
split: true,
viewFilter: selview.getViewFilter(), viewFilter: selview.getViewFilter(),
tbar: [ ' ', selview ], flex: 1,
selModel: new Ext.selection.TreeModel({ selModel: new Ext.selection.TreeModel({
listeners: { listeners: {
selectionchange: function(sm, selected) { selectionchange: function(sm, selected) {
...@@ -283,6 +258,13 @@ Ext.define('PVE.StdWorkspace', { ...@@ -283,6 +258,13 @@ Ext.define('PVE.StdWorkspace', {
}) })
}); });
selview.on('select', function(combo, records) {
if (records && records.length) {
var view = combo.getViewFilter();
rtree.setViewFilter(view);
}
});
Ext.apply(me, { Ext.apply(me, {
layout: { type: 'border' }, layout: { type: 'border' },
border: false, border: false,
...@@ -358,14 +340,23 @@ Ext.define('PVE.StdWorkspace', { ...@@ -358,14 +340,23 @@ Ext.define('PVE.StdWorkspace', {
{ {
region: 'center', region: 'center',
id: 'content', id: 'content',
xtype: 'panel', xtype: 'container',
layout: { type: 'fit' }, layout: { type: 'fit' },
border: false, border: false,
stateful: false, stateful: false,
margins:'0 5 0 0', margins: '0 5 0 0',
items: [ me.defaultContent ] items: []
},
{
region: 'west',
xtype: 'container',
border: false,
layout: { type: 'vbox', align: 'stretch' },
margins: '0 0 0 5',
split: true,
width: 200,
items: [ selview, rtree ]
}, },
rtree,
{ {
xtype: 'pveStatusPanel', xtype: 'pveStatusPanel',
region: 'south', region: 'south',
......
...@@ -10,9 +10,57 @@ Ext.define('PVE.node.Config', { ...@@ -10,9 +10,57 @@ Ext.define('PVE.node.Config', {
throw "no node name specified"; throw "no node name specified";
} }
me.statusStore = Ext.create('PVE.data.ObjectStore', {
url: "/api2/json/nodes/" + nodename + "/status",
interval: 1000
});
var node_command = function(cmd) {
PVE.Utils.API2Request({
params: { command: cmd },
url: '/nodes/' + nodename + '/status',
method: 'POST',
waitMsgTarget: me,
failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
}
});
};
var rebootBtn = Ext.create('PVE.button.Button', {
text: 'Reboot',
confirmMsg: "Do you really want to reboot node '" + nodename + "'?",
handler: function() {
node_command('reboot');
}
});
var shutdownBtn = Ext.create('PVE.button.Button', {
text: 'Shutdown',
confirmMsg: "Do you really want to shutdown node '" + nodename + "'?",
handler: function() {
node_command('shutdown');
}
});
var shellBtn = Ext.create('Ext.Button', {
text: 'Shell',
handler: function() {
var url = Ext.urlEncode({
console: 'shell',
node: nodename
});
var nw = window.open("?" + url, '_blank',
"innerWidth=745,innerheight=427");
nw.focus();
}
});
Ext.apply(me, { Ext.apply(me, {
title: "Node '" + nodename + "'", title: "Node '" + nodename + "'",
hstateid: 'nodetab', hstateid: 'nodetab',
defaults: { statusStore: me.statusStore },
tbar: [ rebootBtn, shutdownBtn, shellBtn ],
items: [ items: [
{ {
title: 'Summary', title: 'Summary',
...@@ -59,5 +107,22 @@ Ext.define('PVE.node.Config', { ...@@ -59,5 +107,22 @@ Ext.define('PVE.node.Config', {
}); });
me.callParent(); me.callParent();
me.statusStore.on('load', function(s, records, success) {
var uptimerec = s.data.get('uptime');
var uptime = uptimerec ? uptimerec.data.value : false;
rebootBtn.setDisabled(!uptime);
shutdownBtn.setDisabled(!uptime);
shellBtn.setDisabled(!uptime);
});
me.on('afterrender', function() {
me.statusStore.startUpdate();
});
me.on('destroy', function() {
me.statusStore.stopUpdate();
});
} }
}); });
...@@ -44,9 +44,7 @@ Ext.define('PVE.node.StatusView', { ...@@ -44,9 +44,7 @@ Ext.define('PVE.node.StatusView', {
}; };
Ext.applyIf(me, { Ext.applyIf(me, {
url: "/api2/json/nodes/" + nodename + "/status",
cwidth1: 150, cwidth1: 150,
interval: 1000,
//height: 276, //height: 276,
rows: rows rows: rows
}); });
......
...@@ -10,84 +10,21 @@ Ext.define('PVE.node.Summary', { ...@@ -10,84 +10,21 @@ Ext.define('PVE.node.Summary', {
throw "no node name specified"; throw "no node name specified";
} }
if (!me.statusStore) {
throw "no status storage specified";
}
var rstore = me.statusStore;
var statusview = Ext.create('PVE.node.StatusView', { var statusview = Ext.create('PVE.node.StatusView', {
title: 'Status', title: 'Status',
pveSelNode: me.pveSelNode, pveSelNode: me.pveSelNode,
style: 'padding-top:0px' style: 'padding-top:0px',
}); rstore: rstore
var rstore = statusview.rstore;
var node_command = function(cmd) {
PVE.Utils.API2Request({
params: { command: cmd },
url: '/nodes/' + nodename + '/status',
method: 'POST',
waitMsgTarget: me,
failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
}
}); });
};
var rrdurl = "/api2/png/nodes/" + nodename + "/rrd"; var rrdurl = "/api2/png/nodes/" + nodename + "/rrd";
var tbar = Ext.create('Ext.toolbar.Toolbar', {
items: [
{
itemId: 'reboot',
text: 'Reboot',
handler: function() {
var msg = "Do you really want to reboot node '" + nodename + "'?";
Ext.Msg.confirm('Confirm', msg, function(btn) {
if (btn !== 'yes') {
return;
}
node_command('reboot');
});
}
},
{
itemId: 'shutdown',
text: 'Shutdown',
handler: function() {
var msg = "Do you really want to shutdown node '" + nodename + "'?";
Ext.Msg.confirm('Confirm', msg, function(btn) {
if (btn !== 'yes') {
return;
}
node_command('shutdown');
});
}
},
{
itemId: 'shell',
text: 'Shell',
handler: function() {
var url = Ext.urlEncode({
console: 'shell',
node: nodename
});
var nw = window.open("?" + url, '_blank',
"innerWidth=745,innerheight=427");
nw.focus();
}
}, '->',
{
xtype: 'pveRRDTypeSelector'
}
]
});
me.mon(rstore, 'load', function(s, records, success) {
var uptimerec = s.data.get('uptime');
var uptime = uptimerec ? uptimerec.data.value : false;
tbar.down('#reboot').setDisabled(!uptime);
tbar.down('#shutdown').setDisabled(!uptime);
tbar.down('#shell').setDisabled(!uptime);
});
Ext.apply(me, { Ext.apply(me, {
autoScroll: true, autoScroll: true,
bodyStyle: 'padding:10px', bodyStyle: 'padding:10px',
...@@ -95,7 +32,7 @@ Ext.define('PVE.node.Summary', { ...@@ -95,7 +32,7 @@ Ext.define('PVE.node.Summary', {
width: 800, width: 800,
style: 'padding-top:10px' style: 'padding-top:10px'
}, },
tbar: tbar, tbar: [ '->', { xtype: 'pveRRDTypeSelector' } ],
items: [ items: [
statusview, statusview,
{ {
...@@ -125,10 +62,6 @@ Ext.define('PVE.node.Summary', { ...@@ -125,10 +62,6 @@ Ext.define('PVE.node.Summary', {
] ]
}); });
me.on('show', rstore.startUpdate);
me.on('hide', rstore.stopUpdate);
me.on('destroy', rstore.stopUpdate);
me.callParent(); me.callParent();
} }
}); });
...@@ -15,12 +15,84 @@ Ext.define('PVE.openvz.Config', { ...@@ -15,12 +15,84 @@ Ext.define('PVE.openvz.Config', {
throw "no VM ID specified"; throw "no VM ID specified";
} }
me.statusStore = Ext.create('PVE.data.ObjectStore', {
url: "/api2/json/nodes/" + nodename + "/openvz/" + vmid + "/status/current",
interval: 1000
});
var vm_command = function(cmd, params) {
PVE.Utils.API2Request({
params: params,
url: '/nodes/' + nodename + '/openvz/' + vmid + "/status/" + cmd,
waitMsgTarget: me,
method: 'POST',
failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
}
});
};
var startBtn = Ext.create('Ext.Button', {
text: 'Start',
handler: function() {
vm_command('start');
}
});
var stopBtn = Ext.create('PVE.button.Button', {
text: 'Stop',
confirmMsg: "Do you really want to stop the VM?",
handler: function() {
vm_command("stop", { fast: 1 });
}
});
var shutdownBtn = Ext.create('PVE.button.Button', {
text: 'Shutdown',
confirmMsg: "Do you really want to shutdown the VM?",
handler: function() {
vm_command('stop');
}
});
var removeBtn = Ext.create('PVE.button.Button', {
text: 'Remove',
confirmMsg: 'Are you sure you want to remove VM ' +
vmid + '? This will permanently erase all VM data.',
handler: function() {
PVE.Utils.API2Request({
url: '/nodes/' + nodename + '/openvz/' + vmid,
method: 'DELETE',
waitMsgTarget: me,
failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
}
});
}
});
var consoleBtn = Ext.create('Ext.Button', {
text: 'Console',
handler: function() {
var url = Ext.urlEncode({
console: 'openvz',
vmid: vmid,
node: nodename
});
var nw = window.open("?" + url, '_blank',
"innerWidth=745,innerheight=427");
nw.focus();
}
});
var vmname = me.pveSelNode.data.name; var vmname = me.pveSelNode.data.name;
var descr = vmname ? " '" + vmname + "'" : ''; var descr = vmname ? " '" + vmname + "'" : '';
Ext.apply(me, { Ext.apply(me, {
title: "OpenVZ container " + vmid + descr + title: "OpenVZ container " + vmid + descr +
" on node '" + nodename + "'", " on node '" + nodename + "'",
hstateid: 'ovztab', hstateid: 'ovztab',
tbar: [ startBtn, stopBtn, shutdownBtn, removeBtn, consoleBtn ],
defaults: { statusStore: me.statusStore },
items: [ items: [
{ {
title: 'Summary', title: 'Summary',
...@@ -59,15 +131,6 @@ Ext.define('PVE.openvz.Config', { ...@@ -59,15 +131,6 @@ Ext.define('PVE.openvz.Config', {
xtype: 'pveLogView', xtype: 'pveLogView',
url: '/api2/json/nodes/' + nodename + '/openvz/' + vmid + '/initlog' url: '/api2/json/nodes/' + nodename + '/openvz/' + vmid + '/initlog'
}, },
/*
{
xtype: 'pveOpenVZConsole',
title: 'Console',
itemId: 'console',
nodename: nodename,
vmid: vmid
},
*/
{ {
xtype: 'pveBackupView', xtype: 'pveBackupView',
title: 'Backup', title: 'Backup',
...@@ -83,5 +146,29 @@ Ext.define('PVE.openvz.Config', { ...@@ -83,5 +146,29 @@ Ext.define('PVE.openvz.Config', {
}); });
me.callParent(); me.callParent();
me.statusStore.on('load', function(s, records, success) {
var status;
if (!success) {
me.workspace.checkVmMigration(me.pveSelNode);
status = 'unknown';
} else {
var rec = s.data.get('status');
status = rec ? rec.data.value : 'unknown';
}
startBtn.setDisabled(status === 'running');
shutdownBtn.setDisabled(status !== 'running');
stopBtn.setDisabled(status === 'stopped');
consoleBtn.setDisabled(status !== 'running');
removeBtn.setDisabled(status !== 'stopped');
});
me.on('afterrender', function() {
me.statusStore.startUpdate();
});
me.on('destroy', function() {
me.statusStore.stopUpdate();
});
} }
}); });
...@@ -74,10 +74,8 @@ Ext.define('PVE.openvz.StatusView', { ...@@ -74,10 +74,8 @@ Ext.define('PVE.openvz.StatusView', {
}; };
Ext.applyIf(me, { Ext.applyIf(me, {
url: "/api2/json/nodes/" + nodename + "/openvz/" + vmid + "/status/current",
cwidth1: 150, cwidth1: 150,
height: 179, height: 179,
interval: 1000,
rows: rows rows: rows
}); });
......
...@@ -19,128 +19,33 @@ Ext.define('PVE.openvz.Summary', { ...@@ -19,128 +19,33 @@ Ext.define('PVE.openvz.Summary', {
throw "no workspace specified"; throw "no workspace specified";
} }
if (!me.statusStore) {
throw "no status storage specified";
}
var rstore = me.statusStore;
var statusview = Ext.create('PVE.openvz.StatusView', { var statusview = Ext.create('PVE.openvz.StatusView', {
title: 'Status', title: 'Status',
pveSelNode: me.pveSelNode, pveSelNode: me.pveSelNode,
width: 400 width: 400,
rstore: rstore
}); });
var rstore = statusview.rstore;
var rrdurl = "/api2/png/nodes/" + nodename + "/openvz/" + vmid + "/rrd"; var rrdurl = "/api2/png/nodes/" + nodename + "/openvz/" + vmid + "/rrd";
var vm_command = function(cmd, params) {
PVE.Utils.API2Request({
params: params,
url: '/nodes/' + nodename + '/openvz/' + vmid + "/status/" + cmd,
waitMsgTarget: me,
method: 'POST',
failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
}
});
};
var tbar = Ext.create('Ext.toolbar.Toolbar', {
items: [
{
itemId: 'start',
text: 'Start',
handler: function() {
vm_command('start');
}
},
{
itemId: 'stop',
text: 'Stop',
handler: function() {
var msg = "Do you really want to stop the VM?";
Ext.Msg.confirm('Confirm', msg, function(btn) {
if (btn !== 'yes') {
return;
}
vm_command("stop", { fast: 1 });
});
}
},
{
itemId: 'shutdown',
text: 'Shutdown',
handler: function() {
var msg = "Do you really want to shutdown the VM?";
Ext.Msg.confirm('Confirm', msg, function(btn) {
if (btn !== 'yes') {
return;
}
vm_command('stop');
});
}
},
{
itemId: 'remove',
text: 'Remove',
handler: function() {
var msg = 'Are you sure you want to remove VM ' +
vmid + '? This will permanently erase all VM data.';
Ext.Msg.confirm('Confirm', msg, function(btn) {
if (btn !== 'yes') {
return;
}
PVE.Utils.API2Request({
url: '/nodes/' + nodename + '/openvz/' + vmid,
method: 'DELETE',
waitMsgTarget: me,
failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
}
});
});
}
},
{
itemId: 'console',
text: 'Console',
handler: function() {
var url = Ext.urlEncode({
console: 'openvz',
vmid: vmid,
node: nodename
});
var nw = window.open("?" + url, '_blank',
"innerWidth=745,innerheight=427");
nw.focus();
}
}, '->',
{
xtype: 'pveRRDTypeSelector'
}
]
});
me.mon(rstore, 'load', function(s, records, success) {
var status;
if (!success) {
me.workspace.checkVmMigration(me.pveSelNode);
status = 'unknown';
} else {
var rec = s.data.get('status');
status = rec ? rec.data.value : 'unknown';
}
tbar.down('#start').setDisabled(status === 'running');
tbar.down('#shutdown').setDisabled(status !== 'running');
tbar.down('#stop').setDisabled(status === 'stopped');
tbar.down('#console').setDisabled(status !== 'running');
tbar.down('#remove').setDisabled(status !== 'stopped');
});
var notesview = Ext.create('PVE.panel.NotesView', { var notesview = Ext.create('PVE.panel.NotesView', {
pveSelNode: me.pveSelNode, pveSelNode: me.pveSelNode,
flex: 1 flex: 1
}); });
Ext.apply(me, { Ext.apply(me, {
tbar: tbar, tbar: [
'->',
{
xtype: 'pveRRDTypeSelector'
}
],
autoScroll: true, autoScroll: true,
bodyStyle: 'padding:10px', bodyStyle: 'padding:10px',
defaults: { defaults: {
...@@ -189,13 +94,9 @@ Ext.define('PVE.openvz.Summary', { ...@@ -189,13 +94,9 @@ Ext.define('PVE.openvz.Summary', {
}); });
me.on('show', function() { me.on('show', function() {
rstore.startUpdate();
notesview.load(); notesview.load();
}); });
me.on('hide', rstore.stopUpdate);
me.on('destroy', rstore.stopUpdate);
me.callParent(); me.callParent();
} }
}); });
Ext.define('PVE.panel.Config', { Ext.define('PVE.panel.Config', {
extend: 'Ext.tab.Panel', extend: 'Ext.panel.Panel',
requires: [
'Ext.state.Manager',
'PVE.grid.ResourceGrid'
],
alias: 'widget.PVE.panel.Config',
initComponent: function() { initComponent: function() {
var me = this; var me = this;
...@@ -13,23 +8,34 @@ Ext.define('PVE.panel.Config', { ...@@ -13,23 +8,34 @@ Ext.define('PVE.panel.Config', {
var sp = Ext.state.Manager.getProvider(); var sp = Ext.state.Manager.getProvider();
var activeTab;
if (stateid) {
var state = sp.get(stateid);
if (state && state.value) {
activeTab = state.value;
}
}
var items = me.items || []; var items = me.items || [];
me.items = null; me.items = undefined;
Ext.applyIf(me, { var tbar = me.tbar || [];
title: me.pveSelNode.data.text, me.tbar = undefined;
showSearch: true,
defaults: {}
});
// pass workspace, pveSelNode and viewFilter to all children var title = me.title || me.pveSelNode.data.text;
Ext.apply(me.defaults, { me.title = undefined;
pveSelNode: me.pveSelNode,
viewFilter: me.viewFilter, tbar.unshift('->');
workspace: me.workspace, tbar.unshift({
border: false xtype: 'tbtext',
text: title,
baseCls: 'x-panel-header-text',
padding: '0 0 5 0'
}); });
Ext.applyIf(me, { showSearch: true });
if (me.showSearch) { if (me.showSearch) {
items.unshift({ items.unshift({
itemId: 'search', itemId: 'search',
...@@ -37,8 +43,27 @@ Ext.define('PVE.panel.Config', { ...@@ -37,8 +43,27 @@ Ext.define('PVE.panel.Config', {
}); });
} }
Ext.apply(me, { var toolbar = Ext.create('Ext.toolbar.Toolbar', {
items: tbar,
style: 'border:0px;',
height: 28
});
var tab = Ext.create('Ext.tab.Panel', {
flex: 1,
border: true,
activeTab: activeTab,
defaults: Ext.apply(me.defaults || {}, {
pveSelNode: me.pveSelNode,
viewFilter: me.viewFilter,
workspace: me.workspace,
border: false
}),
items: items,
listeners: { listeners: {
afterrender: function(tp) {
tp.items.get(0).fireEvent('show', tp.items.get(0));
},
tabchange: function(tp, newcard, oldcard) { tabchange: function(tp, newcard, oldcard) {
var ntab = newcard.itemId; var ntab = newcard.itemId;
// Note: '' is alias for first tab. // Note: '' is alias for first tab.
...@@ -51,36 +76,29 @@ Ext.define('PVE.panel.Config', { ...@@ -51,36 +76,29 @@ Ext.define('PVE.panel.Config', {
sp.set(stateid, state); sp.set(stateid, state);
} }
} }
}, }
items: items
}); });
if (stateid) { Ext.apply(me, {
var state = sp.get(stateid); layout: { type: 'vbox', align: 'stretch' },
if (state && state.value) { items: [ toolbar, tab]
me.activeTab = state.value; });
}
}
me.callParent(); me.callParent();
me.items.get(0).fireEvent('show', me.items.get(0));
var statechange = function(sp, key, state) { var statechange = function(sp, key, state) {
if (stateid && key === stateid) { if (stateid && key === stateid) {
var atab = me.getActiveTab().itemId; console.log("scanhge");
var atab = tab.getActiveTab().itemId;
var ntab = state.value || items[0].itemId; var ntab = state.value || items[0].itemId;
if (state && ntab && (atab != ntab)) { if (state && ntab && (atab != ntab)) {
me.setActiveTab(ntab); tab.setActiveTab(ntab);
} }
} }
}; };
if (stateid) { if (stateid) {
sp.on('statechange', statechange); me.mon(sp, 'statechange', statechange);
me.on('destroy', function() {
sp.un('statechange', statechange);
});
} }
} }
}); });
...@@ -15,12 +15,102 @@ Ext.define('PVE.qemu.Config', { ...@@ -15,12 +15,102 @@ Ext.define('PVE.qemu.Config', {
throw "no VM ID specified"; throw "no VM ID specified";
} }
me.statusStore = Ext.create('PVE.data.ObjectStore', {
url: "/api2/json/nodes/" + nodename + "/qemu/" + vmid + "/status/current",
interval: 1000
});
var vm_command = function(cmd, params) {
PVE.Utils.API2Request({
params: params,
url: '/nodes/' + nodename + '/qemu/' + vmid + "/status/" + cmd,
waitMsgTarget: me,
method: 'POST',
failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
}
});
};
var startBtn = Ext.create('Ext.Button', {
text: 'Start',
handler: function() {
vm_command('start');
}
});
var stopBtn = Ext.create('PVE.button.Button', {
text: 'Stop',
confirmMsg: "Do you really want to stop the VM?",
handler: function() {
vm_command("stop", { timeout: 30 });
}
});
var migrateBtn = Ext.create('Ext.Button', {
text: 'Migrate',
handler: function() {
var win = Ext.create('PVE.qemu.Migrate', {
pveSelNode: me.pveSelNode
});
win.show();
}
});
var resetBtn = Ext.create('PVE.button.Button', {
text: 'Reset',
confirmMsg: "Do you really want to reset the VM?",
handler: function() {
vm_command("reset");
}
});
var shutdownBtn = Ext.create('PVE.button.Button', {
text: 'Shutdown',
confirmMsg: "Do you really want to shutdown the VM?",
handler: function() {
vm_command('shutdown', { timeout: 30 });
}
});
var removeBtn = Ext.create('PVE.button.Button', {
text: 'Remove',
confirmMsg: 'Are you sure you want to remove VM ' +
vmid + '? This will permanently erase all VM data.',
handler: function() {
PVE.Utils.API2Request({
url: '/nodes/' + nodename + '/qemu/' + vmid,
method: 'DELETE',
waitMsgTarget: me,
failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
}
});
}
});
var consoleBtn = Ext.create('Ext.Button', {
text: 'Console',
handler: function() {
var url = Ext.urlEncode({
console: 'kvm',
vmid: vmid,
node: nodename
});
var nw = window.open("?" + url, '_blank',
"innerWidth=745,innerheight=427");
nw.focus();
}
});
var vmname = me.pveSelNode.data.name; var vmname = me.pveSelNode.data.name;
var descr = vmname ? "'" + vmname + "' " : ''; var descr = vmname ? "'" + vmname + "' " : '';
Ext.apply(me, { Ext.apply(me, {
title: "Virtual machine " + descr + "'KVM " + vmid + title: "Virtual machine " + descr + "'KVM " + vmid +
"' on node '" + nodename + "'", "' on node '" + nodename + "'",
hstateid: 'kvmtab', hstateid: 'kvmtab',
tbar: [ startBtn, stopBtn, migrateBtn, resetBtn, shutdownBtn, removeBtn, consoleBtn ],
defaults: { statusStore: me.statusStore },
items: [ items: [
{ {
title: 'Summary', title: 'Summary',
...@@ -42,16 +132,6 @@ Ext.define('PVE.qemu.Config', { ...@@ -42,16 +132,6 @@ Ext.define('PVE.qemu.Config', {
itemId: 'monitor', itemId: 'monitor',
xtype: 'pveQemuMonitor' xtype: 'pveQemuMonitor'
}, },
/*
{
xtype: 'pveKVMConsole',
title: 'Console',
itemId: 'console',
//disabled: true,
nodename: nodename,
vmid: vmid
},
*/
{ {
xtype: 'pveBackupView', xtype: 'pveBackupView',
title: 'Backup', title: 'Backup',
...@@ -67,5 +147,31 @@ Ext.define('PVE.qemu.Config', { ...@@ -67,5 +147,31 @@ Ext.define('PVE.qemu.Config', {
}); });
me.callParent(); me.callParent();
me.statusStore.on('load', function(s, records, success) {
var status;
if (!success) {
me.workspace.checkVmMigration(me.pveSelNode);
status = 'unknown';
} else {
var rec = s.data.get('status');
status = rec ? rec.data.value : 'unknown';
}
startBtn.setDisabled(status === 'running');
resetBtn.setDisabled(status !== 'running');
shutdownBtn.setDisabled(status !== 'running');
stopBtn.setDisabled(status === 'stopped');
consoleBtn.setDisabled(status !== 'running');
removeBtn.setDisabled(status !== 'stopped');
});
me.on('afterrender', function() {
me.statusStore.startUpdate();
});
me.on('destroy', function() {
me.statusStore.stopUpdate();
});
} }
}); });
...@@ -50,10 +50,8 @@ Ext.define('PVE.qemu.StatusView', { ...@@ -50,10 +50,8 @@ Ext.define('PVE.qemu.StatusView', {
}; };
Ext.applyIf(me, { Ext.applyIf(me, {
url: "/api2/json/nodes/" + nodename + "/qemu/" + vmid + "/status/current",
cwidth1: 150, cwidth1: 150,
height: 145, height: 145,
interval: 1000,
rows: rows rows: rows
}); });
......
...@@ -19,152 +19,28 @@ Ext.define('PVE.qemu.Summary', { ...@@ -19,152 +19,28 @@ Ext.define('PVE.qemu.Summary', {
throw "no workspace specified"; throw "no workspace specified";
} }
if (!me.statusStore) {
throw "no status storage specified";
}
var rstore = me.statusStore;
var statusview = Ext.create('PVE.qemu.StatusView', { var statusview = Ext.create('PVE.qemu.StatusView', {
title: 'Status', title: 'Status',
pveSelNode: me.pveSelNode, pveSelNode: me.pveSelNode,
width: 400 width: 400,
rstore: rstore
}); });
var rstore = statusview.rstore;
var rrdurl = "/api2/png/nodes/" + nodename + "/qemu/" + vmid + "/rrd"; var rrdurl = "/api2/png/nodes/" + nodename + "/qemu/" + vmid + "/rrd";
var vm_command = function(cmd, params) {
PVE.Utils.API2Request({
params: params,
url: '/nodes/' + nodename + '/qemu/' + vmid + "/status/" + cmd,
waitMsgTarget: me,
method: 'POST',
failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
}
});
};
var tbar = Ext.create('Ext.toolbar.Toolbar', {
items: [
{
itemId: 'start',
text: 'Start',
handler: function() {
vm_command('start');
}
},
{
itemId: 'stop',
text: 'Stop',
handler: function() {
var msg = "Do you really want to stop the VM?";
Ext.Msg.confirm('Confirm', msg, function(btn) {
if (btn !== 'yes') {
return;
}
vm_command("stop", { timeout: 30 });
});
}
},
{
itemId: 'migrate',
text: 'Migrate',
handler: function() {
var win = Ext.create('PVE.qemu.Migrate', {
pveSelNode: me.pveSelNode
});
win.show();
}
},
{
text: 'Reset',
itemId: 'reset',
handler: function() {
var msg = "Do you really want to reset the VM?";
Ext.Msg.confirm('Confirm', msg, function(btn) {
if (btn !== 'yes') {
return;
}
vm_command("reset");
});
}
},
{
itemId: 'shutdown',
text: 'Shutdown',
handler: function() {
var msg = "Do you really want to shutdown the VM?";
Ext.Msg.confirm('Confirm', msg, function(btn) {
if (btn !== 'yes') {
return;
}
vm_command('shutdown', { timeout: 30 });
});
}
},
{
itemId: 'remove',
text: 'Remove',
handler: function() {
var msg = 'Are you sure you want to remove VM ' +
vmid + '? This will permanently erase all VM data.';
Ext.Msg.confirm('Confirm', msg, function(btn) {
if (btn !== 'yes') {
return;
}
PVE.Utils.API2Request({
url: '/nodes/' + nodename + '/qemu/' + vmid,
method: 'DELETE',
waitMsgTarget: me,
failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
}
});
});
}
},
{
itemId: 'console',
text: 'Console',
handler: function() {
var url = Ext.urlEncode({
console: 'kvm',
vmid: vmid,
node: nodename
});
var nw = window.open("?" + url, '_blank',
"innerWidth=745,innerheight=427");
nw.focus();
}
}, '->',
{
xtype: 'pveRRDTypeSelector'
}
]
});
me.mon(rstore, 'load', function(s, records, success) {
var status;
if (!success) {
me.workspace.checkVmMigration(me.pveSelNode);
status = 'unknown';
} else {
var rec = s.data.get('status');
status = rec ? rec.data.value : 'unknown';
}
tbar.down('#start').setDisabled(status === 'running');
tbar.down('#reset').setDisabled(status !== 'running');
tbar.down('#shutdown').setDisabled(status !== 'running');
tbar.down('#stop').setDisabled(status === 'stopped');
tbar.down('#console').setDisabled(status !== 'running');
tbar.down('#remove').setDisabled(status !== 'stopped');
});
var notesview = Ext.create('PVE.panel.NotesView', { var notesview = Ext.create('PVE.panel.NotesView', {
pveSelNode: me.pveSelNode, pveSelNode: me.pveSelNode,
flex: 1 flex: 1
}); });
Ext.apply(me, { Ext.apply(me, {
tbar: tbar, tbar: [ '->', { xtype: 'pveRRDTypeSelector' } ],
autoScroll: true, autoScroll: true,
bodyStyle: 'padding:10px', bodyStyle: 'padding:10px',
defaults: { defaults: {
...@@ -213,13 +89,9 @@ Ext.define('PVE.qemu.Summary', { ...@@ -213,13 +89,9 @@ Ext.define('PVE.qemu.Summary', {
}); });
me.on('show', function() { me.on('show', function() {
rstore.startUpdate();
notesview.load(); notesview.load();
}); });
me.on('hide', rstore.stopUpdate);
me.on('destroy', rstore.stopUpdate);
me.callParent(); me.callParent();
} }
}); });
...@@ -320,7 +320,7 @@ Ext.define('PVE.tree.ResourceTree', { ...@@ -320,7 +320,7 @@ Ext.define('PVE.tree.ResourceTree', {
}, },
//useArrows: true, //useArrows: true,
//rootVisible: false, //rootVisible: false,
title: 'Resource Tree', //title: 'Resource Tree',
listeners: { listeners: {
destroy: function() { destroy: function() {
rstore.un("load", updateTree); rstore.un("load", updateTree);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment