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

changes to GET /stream/config route

parent de86fd17
No related branches found
No related tags found
No related merge requests found
Pipeline #15156 passed
...@@ -7,13 +7,15 @@ const checkIfLoggedIn = async () => { ...@@ -7,13 +7,15 @@ const checkIfLoggedIn = async () => {
containerDiv = login; containerDiv = login;
//User has a token saved in the browser //User has a token saved in the browser
}else{ }else{
//validate that token
//Check if the token is valid
const response = await fetch('http://localhost:8080/auth/validation', { const response = await fetch('http://localhost:8080/auth/validation', {
method: 'POST', method: 'POST',
headers: {'Authorization': token} headers: {'Authorization': token}
}) })
console.log('RESPONSE', response) console.log('RESPONSE', response)
//Token is valid
//Token is valid, show the streams
if(response.status === 200){ if(response.status === 200){
console.log("SUCCESS") console.log("SUCCESS")
/* /*
......
...@@ -170,8 +170,8 @@ app.post('/auth/validation', async (req, res) => { ...@@ -170,8 +170,8 @@ app.post('/auth/validation', async (req, res) => {
console.log(err) console.log(err)
} }
}) })
// app.get('/login/google', (req, res) => {
// })
app.get('/streams', (req, res) => { app.get('/streams', (req, res) => {
...@@ -204,13 +204,14 @@ app.get('/stream/depth', (req, res) => { ...@@ -204,13 +204,14 @@ app.get('/stream/depth', (req, res) => {
}); });
app.post('/stream/config', async (req, res) => { app.post('/stream/config', async (req, res) => {
const {board_size, square_size, frame_delay, num_frames} = req.body const {board_size, square_size, frame_delay, num_frames, name} = req.body
const savedConfigs = new Config({ const savedConfigs = new Config({
board_size, board_size,
square_size, square_size,
frame_delay, frame_delay,
num_frames, num_frames,
name
}); });
try{ try{
await savedConfigs.save(); await savedConfigs.save();
...@@ -222,9 +223,13 @@ app.post('/stream/config', async (req, res) => { ...@@ -222,9 +223,13 @@ app.post('/stream/config', async (req, res) => {
}) })
app.get('/stream/config', async(req, res) => { app.get('/stream/config', async(req, res) => {
const listOfCongifs = await Config.find({}); //example of uri /stream/config?uri=ftl.utu.fi/stream/calibrations/
console.log(listOfCongifs) //example of uri /stream/config?uri=ftl.utu.fi/stream/calibrations/board_size/value=1
return res.status(200).json(listOfCongifs) const uri = req.query.uri
console.log(uri)
//const listOfCongifs = await Config.find({});
return res.status(200).json(uri)
}) })
//app.get('/stream', (req, res)) //app.get('/stream', (req, res))
...@@ -283,6 +288,7 @@ app.get('/auth/google/redirect', passport.authenticate('google'), async (req, re ...@@ -283,6 +288,7 @@ app.get('/auth/google/redirect', passport.authenticate('google'), async (req, re
return res.send(htmlWithEmbeddedJWT) return res.send(htmlWithEmbeddedJWT)
}catch(err){ }catch(err){
console.log(err) console.log(err)
return res.status(500).json('Login failed')
} }
}) })
......
...@@ -14,7 +14,7 @@ const cameraConfigSchema = mongoose.Schema({ ...@@ -14,7 +14,7 @@ const cameraConfigSchema = mongoose.Schema({
fix_k3: {type: Boolean, default: false}, fix_k3: {type: Boolean, default: false},
fix_k4: {type: Boolean, default: true}, fix_k4: {type: Boolean, default: true},
fix_k5: {type: Boolean, default: true}, fix_k5: {type: Boolean, default: true},
//Mongoose doesn't let you use 'save' as an attribute //Mongoose doesn't let you use the word 'save' as an attribute
//save: {type: Boolean, default: true}, //save: {type: Boolean, default: true},
use_intrinsics: {type: Boolean, default: true}, use_intrinsics: {type: Boolean, default: true},
use_extrinsics: {type: Boolean, default: true}, use_extrinsics: {type: Boolean, default: true},
...@@ -25,7 +25,6 @@ const cameraConfigSchema = mongoose.Schema({ ...@@ -25,7 +25,6 @@ const cameraConfigSchema = mongoose.Schema({
cameraConfigSchema.set('toJSON', { cameraConfigSchema.set('toJSON', {
transform: (document, returnedObject) => { transform: (document, returnedObject) => {
returnedObject.id = returnedObject._id
delete returnedObject._id delete returnedObject._id
delete returnedObject.__v delete returnedObject.__v
} }
......
const MONGODB_URI = 'mongodb+srv://ftl:sOgIX%2638@FTL-w141e.mongodb.net/FTL?retryWrites=true&w=majority'
module.exports = { module.exports = {
MONGODB_URI MONGODB_URI: 'mongodb+srv://ftl:sOgIX%2638@FTL-w141e.mongodb.net/FTL?retryWrites=true&w=majority'
} }
\ 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