diff --git a/.avalon/gen.py b/.avalon/gen.py index 8bc4982..d999470 100644 --- a/.avalon/gen.py +++ b/.avalon/gen.py @@ -3,5 +3,7 @@ binf = sys.argv[1] filesFolder = sys.argv[2] -with open(binf, 'w') as f: - f.write(f'#!/bin/bash\ncd "{filesFolder}"\npython3 "{filesFolder}/villicus.py" "$@"') +with open(binf, "w") as f: + f.write( + f'#!/bin/bash\ncd "{filesFolder}"\npython3 "{filesFolder}/villicus.py" "$@"' + ) diff --git a/source/bar.css b/source/bar.css deleted file mode 100644 index 8db602e..0000000 --- a/source/bar.css +++ /dev/null @@ -1,63 +0,0 @@ -/* The sidebar menu */ -.sidebar { - height: 100%; /* Full-height: remove this if you want "auto" height */ - width: 50px; /* Set the width of the sidebar */ - position: fixed; /* Fixed Sidebar (stay in place on scroll) */ - z-index: 1; /* Stay on top */ - top: 0; /* Stay at the top */ - left: 0; - background-color: #111; /* Black */ - overflow-x: hidden; /* Disable horizontal scroll */ - } - - .sidebar a { - padding: 6px; - text-decoration: none; - font-size: 25px; - color: #818181; - display: block; - background-color: #292929; - min-height: 38px; - max-height: 50px; - } - - .sidebar a img { - height: 44; - width: 38; - } - - .sidebar a:hover { - background-color: #636363; - } - - .main { - margin-left: 50px; /* Same as the width of the sidebar */ - padding: 0px 10px; - } - -.topbar { - background-color: #333; - overflow: hidden; - margin-left: 50px; - border-radius: 20px; - } - - .miniBarProgress { - vertical-align: middle; - color: white; - padding-top: 2px; - padding: 0px 0px 0px 0px; - height: 20px; - position: relative; - top: 0rem; - left: 0rem; - float: left; -} - -.inline { - display: inline-block; -} - -body { - background: #EEEEEE; -} \ No newline at end of file diff --git a/static/bar.css b/static/bar.css new file mode 100644 index 0000000..422fb5f --- /dev/null +++ b/static/bar.css @@ -0,0 +1,93 @@ +/* The sidebar menu */ +.sidebar { + display: flex; + height: 100%; /* Full-height: remove this if you want "auto" height */ + width: 50px; /* Set the width of the sidebar */ + position: fixed; /* Fixed Sidebar (stay in place on scroll) */ + z-index: 1; /* Stay on top */ + top: 0; /* Stay at the top */ + left: 0; + background-color: #111; /* Black */ + flex-direction: column; + justify-content: space-between; +} + +.sidebar a { + padding: 6px; + text-decoration: none; + font-size: 25px; + color: #818181; + display: block; + background-color: #292929; + min-height: 38px; + max-height: 50px; +} + +.sidebar a img { + height: 44; + width: 38; +} + +.sidebar a:hover { + background-color: #636363; +} + +.main { + margin-left: 50px; /* Same as the width of the sidebar */ + padding: 0px 10px; +} + +#statusdisplay > div.barsegment { + width: 50px; + height: 50px; + color: white; +} + +#statusdisplay > div.barsegment > div.barcontainer { + height: 100%; + display: flex; + justify-content: center; + align-items: center; +} + +#statusdisplay > div.barsegment > div.barcontainer > div.bartext { + text-align: center; +} + +.inline { + display: inline-block; +} + +body { + font-family: arial, sans-serif; + background: #EEEEEE; +} + +.tooltip .tooltiptext { + visibility: hidden; + width: 120px; + background-color: black; + color: #fff; + text-align: center; + border-radius: 6px; + padding: 5px 0; + position: relative; + z-index: 1; + top: -40px; + left: 110%;; +} + +.tooltip .tooltiptext::after { + content: ""; + position: absolute; + top: 50%; + right: 100%; + margin-top: -5px; + border-width: 5px; + border-style: solid; + border-color: transparent black transparent transparent; +} + +.tooltip:hover .tooltiptext { + visibility: visible; +} diff --git a/source/details-add.svg b/static/details-add.svg similarity index 100% rename from source/details-add.svg rename to static/details-add.svg diff --git a/source/details.svg b/static/details.svg similarity index 100% rename from source/details.svg rename to static/details.svg diff --git a/source/home.svg b/static/home.svg similarity index 100% rename from source/home.svg rename to static/home.svg diff --git a/static/js/bar.mjs b/static/js/bar.mjs new file mode 100644 index 0000000..f48d28f --- /dev/null +++ b/static/js/bar.mjs @@ -0,0 +1,57 @@ +import {html, render, Component, useState} from 'https://esm.sh/htm/preact/standalone' +import {httpGet} from '/static/js/common.mjs' + +function BarSegment(props) { + return html`
`; +} + +class StatusBar extends Component { + state = { + running: 0, + paused: 0, + killed: 100, + done: 0 + }; + + makeSocket() { + this.socket = new WebSocket((window.location.protocol === "https:" ? "wss://" : "ws://") + window.location.host + "/ws/status"); + + this.socket.addEventListener('message', (event) => { + this.setState(JSON.parse(event.data)); + this.render(); + }); + + this.socket.addEventListener('close', (event) => { + console.warn("Status websocket disconnected, attempting reconnect..."); + + setTimeout(this.makeSocket.bind(this), 10000); + }); + } + + constructor() { + super(); + + this.makeSocket(); + } + + render() { + return html` +<${BarSegment} type=Running percentage=${this.state.running} color=darkgreen/> +<${BarSegment} type=Paused percentage=${this.state.paused} color=darkorange/> +<${BarSegment} type="Killed/Exited" percentage=${this.state.killed} color=darkred/> +<${BarSegment} type=Done percentage=${this.state.done} color="rgb(39, 28, 28)"/> +` + return httpGet("/status"); + } +} + +export {StatusBar, html, render} diff --git a/static/js/common.mjs b/static/js/common.mjs new file mode 100644 index 0000000..2ffe4a7 --- /dev/null +++ b/static/js/common.mjs @@ -0,0 +1,8 @@ +function httpGet(theUrl) { + var xmlHttp = new XMLHttpRequest(); + xmlHttp.open("GET", theUrl, false); // false for synchronous request + xmlHttp.send(null); + return xmlHttp.responseText; +} + +export {httpGet} diff --git a/source/kill.svg b/static/kill.svg similarity index 100% rename from source/kill.svg rename to static/kill.svg diff --git a/source/pause.svg b/static/pause.svg similarity index 100% rename from source/pause.svg rename to static/pause.svg diff --git a/source/play.svg b/static/play.svg similarity index 100% rename from source/play.svg rename to static/play.svg diff --git a/source/reload.svg b/static/reload.svg similarity index 100% rename from source/reload.svg rename to static/reload.svg diff --git a/source/restart.svg b/static/restart.svg similarity index 100% rename from source/restart.svg rename to static/restart.svg diff --git a/source/table.css b/static/table.css similarity index 100% rename from source/table.css rename to static/table.css diff --git a/templates/bar.html b/templates/bar.html index bbea561..14e269f 100644 --- a/templates/bar.html +++ b/templates/bar.html @@ -1,63 +1,37 @@ - - -