-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use get request for logs instead of websocket
- Loading branch information
1 parent
88e0ee2
commit 93be755
Showing
14 changed files
with
29 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .routes import router # noqa : F401 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from __future__ import annotations | ||
|
||
from fastapi import APIRouter, Security | ||
|
||
from goosebit.api.v1.devices.device import routes | ||
from goosebit.auth import validate_user_permissions | ||
|
||
router = APIRouter(prefix="/{dev_id}") | ||
|
||
router.add_api_route( | ||
"/log", | ||
routes.device_logs, | ||
methods=["GET"], | ||
dependencies=[Security(validate_user_permissions, scopes=["device.read"])], | ||
name="bff_device_logs", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,10 @@ | ||
document.addEventListener("DOMContentLoaded", () => { | ||
const logs_ws = create_ws(`/realtime/logs/${device}`); | ||
document.addEventListener("DOMContentLoaded", async () => { | ||
const res = await get_request(`/ui/bff/devices/${device}/log`); | ||
|
||
logs_ws.addEventListener("message", (event) => { | ||
const res = JSON.parse(event.data); | ||
const logElem = document.getElementById("device-log"); | ||
logElem.textContent = res.log; | ||
|
||
const logElem = document.getElementById("device-log"); | ||
if (res.clear) { | ||
logElem.textContent = ""; | ||
} | ||
logElem.textContent += res.log; | ||
|
||
const progressElem = document.getElementById("install-progress"); | ||
progressElem.style.width = `${res.progress}%`; | ||
progressElem.innerHTML = `${res.progress}%`; | ||
}); | ||
const progressElem = document.getElementById("install-progress"); | ||
progressElem.style.width = `${res.progress}%`; | ||
progressElem.innerHTML = `${res.progress}%`; | ||
}); | ||
|
||
function create_ws(s) { | ||
const l = window.location; | ||
const protocol = l.protocol === "https:" ? "wss://" : "ws://"; | ||
const port = l.port !== "80" || l.port !== "443" ? l.port : ""; | ||
const url = `${protocol}${l.hostname}:${port}${s}`; | ||
return new WebSocket(url); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters