feat: local period calculation and refresh button for node usage

- Load panel + node data once on tab open (not per period change)
- Compute 7/14/30 day totals locally from cached daily data
- Add refresh button to subscription section
- No API calls when switching periods
This commit is contained in:
Fringg
2026-02-07 06:50:50 +03:00
parent 14b73f6db5
commit bc6985f522
2 changed files with 59 additions and 42 deletions

View File

@@ -134,10 +134,12 @@ export interface UserNodeUsageItem {
node_name: string;
country_code: string;
total_bytes: number;
daily_bytes: number[];
}
export interface UserNodeUsageResponse {
items: UserNodeUsageItem[];
categories: string[];
period_days: number;
}
@@ -545,11 +547,9 @@ export const adminUsersApi = {
return response.data;
},
// Get node usage
getNodeUsage: async (userId: number, days = 7): Promise<UserNodeUsageResponse> => {
const response = await apiClient.get(`/cabinet/admin/users/${userId}/node-usage`, {
params: { days },
});
// Get node usage (always 30 days with daily breakdown)
getNodeUsage: async (userId: number): Promise<UserNodeUsageResponse> => {
const response = await apiClient.get(`/cabinet/admin/users/${userId}/node-usage`);
return response.data;
},
};