Skip to content
Snippets Groups Projects
Commit c9859ee8 authored by Sami Spets's avatar Sami Spets
Browse files

Added loadConfigs method for client

parent 4145763d
No related branches found
No related tags found
No related merge requests found
Pipeline #16332 passed
......@@ -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");
......
......@@ -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){
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment