diff --git a/web-service/client/src/Streams.js b/web-service/client/src/Streams.js index e93fedd08e65cdc145740a547193817f3fca09e8..b809643be07c89e3a21de343cbe3badbfe70f3ad 100644 --- a/web-service/client/src/Streams.js +++ b/web-service/client/src/Streams.js @@ -30,21 +30,38 @@ const Streams = ({clearCookies}) => { } const renderThumbnails = async () => { + //updates all available thumbnail URIs const thumbs = await fetchThumbnails() - console.log('before', thumbnails) setThumbnails((thumbs)); - console.log('after', thumbnails) - return thumbnails + console.log(thumbnails[0]); + //Problem possibly here, it doesn't encode it correctly? + const encodedURL = encodeURI(thumbnails[0]); + console.log('ENCODED URL', encodedURL); + try{ + const someData = await fetch(`/stream/rgb?uri=${encodedURL}`) + if(!someData){ + throw new Error('Vitun vitun vittu'); + } + const myBlob = await someData.blob + console.log('MYBLOB', myBlob) + const objectURL = URL.createObjectURL(myBlob); + console.log('URL ', objectURL); + } catch(err){ + console.log('Kurwavaara:', err); + } + + return thumbnails; } + return( <div style={{'margin': 'auto', 'textAlign': 'center'}}> <h1>Streams component works!!</h1> <h2>Namibia here we come!</h2> <button onClick={clearCookies}>Logout</button> - <br /> - <button onClick={() => renderThumbnails()}></button> + <br/> + <button onClick={renderThumbnails}></button> </div> ) } diff --git a/web-service/server/src/index.js b/web-service/server/src/index.js index 47e78cfa85d86465bb81fd2471587bf2715f7a41..93b2cefa2decee22004b50ef0653c696bb633432 100644 --- a/web-service/server/src/index.js +++ b/web-service/server/src/index.js @@ -169,17 +169,17 @@ app.get('/stream/depth', (req, res) => { //app.get('/stream', (req, res)) -/** +/* * Route for Google authentication API page -*/ + */ app.get('/google', passport.authenticate('google', { scope: ['profile'] })) -/** +/* * Google authentication API callback route. * Sets the JWT to clients browser and redirects the user back to front page (now has thumbnails). -*/ + */ app.get('/auth/google/redirect', passport.authenticate('google'), (req, res) => { console.log(req.user) const token = jwt.sign(req.user.id, keys.jwt.secret);