Adding users controls on the frontend quit/shutdown/reboot
This commit is contained in:
		@@ -13,8 +13,35 @@ def api_reboot():
 | 
			
		||||
    """ 
 | 
			
		||||
        Reboot the device 
 | 
			
		||||
    """
 | 
			
		||||
    sp.Popen("reboot", shell=True)
 | 
			
		||||
    return jsonify({"mesage": "Let's reboot."})
 | 
			
		||||
    if read_config(("frontend", "reboot_option")):
 | 
			
		||||
        sp.Popen("shutdown -r now", shell=True)
 | 
			
		||||
        return jsonify({"mesage": "Let's reboot."})
 | 
			
		||||
    else:
 | 
			
		||||
        return jsonify({"message": "Option disabled", "status": False})
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@misc_bp.route("/quit", methods=["GET"])
 | 
			
		||||
def api_quit():
 | 
			
		||||
    """ 
 | 
			
		||||
        Quit the interface (Chromium browser) 
 | 
			
		||||
    """
 | 
			
		||||
    if read_config(("frontend", "quit_option")):
 | 
			
		||||
        sp.Popen('pkill -INT -f "chromium-browser"', shell=True)
 | 
			
		||||
        return jsonify({"message": "Let's quit", "status": True})
 | 
			
		||||
    else:
 | 
			
		||||
        return jsonify({"message": "Option disabled", "status": False})
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@misc_bp.route("/shutdown", methods=["GET"])
 | 
			
		||||
def api_shutdown():
 | 
			
		||||
    """ 
 | 
			
		||||
        Reboot the device 
 | 
			
		||||
    """
 | 
			
		||||
    if read_config(("frontend", "shutdown_option")):
 | 
			
		||||
        sp.Popen("shutdown -h now", shell=True)
 | 
			
		||||
        return jsonify({"message": "Let's shutdown", "status": True})
 | 
			
		||||
    else:
 | 
			
		||||
        return jsonify({"message": "Option disabled", "status": False})
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@misc_bp.route("/config", methods=["GET"])
 | 
			
		||||
@@ -27,4 +54,7 @@ def get_config():
 | 
			
		||||
        "hide_mouse": read_config(("frontend", "hide_mouse")),
 | 
			
		||||
        "download_links": read_config(("frontend", "download_links")),
 | 
			
		||||
        "sparklines": read_config(("frontend", "sparklines")),
 | 
			
		||||
        "quit_option": read_config(("frontend", "quit_option")),
 | 
			
		||||
        "shutdown_option": read_config(("frontend", "shutdown_option")),
 | 
			
		||||
        "reboot_option": read_config(("frontend", "reboot_option"))
 | 
			
		||||
    })
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user