Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve:update ParametersModal and api #663

Merged
merged 8 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
229 changes: 226 additions & 3 deletions ui/src/api/generated/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1819,6 +1819,31 @@ export interface ListK8sStorageClasses200Response {
*/
'successful': boolean;
}
/**
*
* @export
* @interface ListOBClusterParameters200Response
*/
export interface ListOBClusterParameters200Response {
/**
*
* @type {Array<ModelParameter>}
* @memberof ListOBClusterParameters200Response
*/
'data': Array<ModelParameter>;
/**
*
* @type {string}
* @memberof ListOBClusterParameters200Response
*/
'message': string;
/**
*
* @type {boolean}
* @memberof ListOBClusterParameters200Response
*/
'successful': boolean;
}
/**
*
* @export
Expand Down Expand Up @@ -2119,6 +2144,91 @@ export interface ListSuspiciousSqls200Response {
*/
'successful': boolean;
}
/**
*
* @export
* @interface ModelParameter
*/
export interface ModelParameter {
/**
*
* @type {string}
* @memberof ModelParameter
*/
'dataType'?: string;
/**
*
* @type {string}
* @memberof ModelParameter
*/
'defaultValue'?: string;
/**
*
* @type {string}
* @memberof ModelParameter
*/
'edit_level'?: string;
/**
*
* @type {string}
* @memberof ModelParameter
*/
'info'?: string;
/**
*
* @type {string}
* @memberof ModelParameter
*/
'isDefault'?: string;
/**
*
* @type {string}
* @memberof ModelParameter
*/
'name'?: string;
/**
*
* @type {string}
* @memberof ModelParameter
*/
'scope'?: string;
/**
*
* @type {string}
* @memberof ModelParameter
*/
'section'?: string;
/**
*
* @type {string}
* @memberof ModelParameter
*/
'svr_ip'?: string;
/**
*
* @type {number}
* @memberof ModelParameter
*/
'svr_port'?: number;
/**
*
* @type {number}
* @memberof ModelParameter
*/
'tenant_id'?: number;
/**
*
* @type {string}
* @memberof ModelParameter
*/
'value'?: string;
/**
*
* @type {string}
* @memberof ModelParameter
*/
'zone'?: string;
}
/**
*
* @export
Expand Down Expand Up @@ -3761,14 +3871,26 @@ export interface ParamPatchOBClusterParam {
* @memberof ParamPatchOBClusterParam
*/
'backupVolume'?: ParamNFSVolumeSpec;
/**
* Delete some parameters
* @type {Array<string>}
* @memberof ParamPatchOBClusterParam
*/
'deletedParameters'?: Array<string>;
/**
* Add or modify some parameters
* @type {Array<CommonKVPair>}
* @memberof ParamPatchOBClusterParam
*/
'modifiedParameters'?: Array<CommonKVPair>;
/**
*
* @type {ParamMonitorSpec}
* @memberof ParamPatchOBClusterParam
*/
'monitor'?: ParamMonitorSpec;
/**
*
* Replace all parameters
* @type {Array<CommonKVPair>}
* @memberof ParamPatchOBClusterParam
*/
Expand Down Expand Up @@ -5501,10 +5623,10 @@ export interface ResponseOBCluster {
'namespace': string;
/**
*
* @type {Array<CommonKVPair>}
* @type {Array<ResponseParameterSpec>}
* @memberof ResponseOBCluster
*/
'parameters': Array<CommonKVPair>;
'parameters': Array<ResponseParameterSpec>;
/**
*
* @type {ResponseResourceSpecRender}
Expand Down Expand Up @@ -6319,6 +6441,31 @@ export interface ResponseOBZoneAvailableResource {
*/
'serverCount': number;
}
/**
*
* @export
* @interface ResponseParameterSpec
*/
export interface ResponseParameterSpec {
/**
*
* @type {string}
* @memberof ResponseParameterSpec
*/
'name': string;
/**
*
* @type {string}
* @memberof ResponseParameterSpec
*/
'specValue': string;
/**
*
* @type {string}
* @memberof ResponseParameterSpec
*/
'value': string;
}
/**
*
* @export
Expand Down Expand Up @@ -11931,6 +12078,44 @@ export const OBClusterApiAxiosParamCreator = function (configuration?: Configura



setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* List OBCluster Parameters by namespace and name
* @summary List OBCluster Parameters
* @param {string} namespace namespace of obcluster resource
* @param {string} name name of obcluster resource
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
listOBClusterParameters: async (namespace: string, name: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'namespace' is not null or undefined
assertParamExists('listOBClusterParameters', 'namespace', namespace)
// verify required parameter 'name' is not null or undefined
assertParamExists('listOBClusterParameters', 'name', name)
const localVarPath = `/api/v1/obclusters/namespace/{namespace}/name/{name}/parameters`
.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;



setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
Expand Down Expand Up @@ -12355,6 +12540,20 @@ export const OBClusterApiFp = function(configuration?: Configuration) {
const localVarOperationServerBasePath = operationServerMap['OBClusterApi.getOBClusterStatistic']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* List OBCluster Parameters by namespace and name
* @summary List OBCluster Parameters
* @param {string} namespace namespace of obcluster resource
* @param {string} name name of obcluster resource
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async listOBClusterParameters(namespace: string, name: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ListOBClusterParameters200Response>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.listOBClusterParameters(namespace, name, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['OBClusterApi.listOBClusterParameters']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* list related events of specific obcluster, including obzone and observer.
* @summary list related events
Expand Down Expand Up @@ -12543,6 +12742,17 @@ export const OBClusterApiFactory = function (configuration?: Configuration, base
getOBClusterStatistic(options?: any): AxiosPromise<GetOBClusterStatistic200Response> {
return localVarFp.getOBClusterStatistic(options).then((request) => request(axios, basePath));
},
/**
* List OBCluster Parameters by namespace and name
* @summary List OBCluster Parameters
* @param {string} namespace namespace of obcluster resource
* @param {string} name name of obcluster resource
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
listOBClusterParameters(namespace: string, name: string, options?: any): AxiosPromise<ListOBClusterParameters200Response> {
return localVarFp.listOBClusterParameters(namespace, name, options).then((request) => request(axios, basePath));
},
/**
* list related events of specific obcluster, including obzone and observer.
* @summary list related events
Expand Down Expand Up @@ -12724,6 +12934,19 @@ export class OBClusterApi extends BaseAPI {
return OBClusterApiFp(this.configuration).getOBClusterStatistic(options).then((request) => request(this.axios, this.basePath));
}

/**
* List OBCluster Parameters by namespace and name
* @summary List OBCluster Parameters
* @param {string} namespace namespace of obcluster resource
* @param {string} name name of obcluster resource
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof OBClusterApi
*/
public listOBClusterParameters(namespace: string, name: string, options?: RawAxiosRequestConfig) {
return OBClusterApiFp(this.configuration).listOBClusterParameters(namespace, name, options).then((request) => request(this.axios, this.basePath));
}

/**
* list related events of specific obcluster, including obzone and observer.
* @summary list related events
Expand Down
55 changes: 29 additions & 26 deletions ui/src/pages/Cluster/Detail/Overview/ParametersModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { obcluster } from '@/api';
import { intl } from '@/utils/intl';
import { Button, Col, Form, Input, Modal, Row, Space } from 'antd';
import { useRequest } from 'ahooks';
import { Button, Col, Form, Input, message, Modal, Row, Space } from 'antd';
import React from 'react';

export interface ParametersModalProps {
Expand All @@ -15,30 +17,30 @@ const ParametersModal: React.FC<ParametersModalProps> = ({
visible,
onCancel,
initialValues,
// onSuccess,
// name,
// namespace,
onSuccess,
name,
namespace,
}) => {
const [form] = Form.useForm<API.CreateClusterData>();
const { validateFields } = form;

// const { runAsync: updateParameters, loading } = useRequest(
// obcluster.patchOBCluster,
// {
// manual: true,
// onSuccess: (res) => {
// if (res.successful) {
// message.success(
// intl.formatMessage({
// id: 'src.pages.Cluster.Detail.Overview.E908AA54',
// defaultMessage: '编辑参数已成功',
// }),
// );
// onSuccess();
// }
// },
// },
// );
const { runAsync: updateParameters, loading } = useRequest(
obcluster.patchOBCluster,
{
manual: true,
onSuccess: (res) => {
if (res.successful) {
message.success(
intl.formatMessage({
id: 'src.pages.Cluster.Detail.Overview.E908AA54',
defaultMessage: '编辑参数已成功',
}),
);
onSuccess();
}
},
},
);

return (
<Modal
Expand All @@ -55,12 +57,13 @@ const ParametersModal: React.FC<ParametersModalProps> = ({
<Button onClick={onCancel}>取消</Button>
<Button
type="primary"
// loading={loading}
// TODO 单独编辑参数接口
loading={loading}
onClick={() => {
validateFields().then((values) => {
console.log('values', values);
// updateParameters(name, namespace, values, `编辑参数已成功`);
const objValue = {
modifiedParameters: [values],
};
updateParameters(name, namespace, objValue, `编辑参数已成功`);
});
}}
>
Expand All @@ -78,7 +81,7 @@ const ParametersModal: React.FC<ParametersModalProps> = ({
defaultMessage: '参数名',
})}
initialValue={initialValues?.name}
name={'name'}
name={'key'}
>
<Input disabled={true} />
</Form.Item>
Expand Down
Loading