Dashboard: show correct status after switching the client state

fix huawei hilink service (udev rule)
This commit is contained in:
Christian Zeitnitz 2021-03-15 13:29:16 +01:00
parent c87253a06b
commit 11e2724afa
3 changed files with 22 additions and 33 deletions

View file

@ -71,7 +71,7 @@ if (isset($_POST['interface'])) {
if (!empty($rule) ) exec('echo \''.$rule.'\' | sudo /usr/bin/tee -a '.$udevfile);
}
$ret=print_r($ret,true);
$jsonData = ['return'=>0,'output'=>['Udev rules changed for device '.$dev ] ];
$jsonData = ['return'=>0,'output'=>['Settings changed for device '.$dev ] ];
echo json_encode($jsonData);
return;
}

View file

@ -24,6 +24,24 @@ function DisplayDashboard(&$extraFooterScripts)
$status->showMessages();
return;
}
// ------------------------- Button pressed to switch client on/off ---------------------------------------------------------
$switchedOn = false;
if (!RASPI_MONITOR_ENABLED) {
if (isset($_POST['ifdown_wlan0'])) {
// Pressed stop button
$status->addMessage(sprintf(_('Interface is going %s.'), _('down')), 'warning');
setClientState("down");
$status->addMessage(sprintf(_('Interface is now %s.'), _('down')), 'success');
} elseif (isset($_POST['ifup_wlan0'])) {
// Pressed start button
$status->addMessage(sprintf(_('Interface is going %s.'), _('up')), 'warning');
setClientState("up");
$status->addMessage(sprintf(_('Interface is now %s.'), _('up')), 'success');
$switchedOn = true;
}
}
// ----------------------------- INFOS ABOUT THE ACCESS POINT -------------------------------------------------------------
@ -112,36 +130,8 @@ function DisplayDashboard(&$extraFooterScripts)
if ($interfaceState === 'UP') {
$classMsgDevicestatus = 'success';
}
if (!RASPI_MONITOR_ENABLED) {
if (isset($_POST['ifdown_wlan0'])) {
// Pressed stop button
if ($interfaceState === 'UP') {
$status->addMessage(sprintf(_('Interface is going %s.'), _('down')), 'warning');
setClientState("down");
// exec('sudo /usr/local/sbin/switchClientState.sh down');
$status->addMessage(sprintf(_('Interface is now %s.'), _('down')), 'success');
} elseif ($interfaceState === 'unknown') {
$status->addMessage(_('Interface state unknown.'), 'danger');
} else {
$status->addMessage(sprintf(_('Interface already %s.'), _('down')), 'warning');
}
} elseif (isset($_POST['ifup_wlan0'])) {
// Pressed start button
if ($interfaceState === 'DOWN') {
$status->addMessage(sprintf(_('Interface is going %s.'), _('up')), 'warning');
setClientState("up");
// exec('sudo /usr/local/sbin/switchClientState.sh up');
exec('sudo ip -s a f label ' . $raspi_client);
$status->addMessage(sprintf(_('Interface is now %s.'), _('up')), 'success');
} elseif ($interfaceState === 'unknown') {
$status->addMessage(_('Interface state unknown.'), 'danger');
} else {
$status->addMessage(sprintf(_('Interface already %s.'), _('up')), 'warning');
}
} else {
$status->addMessage(sprintf(_('Interface is %s.'), strtolower($interfaceState)), $classMsgDevicestatus);
}
}
if ($switchedOn) exec('sudo ip -s a f label ' . $raspi_client);
// brought in from template
$arrHostapdConf = parse_ini_file(RASPI_CONFIG.'/hostapd.ini');

View file

@ -49,5 +49,4 @@ www-data ALL=(ALL) NOPASSWD:/usr/local/sbin/onoff_huawei_hilink.sh *
www-data ALL=(ALL) NOPASSWD:/bin/sed -i * /etc/wvdial.conf
www-data ALL=(ALL) NOPASSWD:/bin/sed -i * /etc/udev/rules.d/80-raspap-net-devices.rules
www-data ALL=(ALL) NOPASSWD:/usr/bin/tee -a /etc/udev/rules.d/80-raspap-net-devices.rules
www-data ALL=(ALL) NOPASSWD:/usr/local/sbin/switchClientState.sh *