diff --git a/build.sh b/build.sh index c17979e..c5b6299 100644 --- a/build.sh +++ b/build.sh @@ -9,5 +9,6 @@ docker build -f buscribe-api/Dockerfile -t buscribe-api:$VERSION . docker build -f docker-less/Dockerfile -t lessc . docker run --rm -v "$(pwd)"/buscribe-web:/buscribe-web lessc /buscribe-web/style.less > buscribe-web/style.css +docker run --rm -v "$(pwd)"/professor:/professor lessc /professor/style.less > professor/style.css docker build -f nginx/Dockerfile -t buscribe-web:$VERSION . diff --git a/nginx/Dockerfile b/nginx/Dockerfile index 24bfe15..5e167c8 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -1,4 +1,5 @@ FROM nginx:latest COPY buscribe-web /usr/share/nginx/html/buscribe +COPY professor /usr/share/nginx/html/professor COPY nginx/nginx.conf /etc/nginx/nginx.conf \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 77dbae2..695c8e0 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -45,6 +45,9 @@ http { location /buscribe { alias /usr/share/nginx/html/buscribe; } + location /professor { + alias /usr/share/nginx/html/professor; + } location /buscribe/loadingreadyrun/json { proxy_pass http://buscribeapilrr:8010/buscribe/json; } location /buscribe/desertbus/json { proxy_pass http://buscribeapidb:8010/buscribe/json; } diff --git a/professor/professor.html b/professor/professor.html index f5ba3ff..ead92a1 100644 --- a/professor/professor.html +++ b/professor/professor.html @@ -15,7 +15,7 @@ - + @@ -35,6 +35,24 @@ + + + + + + + + + + + + + + + + +
+
@@ -47,6 +65,9 @@ - + + \ No newline at end of file diff --git a/professor/script.js b/professor/script.js index 3a42ba8..604ef74 100644 --- a/professor/script.js +++ b/professor/script.js @@ -27,13 +27,37 @@ function pageReady() { const bgOpacitySelector = document.querySelector('.vjs-bg-opacity > select'); bgOpacitySelector.value = "0.5" - fetch(`//localhost:8005/professor/line/${line_id}`) + fetch(`//localhost:8011/professor/line/${line_id}`) .then(response => response.json()) .then(fillLineInfo) .then(initializePlayer); } +function doGoogle() { + google.accounts.id.initialize({ + client_id: "164084252563-kaks3no7muqb82suvbubg7r0o87aip7n.apps.googleusercontent.com", + callback: loggedIn, + auto_select: true + }); + google.accounts.id.renderButton( + document.getElementById("googleLoginButton"), + {theme: "outline", size: "large"} // customization attributes + ); + google.accounts.id.prompt(); // also display the One Tap dialog +} + +function loggedIn(response) { + + // credentials = parseJwt(response.credential) + // TODO: add specifiers + document.cookie = `credentials=${response.credential}`; + + document.getElementById("googleLoginButton").style.display = "none"; + + console.log(response); +} + function fillLineInfo(line_json) { // document.getElementById("original_transcription").innerText = line_json.line_data.text; line = line_json @@ -45,7 +69,7 @@ function fillLineInfo(line_json) { function initializePlayer() { videojs.getPlayer("player").src([ - {src: `//localhost:8005/professor/line/${line_id}/playlist.m3u8`} + {src: `//localhost:8011/professor/line/${line_id}/playlist.m3u8`} ]); videojs.getPlayer("player").addRemoteTextTrack({ kind: "captions", @@ -73,7 +97,7 @@ async function submit() { } } - return await fetch("//localhost:8005/professor/speaker", + return await fetch("//localhost:8011/professor/speaker", { method: "PUT", headers: { @@ -86,7 +110,7 @@ async function submit() { .pop(), 10)); })); - fetch(`//localhost:8005/professor/line/${line_id}`, + fetch(`//localhost:8011/professor/line/${line_id}`, { method: "POST", headers: { @@ -103,7 +127,7 @@ async function submit() { } $(function () { - fetch("//localhost:8005/professor/speaker") + fetch("//localhost:8011/professor/speaker") .then(response => response.json()) .then(function (speakers_json) { speakers = speakers_json; @@ -152,4 +176,17 @@ $(function () { } ) -}); \ No newline at end of file +}); + +function parseJwt(token) { + const base64Url = token.split('.')[1]; + const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/'); + const jsonPayload = decodeURIComponent( + atob(base64) + .split('') + .map(function (c) { + return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); + }).join('')); + + return JSON.parse(jsonPayload); +} \ No newline at end of file