splash_screen: use moonraker for actions if connected, hide system panel if it isn't connected
use systemctl if moonraker isn't available close #615
This commit is contained in:
parent
562e49b8d2
commit
ea3e7ad3d1
@ -268,6 +268,7 @@ panel: network
|
||||
name: {{ gettext('System') }}
|
||||
icon: info
|
||||
panel: system
|
||||
enable: {{ moonraker_connected }}
|
||||
|
||||
[menu __splashscreen settings]
|
||||
name: {{ gettext('Settings') }}
|
||||
|
@ -104,6 +104,10 @@ class MenuPanel(ScreenPanel):
|
||||
if enable is False:
|
||||
return False
|
||||
|
||||
if enable == "{{ moonraker_connected }}":
|
||||
logging.info("moonraker is_connected %s", self._screen._ws.is_connected())
|
||||
return self._screen._ws.is_connected()
|
||||
|
||||
if not self.j2_data:
|
||||
self.j2_data = self._printer.get_printer_status_data()
|
||||
try:
|
||||
|
@ -131,7 +131,21 @@ class SplashScreenPanel(ScreenPanel):
|
||||
|
||||
|
||||
def shutdown(self, widget):
|
||||
os.system("sudo shutdown -P now")
|
||||
_ = self.lang.gettext
|
||||
if self._screen._ws.is_connected():
|
||||
self._screen._confirm_send_action(widget,
|
||||
_("Are you sure you wish to shutdown the system?"),
|
||||
"machine.shutdown")
|
||||
else:
|
||||
logging.info("OS Shutdown")
|
||||
os.system("systemctl poweroff")
|
||||
|
||||
def restart_system(self, widget):
|
||||
os.system("sudo reboot now")
|
||||
_ = self.lang.gettext
|
||||
if self._screen._ws.is_connected():
|
||||
self._screen._confirm_send_action(widget,
|
||||
_("Are you sure you wish to reboot the system?"),
|
||||
"machine.reboot")
|
||||
else:
|
||||
logging.info("OS Reboot")
|
||||
os.system("systemctl reboot")
|
||||
|
Loading…
x
Reference in New Issue
Block a user