From 2521625ecc43c6b6f01db26e57bc49d719a9a05f Mon Sep 17 00:00:00 2001 From: yangon <2689991790@qq.com> Date: Thu, 23 May 2024 15:45:39 +0800 Subject: [PATCH] Support editing functions of each module (#402) * fix:Correct the way resources are obtained (#292) * Support editing functions of each module --- ui/config/config.ts | 1 - ui/mock/alertAPI.ts | 86 ++ ui/src/api/generated/api.ts | 981 +++++++++++++++++- ui/src/components/InputLabel/index.tsx | 50 +- ui/src/pages/Alert/AlarmFilter/index.tsx | 6 +- ui/src/pages/Alert/Rules/RuleDrawerForm.tsx | 37 +- ui/src/pages/Alert/Rules/index.tsx | 9 +- .../pages/Alert/Shield/ShieldDrawerForm.tsx | 82 +- ui/src/pages/Alert/Shield/ShieldObjInput.tsx | 12 +- ui/src/pages/Alert/Shield/index.tsx | 16 +- ui/src/pages/Alert/helper.ts | 128 ++- ui/src/type/alert.d.ts | 36 +- 12 files changed, 1350 insertions(+), 94 deletions(-) diff --git a/ui/config/config.ts b/ui/config/config.ts index 0156ffb17..50c89aa2d 100644 --- a/ui/config/config.ts +++ b/ui/config/config.ts @@ -9,7 +9,6 @@ export default defineConfig({ request: {}, favicons: ['/logo.png'], title: 'OceanBase Dashboard', - mock: false, layout: false, locale: { default: 'zh-CN', diff --git a/ui/mock/alertAPI.ts b/ui/mock/alertAPI.ts index a9982d981..8013661c3 100644 --- a/ui/mock/alertAPI.ts +++ b/ui/mock/alertAPI.ts @@ -129,4 +129,90 @@ export default { message: 'string', successful: true, }, + 'GET /api/v1/alarm/silence/silencers/string': { + data: { + comment: 'string', + createdBy: 'string', + endsAt: 1716282320833, + id: 'string', + instances: [ + { + obcluster: 'string', + observer: 'string', + obtenant: 'string', + obzone: 'string', + type: 'obcluster', + }, + ], + rules: ['string'], + matchers: [ + { + isRegex: true, + name: 'string', + value: 'string', + }, + ], + startsAt: 0, + status: { + state: 'active', + }, + updatedAt: 0, + }, + message: 'string', + successful: true, + }, + 'GET /api/v1/alarm/rule/rules/string': { + data: { + description: 'string', + duration: 0, + evaluationTime: 0, + health: 'unknown', + instanceType: 'obcluster', + keepFiringFor: 0, + labels: [ + { + key: 'string', + value: 'string', + }, + ], + lastError: 'string', + lastEvaluation: 0, + name: 'string', + query: 'string', + serverity: 'critical', + state: 'active', + summary: 'string', + type: 'builtin', + }, + message: 'string', + successful: true, + }, + 'GET /api/v1/alarm/receiver/receivers/string': { + data: { + config: 'string', + name: 'string', + type: 'discord', + }, + message: 'string', + successful: true, + }, + 'GET /api/v1/alarm/route/routes/string': { + data: { + aggregateLabels: ['string'], + groupInterval: 0, + groupWait: 0, + id: 'string', + matchers: [ + { + isRegex: true, + name: 'string', + value: 'string', + }, + ], + receiver: 'string', + repeatInterval: 0, + }, + message: 'string', + successful: true, + }, }; diff --git a/ui/src/api/generated/api.ts b/ui/src/api/generated/api.ts index b81e5d620..8cfbef3dd 100644 --- a/ui/src/api/generated/api.ts +++ b/ui/src/api/generated/api.ts @@ -390,6 +390,31 @@ export interface CreateOBCluster200Response { */ 'successful': boolean; } +/** + * + * @export + * @interface CreateOBPROXY200Response + */ +export interface CreateOBPROXY200Response { + /** + * + * @type {ObproxyOBProxy} + * @memberof CreateOBPROXY200Response + */ + 'data': ObproxyOBProxy; + /** + * + * @type {string} + * @memberof CreateOBPROXY200Response + */ + 'message': string; + /** + * + * @type {boolean} + * @memberof CreateOBPROXY200Response + */ + 'successful': boolean; +} /** * * @export @@ -940,6 +965,31 @@ export interface ListOBClusters200Response { */ 'successful': boolean; } +/** + * + * @export + * @interface ListOBProxies200Response + */ +export interface ListOBProxies200Response { + /** + * + * @type {Array} + * @memberof ListOBProxies200Response + */ + 'data': Array; + /** + * + * @type {string} + * @memberof ListOBProxies200Response + */ + 'message': string; + /** + * + * @type {boolean} + * @memberof ListOBProxies200Response + */ + 'successful': boolean; +} /** * * @export @@ -1746,6 +1796,307 @@ export interface ModelsStorageSpec { */ 'storageSize'?: number; } +/** + * + * @export + * @interface ObproxyCreateOBProxyParam + */ +export interface ObproxyCreateOBProxyParam { + /** + * + * @type {string} + * @memberof ObproxyCreateOBProxyParam + */ + 'image': string; + /** + * + * @type {string} + * @memberof ObproxyCreateOBProxyParam + */ + 'name': string; + /** + * + * @type {string} + * @memberof ObproxyCreateOBProxyParam + */ + 'namespace': string; + /** + * + * @type {ObproxyK8sObject} + * @memberof ObproxyCreateOBProxyParam + */ + 'obCluster': ObproxyK8sObject; + /** + * + * @type {Array} + * @memberof ObproxyCreateOBProxyParam + */ + 'parameters'?: Array; + /** + * + * @type {string} + * @memberof ObproxyCreateOBProxyParam + */ + 'proxyClusterName': string; + /** + * Password should be encrypted + * @type {string} + * @memberof ObproxyCreateOBProxyParam + */ + 'proxySysPassword': string; + /** + * + * @type {number} + * @memberof ObproxyCreateOBProxyParam + */ + 'replicas': number; + /** + * + * @type {CommonResourceSpec} + * @memberof ObproxyCreateOBProxyParam + */ + 'resource': CommonResourceSpec; + /** + * + * @type {string} + * @memberof ObproxyCreateOBProxyParam + */ + 'serviceType': ObproxyCreateOBProxyParamServiceTypeEnum; +} + +export const ObproxyCreateOBProxyParamServiceTypeEnum = { + ClusterIP: 'ClusterIP', + NodePort: 'NodePort', + LoadBalancer: 'LoadBalancer', + ExternalName: 'ExternalName' +} as const; + +export type ObproxyCreateOBProxyParamServiceTypeEnum = typeof ObproxyCreateOBProxyParamServiceTypeEnum[keyof typeof ObproxyCreateOBProxyParamServiceTypeEnum]; + +/** + * + * @export + * @interface ObproxyK8sObject + */ +export interface ObproxyK8sObject { + /** + * + * @type {string} + * @memberof ObproxyK8sObject + */ + 'name': string; + /** + * + * @type {string} + * @memberof ObproxyK8sObject + */ + 'namespace': string; +} +/** + * + * @export + * @interface ObproxyOBProxy + */ +export interface ObproxyOBProxy { + /** + * + * @type {string} + * @memberof ObproxyOBProxy + */ + 'creationTime': string; + /** + * + * @type {string} + * @memberof ObproxyOBProxy + */ + 'image': string; + /** + * + * @type {string} + * @memberof ObproxyOBProxy + */ + 'name': string; + /** + * + * @type {string} + * @memberof ObproxyOBProxy + */ + 'namespace': string; + /** + * + * @type {ObproxyK8sObject} + * @memberof ObproxyOBProxy + */ + 'obCluster': ObproxyK8sObject; + /** + * + * @type {Array} + * @memberof ObproxyOBProxy + */ + 'parameters': Array; + /** + * + * @type {Array} + * @memberof ObproxyOBProxy + */ + 'pods': Array; + /** + * + * @type {string} + * @memberof ObproxyOBProxy + */ + 'proxyClusterName': string; + /** + * + * @type {string} + * @memberof ObproxyOBProxy + */ + 'proxySysSecret': string; + /** + * + * @type {number} + * @memberof ObproxyOBProxy + */ + 'replicas': number; + /** + * + * @type {CommonResourceSpec} + * @memberof ObproxyOBProxy + */ + 'resource': CommonResourceSpec; + /** + * + * @type {ResponseK8sService} + * @memberof ObproxyOBProxy + */ + 'service': ResponseK8sService; + /** + * + * @type {string} + * @memberof ObproxyOBProxy + */ + 'serviceIp': string; + /** + * + * @type {string} + * @memberof ObproxyOBProxy + */ + 'status': string; +} +/** + * + * @export + * @interface ObproxyOBProxyOverview + */ +export interface ObproxyOBProxyOverview { + /** + * + * @type {string} + * @memberof ObproxyOBProxyOverview + */ + 'creationTime': string; + /** + * + * @type {string} + * @memberof ObproxyOBProxyOverview + */ + 'image': string; + /** + * + * @type {string} + * @memberof ObproxyOBProxyOverview + */ + 'name': string; + /** + * + * @type {string} + * @memberof ObproxyOBProxyOverview + */ + 'namespace': string; + /** + * + * @type {ObproxyK8sObject} + * @memberof ObproxyOBProxyOverview + */ + 'obCluster': ObproxyK8sObject; + /** + * + * @type {string} + * @memberof ObproxyOBProxyOverview + */ + 'proxyClusterName': string; + /** + * + * @type {number} + * @memberof ObproxyOBProxyOverview + */ + 'replicas': number; + /** + * + * @type {string} + * @memberof ObproxyOBProxyOverview + */ + 'serviceIp': string; + /** + * + * @type {string} + * @memberof ObproxyOBProxyOverview + */ + 'status': string; +} +/** + * + * @export + * @interface ObproxyPatchOBProxyParam + */ +export interface ObproxyPatchOBProxyParam { + /** + * + * @type {Array} + * @memberof ObproxyPatchOBProxyParam + */ + 'addedParameters'?: Array; + /** + * + * @type {Array} + * @memberof ObproxyPatchOBProxyParam + */ + 'deletedParameters'?: Array; + /** + * + * @type {string} + * @memberof ObproxyPatchOBProxyParam + */ + 'image'?: string; + /** + * + * @type {number} + * @memberof ObproxyPatchOBProxyParam + */ + 'replicas'?: number; + /** + * + * @type {CommonResourceSpec} + * @memberof ObproxyPatchOBProxyParam + */ + 'resource'?: CommonResourceSpec; + /** + * + * @type {string} + * @memberof ObproxyPatchOBProxyParam + */ + 'serviceType'?: ObproxyPatchOBProxyParamServiceTypeEnum; +} + +export const ObproxyPatchOBProxyParamServiceTypeEnum = { + ClusterIP: 'ClusterIP', + NodePort: 'NodePort', + LoadBalancer: 'LoadBalancer', + ExternalName: 'ExternalName' +} as const; + +export type ObproxyPatchOBProxyParamServiceTypeEnum = typeof ObproxyPatchOBProxyParamServiceTypeEnum[keyof typeof ObproxyPatchOBProxyParamServiceTypeEnum]; + /** * * @export @@ -2918,19 +3269,74 @@ export interface ResponseBackupPolicy { /** * * @export - * @interface ResponseDashboardInfo + * @interface ResponseContainerInfo */ -export interface ResponseDashboardInfo { +export interface ResponseContainerInfo { /** * * @type {string} - * @memberof ResponseDashboardInfo + * @memberof ResponseContainerInfo */ - 'appName': string; + 'image': string; /** * - * @type {string} - * @memberof ResponseDashboardInfo + * @type {CommonResourceSpec} + * @memberof ResponseContainerInfo + */ + 'limits': CommonResourceSpec; + /** + * + * @type {string} + * @memberof ResponseContainerInfo + */ + 'name': string; + /** + * + * @type {Array} + * @memberof ResponseContainerInfo + */ + 'ports': Array; + /** + * + * @type {boolean} + * @memberof ResponseContainerInfo + */ + 'ready': boolean; + /** + * + * @type {CommonResourceSpec} + * @memberof ResponseContainerInfo + */ + 'requests': CommonResourceSpec; + /** + * + * @type {number} + * @memberof ResponseContainerInfo + */ + 'restartCount': number; + /** + * + * @type {string} + * @memberof ResponseContainerInfo + */ + 'startTime': string; +} +/** + * + * @export + * @interface ResponseDashboardInfo + */ +export interface ResponseDashboardInfo { + /** + * + * @type {string} + * @memberof ResponseDashboardInfo + */ + 'appName': string; + /** + * + * @type {string} + * @memberof ResponseDashboardInfo */ 'publicKey': string; /** @@ -3173,6 +3579,135 @@ export interface ResponseK8sNodeResource { */ 'memoryUsed': number; } +/** + * + * @export + * @interface ResponseK8sPodInfo + */ +export interface ResponseK8sPodInfo { + /** + * + * @type {Array} + * @memberof ResponseK8sPodInfo + */ + 'containers': Array; + /** + * + * @type {string} + * @memberof ResponseK8sPodInfo + */ + 'message': string; + /** + * + * @type {string} + * @memberof ResponseK8sPodInfo + */ + 'name': string; + /** + * + * @type {string} + * @memberof ResponseK8sPodInfo + */ + 'namespace': string; + /** + * + * @type {string} + * @memberof ResponseK8sPodInfo + */ + 'nodeName': string; + /** + * + * @type {string} + * @memberof ResponseK8sPodInfo + */ + 'podIP': string; + /** + * + * @type {string} + * @memberof ResponseK8sPodInfo + */ + 'reason': string; + /** + * + * @type {string} + * @memberof ResponseK8sPodInfo + */ + 'startTime': string; + /** + * + * @type {string} + * @memberof ResponseK8sPodInfo + */ + 'status': string; +} +/** + * + * @export + * @interface ResponseK8sService + */ +export interface ResponseK8sService { + /** + * + * @type {string} + * @memberof ResponseK8sService + */ + 'clusterIP'?: string; + /** + * + * @type {string} + * @memberof ResponseK8sService + */ + 'externalIP'?: string; + /** + * + * @type {string} + * @memberof ResponseK8sService + */ + 'name'?: string; + /** + * + * @type {string} + * @memberof ResponseK8sService + */ + 'namespace'?: string; + /** + * + * @type {Array} + * @memberof ResponseK8sService + */ + 'ports'?: Array; + /** + * + * @type {string} + * @memberof ResponseK8sService + */ + 'type'?: string; +} +/** + * + * @export + * @interface ResponseK8sServicePort + */ +export interface ResponseK8sServicePort { + /** + * + * @type {string} + * @memberof ResponseK8sServicePort + */ + 'name'?: string; + /** + * + * @type {number} + * @memberof ResponseK8sServicePort + */ + 'port'?: number; + /** + * + * @type {number} + * @memberof ResponseK8sServicePort + */ + 'targetPort'?: number; +} /** * * @export @@ -4766,7 +5301,7 @@ export interface SilenceSilencerParam { * @type {Array} * @memberof SilenceSilencerParam */ - 'instance': Array; + 'instances': Array; /** * * @type {Array} @@ -7961,6 +8496,438 @@ export class OBClusterApi extends BaseAPI { +/** + * OBProxyApi - axios parameter creator + * @export + */ +export const OBProxyApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * Create OBProxy with the specified parameters + * @summary Create OBProxy + * @param {ObproxyCreateOBProxyParam} body Request body for creating obproxy + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createOBPROXY: async (body: ObproxyCreateOBProxyParam, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'body' is not null or undefined + assertParamExists('createOBPROXY', 'body', body) + const localVarPath = `/api/v1/obproxies`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication ApiKeyAuth required + await setApiKeyToObject(localVarHeaderParameter, "Cookie", configuration) + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Delete OBProxy by namespace and name + * @summary Delete OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deleteOBProxy: async (namespace: string, name: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'namespace' is not null or undefined + assertParamExists('deleteOBProxy', 'namespace', namespace) + // verify required parameter 'name' is not null or undefined + assertParamExists('deleteOBProxy', 'name', name) + const localVarPath = `/api/v1/obproxies/{namespace}/{name}` + .replace(`{${"namespace"}}`, encodeURIComponent(String(namespace))) + .replace(`{${"name"}}`, encodeURIComponent(String(name))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication ApiKeyAuth required + await setApiKeyToObject(localVarHeaderParameter, "Cookie", configuration) + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Get OBProxy by namespace and name + * @summary Get OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getOBProxy: async (namespace: string, name: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'namespace' is not null or undefined + assertParamExists('getOBProxy', 'namespace', namespace) + // verify required parameter 'name' is not null or undefined + assertParamExists('getOBProxy', 'name', name) + const localVarPath = `/api/v1/obproxies/{namespace}/{name}` + .replace(`{${"namespace"}}`, encodeURIComponent(String(namespace))) + .replace(`{${"name"}}`, encodeURIComponent(String(name))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication ApiKeyAuth required + await setApiKeyToObject(localVarHeaderParameter, "Cookie", configuration) + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * list obproxies + * @summary list obproxies + * @param {string} [ns] ns + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + listOBProxies: async (ns?: string, options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/v1/obproxies`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication ApiKeyAuth required + await setApiKeyToObject(localVarHeaderParameter, "Cookie", configuration) + + if (ns !== undefined) { + localVarQueryParameter['ns'] = ns; + } + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Patch OBProxy with the specified parameters + * @summary Patch OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {ObproxyPatchOBProxyParam} body Request body for patching obproxy + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + patchOBProxy: async (namespace: string, name: string, body: ObproxyPatchOBProxyParam, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'namespace' is not null or undefined + assertParamExists('patchOBProxy', 'namespace', namespace) + // verify required parameter 'name' is not null or undefined + assertParamExists('patchOBProxy', 'name', name) + // verify required parameter 'body' is not null or undefined + assertParamExists('patchOBProxy', 'body', body) + const localVarPath = `/api/v1/obproxies/{namespace}/{name}` + .replace(`{${"namespace"}}`, encodeURIComponent(String(namespace))) + .replace(`{${"name"}}`, encodeURIComponent(String(name))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PATCH', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication ApiKeyAuth required + await setApiKeyToObject(localVarHeaderParameter, "Cookie", configuration) + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * OBProxyApi - functional programming interface + * @export + */ +export const OBProxyApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = OBProxyApiAxiosParamCreator(configuration) + return { + /** + * Create OBProxy with the specified parameters + * @summary Create OBProxy + * @param {ObproxyCreateOBProxyParam} body Request body for creating obproxy + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async createOBPROXY(body: ObproxyCreateOBProxyParam, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.createOBPROXY(body, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['OBProxyApi.createOBPROXY']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Delete OBProxy by namespace and name + * @summary Delete OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async deleteOBProxy(namespace: string, name: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.deleteOBProxy(namespace, name, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['OBProxyApi.deleteOBProxy']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Get OBProxy by namespace and name + * @summary Get OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async getOBProxy(namespace: string, name: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.getOBProxy(namespace, name, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['OBProxyApi.getOBProxy']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * list obproxies + * @summary list obproxies + * @param {string} [ns] ns + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async listOBProxies(ns?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.listOBProxies(ns, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['OBProxyApi.listOBProxies']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Patch OBProxy with the specified parameters + * @summary Patch OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {ObproxyPatchOBProxyParam} body Request body for patching obproxy + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async patchOBProxy(namespace: string, name: string, body: ObproxyPatchOBProxyParam, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.patchOBProxy(namespace, name, body, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['OBProxyApi.patchOBProxy']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + } +}; + +/** + * OBProxyApi - factory interface + * @export + */ +export const OBProxyApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = OBProxyApiFp(configuration) + return { + /** + * Create OBProxy with the specified parameters + * @summary Create OBProxy + * @param {ObproxyCreateOBProxyParam} body Request body for creating obproxy + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createOBPROXY(body: ObproxyCreateOBProxyParam, options?: any): AxiosPromise { + return localVarFp.createOBPROXY(body, options).then((request) => request(axios, basePath)); + }, + /** + * Delete OBProxy by namespace and name + * @summary Delete OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deleteOBProxy(namespace: string, name: string, options?: any): AxiosPromise { + return localVarFp.deleteOBProxy(namespace, name, options).then((request) => request(axios, basePath)); + }, + /** + * Get OBProxy by namespace and name + * @summary Get OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getOBProxy(namespace: string, name: string, options?: any): AxiosPromise { + return localVarFp.getOBProxy(namespace, name, options).then((request) => request(axios, basePath)); + }, + /** + * list obproxies + * @summary list obproxies + * @param {string} [ns] ns + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + listOBProxies(ns?: string, options?: any): AxiosPromise { + return localVarFp.listOBProxies(ns, options).then((request) => request(axios, basePath)); + }, + /** + * Patch OBProxy with the specified parameters + * @summary Patch OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {ObproxyPatchOBProxyParam} body Request body for patching obproxy + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + patchOBProxy(namespace: string, name: string, body: ObproxyPatchOBProxyParam, options?: any): AxiosPromise { + return localVarFp.patchOBProxy(namespace, name, body, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * OBProxyApi - object-oriented interface + * @export + * @class OBProxyApi + * @extends {BaseAPI} + */ +export class OBProxyApi extends BaseAPI { + /** + * Create OBProxy with the specified parameters + * @summary Create OBProxy + * @param {ObproxyCreateOBProxyParam} body Request body for creating obproxy + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof OBProxyApi + */ + public createOBPROXY(body: ObproxyCreateOBProxyParam, options?: RawAxiosRequestConfig) { + return OBProxyApiFp(this.configuration).createOBPROXY(body, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Delete OBProxy by namespace and name + * @summary Delete OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof OBProxyApi + */ + public deleteOBProxy(namespace: string, name: string, options?: RawAxiosRequestConfig) { + return OBProxyApiFp(this.configuration).deleteOBProxy(namespace, name, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Get OBProxy by namespace and name + * @summary Get OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof OBProxyApi + */ + public getOBProxy(namespace: string, name: string, options?: RawAxiosRequestConfig) { + return OBProxyApiFp(this.configuration).getOBProxy(namespace, name, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * list obproxies + * @summary list obproxies + * @param {string} [ns] ns + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof OBProxyApi + */ + public listOBProxies(ns?: string, options?: RawAxiosRequestConfig) { + return OBProxyApiFp(this.configuration).listOBProxies(ns, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Patch OBProxy with the specified parameters + * @summary Patch OBProxy + * @param {string} namespace namespace of obproxy deployment + * @param {string} name name of obproxy deployment + * @param {ObproxyPatchOBProxyParam} body Request body for patching obproxy + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof OBProxyApi + */ + public patchOBProxy(namespace: string, name: string, body: ObproxyPatchOBProxyParam, options?: RawAxiosRequestConfig) { + return OBProxyApiFp(this.configuration).patchOBProxy(namespace, name, body, options).then((request) => request(this.axios, this.basePath)); + } +} + + + /** * OBTenantApi - axios parameter creator * @export diff --git a/ui/src/components/InputLabel/index.tsx b/ui/src/components/InputLabel/index.tsx index 570b6984d..cce9bb527 100644 --- a/ui/src/components/InputLabel/index.tsx +++ b/ui/src/components/InputLabel/index.tsx @@ -1,6 +1,6 @@ import { DeleteOutlined, PlusOutlined } from '@ant-design/icons'; import { Button, Checkbox, Col, Form, Input, Popconfirm, Row } from 'antd'; -import styles from './index.less' +import styles from './index.less'; interface InputLabelProps { wrapFormName: string; @@ -8,6 +8,7 @@ interface InputLabelProps { valueFormName: string; regBoxFormName?: string; showDelete?: boolean; + maxCount?: number; } export default function InputLabel({ @@ -16,6 +17,7 @@ export default function InputLabel({ valueFormName, regBoxFormName, showDelete = true, + maxCount, }: InputLabelProps) { return ( @@ -24,12 +26,12 @@ export default function InputLabel({
{fields.map(({ key, name }, index) => ( - + - + @@ -43,7 +45,7 @@ export default function InputLabel({ )} {showDelete && fields.length > 1 && ( - + ))} - - - - - - - + {!maxCount || fields.length < maxCount ? ( + + + + + + + + ) : null}
); }} diff --git a/ui/src/pages/Alert/AlarmFilter/index.tsx b/ui/src/pages/Alert/AlarmFilter/index.tsx index 483607ee3..6c598bcba 100644 --- a/ui/src/pages/Alert/AlarmFilter/index.tsx +++ b/ui/src/pages/Alert/AlarmFilter/index.tsx @@ -10,8 +10,8 @@ import { useUpdateEffect } from 'ahooks'; import type { FormInstance } from 'antd'; import { Button, Col, DatePicker, Form, Input, Row, Select, Tag } from 'antd'; import { useEffect, useState } from 'react'; -import type { ServersList, TenantsList } from '../helper'; import { getSelectList } from '../helper'; +import { Alert } from '@/type/alert'; interface AlarmFilterProps { form: FormInstance; @@ -42,7 +42,7 @@ export default function AlarmFilter({ form, type }: AlarmFilterProps) { })); } if (type === 'obtenant') { - return (list as TenantsList[]).map((cluster) => ({ + return (list as Alert.TenantsList[]).map((cluster) => ({ label: {cluster.clusterName}, title: cluster.clusterName, options: cluster.tenants?.map((item) => ({ @@ -52,7 +52,7 @@ export default function AlarmFilter({ form, type }: AlarmFilterProps) { })); } if (type === 'observer') { - return (list as ServersList[]).map((cluster) => ({ + return (list as Alert.ServersList[]).map((cluster) => ({ label: {cluster.clusterName}, title: cluster.clusterName, options: cluster.servers?.map((item) => ({ diff --git a/ui/src/pages/Alert/Rules/RuleDrawerForm.tsx b/ui/src/pages/Alert/Rules/RuleDrawerForm.tsx index 4a4f5af7b..5caa4d01b 100644 --- a/ui/src/pages/Alert/Rules/RuleDrawerForm.tsx +++ b/ui/src/pages/Alert/Rules/RuleDrawerForm.tsx @@ -1,8 +1,10 @@ +import { alert } from '@/api'; import AlertDrawer from '@/components/AlertDrawer'; import InputLabel from '@/components/InputLabel'; +import { LEVER_OPTIONS_ALARM, SERVERITY_MAP } from '@/constants'; import { QuestionCircleOutlined } from '@ant-design/icons'; import type { DrawerProps } from 'antd'; -import { Col, Form, Input, InputNumber, Row, Select } from 'antd'; +import { Col, Form, Input, InputNumber, Row, Select, Tag } from 'antd'; import { useEffect } from 'react'; type AlertRuleDrawerProps = { @@ -25,9 +27,13 @@ export default function RuleDrawerForm({ useEffect(() => { if (ruleName) { - // Something to do + alert.getRule(ruleName).then(({ data, successful }) => { + if (successful) { + form.setFieldsValue({ ...data }); + } + }); } - }, []); + }, [ruleName]); return ( - - ({ + value: item.value, + label: ( + + {item.label} + + ), + }))} + placeholder="请选择" + /> @@ -90,7 +115,7 @@ export default function RuleDrawerForm({ }, ]} label="持续时间" - name={'description'} + name={'duration'} > diff --git a/ui/src/pages/Alert/Rules/index.tsx b/ui/src/pages/Alert/Rules/index.tsx index 888155fdf..835bf6490 100644 --- a/ui/src/pages/Alert/Rules/index.tsx +++ b/ui/src/pages/Alert/Rules/index.tsx @@ -14,6 +14,7 @@ const { Text } = Typography; export default function Rules() { const [form] = Form.useForm(); const { data: listRulesRes, refresh } = useRequest(alert.listRules); + const [editRuleName,setEditRuleName] = useState() const { run: deleteRule } = useRequest(alert.deleteRule, { onSuccess: ({ successful }) => { if (successful) { @@ -24,6 +25,11 @@ export default function Rules() { const [drawerOpen, setDrawerOpen] = useState(false); const listRules = listRulesRes?.data || []; + const editRule = (ruleName:string)=>{ + setEditRuleName(ruleName); + setDrawerOpen(true); + } + const columns: ColumnsType = [ { title: '告警规则名', @@ -66,7 +72,7 @@ export default function Rules() { dataIndex: 'action', render: (_, record) => ( <> -