Commit 8f7b120a authored by Dietmar Maurer's avatar Dietmar Maurer

lxc GUI: add DNS panel

parent d667a3f3
......@@ -144,6 +144,7 @@ JSSRC= \
lxc/Network.js \
lxc/Resources.js \
lxc/Options.js \
lxc/DNS.js \
lxc/Config.js \
lxc/CreateWizard.js \
pool/StatusView.js \
......
......@@ -135,6 +135,11 @@ Ext.define('PVE.lxc.Config', {
itemId: 'network',
xtype: 'pveLxcNetworkView'
},
{
title: gettext('DNS'),
itemId: 'dns',
xtype: 'pveLxcDNS'
},
{
title: gettext('Options'),
itemId: 'options',
......
/*jslint confusion: true */
Ext.define('PVE.lxc.DNS', {
extend: 'PVE.grid.ObjectGrid',
alias: ['widget.pveLxcDNS'],
initComponent : function() {
var me = this;
var i;
var nodename = me.pveSelNode.data.node;
if (!nodename) {
throw "no node name specified";
}
var vmid = me.pveSelNode.data.vmid;
if (!vmid) {
throw "no VM ID specified";
}
var caps = Ext.state.Manager.get('GuiCap');
var rows = {
hostname: {
required: true,
defaultValue: me.pveSelNode.data.name,
header: gettext('Hostname'),
editor: caps.vms['VM.Config.Network'] ? {
xtype: 'pveWindowEdit',
subject: gettext('Hostname'),
items: {
xtype: 'textfield',
name: 'hostname',
vtype: 'DnsName',
value: '',
fieldLabel: gettext('Hostname'),
allowBlank: true,
emptyText: me.pveSelNode.data.name
}
} : undefined
},
searchdomain: {
header: gettext('DNS domain'),
defaultValue: '',
editor: caps.vms['VM.Config.Network'] ? {
xtype: 'pveWindowEdit',
subject: gettext('DNS domain'),
items: {
xtype: 'pvetextfield',
name: 'searchdomain',
fieldLabel: gettext('DNS domain'),
allowBlank: false
}
} : undefined
},
nameserver: {
header: gettext('DNS server'),
defaultValue: '',
editor: caps.vms['VM.Config.Network'] ? {
xtype: 'pveWindowEdit',
subject: gettext('DNS server'),
items: {
xtype: 'pvetextfield',
name: 'nameserver',
fieldLabel: gettext('DNS server'),
allowBlank: false
}
} : undefined
}
};
var baseurl = 'nodes/' + nodename + '/lxc/' + vmid + '/config';
var reload = function() {
me.rstore.load();
};
var sm = Ext.create('Ext.selection.RowModel', {});
var run_editor = function() {
var rec = sm.getSelection()[0];
if (!rec) {
return;
}
var rowdef = rows[rec.data.key];
if (!rowdef.editor) {
return;
}
var config = Ext.apply({
pveSelNode: me.pveSelNode,
confid: rec.data.key,
url: '/api2/extjs/' + baseurl
}, rowdef.editor);
var win = Ext.createWidget(rowdef.editor.xtype, config);
win.load();
win.show();
win.on('destroy', reload);
};
var edit_btn = new PVE.button.Button({
text: gettext('Edit'),
disabled: true,
selModel: sm,
enableFn: function(rec) {
var rowdef = rows[rec.data.key];
return !!rowdef.editor;
},
handler: run_editor
});
var set_button_status = function() {
var sm = me.getSelectionModel();
var rec = sm.getSelection()[0];
if (!rec) {
edit_btn.disable();
return;
}
var rowdef = rows[rec.data.key];
edit_btn.setDisabled(!rowdef.editor);
};
Ext.applyIf(me, {
url: "/api2/json/nodes/" + nodename + "/lxc/" + vmid + "/config",
selModel: sm,
cwidth1: 150,
tbar: [ edit_btn ],
rows: rows,
listeners: {
itemdblclick: run_editor,
selectionchange: set_button_status
}
});
me.callParent();
me.on('show', reload);
}
});
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