@@ -9,7 +9,7 @@
'require validation';
'require tools.widgets as widgets';
-var callHostHints, callDUIDHints, callDHCPLeases, CBILeaseStatus, CBILease6Status;
+var callHostHints, callDUIDHints, callDHCPLeases, callRcList, CBIServiceEnabled, CBIServiceRunning, CBILeaseStatus, CBILease6Status;
callHostHints = rpc.declare({
object: 'luci-rpc',
@@ -29,6 +29,37 @@ callDHCPLeases = rpc.declare({
expect: { '': {} }
});
+callRcList = rpc.declare({
+ object: 'rc',
+ method: 'list',
+ params: ['name'],
+ expect: { '': {} }
+});
+
+CBIServiceEnabled = form.DummyValue.extend({
+ renderWidget: function(section_id, option_id, cfgvalue) {
+ return E([], [
+ E('span', {}, cfgvalue ? _('Enabled') : _('Disabled')),
+ ' ',
+ E('button', {
+ 'class': 'btn'
+ }, [ cfgvalue ? _('Disable') : _('Enable') ])
+ ]);
+ },
+});
+
+CBIServiceRunning = form.DummyValue.extend({
+ renderWidget: function(section_id, option_id, cfgvalue) {
+ return E([], [
+ E('span', {}, cfgvalue ? _('Started') : _('Stopped')),
+ ' ',
+ E('button', {
+ 'class': 'btn'
+ }, [ cfgvalue ? _('Stop') : _('Start') ])
+ ]);
+ },
+});
+
CBILeaseStatus = form.DummyValue.extend({
renderWidget: function(section_id, option_id, cfgvalue) {
return E([
@@ -277,7 +308,8 @@ return view.extend({
callHostHints(),
callDUIDHints(),
getDHCPPools(),
- network.getNetworks()
+ network.getNetworks(),
+ callRcList('dnsmasq')
]);
},
@@ -287,6 +319,7 @@ return view.extend({
duids = hosts_duids_pools[1],
pools = hosts_duids_pools[2],
networks = hosts_duids_pools[3],
+ service = hosts_duids_pools[4],
m, s, o, ss, so;
let noi18nstrings = {
@@ -315,6 +348,16 @@ return view.extend({
m = new form.Map('dhcp', _('DHCP and DNS'),
_('Dnsmasq is a lightweight <abbr title="Dynamic Host Configuration Protocol">DHCP</abbr> server and <abbr title="Domain Name System">DNS</abbr> forwarder.'));
+ s = m.section(form.TypedSection);
+ s.anonymous = true;
+ s.cfgsections = function() { return [ '_status' ] };
+
+ o = s.option(CBIServiceEnabled, '_enabled', _('Autostart'));
+ o.cfgvalue = function() { return service.dnsmasq.enabled; };
+
+ o = s.option(CBIServiceRunning, '_running', _('Current status'));
+ o.cfgvalue = function() { return service.dnsmasq.running; };
+
s = m.section(form.TypedSection, 'dnsmasq');
s.anonymous = false;
s.addremove = true;