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

waiting for merge

parent 26e6f2bf
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
This diff is collapsed.
......@@ -26,6 +26,7 @@
</a>
</div>
</div>
<button style="padding-top: 150px; text-align: center" onclick="checkIfLoggedIn()"></button>
</body>
<script src='./js/index.js'></script>
<script src='./js/lib/libde265.min.js'></script>
......
......@@ -6,7 +6,7 @@ const checkIfLoggedIn = async () => {
//User has a token saved in the browser
}else{
//validate that token
const response = await fetch('http://localhost:8080/auth/validation', {
const response = await fetch('http://localhost:8080/auth/validation/', {
method: 'POST',
headers: {'Authorization': token}
})
......@@ -17,7 +17,7 @@ const checkIfLoggedIn = async () => {
/*
Most likely it will render a new HTML file
*/
document.getElementById('container').innerHTML = "<p>Salainen sivu</p>"
renderThumbnails()
}
}
}
......@@ -33,6 +33,7 @@ const handleLogin = () => {
const getAvailableStreams = async () => {
const streamsInJson = await fetch('http://localhost:8080/streams');
const streams = await streamsInJson.json();
console.log('AVAILABLE', streams)
return streams;
}
......@@ -41,26 +42,26 @@ const getAvailableStreams = async () => {
//Creates thumbnail (image) for all available streams and adds them to div class='container'
const renderThumbnails = async () => {
// const thumbnails = getAvailableStreams();
// console.log('THUMBNAILS', thumbnails)
const thumbnails = await getAvailableStreams();
console.log('THUMBNAILS', thumbnails)
const containerDiv = document.getElementById('container')
containerDiv.innerHTML = '';
console.log(containerDiv)
for(var i=0; i<2; i++){
// const encodedURI = encodeURIComponent(thumbnails[i])
// try{
// const someData = await fetch(`http://localhost:8080/stream/rgb?uri=${encodedURI}`)
// console.log('SOME DATA', someData)
// if(!someData.ok){
// throw new Error('Image not found')
// }
// const myBlob = await someData.blob();
// const objectURL = URL.createObjectURL(myBlob);
// containerDiv.innerHTML += `<img src='${objectURL}' alt="Hups" width='500px'></img>`
containerDiv.innerHTML += `<img src='https://via.placeholder.com/350x150' alt="Hups" width='350px'></img>`
// }catch(err){
// console.log("Couldn't create thumbnail");
// return
// }
for(var i=0; i<thumbnails.length; i++){
const encodedURI = encodeURIComponent(thumbnails[i])
try{
const someData = await fetch(`http://localhost:8080/stream/rgb?uri=${encodedURI}`)
console.log('SOME DATA', someData)
if(!someData.ok){
throw new Error('Image not found')
}
const myBlob = await someData.blob();
console.log('BLOB', myBlob)
const objectURL = URL.createObjectURL(myBlob);
containerDiv.innerHTML += `<img src='${objectURL}' alt="Hups" width='500px'></img>`
}catch(err){
console.log("Couldn't create thumbnail");
return
}
}
}
\ No newline at end of file
......@@ -144,10 +144,12 @@ app.get('/', (req, res) => {
});
app.post('/auth/validation', (req, res) => {
const token = req.headers.authorization.split(" ")
const decoded = jwt.verify(token[1], keys.jwt.secret)
const token = req.headers.authorization
const splitted = token.split(" ");
const decoded = jwt.verify(splitted[1], keys.jwt.secret)
console.log(decoded)
return res.status(200)
return res.status(200).json("piippiip")
})
// app.get('/login/google', (req, res) => {
// })
......
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