From 2840c5c21ef7f32795e93e9de5ece1ae9d7e3009 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 28 Jan 2022 11:03:57 +0100 Subject: [PATCH] manager control over form of print tag --- ereuse_devicehub/static/js/print.pdf.js | 58 +++++++++++++++++++ .../templates/inventory/tag_details.html | 26 +++++---- 2 files changed, 74 insertions(+), 10 deletions(-) create mode 100644 ereuse_devicehub/static/js/print.pdf.js diff --git a/ereuse_devicehub/static/js/print.pdf.js b/ereuse_devicehub/static/js/print.pdf.js new file mode 100644 index 00000000..46f7b89a --- /dev/null +++ b/ereuse_devicehub/static/js/print.pdf.js @@ -0,0 +1,58 @@ +$(document).ready(function() { + STORAGE_KEY = 'tag-spec-key'; + $("#printerType").on("change", change_size); + change_size(); + load_size(); + // printpdf(); +}) + +function qr_draw(url) { + var qrcode = new QRCode(document.getElementById("qrcode"), { + text: url, + width: 128, + height: 128, + colorDark : "#000000", + colorLight : "#ffffff", + correctLevel : QRCode.CorrectLevel.H + }); +} + +function save_size() { + var height = $("#height-tag").val(); + var width = $("#width-tag").val(); + var sizePreset = $("#printerType").val(); + var data = {"height": height, "width": width, "sizePreset": sizePreset}; + localStorage.setItem(STORAGE_KEY, JSON.stringify(data)); +} + +function load_size() { + var data = JSON.parse(localStorage.getItem(STORAGE_KEY)); + if (data){ + $("#height-tag").val(data.height); + $("#width-tag").val(data.width); + $("#printerType").val(data.sizePreset); + }; +} + +function reset_size() { + localStorage.removeItem(STORAGE_KEY); + $("#printerType").val('brotherSmall'); + change_size(); +} + +function change_size() { + var sizePreset = $("#printerType").val(); + if (sizePreset == 'brotherSmall') { + $("#height-tag").val(29); + $("#width-tag").val(62); + } else if (sizePreset == 'smallTagPrinter') { + $("#height-tag").val(59); + $("#width-tag").val(97); + } +} + +function printpdf() { + var height = $("#height-tag").val(); + var width = $("#width-tag").val(); + console.log(height); +} diff --git a/ereuse_devicehub/templates/inventory/tag_details.html b/ereuse_devicehub/templates/inventory/tag_details.html index 9310bdff..e7602562 100644 --- a/ereuse_devicehub/templates/inventory/tag_details.html +++ b/ereuse_devicehub/templates/inventory/tag_details.html @@ -75,19 +75,30 @@
- + mm
- + mm
+
+
+ Print +
+
+ Save +
+
+ Reset +
+
@@ -96,16 +107,11 @@ + + {% endblock main %}