fix cookie check logic

This commit is contained in:
Arthur Lu 2023-04-19 05:58:30 +00:00
parent 9f6bf6a8ad
commit e9ec759940
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); window.addEventListener("DOMContentLoaded", init);
@ -11,6 +11,11 @@ let SIPrefix = [
] ]
async function init () { async function init () {
let cookie = document.cookie;
if (cookie === "") {
goToPage("login.html");
}
let resources = await requestAPI("/user/resources"); let resources = await requestAPI("/user/resources");
buildResourceTable(resources, "#resource-table"); buildResourceTable(resources, "#resource-table");
} }

View File

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