From 77f1bf6cc8dfb4208e4797d7cbf8ee21643ac8b1 Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Thu, 23 Jan 2020 11:19:37 +0100
Subject: [PATCH] not working test
---
app/static/js/nopaque.js | 24 ++++++++++++++++++
app/templates/test/index.html.j2 | 42 +++++++++++++++-----------------
app/test/events.py | 17 ++++++-------
3 files changed, 51 insertions(+), 32 deletions(-)
diff --git a/app/static/js/nopaque.js b/app/static/js/nopaque.js
index bde7cb62..89afcea0 100644
--- a/app/static/js/nopaque.js
+++ b/app/static/js/nopaque.js
@@ -16,6 +16,29 @@ nopaque["foreignJobsSubscribers"] = [];
// nopaque functions
+nopaque["forms"] = {};
+nopaque["forms"]["init"] = function() {
+ for (let form of document.querySelectorAll(".nopaque-form")) {
+ form.addEventListener("submit", function(event) {
+ event.preventDefault();
+ if (form.dataset.hasOwnProperty('loadingModal')) {
+ let loadingModalElement = document.getElementById(form.dataset.loadingModal);
+ M.Modal.getInstance(loadingModalElement).open();
+ }
+ let data = {};
+ for (let input of form.querySelectorAll("input")) {
+ if (input.type === "file") {
+ file = input.files[0];
+ data[`${input.name}-wrapper`] = {"bytes": file, "name": file.name};
+ } else {
+ data[input.name] = input.value;
+ }
+ }
+ nopaque.socket.emit(`submit-${form.id}`, data);
+ });
+ }
+}
+
nopaque["navigation"] = {};
nopaque["navigation"]["init"] = function() {
for (let entry of document.querySelectorAll("#slide-out a:not(.subheader)")) {
@@ -112,6 +135,7 @@ document.addEventListener("DOMContentLoaded", function() {
{"alignment": "right", "constrainWidth": false, "coverTrigger": false});
M.Dropdown.init(document.getElementById("nav-account"),
{"alignment": "right", "constrainWidth": false, "coverTrigger": false});
+ nopaque.forms.init();
nopaque.navigation.init();
nopaque.socket.emit("subscribe_user_ressources");
});
diff --git a/app/templates/test/index.html.j2 b/app/templates/test/index.html.j2
index f0ec41f1..3fb77913 100644
--- a/app/templates/test/index.html.j2
+++ b/app/templates/test/index.html.j2
@@ -7,7 +7,7 @@