diff --git a/web-service/server/src/index.js b/web-service/server/src/index.js index 9d0457082c1edb444f28124ace541520179b02bb..dc735319112998f1dba38dd91b4128abd1b80851 100644 --- a/web-service/server/src/index.js +++ b/web-service/server/src/index.js @@ -231,34 +231,55 @@ 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 - let uri = req.query.uri; + let uri = encodeURIComponent(req.query.uri); // let response = await Configs.find({URI: uri}); // if(dbData[0].data){ // return res.status(200).json(dbData[0]); // }else{ // let peer1 = uri_data[] - console.log("CONFIGURATION URI", uri) - let peer = uri_data[uri].peer - let response; - if(peer){ - response = peer.rpc("get_cfg", uri) - console.log("PEER", peer) - } - return res.status(200).json(response); + // console.log("CONFIGURATION URI", uri) + // let peer = uri_data[uri].peer + // let response; + // if(peer){ + // response = peer.rpc("get_cfg", uri) + // console.log("PEER", response) + // if(response){ + // return res.status(200).json(response); + // } + // } // } + //Pitää parsii uri ja tehä siitä JSON-objekti + const baseURI = "ftl%3A%2F%2Futu.fi%2Fstream%2Fconfigurations" + splittedUri = uri.substring(47); + let depth = splittedUri.split("%2F"); + console.log("DEPTH", depth) + let queryURI = baseURI + '%2F' + depth[0] + console.log("QUERYURI", queryURI) + if(depth.length === 0){ + }else if(depth.length === 1){ + }else{ + let lastObject; + let helpObj; + let helper; + for(let i=depth.length-2; i=>0; i--){ + helper = { + [depth[i]]: depth[i+1] + } + helpObj = { + [depth[i]]: depth[i+1] + } + + } + } + + - // const baseURI = "ftl%3A%2F%2Futu.fi%2Fstream%2Fconfigurations" - // const uri = wholeURI.substring(47); - // let depth = uri.split("%2F"); - // console.log("DEPTH", depth) - // let queryURI = baseURI + '%2F' + depth[0] - // console.log("QUERYURI", queryURI) // let response = await Configs.find({ URI : queryURI}); // const objects = response[0].data diff --git a/web-service/server/src/public/js/bundle.js b/web-service/server/src/public/js/bundle.js index 3cc86614e5982db37e163d9d330adc6a6f9701a0..a34a709297bc2ce96ab9e5d2cd9a929fd5b45791 100644 --- a/web-service/server/src/public/js/bundle.js +++ b/web-service/server/src/public/js/bundle.js @@ -4739,9 +4739,10 @@ updateConfigs = async () => { * current_data.configURI is a dropdown menu */ + current_data.configs = 'ftl://utu.fi/stream/configurations/calibrations/default' loadConfigs = async () => { console.log("URI", current_data.uri) - const uri = encodeURIComponent(current_data.uri); + const uri = encodeURIComponent(current_data.configs); const rawResp = await fetch(`http://localhost:8080/stream/config?uri=${uri}`) const content = await rawResp.json(); console.log(content) diff --git a/web-service/server/src/public/js/index.js b/web-service/server/src/public/js/index.js index 05bf292ffec3dee65dd024ca82d6c1f28d54b28d..d5fda51448f5fc69035a2e073ed48b56a9f4d782 100644 --- a/web-service/server/src/public/js/index.js +++ b/web-service/server/src/public/js/index.js @@ -219,9 +219,10 @@ updateConfigs = async () => { * current_data.configURI is a dropdown menu */ + current_data.configs = 'ftl://utu.fi/stream/configurations/calibrations/default' loadConfigs = async () => { console.log("URI", current_data.uri) - const uri = encodeURIComponent(current_data.uri); + const uri = encodeURIComponent(current_data.configs); const rawResp = await fetch(`http://localhost:8080/stream/config?uri=${uri}`) const content = await rawResp.json(); console.log(content)