Archived
Добавлен frontend-вызов обнаружения шаблонов Proxmox
This commit is contained in:
+5
-15
@@ -1,17 +1,9 @@
|
||||
const BASE = "/api";
|
||||
const TOKEN_KEY = "access_token";
|
||||
|
||||
export function getToken() {
|
||||
return sessionStorage.getItem(TOKEN_KEY);
|
||||
}
|
||||
|
||||
export function setToken(token) {
|
||||
sessionStorage.setItem(TOKEN_KEY, token);
|
||||
}
|
||||
|
||||
export function clearToken() {
|
||||
sessionStorage.removeItem(TOKEN_KEY);
|
||||
}
|
||||
export function getToken() { return sessionStorage.getItem(TOKEN_KEY); }
|
||||
export function setToken(token) { sessionStorage.setItem(TOKEN_KEY, token); }
|
||||
export function clearToken() { sessionStorage.removeItem(TOKEN_KEY); }
|
||||
|
||||
async function request(path, options = {}) {
|
||||
const token = getToken();
|
||||
@@ -29,10 +21,7 @@ async function request(path, options = {}) {
|
||||
}
|
||||
|
||||
export async function register(email, password) {
|
||||
return request("/auth/register", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ email, password }),
|
||||
});
|
||||
return request("/auth/register", { method: "POST", body: JSON.stringify({ email, password }) });
|
||||
}
|
||||
|
||||
export async function login(email, password) {
|
||||
@@ -50,6 +39,7 @@ export async function login(email, password) {
|
||||
|
||||
export function getMe() { return request("/auth/me"); }
|
||||
export function listTemplates() { return request("/templates"); }
|
||||
export function listProxmoxTemplates() { return request("/templates/from-proxmox"); }
|
||||
export function createTemplate(payload) { return request("/templates", { method: "POST", body: JSON.stringify(payload) }); }
|
||||
export function deactivateTemplate(id) { return request(`/templates/${id}`, { method: "DELETE" }); }
|
||||
export function listInstances() { return request("/instances"); }
|
||||
|
||||
Reference in New Issue
Block a user