From 54c9722048270e5517546f9f6b1a8030158e6278 Mon Sep 17 00:00:00 2001 From: Oracle Server Date: Sun, 21 May 2023 19:23:07 +0000 Subject: [PATCH] fix errors in redirects on website, don't try to insert null owner, add cd for oracle server --- .github/workflows/deploy_oracle.yml | 20 ++++++++++++++++++++ velconnect/db.py | 1 + velconnect/routes/api.py | 6 +++++- velconnect/templates/index.html | 9 ++++++--- 4 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/deploy_oracle.yml diff --git a/.github/workflows/deploy_oracle.yml b/.github/workflows/deploy_oracle.yml new file mode 100644 index 0000000..d714452 --- /dev/null +++ b/.github/workflows/deploy_oracle.yml @@ -0,0 +1,20 @@ +name: Deploy to VelNet Oracle server + +on: + push: + branches: ["main"] + paths: ["velconnect/**"] +jobs: + run_pull: + name: Pull new version + runs-on: ubuntu-latest + steps: + - name: install ssh keys + run: | + install -m 600 -D /dev/null ~/.ssh/id_rsa + echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa + ssh-keyscan -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts + - name: connect and pull + run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd ${{ secrets.SSH_WORK_DIR }} && git pull && docker compose up -d --build && exit" + - name: cleanup + run: rm -rf ~/.ssh diff --git a/velconnect/db.py b/velconnect/db.py index f5a0b01..0de8f01 100644 --- a/velconnect/db.py +++ b/velconnect/db.py @@ -19,6 +19,7 @@ class DB: # create the db with open('CreateDB.sql', 'r') as f: curr.executescript(f.read()) + conn.commit() conn.set_trace_callback(print) return conn, curr diff --git a/velconnect/routes/api.py b/velconnect/routes/api.py index 624e90f..6ed5aa2 100644 --- a/velconnect/routes/api.py +++ b/velconnect/routes/api.py @@ -237,10 +237,14 @@ def set_data_with_random_key(request: fastapi.Request, data: dict, owner: str, m @router.post('/set_data/{key}') -def set_data(request: fastapi.Request, data: dict, key: str = None, owner: str = None, modified_by: str = None, +def set_data(request: fastapi.Request, data: dict, key: str = None, owner: str = 'none', modified_by: str = None, category: str = None, visibility: Visibility = Visibility.public) -> dict: """Creates a little storage bucket for arbitrary data""" + # sqlite composite key isn't necessarily unique if a value is null + if owner == None: + owner = 'none' + # add the client's IP address if no sender specified if 'modified_by' in data: modified_by = data['modified_by'] diff --git a/velconnect/templates/index.html b/velconnect/templates/index.html index 4143ec4..d11c404 100644 --- a/velconnect/templates/index.html +++ b/velconnect/templates/index.html @@ -312,14 +312,17 @@ ] }); - document.getElementById('cover_image').src = `/static/img/cover_${respData['device']['current_app']}.png` - document.getElementById('shareable_link').href = `/join/${respData['device']['current_app']}/${respData['device']['current_room']}` + if (respData['device']['current_app']) { + document.getElementById('cover_image').src = `/static/img/cover_${respData['device']['current_app']}.png` + document.getElementById('shareable_link').href = `/join/${respData['device']['current_app']}/${respData['device']['current_room']}` + } loading.style.display = "none"; headset_details.style.display = "block"; }, (status) => { loading.style.display = "none"; failure.style.display = "block"; + window.location.href = "/pair"; }); @@ -441,7 +444,7 @@ const bntPubCam = document.getElementById("bnt_pubcam"); const bntPubScreen = document.getElementById("bnt_pubscreen"); - setDeviceData({"streamer_stream_id": roomName}); + // setDeviceData({"streamer_stream_id": roomName}); const serverURL = "wss://velnet.ugavel.com/ws";