fix formatting
This commit is contained in:
parent
d2dbbea292
commit
24df8df731
6
db.js
6
db.js
@ -4,7 +4,7 @@ class localdb {
|
|||||||
#template = "localdb.json.template";
|
#template = "localdb.json.template";
|
||||||
#filename = "localdb.json";
|
#filename = "localdb.json";
|
||||||
#data = null;
|
#data = null;
|
||||||
constructor () {
|
constructor() {
|
||||||
try {
|
try {
|
||||||
this.load(this.#filename);
|
this.load(this.#filename);
|
||||||
}
|
}
|
||||||
@ -19,10 +19,10 @@ class localdb {
|
|||||||
save(path) {
|
save(path) {
|
||||||
writeFileSync(path, JSON.stringify(this.#data));
|
writeFileSync(path, JSON.stringify(this.#data));
|
||||||
}
|
}
|
||||||
getResourceConfig () {
|
getResourceConfig() {
|
||||||
return this.#data.resources;
|
return this.#data.resources;
|
||||||
}
|
}
|
||||||
getUserConfig (username) {
|
getUserConfig(username) {
|
||||||
if (this.#data.users[username]) {
|
if (this.#data.users[username]) {
|
||||||
return this.#data.users[username];
|
return this.#data.users[username];
|
||||||
}
|
}
|
||||||
|
2
pve.js
2
pve.js
@ -35,7 +35,7 @@ export async function requestPVE(path, method, cookies, body = null, token = nul
|
|||||||
|
|
||||||
export async function handleResponse(node, result, res) {
|
export async function handleResponse(node, result, res) {
|
||||||
const waitFor = delay => new Promise(resolve => setTimeout(resolve, delay));
|
const waitFor = delay => new Promise(resolve => setTimeout(resolve, delay));
|
||||||
if (result.data.data && typeof(result.data.data) === "string" && result.data.data.startsWith("UPID:")) {
|
if (result.data.data && typeof (result.data.data) === "string" && result.data.data.startsWith("UPID:")) {
|
||||||
let upid = result.data.data;
|
let upid = result.data.data;
|
||||||
while (true) {
|
while (true) {
|
||||||
let taskStatus = await requestPVE(`/nodes/${node}/tasks/${upid}/status`, "GET", null, null, pveAPIToken);
|
let taskStatus = await requestPVE(`/nodes/${node}/tasks/${upid}/status`, "GET", null, null, pveAPIToken);
|
||||||
|
2
utils.js
2
utils.js
@ -27,7 +27,7 @@ export async function checkAuth(cookies, res, vmpath = null) {
|
|||||||
return auth;
|
return auth;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getUserResources (req, username) {
|
export async function getUserResources(req, username) {
|
||||||
let dbResources = db.getResourceConfig();
|
let dbResources = db.getResourceConfig();
|
||||||
let used = await getUsedResources(req, dbResources);
|
let used = await getUsedResources(req, dbResources);
|
||||||
let max = db.getUserConfig(username).resources.max;
|
let max = db.getUserConfig(username).resources.max;
|
||||||
|
Loading…
Reference in New Issue
Block a user