fix cookie check logic

This commit is contained in:
Arthur Lu 2023-04-19 05:58:30 +00:00
parent 8f37806280
commit 289ca85e81
2 changed files with 12 additions and 9 deletions

View File

@ -1,4 +1,4 @@
import {requestPVE, requestAPI} from "./utils.js";
import {requestAPI, goToPage} from "./utils.js";
window.addEventListener("DOMContentLoaded", init);
@ -11,6 +11,11 @@ let SIPrefix = [
]
async function init () {
let cookie = document.cookie;
if (cookie === "") {
goToPage("login.html");
}
let resources = await requestAPI("/user/resources");
buildResourceTable(resources, "#resource-table");
}

View File

@ -4,6 +4,11 @@ import {Dialog} from "./dialog.js";
window.addEventListener("DOMContentLoaded", init);
async function init () {
let cookie = document.cookie;
if (cookie === "") {
goToPage("login.html");
}
await populateInstances();
let addInstanceBtn = document.querySelector("#instance-add");
@ -11,15 +16,8 @@ async function init () {
}
async function populateInstances () {
let cookie = document.cookie;
if (cookie === "") {
goToPage("login.html");
}
let resources = await requestPVE("/cluster/resources", "GET", null);
let instanceContainer = document.getElementById("instance-container")
let instanceContainer = document.getElementById("instance-container");
let instances = [];
resources.data.forEach((element) => {