Skip to content

Commit

Permalink
feat(web): support resource monitor (#1471)
Browse files Browse the repository at this point in the history
* feat(web): support resource monitor

* refactor(web): adjust code

* refactor(web): optimize request

* fix
  • Loading branch information
newfish-cmyk authored Aug 22, 2023
1 parent 9e2c17d commit 4e3edb3
Show file tree
Hide file tree
Showing 16 changed files with 436 additions and 244 deletions.
7 changes: 5 additions & 2 deletions web/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
"CostTrend": "Cost Trend",
"Balance": "Balance",
"Pause": "Pause",
"AppMonitor": "App Monitoring"
"AppMonitor": "Application Monitor"
},
"StoragePanel": {
"All": "Total Capacity",
Expand Down Expand Up @@ -611,5 +611,8 @@
"QuitSuccess": "Quit",
"Quit": "Quit"
},
"Collaborative": "Collaborative"
"Collaborative": "Collaborative",
"Used": "Used",
"Remaining": "Remaining",
"Pod": "Pod"
}
5 changes: 4 additions & 1 deletion web/public/locales/zh-CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -611,5 +611,8 @@
"QuitSuccess": "退出成功",
"Quit": "退出"
},
"Collaborative": "协作"
"Collaborative": "协作",
"Used": "已使用",
"Remaining": "剩余",
"Pod": "实例"
}
5 changes: 4 additions & 1 deletion web/public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -611,5 +611,8 @@
"QuitSuccess": "退出成功",
"Quit": "退出"
},
"Collaborative": "协作"
"Collaborative": "协作",
"Used": "已使用",
"Remaining": "剩余",
"Pod": "实例"
}
17 changes: 17 additions & 0 deletions web/src/apis/typing.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ export type TBundle = {
updatedAt: string;
};

export type TMonitorData = {
cpuUsage: TCpuUsageData;
memoryUsage: TCpuUsageData;
databaseUsage: TDatabaseUsage;
storageUsage: TDatabaseUsage;
};

export type TCpuUsageData = {
metric: { pod: string };
values: Array<[number, string]>;
}[];

export type TDatabaseUsage = {
metric: { pod: string };
value: [number, string];
}[];

export type TSpec = {
cpu: Cpu;
memory: Memory;
Expand Down
65 changes: 35 additions & 30 deletions web/src/apis/v1/api-auto.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ declare namespace Definitions {
params?: {};
};

export type SendEmailCodeDto = {
email?: string;
type?: string /* verify code type */;
};

export type BindEmailDto = {
email?: string;
code?: string /* verify code */;
};

export type CompileFunctionDto = {
code?: string /* The source code of the function */;
};
Expand Down Expand Up @@ -296,6 +286,11 @@ declare namespace Definitions {
pat?: string /* PAT */;
};

export type SendEmailCodeDto = {
email?: string;
type?: string /* verify code type */;
};

export type CreatePATDto = {
name?: string;
expiresIn?: number;
Expand All @@ -318,6 +313,11 @@ declare namespace Definitions {
newSmsCode?: string /* sms verify code for new phone number */;
};

export type BindEmailDto = {
email?: string;
code?: string /* verify code */;
};

export type BindUsernameDto = {
username?: string /* username */;
};
Expand Down Expand Up @@ -385,6 +385,11 @@ declare namespace Definitions {
updatedAt?: string;
};

export type GetGroupInviteCodeDetailDto = {
group?: Definitions.Group;
invitedBy?: Definitions.User;
};

export type CreateGroupDto = {
name?: string;
};
Expand All @@ -403,12 +408,13 @@ declare namespace Definitions {
code?: string;
role?: string;
groupId?: string;
createdBy?: string;
createdAt?: string;
updatedAt?: string;
};

export type GroupMember = {
id?: string;
_id?: string;
uid?: string;
groupId?: string;
role?: string;
Expand All @@ -420,8 +426,6 @@ declare namespace Definitions {
role?: string;
};

export type GroupApplication = {};

export type CreateAutoscalingDto = {
enable?: boolean;
minReplicas?: number;
Expand Down Expand Up @@ -516,6 +520,15 @@ declare namespace Definitions {
methods?: string[];
code?: string /* The source code of the function */;
};

export type User = {
_id?: string;
username?: string;
email?: string;
phone?: string;
createdAt?: string;
updatedAt?: string;
};
}

declare namespace Paths {
Expand Down Expand Up @@ -1103,6 +1116,14 @@ declare namespace Paths {
export type Responses = any;
}

namespace UserControllerBindEmail {
export type QueryParameters = any;

export type BodyParameters = Definitions.BindEmailDto;

export type Responses = any;
}

namespace UserControllerBindUsername {
export type QueryParameters = any;

Expand Down Expand Up @@ -1503,23 +1524,7 @@ declare namespace Paths {
export type Responses = any;
}

namespace GroupApplicationControllerAppend {
export type QueryParameters = any;

export type BodyParameters = any;

export type Responses = any;
}

namespace GroupApplicationControllerRemove {
export type QueryParameters = any;

export type BodyParameters = any;

export type Responses = any;
}

namespace GroupApplicationControllerFind {
namespace MonitorControllerGetData {
export type QueryParameters = any;

export type BodyParameters = any;
Expand Down
64 changes: 2 additions & 62 deletions web/src/apis/v1/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function GroupControllerFindGroupByInviteCode(
params: Paths.GroupControllerFindGroupByInviteCode.BodyParameters,
): Promise<{
error: string;
data: Definitions.Group;
data: Definitions.GetGroupInviteCodeDetailDto;
}> {
// /v1/group/invite/code/{code}/group
let _params: { [key: string]: any } = {
Expand Down Expand Up @@ -187,7 +187,7 @@ export async function GroupInviteControllerGenerateInviteCode(
}

/**
* Reset group invite code
* Delete group invite code
*/
export async function GroupInviteControllerDeleteInviteCode(
params: Paths.GroupInviteControllerDeleteInviteCode.BodyParameters,
Expand Down Expand Up @@ -305,63 +305,3 @@ export async function GroupMemberControllerLeaveGroup(
data: params,
});
}

/**
* Append an application to a group
*/
export async function GroupApplicationControllerAppend(
params: Paths.GroupApplicationControllerAppend.BodyParameters,
): Promise<{
error: string;
data: Definitions.GroupApplication;
}> {
// /v1/group/{groupId}/application/{appid}
let _params: { [key: string]: any } = {
appid: useGlobalStore.getState().currentApp?.appid || "",
...params,
};
return request(`/v1/group/${_params.groupId}/application/${_params.appid}`, {
method: "POST",
data: params,
});
}

/**
* Remove an application from a group
*/
export async function GroupApplicationControllerRemove(
params: Paths.GroupApplicationControllerRemove.BodyParameters,
): Promise<{
error: string;
data: Paths.GroupApplicationControllerRemove.Responses;
}> {
// /v1/group/{groupId}/application/{appid}
let _params: { [key: string]: any } = {
appid: useGlobalStore.getState().currentApp?.appid || "",
...params,
};
return request(`/v1/group/${_params.groupId}/application/${_params.appid}`, {
method: "DELETE",
data: params,
});
}

/**
* Get application list of a group
*/
export async function GroupApplicationControllerFind(
params: Paths.GroupApplicationControllerFind.BodyParameters,
): Promise<{
error: string;
data: Paths.GroupApplicationControllerFind.Responses;
}> {
// /v1/group/{groupId}/application
let _params: { [key: string]: any } = {
appid: useGlobalStore.getState().currentApp?.appid || "",
...params,
};
return request(`/v1/group/${_params.groupId}/application`, {
method: "GET",
params: params,
});
}
31 changes: 31 additions & 0 deletions web/src/apis/v1/monitor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// @ts-ignore
/* eslint-disable */
///////////////////////////////////////////////////////////////////////
// //
// this file is autogenerated by service-generate //
// do not edit this file manually //
// //
///////////////////////////////////////////////////////////////////////
/// <reference path = "api-auto.d.ts" />
import request from "@/utils/request";
import useGlobalStore from "@/pages/globalStore";

/**
* Get monitor metrics data
*/
export async function MonitorControllerGetData(
params: Paths.MonitorControllerGetData.BodyParameters,
): Promise<{
error: string;
data: Paths.MonitorControllerGetData.Responses;
}> {
// /v1/monitor/{appid}/metrics
let _params: { [key: string]: any } = {
appid: useGlobalStore.getState().currentApp?.appid || "",
...params,
};
return request(`/v1/monitor/${_params.appid}/metrics`, {
method: "GET",
params: params,
});
}
Loading

0 comments on commit 4e3edb3

Please sign in to comment.