Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
ftl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nicolas Pope
ftl
Commits
12e16196
Commit
12e16196
authored
5 years ago
by
Sami Spets
Browse files
Options
Downloads
Patches
Plain Diff
Refactoring done
parent
81716845
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
web-service/server/src/index.js
+13
-53
13 additions, 53 deletions
web-service/server/src/index.js
with
13 additions
and
53 deletions
web-service/server/src/index.js
+
13
−
53
View file @
12e16196
...
...
@@ -230,65 +230,25 @@ 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
settings
=
encodeURIComponent
(
req
.
query
.
settings
);
const
setting
=
req
.
query
.
settings
;
//example of uri ftlab.utu.fi/stream/config?uri=ftl://utu.fi#reconstruction_snap10/merge
const
settings
=
req
.
query
.
settings
;
const
uri
=
req
.
query
.
uri
;
// let response = await Configs.find({URI: uri});
// //Check if DB has data
// let response = await Configs.find({URI: settings});
// if(dbData[0].data){
// return res.status(200).json(dbData[0]);
// }else{
// }
// }
const
baseURI
=
"
ftl%3A%2F%2Futu.fi%2Fstream%2Fconfigurations
"
splittedUri
=
settings
.
substring
(
47
);
let
depth
=
splittedUri
.
split
(
"
%2F
"
);
if
(
depth
[
depth
.
length
-
1
].
length
===
0
){
depth
.
pop
();
}
// console.log("DEPTH", depth)
let
queryURI
=
baseURI
+
'
%2F
'
+
depth
[
0
]
// console.log("QUERYURI", queryURI)
// var configURI;
// switch(depth.length){
// case 0:
// return res.status(502)
// case 1:
// configURI = JSON.stringify(depth[0]);
// break;
// case 2:
// const obj = { [depth[depth.length-2]]: depth[depth.length-1] }
// configURI = JSON.stringify(obj);
// break;
// default:
// let lastObject = { [depth[depth.length-2]]: depth[depth.length-1] }
// let helper = { [depth[depth.length-3]]: lastObject }
// if(depth.length<4){
// configURI = JSON.stringify(helper);
// }
// for(let i=depth.length-4; i>=0; i--){
// if(i<=0){
// configURI = JSON.stringify(helper)
// }
// lastObject = { [depth[i-1]]: helper }
// helper = lastObject
// }
let
peer
=
uri_data
[
uri
].
peer
if
(
peer
){
console
.
log
(
"
get_cfg
"
,
settings
)
peer
.
rpc
(
"
get_cfg
"
,
(
response
)
=>
{
if
(
response
){
return
res
.
status
(
200
).
json
(
response
);
}
},
settings
)
}
// }
// return res.status(200).json(configURI);
let
peer
=
uri_data
[
uri
].
peer
if
(
peer
){
console
.
log
(
"
get_cfg
"
,
setting
)
peer
.
rpc
(
"
get_cfg
"
,
(
response
)
=>
{
console
.
log
(
response
)
if
(
response
){
return
res
.
status
(
200
).
json
(
response
);
}
},
setting
)
}
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment