prep for selfservice

This commit is contained in:
Sam W 2023-08-18 20:04:14 +02:00
parent 0dc4505630
commit 24b3acb3de
3 changed files with 36 additions and 15 deletions

View File

@ -23,7 +23,7 @@
packages.default = mach-lib.mkPython {
requirements = builtins.readFile ./requirements.txt;
};
devShells.default = pkgs.devshell.mkShell {packages = with pkgs; [packages.default imagemagick resvg python3Packages.brother-ql];};
devShells.default = pkgs.devshell.mkShell {packages = with pkgs; [packages.default imagemagick resvg];};
formatter = pkgs.alejandra;
});
}

View File

@ -2,3 +2,4 @@ quart
pyinstaller
aiohttp
aiofiles
brother_ql

View File

@ -20,28 +20,48 @@
</style>
</head>
<body>
<div>
<h1>ISO7010 Warning Stickers On Demand</h1>
<p>Brought to you by @samw@hacksrus.xyz. Label tape donations received with...</p>
<img src="/static/manythanks.png" height="100px">
</div>
{% for section, ws in ws.items() %}
<h2>{{ section }}</h2>
<div id="things">
{% for w in ws %}
<div class="thing">
<div class="thing" onclick="printme('{{w.name}}')">
<img src="{{ w.url }}" width="100%">
<div>
<div>
{{ w.name }}
</div>
<div>
{{ counts.get(w.name, 0) }}
</div>
<form method="POST">
<input type="number" min="1" max="10" value="1" name="count">
<button type="submit" name="w" value="{{ w.name }}">Print</button>
</form>
</div>
<div style="text-align: center; font-size: 20px;"> {{ w.name }} </div>
<button style="height: 30px; width: 100%">PRINT IT</button>
</div>
{% endfor %}
</div>
{% endfor %}
<script>
printing = false;
function printme(it) {
if (printing) {
return;
}
printing = true;
let formData = new FormData();
formData.append("w", it);
formData.append("count", 1);
for (e of document.getElementsByTagName("button")) {
e.disabled = true;
e.innerText = "printing....";
}
fetch("/", {
method: "POST",
body: new URLSearchParams(formData),
}).finally(() => {
for (e of document.getElementsByTagName("button")) {
e.disabled = false;
e.innerText = "PRINT IT";
}
printing = false;
})
}
</script>
</body>
</html>