mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 06:05:24 +00:00
feat: finish the homepage plugin, move service links and canvas out of core (B19)
This commit is contained in:
1 parent
21937a6b02
commit
d4ec444558
256 files changed
+27365
-9077
No files matched your search
@@ -1,5 +1,4 @@
|
||||
import { dashboardApi, handleApiError } from "@/main-axios";
|
||||
import { normalizeServiceLinkUrl } from "@/lib/service-link-url";
|
||||
import { authApi, handleApiError } from "@/main-axios";
|
||||
|
||||
// DASHBOARD API
|
||||
// ============================================================================
|
||||
@@ -22,7 +21,7 @@ export interface RecentActivityItem {
|
||||
|
||||
export async function getUptime(): Promise<UptimeInfo> {
|
||||
try {
|
||||
const response = await dashboardApi.get("/uptime");
|
||||
const response = await authApi.get("/dashboard/uptime");
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw handleApiError(error, "fetch uptime");
|
||||
@@ -33,7 +32,7 @@ export async function getRecentActivity(
|
||||
limit?: number,
|
||||
): Promise<RecentActivityItem[]> {
|
||||
try {
|
||||
const response = await dashboardApi.get("/activity/recent", {
|
||||
const response = await authApi.get("/dashboard/activity/recent", {
|
||||
params: { limit },
|
||||
});
|
||||
return response.data;
|
||||
@@ -48,7 +47,7 @@ export async function logActivity(
|
||||
hostName: string,
|
||||
): Promise<{ message: string; id: number | string }> {
|
||||
try {
|
||||
const response = await dashboardApi.post("/activity/log", {
|
||||
const response = await authApi.post("/dashboard/activity/log", {
|
||||
type,
|
||||
hostId,
|
||||
hostName,
|
||||
@@ -61,71 +60,9 @@ export async function logActivity(
|
||||
|
||||
export async function resetRecentActivity(): Promise<{ message: string }> {
|
||||
try {
|
||||
const response = await dashboardApi.delete("/activity/reset");
|
||||
const response = await authApi.delete("/dashboard/activity/reset");
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw handleApiError(error, "reset recent activity");
|
||||
}
|
||||
}
|
||||
|
||||
export interface ServiceLink {
|
||||
id: number;
|
||||
userId: string;
|
||||
label: string;
|
||||
url: string;
|
||||
order: number;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export async function getServiceLinks(): Promise<ServiceLink[]> {
|
||||
try {
|
||||
const response = await dashboardApi.get("/service-links");
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw handleApiError(error, "fetch service links");
|
||||
}
|
||||
}
|
||||
|
||||
export async function createServiceLink(
|
||||
label: string,
|
||||
url: string,
|
||||
): Promise<ServiceLink> {
|
||||
try {
|
||||
const response = await dashboardApi.post("/service-links", {
|
||||
label,
|
||||
url: normalizeServiceLinkUrl(url),
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw handleApiError(error, "create service link");
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteServiceLink(
|
||||
id: number,
|
||||
): Promise<{ message: string }> {
|
||||
try {
|
||||
const response = await dashboardApi.delete(`/service-links/${id}`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw handleApiError(error, "delete service link");
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateServiceLink(
|
||||
id: number,
|
||||
updates: { label?: string; url?: string },
|
||||
): Promise<ServiceLink> {
|
||||
try {
|
||||
const response = await dashboardApi.put(`/service-links/${id}`, {
|
||||
...updates,
|
||||
url:
|
||||
updates.url !== undefined
|
||||
? normalizeServiceLinkUrl(updates.url)
|
||||
: undefined,
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw handleApiError(error, "update service link");
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
import { homepageApi, handleApiError } from "@/main-axios";
|
||||
import type {
|
||||
HomepageItemRow,
|
||||
HomepageLayoutData,
|
||||
HomepageLayoutRow,
|
||||
WidgetTypeId,
|
||||
} from "@/types/homepage-types";
|
||||
|
||||
export async function getHomepageItems(): Promise<HomepageItemRow[]> {
|
||||
try {
|
||||
const res = await homepageApi.get("/items");
|
||||
return res.data;
|
||||
} catch (error) {
|
||||
throw handleApiError(error, "fetch homepage items");
|
||||
}
|
||||
}
|
||||
|
||||
export async function createHomepageItem(data: {
|
||||
typeId: WidgetTypeId;
|
||||
title?: string | null;
|
||||
config?: Record<string, unknown>;
|
||||
}): Promise<HomepageItemRow> {
|
||||
try {
|
||||
const res = await homepageApi.post("/items", data);
|
||||
return res.data;
|
||||
} catch (error) {
|
||||
throw handleApiError(error, "create homepage item");
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateHomepageItem(
|
||||
id: number,
|
||||
data: {
|
||||
title?: string | null;
|
||||
config?: Record<string, unknown>;
|
||||
},
|
||||
): Promise<HomepageItemRow> {
|
||||
try {
|
||||
const res = await homepageApi.put(`/items/${id}`, data);
|
||||
return res.data;
|
||||
} catch (error) {
|
||||
throw handleApiError(error, "update homepage item");
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteHomepageItem(id: number): Promise<void> {
|
||||
try {
|
||||
await homepageApi.delete(`/items/${id}`);
|
||||
} catch (error) {
|
||||
throw handleApiError(error, "delete homepage item");
|
||||
}
|
||||
}
|
||||
|
||||
export async function getHomepageLayout(): Promise<HomepageLayoutRow | null> {
|
||||
try {
|
||||
const res = await homepageApi.get("/layout");
|
||||
return res.data;
|
||||
} catch (error) {
|
||||
throw handleApiError(error, "fetch homepage layout");
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveHomepageLayout(
|
||||
layout: HomepageLayoutData,
|
||||
): Promise<HomepageLayoutRow> {
|
||||
try {
|
||||
const res = await homepageApi.put("/layout", layout);
|
||||
return res.data;
|
||||
} catch (error) {
|
||||
throw handleApiError(error, "save homepage layout");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user