diff --git a/web-service/server/src/index.js b/web-service/server/src/index.js index ca6d16eb95a8505d9d009fc2cc47963c33ca4623..ebab412ab53c4fa5e369a749aaf606b8f694d19b 100644 --- a/web-service/server/src/index.js +++ b/web-service/server/src/index.js @@ -231,8 +231,11 @@ app.post('/stream/config', async (req, res) => { app.get('/stream/config', async(req, res) => { //example of uri ftlab.utu.fi/stream/config?uri=ftl://utu.fi/stream/configurations/calibrations/default/board_size - const wholeURI = encodeURIComponent(req.query.uri) + let dataURI = await Configs.find({URI: wholeURI}); + if(dataURI[0].data.length){ + return res.status(200).json(dataURI[0]); + } const baseURI = "ftl%3A%2F%2Futu.fi%2Fstream%2Fconfigurations" const uri = wholeURI.substring(47); let depth = uri.split("%2F"); diff --git a/web-service/server/src/public/js/bundle.js b/web-service/server/src/public/js/bundle.js index d59fd118b23415f6c09ff8d01cd93dda0423e99e..8cf67432f1173446e9b1db9dd6302c0f1d68cf8f 100644 --- a/web-service/server/src/public/js/bundle.js +++ b/web-service/server/src/public/js/bundle.js @@ -4720,17 +4720,29 @@ renderConfigOptions = () => { doc.innerHTML = input } -changeConfigs = async () => { +updateConfigs = 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: JSON.stringify({board_size: [0, 5], square_size: 1, frame_delay: 5, num_frames: 10, URI: "current_data.uri"}) }); const content = await rawResp.json(); console.log(content) +} + +//current_data.configURI +//configURI = +/** + * current_data.configURI is a dropdown menu + */ + +loadConfigs = async () => { + const rawResp = await fetch(`http://localhost:8080/stream/config?uri=current_data.uri`) + const content = await rawResp.json(); + console.log(content) } },{"../../peer":22}],24:[function(require,module,exports){ (function (global){ diff --git a/web-service/server/src/public/js/index.js b/web-service/server/src/public/js/index.js index 2f304dc023a2596ca9603a84b5807b3e0cea5593..becff622110916f94afb17bf014db18f5c8127fb 100644 --- a/web-service/server/src/public/js/index.js +++ b/web-service/server/src/public/js/index.js @@ -200,7 +200,7 @@ renderConfigOptions = () => { doc.innerHTML = input } -changeConfigs = async () => { +updateConfigs = async () => { const rawResp = await fetch('http://localhost:8080/stream/config', { method: 'POST', headers: { @@ -211,4 +211,16 @@ changeConfigs = async () => { }); const content = await rawResp.json(); console.log(content) +} + +//current_data.configURI +//configURI = +/** + * current_data.configURI is a dropdown menu + */ + +loadConfigs = async () => { + const rawResp = await fetch(`http://localhost:8080/stream/config?uri=current_data.uri`) + const content = await rawResp.json(); + console.log(content) } \ No newline at end of file