Skip to content

Commit cf53633

Browse files
committed
improve: update parametersModal and api
1 parent 231c13f commit cf53633

File tree

2 files changed

+255
-29
lines changed

2 files changed

+255
-29
lines changed

ui/src/api/generated/api.ts

Lines changed: 226 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,6 +1819,31 @@ export interface ListK8sStorageClasses200Response {
18191819
*/
18201820
'successful': boolean;
18211821
}
1822+
/**
1823+
*
1824+
* @export
1825+
* @interface ListOBClusterParameters200Response
1826+
*/
1827+
export interface ListOBClusterParameters200Response {
1828+
/**
1829+
*
1830+
* @type {Array<ModelParameter>}
1831+
* @memberof ListOBClusterParameters200Response
1832+
*/
1833+
'data': Array<ModelParameter>;
1834+
/**
1835+
*
1836+
* @type {string}
1837+
* @memberof ListOBClusterParameters200Response
1838+
*/
1839+
'message': string;
1840+
/**
1841+
*
1842+
* @type {boolean}
1843+
* @memberof ListOBClusterParameters200Response
1844+
*/
1845+
'successful': boolean;
1846+
}
18221847
/**
18231848
*
18241849
* @export
@@ -2119,6 +2144,91 @@ export interface ListSuspiciousSqls200Response {
21192144
*/
21202145
'successful': boolean;
21212146
}
2147+
/**
2148+
*
2149+
* @export
2150+
* @interface ModelParameter
2151+
*/
2152+
export interface ModelParameter {
2153+
/**
2154+
*
2155+
* @type {string}
2156+
* @memberof ModelParameter
2157+
*/
2158+
'dataType'?: string;
2159+
/**
2160+
*
2161+
* @type {string}
2162+
* @memberof ModelParameter
2163+
*/
2164+
'defaultValue'?: string;
2165+
/**
2166+
*
2167+
* @type {string}
2168+
* @memberof ModelParameter
2169+
*/
2170+
'edit_level'?: string;
2171+
/**
2172+
*
2173+
* @type {string}
2174+
* @memberof ModelParameter
2175+
*/
2176+
'info'?: string;
2177+
/**
2178+
*
2179+
* @type {string}
2180+
* @memberof ModelParameter
2181+
*/
2182+
'isDefault'?: string;
2183+
/**
2184+
*
2185+
* @type {string}
2186+
* @memberof ModelParameter
2187+
*/
2188+
'name'?: string;
2189+
/**
2190+
*
2191+
* @type {string}
2192+
* @memberof ModelParameter
2193+
*/
2194+
'scope'?: string;
2195+
/**
2196+
*
2197+
* @type {string}
2198+
* @memberof ModelParameter
2199+
*/
2200+
'section'?: string;
2201+
/**
2202+
*
2203+
* @type {string}
2204+
* @memberof ModelParameter
2205+
*/
2206+
'svr_ip'?: string;
2207+
/**
2208+
*
2209+
* @type {number}
2210+
* @memberof ModelParameter
2211+
*/
2212+
'svr_port'?: number;
2213+
/**
2214+
*
2215+
* @type {number}
2216+
* @memberof ModelParameter
2217+
*/
2218+
'tenant_id'?: number;
2219+
/**
2220+
*
2221+
* @type {string}
2222+
* @memberof ModelParameter
2223+
*/
2224+
'value'?: string;
2225+
/**
2226+
*
2227+
* @type {string}
2228+
* @memberof ModelParameter
2229+
*/
2230+
'zone'?: string;
2231+
}
21222232
/**
21232233
*
21242234
* @export
@@ -3761,14 +3871,26 @@ export interface ParamPatchOBClusterParam {
37613871
* @memberof ParamPatchOBClusterParam
37623872
*/
37633873
'backupVolume'?: ParamNFSVolumeSpec;
3874+
/**
3875+
* Delete some parameters
3876+
* @type {Array<string>}
3877+
* @memberof ParamPatchOBClusterParam
3878+
*/
3879+
'deletedParameters'?: Array<string>;
3880+
/**
3881+
* Add or modify some parameters
3882+
* @type {Array<CommonKVPair>}
3883+
* @memberof ParamPatchOBClusterParam
3884+
*/
3885+
'modifiedParameters'?: Array<CommonKVPair>;
37643886
/**
37653887
*
37663888
* @type {ParamMonitorSpec}
37673889
* @memberof ParamPatchOBClusterParam
37683890
*/
37693891
'monitor'?: ParamMonitorSpec;
37703892
/**
3771-
*
3893+
* Replace all parameters
37723894
* @type {Array<CommonKVPair>}
37733895
* @memberof ParamPatchOBClusterParam
37743896
*/
@@ -5501,10 +5623,10 @@ export interface ResponseOBCluster {
55015623
'namespace': string;
55025624
/**
55035625
*
5504-
* @type {Array<CommonKVPair>}
5626+
* @type {Array<ResponseParameterSpec>}
55055627
* @memberof ResponseOBCluster
55065628
*/
5507-
'parameters': Array<CommonKVPair>;
5629+
'parameters': Array<ResponseParameterSpec>;
55085630
/**
55095631
*
55105632
* @type {ResponseResourceSpecRender}
@@ -6319,6 +6441,31 @@ export interface ResponseOBZoneAvailableResource {
63196441
*/
63206442
'serverCount': number;
63216443
}
6444+
/**
6445+
*
6446+
* @export
6447+
* @interface ResponseParameterSpec
6448+
*/
6449+
export interface ResponseParameterSpec {
6450+
/**
6451+
*
6452+
* @type {string}
6453+
* @memberof ResponseParameterSpec
6454+
*/
6455+
'name': string;
6456+
/**
6457+
*
6458+
* @type {string}
6459+
* @memberof ResponseParameterSpec
6460+
*/
6461+
'specValue': string;
6462+
/**
6463+
*
6464+
* @type {string}
6465+
* @memberof ResponseParameterSpec
6466+
*/
6467+
'value': string;
6468+
}
63226469
/**
63236470
*
63246471
* @export
@@ -11931,6 +12078,44 @@ export const OBClusterApiAxiosParamCreator = function (configuration?: Configura
1193112078

1193212079

1193312080

12081+
setSearchParams(localVarUrlObj, localVarQueryParameter);
12082+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
12083+
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
12084+
12085+
return {
12086+
url: toPathString(localVarUrlObj),
12087+
options: localVarRequestOptions,
12088+
};
12089+
},
12090+
/**
12091+
* List OBCluster Parameters by namespace and name
12092+
* @summary List OBCluster Parameters
12093+
* @param {string} namespace namespace of obcluster resource
12094+
* @param {string} name name of obcluster resource
12095+
* @param {*} [options] Override http request option.
12096+
* @throws {RequiredError}
12097+
*/
12098+
listOBClusterParameters: async (namespace: string, name: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
12099+
// verify required parameter 'namespace' is not null or undefined
12100+
assertParamExists('listOBClusterParameters', 'namespace', namespace)
12101+
// verify required parameter 'name' is not null or undefined
12102+
assertParamExists('listOBClusterParameters', 'name', name)
12103+
const localVarPath = `/api/v1/obclusters/namespace/{namespace}/name/{name}/parameters`
12104+
.replace(`{${"namespace"}}`, encodeURIComponent(String(namespace)))
12105+
.replace(`{${"name"}}`, encodeURIComponent(String(name)));
12106+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
12107+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
12108+
let baseOptions;
12109+
if (configuration) {
12110+
baseOptions = configuration.baseOptions;
12111+
}
12112+
12113+
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
12114+
const localVarHeaderParameter = {} as any;
12115+
const localVarQueryParameter = {} as any;
12116+
12117+
12118+
1193412119
setSearchParams(localVarUrlObj, localVarQueryParameter);
1193512120
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1193612121
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
@@ -12355,6 +12540,20 @@ export const OBClusterApiFp = function(configuration?: Configuration) {
1235512540
const localVarOperationServerBasePath = operationServerMap['OBClusterApi.getOBClusterStatistic']?.[localVarOperationServerIndex]?.url;
1235612541
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
1235712542
},
12543+
/**
12544+
* List OBCluster Parameters by namespace and name
12545+
* @summary List OBCluster Parameters
12546+
* @param {string} namespace namespace of obcluster resource
12547+
* @param {string} name name of obcluster resource
12548+
* @param {*} [options] Override http request option.
12549+
* @throws {RequiredError}
12550+
*/
12551+
async listOBClusterParameters(namespace: string, name: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ListOBClusterParameters200Response>> {
12552+
const localVarAxiosArgs = await localVarAxiosParamCreator.listOBClusterParameters(namespace, name, options);
12553+
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
12554+
const localVarOperationServerBasePath = operationServerMap['OBClusterApi.listOBClusterParameters']?.[localVarOperationServerIndex]?.url;
12555+
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
12556+
},
1235812557
/**
1235912558
* list related events of specific obcluster, including obzone and observer.
1236012559
* @summary list related events
@@ -12543,6 +12742,17 @@ export const OBClusterApiFactory = function (configuration?: Configuration, base
1254312742
getOBClusterStatistic(options?: any): AxiosPromise<GetOBClusterStatistic200Response> {
1254412743
return localVarFp.getOBClusterStatistic(options).then((request) => request(axios, basePath));
1254512744
},
12745+
/**
12746+
* List OBCluster Parameters by namespace and name
12747+
* @summary List OBCluster Parameters
12748+
* @param {string} namespace namespace of obcluster resource
12749+
* @param {string} name name of obcluster resource
12750+
* @param {*} [options] Override http request option.
12751+
* @throws {RequiredError}
12752+
*/
12753+
listOBClusterParameters(namespace: string, name: string, options?: any): AxiosPromise<ListOBClusterParameters200Response> {
12754+
return localVarFp.listOBClusterParameters(namespace, name, options).then((request) => request(axios, basePath));
12755+
},
1254612756
/**
1254712757
* list related events of specific obcluster, including obzone and observer.
1254812758
* @summary list related events
@@ -12724,6 +12934,19 @@ export class OBClusterApi extends BaseAPI {
1272412934
return OBClusterApiFp(this.configuration).getOBClusterStatistic(options).then((request) => request(this.axios, this.basePath));
1272512935
}
1272612936

12937+
/**
12938+
* List OBCluster Parameters by namespace and name
12939+
* @summary List OBCluster Parameters
12940+
* @param {string} namespace namespace of obcluster resource
12941+
* @param {string} name name of obcluster resource
12942+
* @param {*} [options] Override http request option.
12943+
* @throws {RequiredError}
12944+
* @memberof OBClusterApi
12945+
*/
12946+
public listOBClusterParameters(namespace: string, name: string, options?: RawAxiosRequestConfig) {
12947+
return OBClusterApiFp(this.configuration).listOBClusterParameters(namespace, name, options).then((request) => request(this.axios, this.basePath));
12948+
}
12949+
1272712950
/**
1272812951
* list related events of specific obcluster, including obzone and observer.
1272912952
* @summary list related events

ui/src/pages/Cluster/Detail/Overview/ParametersModal.tsx

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { obcluster } from '@/api';
12
import { intl } from '@/utils/intl';
2-
import { Button, Col, Form, Input, Modal, Row, Space } from 'antd';
3+
import { useRequest } from 'ahooks';
4+
import { Button, Col, Form, Input, message, Modal, Row, Space } from 'antd';
35
import React from 'react';
46

57
export interface ParametersModalProps {
@@ -15,30 +17,30 @@ const ParametersModal: React.FC<ParametersModalProps> = ({
1517
visible,
1618
onCancel,
1719
initialValues,
18-
// onSuccess,
19-
// name,
20-
// namespace,
20+
onSuccess,
21+
name,
22+
namespace,
2123
}) => {
2224
const [form] = Form.useForm<API.CreateClusterData>();
2325
const { validateFields } = form;
2426

25-
// const { runAsync: updateParameters, loading } = useRequest(
26-
// obcluster.patchOBCluster,
27-
// {
28-
// manual: true,
29-
// onSuccess: (res) => {
30-
// if (res.successful) {
31-
// message.success(
32-
// intl.formatMessage({
33-
// id: 'src.pages.Cluster.Detail.Overview.E908AA54',
34-
// defaultMessage: '编辑参数已成功',
35-
// }),
36-
// );
37-
// onSuccess();
38-
// }
39-
// },
40-
// },
41-
// );
27+
const { runAsync: updateParameters, loading } = useRequest(
28+
obcluster.patchOBCluster,
29+
{
30+
manual: true,
31+
onSuccess: (res) => {
32+
if (res.successful) {
33+
message.success(
34+
intl.formatMessage({
35+
id: 'src.pages.Cluster.Detail.Overview.E908AA54',
36+
defaultMessage: '编辑参数已成功',
37+
}),
38+
);
39+
onSuccess();
40+
}
41+
},
42+
},
43+
);
4244

4345
return (
4446
<Modal
@@ -55,12 +57,13 @@ const ParametersModal: React.FC<ParametersModalProps> = ({
5557
<Button onClick={onCancel}>取消</Button>
5658
<Button
5759
type="primary"
58-
// loading={loading}
59-
// TODO 单独编辑参数接口
60+
loading={loading}
6061
onClick={() => {
6162
validateFields().then((values) => {
62-
console.log('values', values);
63-
// updateParameters(name, namespace, values, `编辑参数已成功`);
63+
const objValue = {
64+
modifiedParameters: [values],
65+
};
66+
updateParameters(name, namespace, objValue, `编辑参数已成功`);
6467
});
6568
}}
6669
>
@@ -78,7 +81,7 @@ const ParametersModal: React.FC<ParametersModalProps> = ({
7881
defaultMessage: '参数名',
7982
})}
8083
initialValue={initialValues?.name}
81-
name={'name'}
84+
name={'key'}
8285
>
8386
<Input disabled={true} />
8487
</Form.Item>

0 commit comments

Comments
 (0)