mirror of
https://github.com/Buriburizaem0n/nezha-dash-v1.git
synced 2026-05-06 13:58:43 +00:00
feat: add server metrics fetching and update translations
- Implemented `fetchServerMetrics` function in `nezha-api.ts` to retrieve server metrics based on metric type and period. - Added new metric types and periods to `nezha-api.ts` type definitions. - Updated English and Chinese translations to include new terms for metrics and periods. - Commented out `ServerDetailSummary` component in `ServerDetail.tsx` for future use.
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import type {
|
||||
LoginUserResponse,
|
||||
MetricPeriod,
|
||||
MetricType,
|
||||
MonitorResponse,
|
||||
ServerGroupResponse,
|
||||
ServerMetricsResponse,
|
||||
ServiceResponse,
|
||||
SettingResponse,
|
||||
} from "@/types/nezha-api";
|
||||
@@ -69,3 +72,19 @@ export const fetchSetting = async (): Promise<SettingResponse> => {
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
export const fetchServerMetrics = async (
|
||||
server_id: number,
|
||||
metric: MetricType,
|
||||
period?: MetricPeriod,
|
||||
): Promise<ServerMetricsResponse> => {
|
||||
const query = period
|
||||
? `?metric=${metric}&period=${period}`
|
||||
: `?metric=${metric}`;
|
||||
const response = await fetch(`/api/v1/server/${server_id}/metrics${query}`);
|
||||
const data = await response.json();
|
||||
if (data.error) {
|
||||
throw new Error(data.error);
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user