diff --git a/unity_package/Runtime/VELConnectManager.cs b/unity_package/Runtime/VELConnectManager.cs index 46e8034..9831b77 100644 --- a/unity_package/Runtime/VELConnectManager.cs +++ b/unity_package/Runtime/VELConnectManager.cs @@ -128,7 +128,7 @@ namespace VELConnect // Start is called before the first frame update private void Start() { - SetDeviceBaseData(new Dictionary + SetDeviceField(new Dictionary { { "current_app", Application.productName }, { "pairing_code", PairingCode } @@ -141,7 +141,7 @@ namespace VELConnect VelNetManager.OnJoinedRoom += room => { - SetDeviceBaseData(new Dictionary + SetDeviceField(new Dictionary { { "current_app", Application.productName }, { "current_room", room }, @@ -463,11 +463,11 @@ namespace VELConnect /// /// Sets data on the device keys themselves /// - public static void SetDeviceBaseData(Dictionary data) + public static void SetDeviceField(Dictionary device) { instance.PostRequestCallback( instance.velConnectUrl + "/api/v2/device/set_data/" + DeviceId, - JsonConvert.SerializeObject(data), + JsonConvert.SerializeObject(device), new Dictionary { { "modified_by", DeviceId } } ); } diff --git a/velconnect/routes/website.py b/velconnect/routes/website.py index fa41f47..0e3ae10 100644 --- a/velconnect/routes/website.py +++ b/velconnect/routes/website.py @@ -1,5 +1,7 @@ +import fastapi from fastapi import APIRouter from fastapi.responses import FileResponse +from fastapi.templating import Jinja2Templates # APIRouter creates path operations for user module router = APIRouter( @@ -8,6 +10,8 @@ router = APIRouter( include_in_schema=False ) +templates = Jinja2Templates(directory="templates") + @router.get('/') def index(): @@ -27,3 +31,8 @@ def success(): @router.get('/failure') def failure(): return FileResponse("templates/failure.html") + + +@router.get('/join/{app_id}/{link}') +def join(request: fastapi.Request, app_id: str, link: str): + return templates.TemplateResponse("join.html", {"request": request, "app_id": app_id, "link": link}) diff --git a/velconnect/static/js/device_details.js b/velconnect/static/js/device_details.js new file mode 100644 index 0000000..f5eadc0 --- /dev/null +++ b/velconnect/static/js/device_details.js @@ -0,0 +1,34 @@ +{ +// check cookie + let hw_id = getCookie('hw_id'); + + if (hw_id !== "" && hw_id !== undefined && hw_id !== "undefined") { + + httpGetAsync('/api/v2/device/get_data/' + hw_id, (resp) => { + console.log(resp); + let respData = JSON.parse(resp); + + if ("error" in respData) { + window.location.href = "/pair"; + } + + writeClass('hw_id', respData['device']['hw_id']); + writeClass('pairing_code', respData['device']['pairing_code']); + writeValue('current_app', respData['device']['current_app']); + writeValue('current_room', respData['device']['current_room']); + writeClass('date_created', respData['device']['date_created'] + "
" + timeSinceString(respData['device']['date_created']) + " ago"); + writeClass('last_modified', respData['device']['last_modified'] + "
" + timeSinceString(respData['device']['last_modified']) + " ago"); + writeValue('user_name', respData['device']['friendly_name']); + writeValue('avatar_url', respData['device']['data']?.['avatar_url']); + writeValue('tv_url', respData['room']?.['data']?.['tv_url']); + writeValue('carpet_color', respData['room']?.['data']?.['carpet_color']); + if (carpet_color) carpet_color.parentElement.style.color = "" + respData['room']?.['data']?.['carpet_color']; + + loading.style.display = "none"; + headset_details.style.display = "block"; + }, (status) => { + loading.style.display = "none"; + failure.style.display = "block"; + }); + } +} \ No newline at end of file diff --git a/velconnect/static/js/velconnect_util.js b/velconnect/static/js/velconnect_util.js new file mode 100644 index 0000000..b0a4dff --- /dev/null +++ b/velconnect/static/js/velconnect_util.js @@ -0,0 +1,48 @@ +function setDeviceField(device) { + let hw_id = getCookie('hw_id'); + fetch('/api/v2/device/set_data/' + hw_id, { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + + body: JSON.stringify(device) + }) + .then(_ => console.log('success')) + .catch(_ => console.log('fail')); +} + +function setDeviceData(data, successCallback, failureCallback) { + let hw_id = getCookie('hw_id'); + fetch('/api/v2/device/set_data/' + hw_id, { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + + body: JSON.stringify({"data": data}) + }) + .then(_ => { + console.log('success'); + successCallback?.(); + }) + .catch(_ => { + console.log('fail'); + failureCallback?.(); + }); +} + +function setRoomData(data) { + fetch('/api/v2/set_data/' + current_app.value + "_" + current_room.value, { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + body: JSON.stringify(data) + }) + .then(_ => console.log('success')) + .catch(_ => console.log('fail')); +} \ No newline at end of file diff --git a/velconnect/templates/index.html b/velconnect/templates/index.html index f1b2c4f..0f3510d 100644 --- a/velconnect/templates/index.html +++ b/velconnect/templates/index.html @@ -93,7 +93,7 @@
-
Last Login
+
Last Modified
---
diff --git a/velconnect/templates/join.html b/velconnect/templates/join.html new file mode 100644 index 0000000..22ed8c8 --- /dev/null +++ b/velconnect/templates/join.html @@ -0,0 +1,168 @@ + + + + + + + + + + + + + VEL Connect + + + + + + + + + + +
+ +


+
+
+ + + + + + + + + +
+ + + \ No newline at end of file