This commit is contained in:
maaa 2023-08-19 19:20:37 +02:00
parent 52cff35cd2
commit 38c0f90285
2 changed files with 13 additions and 4 deletions

View File

@ -61,3 +61,7 @@ please display a warning before this action
POST - /api/exportnotes - export notes, provide "secretKey" POST - /api/exportnotes - export notes, provide "secretKey"
note content and title will have to be decrypted note content and title will have to be decrypted
POST - /api/sessions/list - show all sessions, provide "secretKey"
POST - /api/sessions/remove - remove session, provide "secretKey" and "sessionId"

View File

@ -9,6 +9,10 @@ if (localStorage.getItem("DONOTSHARE-password") === null) {
throw new Error(); throw new Error();
} }
if (localStorage.getItem("CACHE-username") !== null) {
document.getElementById("usernameBox").innerText = localStorage.getItem("CACHE-username")
}
function formatBytes(a, b = 2) { if (!+a) return "0 Bytes"; const c = 0 > b ? 0 : b, d = Math.floor(Math.log(a) / Math.log(1000)); return `${parseFloat((a / Math.pow(1000, d)).toFixed(c))} ${["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"][d]}` } function formatBytes(a, b = 2) { if (!+a) return "0 Bytes"; const c = 0 > b ? 0 : b, d = Math.floor(Math.log(a) / Math.log(1000)); return `${parseFloat((a / Math.pow(1000, d)).toFixed(c))} ${["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"][d]}` }
function truncateString(str, num) { function truncateString(str, num) {
@ -182,7 +186,7 @@ function updateUserInfo() {
displayError("Something went wrong. Signing you out..") displayError("Something went wrong. Signing you out..")
closeErrorButton.classList.add("hidden") closeErrorButton.classList.add("hidden")
usernameBox.innerText = "" usernameBox.innerText = ""
setTimeout(function() { setTimeout(function () {
window.location.replace("/api/logout") window.location.replace("/api/logout")
}, 2500); }, 2500);
} else { } else {
@ -193,6 +197,7 @@ function updateUserInfo() {
storageProgressThing.value = responseData["storageused"] storageProgressThing.value = responseData["storageused"]
storageProgressThing.max = responseData["storagemax"] storageProgressThing.max = responseData["storagemax"]
noteCount = responseData["notecount"] noteCount = responseData["notecount"]
localStorage.setItem("CACHE-username", responseData["username"])
} }
} }
doStuff() doStuff()
@ -256,9 +261,9 @@ sessionManagerButton.addEventListener("click", (event) => {
let sessionRemoveButton = document.createElement("button") let sessionRemoveButton = document.createElement("button")
sessionText.classList.add("w300") sessionText.classList.add("w300")
if (responseData[i]["thisSession"] == true) { if (responseData[i]["thisSession"] == true) {
sessionText.innerHTML = "<span style='background-color: #157efb; color: white; padding: 8px; border-radius: 8px; margin-right: 5px;'>current</span>" + truncateString(responseData[i]["device"], 18) sessionText.innerText = "(current) " + truncateString(responseData[i]["device"], 18)
} else { } else {
sessionText.innerHTML = truncateString(responseData[i]["device"], 27) sessionText.innerText = truncateString(responseData[i]["device"], 27)
} }
sessionText.title = responseData[i]["device"] sessionText.title = responseData[i]["device"]
sessionRemoveButton.innerText = "X" sessionRemoveButton.innerText = "X"