move api path info to vars.js
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
c09300e6a0
commit
860fd2c828
@ -1,9 +1,8 @@
|
||||
import {requestPVE, goToPage, getURIData, reload} from "./utils.js";
|
||||
import {pveconfig} from "./meta.js";
|
||||
import {requestPVE, goToPage, getURIData, reload, resources} from "./utils.js";
|
||||
|
||||
window.addEventListener("DOMContentLoaded", init);
|
||||
|
||||
let diskMetaData = pveconfig.diskMetaData;
|
||||
let diskMetaData = resources.disk;
|
||||
|
||||
let node;
|
||||
let type;
|
||||
|
@ -1,19 +0,0 @@
|
||||
export const pveconfig = {
|
||||
pveAPI: "https://pve.tronnet.net/api2/json",
|
||||
diskMetaData: {
|
||||
//actionBarOrder: ["config", "move", "reassign", "resize", "delete_detach_attach"],
|
||||
actionBarOrder: ["config", "move", "resize", "delete_detach_attach"], // handle reassign later
|
||||
lxc: {
|
||||
prefixOrder: ["rootfs", "mp", "unused"],
|
||||
rootfs: {name: "ROOTFS", icon: "images/resources/drive.svg", actions: ["move", "resize"]},
|
||||
mp: {name: "MP", icon: "images/resources/drive.svg", actions: ["config", "detach", "move", "reassign", "resize"]},
|
||||
unused: {name: "UNUSED", icon: "images/resources/drive.svg", actions: ["attach", "delete", "reassign"]}
|
||||
},
|
||||
qemu: {
|
||||
prefixOrder: ["ide", "sata", "unused"],
|
||||
ide: {name: "IDE", icon: "images/resources/disk.svg", actions: ["config", "delete"]},
|
||||
sata: {name: "SATA", icon: "images/resources/drive.svg", actions: ["detach", "move", "reassign", "resize"]},
|
||||
unused: {name: "UNUSED", icon: "images/resources/drive.svg", actions: ["attach", "delete", "reassign"]}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import {pveconfig} from "./meta.js";
|
||||
import {pveAPI} from "/vars.js";
|
||||
|
||||
export class ResponseError extends Error {
|
||||
constructor(message) {
|
||||
@ -14,6 +14,25 @@ export class NetworkError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
export const resources = {
|
||||
disk: {
|
||||
//actionBarOrder: ["config", "move", "reassign", "resize", "delete_detach_attach"],
|
||||
actionBarOrder: ["config", "move", "resize", "delete_detach_attach"], // handle reassign later
|
||||
lxc: {
|
||||
prefixOrder: ["rootfs", "mp", "unused"],
|
||||
rootfs: {name: "ROOTFS", icon: "images/resources/drive.svg", actions: ["move", "resize"]},
|
||||
mp: {name: "MP", icon: "images/resources/drive.svg", actions: ["config", "detach", "move", "reassign", "resize"]},
|
||||
unused: {name: "UNUSED", icon: "images/resources/drive.svg", actions: ["attach", "delete", "reassign"]}
|
||||
},
|
||||
qemu: {
|
||||
prefixOrder: ["ide", "sata", "unused"],
|
||||
ide: {name: "IDE", icon: "images/resources/disk.svg", actions: ["config", "delete"]},
|
||||
sata: {name: "SATA", icon: "images/resources/drive.svg", actions: ["detach", "move", "reassign", "resize"]},
|
||||
unused: {name: "UNUSED", icon: "images/resources/drive.svg", actions: ["attach", "delete", "reassign"]}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getCookie(cname) {
|
||||
let name = cname + "=";
|
||||
let decodedCookie = decodeURIComponent(document.cookie);
|
||||
@ -59,7 +78,7 @@ export async function requestPVE (path, method, body = null, auth = true) {
|
||||
content.headers.CSRFPreventionToken = getCookie("CSRFPreventionToken");
|
||||
}
|
||||
|
||||
let response = await fetch(`${pveconfig.pveAPI}${path}`, content)
|
||||
let response = await fetch(`${pveAPI}${path}`, content)
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new ResponseError(`recieved response status code ${response.status}`);
|
||||
|
Loading…
Reference in New Issue
Block a user