mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
MDNS: add status indicator (#244)
* remove unused variables * working status indicator
This commit is contained in:
+14
-3
@@ -38,8 +38,20 @@ class ServiceController extends ApiControllerBase
|
||||
{
|
||||
$backend = new Backend();
|
||||
$result = array('result' => 'failed');
|
||||
$mdlMDNSRepeater = new MDNSRepeater();
|
||||
$result['result'] = $backend->configdRun('mdnsrepeater status');
|
||||
$res = $backend->configdRun('mdnsrepeater status');
|
||||
if (stripos($res, 'is running')) {
|
||||
$result['result'] = 'running';
|
||||
} elseif (stripos($res, 'not running')) {
|
||||
$general = new MDNSRepeater();
|
||||
if ((string)$general->enabled == '1') {
|
||||
$result['result'] = 'stopped';
|
||||
} else {
|
||||
$result['result'] = 'disabled';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$result['message'] = $res;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -56,7 +68,6 @@ class ServiceController extends ApiControllerBase
|
||||
{
|
||||
$backend = new Backend();
|
||||
$result = array("result" => "failed");
|
||||
$mdlMDNSRepeater = new MDNSRepeater();
|
||||
$result['result'] = $backend->configdRun('mdnsrepeater stop');
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ $( document ).ready(function() {
|
||||
$('.selectpicker').selectpicker('refresh');
|
||||
});
|
||||
ajaxCall(url="/api/mdnsrepeater/service/status", sendData={}, callback=function(data,status) {
|
||||
updateServiceStatusUI(data['status']);
|
||||
updateServiceStatusUI(data['result']);
|
||||
});
|
||||
|
||||
// link save button to API set action
|
||||
@@ -43,7 +43,7 @@ $( document ).ready(function() {
|
||||
saveFormToEndpoint(url="/api/mdnsrepeater/settings/set", formid='general',callback_ok=function(){
|
||||
ajaxCall(url="/api/mdnsrepeater/service/restart", sendData={}, callback=function(data,status) {
|
||||
ajaxCall(url="/api/mdnsrepeater/service/status", sendData={}, callback=function(data,status) {
|
||||
updateServiceStatusUI(data['status']);
|
||||
updateServiceStatusUI(data['result']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,24 +1,20 @@
|
||||
[start]
|
||||
command:service mdns-repeater start
|
||||
parameters:%s
|
||||
type:script
|
||||
message:starting mdns-repeater
|
||||
|
||||
[stop]
|
||||
command:service mdns-repeater stop
|
||||
parameters:%s
|
||||
type:script
|
||||
message:stopping mdns-repeater
|
||||
|
||||
[status]
|
||||
command:service mdns-repeater status
|
||||
parameters:%s
|
||||
type:script
|
||||
command:service mdns-repeater status; true
|
||||
type:script_output
|
||||
message:mdns-repeater status
|
||||
|
||||
[restart]
|
||||
command:service mdns-repeater restart
|
||||
parameters:%s
|
||||
type:script
|
||||
message:restarting mdns-repeater
|
||||
|
||||
|
||||
Reference in New Issue
Block a user