From bc90226cb20ecd8860ae927f93083f48f02fe22e Mon Sep 17 00:00:00 2001
From: Sami Spets <savasp@utu.fi>
Date: Mon, 18 Nov 2019 09:56:01 +0200
Subject: [PATCH] Minor changes into POST /stream/config route

---
 web-service/server/src/index.js           |  8 +----
 web-service/server/src/public/js/index.js | 38 +++++++++++------------
 2 files changed, 19 insertions(+), 27 deletions(-)

diff --git a/web-service/server/src/index.js b/web-service/server/src/index.js
index fb7f93038..b3301b177 100644
--- a/web-service/server/src/index.js
+++ b/web-service/server/src/index.js
@@ -207,14 +207,8 @@ app.get('/stream/depth', (req, res) => {
 });
 
 app.post('/stream/config', async (req, res) => {
-	const {board_size, square_size, frame_delay, num_frames, URI} = req.body;
+	const {URI, data} = req.body;
 	console.log(req.body)
-	const data = {
-		board_size,
-		square_size,
-		frame_delay,
-		num_frames
-	}
 	const savedConfigs = new Configs({
 		URI,
 		data
diff --git a/web-service/server/src/public/js/index.js b/web-service/server/src/public/js/index.js
index 1a19ccbac..1afbd599b 100644
--- a/web-service/server/src/public/js/index.js
+++ b/web-service/server/src/public/js/index.js
@@ -191,39 +191,37 @@ const cardLogic = () => {
 configs = () => {
     const container = document.getElementById("container");
     container.innerHTML = `<div class="ftlab-configurations"></div>`;
-    let configContainer = document.getElementsByClassName("ftlab-configurations")[0];
+    // let configContainer = document.getElementsByClassName("ftlab-configurations")[0];
+    renderConfigOptions();
 }
 
 renderConfigOptions = () => {
-    const input = `<p>input1</p><br><input type="text">`
+    const input = `<p>input1</p><br>ftl://utu.fi#<input type="text">`
     const doc = document.getElementsByClassName('ftlab-configurations')[0];
-    doc.innerHTML = input
+    doc.innerHTML = input;
 }
 
-updateConfigs = async () => {
+current_data.configURI = "ftl://utu.fi#reconstruction_snap10/merge"
+
+loadConfigs = async () => {
+    const configURI = encodeURIComponent(current_data.configURI);
+    const uri = encodeURIComponent(current_data.uri)
+    const rawResp = await fetch(`http://localhost:8080/stream/config?settings=${configURI}&uri=${uri}`)
+    const response = await rawResp.json();
+    const content = JSON.parse(response);
+    container.innerHTML += `<p>${response}</p>`;
+    console.log(content)
+}
+
+saveConfigs = async () => {
     const rawResp = await fetch('http://localhost:8080/stream/config', {
         method: 'POST',
         headers: {
             'Accept': 'application/json',
             'Content-Type': 'application/json'
         },
-        body: JSON.stringify({board_size: [0, 5], square_size: 1, frame_delay: 5, num_frames: 10, URI: "current_data.uri"})
+        body: {uri: current_data.configURI, data: current_data.configData}
     });
     const content = await rawResp.json();
     console.log(content)
-}
-
-//current_data.configURI
-//configURI = 
-/**
- * current_data.configURI is a dropdown menu
- */
-
-current_data.configs = "ftl://utu.fi#reconstruction_snap10/merge/maxerror"
-loadConfigs = async () => {
-    const configURI = encodeURIComponent(current_data.configs);
-    const uri = encodeURIComponent(current_data.uri)
-    const rawResp = await fetch(`http://localhost:8080/stream/config?settings=${configURI}&uri=${uri}`)
-    const content = await rawResp.json();
-    console.log(content)
 }
\ No newline at end of file
-- 
GitLab