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

feat:Delete resource pool #245

Merged
merged 2 commits into from
Mar 14, 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
19 changes: 13 additions & 6 deletions ui/src/components/TopoComponent/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
CLUSTER_IMG_MAP,
SERVER_IMG_MAP,
ZONE_IMG_MAP,
TOPO_INFO_CONFIG
} from '@/constants';
import { intl } from '@/utils/intl';
import { Graph, IG6GraphEvent, INode, IShape } from '@antv/g6';
Expand Down Expand Up @@ -199,12 +200,18 @@ export const formatTopoData = (
};
topoData.children = getChildren(responseData.topology, tenantReplicas);

let basicInfo: BasicInfoType = {
name: responseData.name,
namespace: responseData.namespace,
status: responseData.status,
image: responseData.image,
};
// let basicInfo: BasicInfoType = {
// name: responseData.name,
// namespace: responseData.namespace,
// status: responseData.status,
// image: responseData.image,
// };
let basicInfo:API.ClusterInfo = {};
for(let key of Object.keys(responseData)){
if(TOPO_INFO_CONFIG.includes(key)){
basicInfo[key] = responseData[key];
}
}

return {
topoData,
Expand Down
16 changes: 13 additions & 3 deletions ui/src/components/TopoComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { ReactElement, useEffect, useMemo, useRef, useState } from 'react';

import showDeleteConfirm from '@/components/customModal/DeleteModal';
import OperateModal from '@/components/customModal/OperateModal';
import { RESULT_STATUS } from '@/constants';
import BasicInfo from '@/pages/Cluster/Detail/Overview/BasicInfo';
import { deleteObcluster, deleteObzone, getClusterDetailReq } from '@/services';
import { getNSName } from '../../pages/Cluster/Detail/Overview/helper';
import { ReactNode, config } from './G6register';
import type { OperateTypeLabel } from './constants';
import { RESULT_STATUS } from '@/constants';
import {
clusterOperate,
clusterOperateOfTenant,
Expand Down Expand Up @@ -49,11 +49,13 @@ export default function TopoComponent({
const [inNode, setInNode] = useState<boolean>(false);
const [inModal, setInModal] = useState<boolean>(false);
const [operateDisable, setOperateDisable] = useState<boolean>(false);

const [[ns, name]] = useState(
namespace && clusterNameOfKubectl
? [namespace, clusterNameOfKubectl]
: getNSName(),
);

//Control the visibility of operation and maintenance modal
const [operateModalVisible, setOperateModalVisible] =
useState<boolean>(false);
Expand Down Expand Up @@ -114,7 +116,13 @@ export default function TopoComponent({
zoneName: chooseZoneName.current,
});
if (res.successful) {
message.success(res.message);
message.success(
res.message ||
intl.formatMessage({
id: 'Dashboard.components.TopoComponent.DeletedSuccessfully',
defaultMessage: '删除成功',
}),
);
getTopoData({ ns, name, useFor: 'topo', tenantReplicas });
}
};
Expand Down Expand Up @@ -286,10 +294,12 @@ export default function TopoComponent({
? header
: originTopoData && (
<BasicInfo
style={{ backgroundColor: '#f5f8fe', border:'none' }}
extra={false}
style={{ backgroundColor: '#f5f8fe', border: 'none' }}
{...(originTopoData.basicInfo as API.ClusterInfo)}
/>
)}

<div style={{ height: '100%' }} id="topoContainer"></div>
{useMemo(
() => (
Expand Down
29 changes: 27 additions & 2 deletions ui/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,30 @@ const MINIMAL_CONFIG = {

const RESULT_STATUS = ['running','failed'];

const BACKUP_RESULT_STATUS = ['RUNNING','FAILED','PAUSED']
const BACKUP_RESULT_STATUS = ['RUNNING','FAILED','PAUSED'];

const CLUSTER_INFO_CONFIG = [
'name',
'namespace',
'status',
'image',
'resource',
'storage',
'backupVolume',
'monitor',
'rootPasswordSecret',
'mode',
'parameters'
]

const TOPO_INFO_CONFIG = [
'name',
'namespace',
'status',
'image',
'mode',
'rootPasswordSecret',
]

const RESOURCE_NAME_REG = /^[a-z\-]+$/;
// use for tenant name or zone name
Expand All @@ -82,5 +105,7 @@ export {
RESULT_STATUS,
BACKUP_RESULT_STATUS,
RESOURCE_NAME_REG,
TZ_NAME_REG
TZ_NAME_REG,
CLUSTER_INFO_CONFIG,
TOPO_INFO_CONFIG
};
8 changes: 7 additions & 1 deletion ui/src/i18n/strings/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -629,5 +629,11 @@
"Dashboard.Detail.Overview.Replicas.ClogDiskSize": "Clog disk size",
"Dashboard.Detail.Overview.Replicas.ResourcePool": "Resource Pool",
"Dashboard.Detail.Overview.Replicas.ResourcePoolReplicazone": "Resource pool-{replicaZone}",
"Dashboard.Detail.Overview.TenantOverview": "Tenant overview"
"Dashboard.Detail.Overview.TenantOverview": "Tenant overview",
"Dashboard.Cluster.New.Topo.TheFirstCharacterMustBe": "The first character must be a letter or an underscore and cannot contain-",
"Dashboard.Detail.Overview.Replicas.DeletedSuccessfully": "Deleted successfully",
"Dashboard.Detail.Overview.Replicas.Edit": "Edit",
"Dashboard.Detail.Overview.Replicas.AreYouSureYouWant": "Are you sure you want to delete the tenant's resource pool on {replicaZone}?",
"Dashboard.Detail.Overview.Replicas.Delete": "Delete",
"Dashboard.components.TopoComponent.DeletedSuccessfully": "Deleted successfully"
}
10 changes: 8 additions & 2 deletions ui/src/i18n/strings/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,12 @@
"Dashboard.Detail.Overview.Replicas.MinimumAvailableCpu": "最小可用 CPU",
"Dashboard.Detail.Overview.Replicas.ClogDiskSize": "Clog 盘大小",
"Dashboard.Detail.Overview.Replicas.ResourcePool": "资源池",
"Dashboard.Detail.Overview.Replicas.ResourcePoolReplicazone": "资源池 - {{replicaZone}}",
"Dashboard.Detail.Overview.TenantOverview": "租户概览"
"Dashboard.Detail.Overview.Replicas.ResourcePoolReplicazone": "资源池 - {replicaZone}",
"Dashboard.Detail.Overview.TenantOverview": "租户概览",
"Dashboard.Cluster.New.Topo.TheFirstCharacterMustBe": "首字符必须是字母或者下划线,不能包含 -",
"Dashboard.Detail.Overview.Replicas.DeletedSuccessfully": "删除成功",
"Dashboard.Detail.Overview.Replicas.Edit": "编辑",
"Dashboard.Detail.Overview.Replicas.AreYouSureYouWant": "确定要删除该租户在{replicaZone}上的资源池吗?",
"Dashboard.Detail.Overview.Replicas.Delete": "删除",
"Dashboard.components.TopoComponent.DeletedSuccessfully": "删除成功"
}
159 changes: 82 additions & 77 deletions ui/src/pages/Cluster/Detail/Overview/BasicInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { COLOR_MAP } from '@/constants';
import { intl } from '@/utils/intl';
import { Card, Col, Descriptions, Switch, Tag } from 'antd';
import { Card,Col,Descriptions,Switch,Tag } from 'antd';
import { useState } from 'react';

import styles from './index.less';
Expand All @@ -10,69 +10,72 @@ export default function BasicInfo({
namespace,
status,
image,
mode,
rootPasswordSecret,
resource,
storage,
backupVolume,
monitor,
rootPasswordSecret,
mode,
parameters,
extra = true,
style,
}: API.ClusterInfo & { style: React.CSSProperties }) {
}: API.ClusterInfo & { style?: React.CSSProperties,extra?: boolean }) {
const [checked, setChecked] = useState<boolean>(false);
const OBServerConfig = [
{
label: 'CPU',
value: resource.cpu,
},
{
label: 'Memory',
value: resource.memory,
},
{
label: intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.DatafileStorageClass',
defaultMessage: 'Datafile 存储类',
}),
value: storage.dataStorage.storageClass,
},
{
label: intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.DatafileStorageSize',
defaultMessage: 'Datafile 存储大小',
}),
value: storage.dataStorage.size,
},
{
label: intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.RedologStorageClass',
defaultMessage: 'RedoLog 存储类',
}),
value: storage.redoLogStorage.storageClass,
},
{
label: intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.RedologSize',
defaultMessage: 'RedoLog 大小',
}),
value: storage.redoLogStorage.size,
},
{
label: intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.SystemLogStorageClass',
defaultMessage: '系统日志存储类',
}),
value: storage.sysLogStorage.storageClass,
},
{
label: intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.SystemLogStorageSize',
defaultMessage: '系统日志存储大小',
}),
value: storage.sysLogStorage.size,
},
];

const OBServerConfig = extra
? [
{
label: 'CPU',
value: resource.cpu,
},
{
label: 'Memory',
value: resource.memory,
},
{
label: intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.DatafileStorageClass',
defaultMessage: 'Datafile 存储类',
}),
value: storage.dataStorage.storageClass,
},
{
label: intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.DatafileStorageSize',
defaultMessage: 'Datafile 存储大小',
}),
value: storage.dataStorage.size,
},
{
label: intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.RedologStorageClass',
defaultMessage: 'RedoLog 存储类',
}),
value: storage.redoLogStorage.storageClass,
},
{
label: intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.RedologSize',
defaultMessage: 'RedoLog 大小',
}),
value: storage.redoLogStorage.size,
},
{
label: intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.SystemLogStorageClass',
defaultMessage: '系统日志存储类',
}),
value: storage.sysLogStorage.storageClass,
},
{
label: intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.SystemLogStorageSize',
defaultMessage: '系统日志存储大小',
}),
value: storage.sysLogStorage.size,
},
]
: [];

return (
<Col span={24}>
<Card style={style}>
Expand Down Expand Up @@ -135,26 +138,28 @@ export default function BasicInfo({
{rootPasswordSecret || '-'}
</Descriptions.Item>
</Descriptions>
<div style={{ marginBottom: 12 }}>
<span
style={{
color: '#132039',
fontSize: 16,
fontWeight: 600,
marginRight: 8,
}}
>
{intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.DetailedClusterConfiguration',
defaultMessage: '集群详细配置',
})}
</span>
<Switch
checked={checked}
onChange={(checked) => setChecked(checked)}
/>
</div>
{checked && (
{extra && (
<div style={{ marginBottom: 12 }}>
<span
style={{
color: '#132039',
fontSize: 16,
fontWeight: 600,
marginRight: 8,
}}
>
{intl.formatMessage({
id: 'Dashboard.Detail.Overview.BasicInfo.DetailedClusterConfiguration',
defaultMessage: '集群详细配置',
})}
</span>
<Switch
checked={checked}
onChange={(checked) => setChecked(checked)}
/>
</div>
)}
{checked && extra && (
<div className={styles.detailConfig}>
<Descriptions
style={{ width: '50%' }}
Expand Down
1 change: 1 addition & 0 deletions ui/src/pages/Cluster/Detail/Overview/ZoneTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export default function ZoneTable({
})}
</a>
<a
style={{ color:'#ff4b4b' }}
onClick={() => {
showDeleteConfirm({
onOk: () => remove(record.zone),
Expand Down
17 changes: 2 additions & 15 deletions ui/src/pages/Cluster/Detail/Overview/helper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Functions without UI
import { CLUSTER_INFO_CONFIG } from "@/constants";

/**
* Get the namespace, name and cluster name or tenant name through the path of the url
Expand Down Expand Up @@ -32,20 +33,6 @@ const getNSName = () => {
return res;
};

const clusterInfoConfig = [
'name',
'namespace',
'status',
'image',
'resource',
'storage',
'backupVolume',
'monitor',
'rootPasswordSecret',
'mode',
'parameters'
]

// if there is cluster|zone|server whose status isn't running,the return status is operating.
const formatClusterData = (responseData: any): API.ClusterDetail => {
const res: any = {
Expand All @@ -59,7 +46,7 @@ const formatClusterData = (responseData: any): API.ClusterDetail => {
if (key === 'status' && responseData[key] !== 'running') {
status = 'operating';
}
if(clusterInfoConfig.includes(key)){
if(CLUSTER_INFO_CONFIG.includes(key)){
res['info'][key] = responseData[key];
}
if (key === 'metrics') {
Expand Down
Loading
Loading