luci/applications/luci-app-keepalived/htdocs/luci-static/resources/view/keepalived/ipaddress.js
Jaymin Patel d1a82d2886 luci-app-keepalived: Add LuCI for keepalived
LuCI Support for Keepalived

Signed-off-by: Jaymin Patel <jem.patel@gmail.com>
2022-10-23 16:19:33 +05:30

90 lines
2.3 KiB
JavaScript

'use strict';
'require view';
'require ui';
'require form';
'require uci';
'require tools.widgets as widgets';
return view.extend({
load: function() {
return Promise.all([
uci.load('keepalived'),
]);
},
renderIPAddress: function(m) {
var s, o;
s = m.section(form.GridSection, 'ipaddress', _('IP Addresses'),
_('Addresses would be referenced into Static and Virtual IP Address of VRRP instances'));
s.anonymous = true;
s.addremove = true;
s.nodescriptions = true;
o = s.option(form.Value, 'name', _('Name'));
o.rmempty = false;
o.optional = false;
o.placeholder = 'name';
o = s.option(form.Value, 'address', _('Address'),
_('IP Address of the object'));
o.rmempty = false;
o.optional = false;
o.datatype = 'ipaddr';
o.placeholder = '192.168.1.1';
o = s.option(widgets.DeviceSelect, 'device', _('Device'),
_('Device to use to assign the Address'));
o.optional = true;
o.noaliases = true;
o = s.option(form.Value, 'label_suffix', _('Virtual Device Label'),
_('Creates virtual device with Label'));
o.datatype = 'maxlength(4)';
o.optional = true;
o = s.option(form.ListValue, 'scope', _('Scope'),
_('Scope of the Address'));
o.value('site', _('Site'));
o.value('link', _('Link'));
o.value('host', _('Host'));
o.value('nowhere', _('No Where'));
o.value('global', _('Global'));
o.optional = true;
},
renderStaticIPAddress: function(m) {
var s, o;
var ipaddress;
ipaddress = uci.sections('keepalived', 'ipaddress');
if (ipaddress == '') {
ui.addNotification(null, E('p', _('IP Addresses must be configured for Static IP List')));
}
s = m.section(form.GridSection, 'static_ipaddress', _('Static IP Addresses'),
_('Static Addresses are not moved by vrrpd, they stay on the machine.') + '<br/>' +
_('If you already have IPs on your machines and your machines can ping each other, you don\'t need this section'));
s.anonymous = true;
s.addremove = true;
s.nodescriptions = true;
o = s.option(form.DynamicList, 'address', _('IP Address'),
_('List of IP Addresses'));
for (var i = 0; i < ipaddress.length; i++) {
o.value(ipaddress[i]['name']);
}
o.optional = true;
},
render: function() {
var m;
m = new form.Map('keepalived');
this.renderIPAddress(m);
this.renderStaticIPAddress(m);
return m.render();
}
});