diff --git a/script.js b/script.js new file mode 100644 index 0000000..078daad --- /dev/null +++ b/script.js @@ -0,0 +1,32 @@ +var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')) +var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) { + return new bootstrap.Tooltip(tooltipTriggerEl) +}) +const delay = ms => new Promise(res => setTimeout(res, ms)); +fetch ("run.txt") +.then(x => x.text()) +.then(y => document.getElementById("run").innerHTML = y); +fetch ("block.txt") +.then(x => x.text()) +.then(y => document.getElementById("blocked").innerHTML = y); +async function reboot(){ + document.getElementById("rebooticon").innerHTML = "" + fetch ("reboot.run") + .then(x => x.text()) + .then(y => document.getElementById("rebooticon").innerHTML = y); + await delay(2000) + document.getElementById("rebooticon").innerHTML = "" +} +async function refresh(){ +document.getElementById("refresh").innerHTML = "" +document.getElementById("run").innerHTML = "" +document.getElementById("blocked").innerHTML = "" +fetch ("run.txt") +.then(x => x.text()) +.then(y => document.getElementById("run").innerHTML = y) +fetch ("block.txt") +.then(x => x.text()) +.then(y => document.getElementById("blocked").innerHTML = y); +await delay(2000) +document.getElementById("refresh").innerHTML = "" +} \ No newline at end of file diff --git a/sweebot-dashboard.py b/sweebot-dashboard.py new file mode 100644 index 0000000..b664a45 --- /dev/null +++ b/sweebot-dashboard.py @@ -0,0 +1,34 @@ +from flask import Flask +from flask import send_file +from flask import request +from flask import redirect +import os +from time import sleep as wait +app = Flask(__name__) + +@app.route('/') +def index(): + return send_file("sweebot.html", mimetype='text/html') +@app.route('/run.txt') +def run(): + wait(2) + return send_file("run.txt", mimetype='text/html') +@app.route('/block.txt') +def block(): + wait(2) + return send_file("block.txt", mimetype='text/html') +@app.route('/script.js') +def script(): + return send_file("script.js", mimetype='application/javascript') +@app.route('/reboot.run') +def reboot(): + os.system("systemctl --user restart sweebot") + wait(1) + return "" + + +if __name__ == '__main__': + + # run() method of Flask class runs the application + # on the local development server. + app.run(host='0.0.0.0',port=2001) \ No newline at end of file diff --git a/sweebot.html b/sweebot.html new file mode 100644 index 0000000..c260f63 --- /dev/null +++ b/sweebot.html @@ -0,0 +1,18 @@ + +