diff --git a/chaosmeta-platform-frontend/Dockerfile b/chaosmeta-platform-frontend/Dockerfile new file mode 100644 index 0000000..3343d7e --- /dev/null +++ b/chaosmeta-platform-frontend/Dockerfile @@ -0,0 +1,13 @@ +# 设置 Node.js 版本 +FROM node:16-alpine + +# 设置工作目录 +WORKDIR /app + +# 将 package.json 和 package-lock.json 复制到工作目录中 +COPY . . + +RUN yarn install + +# 设置容器启动时的命令 +CMD ["yarn", "start"] \ No newline at end of file diff --git a/chaosmeta-platform-frontend/config/router.ts b/chaosmeta-platform-frontend/config/router.ts index da570c6..a7cf7e7 100644 --- a/chaosmeta-platform-frontend/config/router.ts +++ b/chaosmeta-platform-frontend/config/router.ts @@ -1,7 +1,7 @@ export default [ { path: '/', - redirect: '/space/overview', + redirect: '/login', }, { path: '/*', component: '@/pages/404' }, { diff --git a/chaosmeta-platform-frontend/src/app.tsx b/chaosmeta-platform-frontend/src/app.tsx index d73569e..9c3f478 100644 --- a/chaosmeta-platform-frontend/src/app.tsx +++ b/chaosmeta-platform-frontend/src/app.tsx @@ -96,36 +96,10 @@ export const layout = () => { }, siderWidth: 208, layout: 'mix', - // breakpoint: false, splitMenus: true, - // collapsedButtonRender: (porps) => { - // return null; - // }, - // collapsed: false, rightContentRender: () => { return ; }, - // headerRender: (layoutProps: any) => { - // const { title, logo } = layoutProps; - // return ( - //
- //
- // {title} - // - //
- //
- // - // {initialState?.name} - //
- //
- // ); - // }, menuExtraRender: (props: any) => { if (props?.matchMenuKeys[0] === '/setting') { return null; diff --git a/chaosmeta-platform-frontend/src/components/AddSpaceDrawer/index.tsx b/chaosmeta-platform-frontend/src/components/AddSpaceDrawer/index.tsx index 4dd456f..d07da8f 100644 --- a/chaosmeta-platform-frontend/src/components/AddSpaceDrawer/index.tsx +++ b/chaosmeta-platform-frontend/src/components/AddSpaceDrawer/index.tsx @@ -49,7 +49,12 @@ const AddSpaceDrawer: React.FC = (props) => { // 更新空间信息 handleUpdateSpaceId(res?.data?.id); setOpen(false); - history.push('/space/setting'); + history.push({ + pathname: '/space/setting', + query: { + spaceId: res?.data?.id, + }, + }); } }, }); @@ -58,9 +63,6 @@ const AddSpaceDrawer: React.FC = (props) => { * 创建空间 */ const handleCreate = () => { - // setCurSpace() - // handleUpdateSpaceId('20', 'ceshi') - // return form.validateFields().then((values) => { create?.run(values); }); diff --git a/chaosmeta-platform-frontend/src/components/Select/KubernetesNamespaceSelect/index.tsx b/chaosmeta-platform-frontend/src/components/Select/KubernetesNamespaceSelect/index.tsx index 086dc47..e0f5ba3 100644 --- a/chaosmeta-platform-frontend/src/components/Select/KubernetesNamespaceSelect/index.tsx +++ b/chaosmeta-platform-frontend/src/components/Select/KubernetesNamespaceSelect/index.tsx @@ -24,7 +24,7 @@ const KubernetesNamespaceSelect = (props: IProps) => { } }, [list]); - const getUser = useRequest(queryNamespaceList, { + const getNamespaceList = useRequest(queryNamespaceList, { manual: true, formatResult: (res: any) => res, debounceInterval: 300, @@ -37,15 +37,8 @@ const KubernetesNamespaceSelect = (props: IProps) => { }, }); - // 输入有值时进行搜索 - // const handleUserSearch = (val: string) => { - // if (val) { - // getUser?.run({ identifier: val }); - // } - // }; - useEffect(() => { - getUser?.run({ page: 1, page_size: 500 }); + getNamespaceList?.run({ page: 1, page_size: 500 }); }, []); return ( @@ -55,7 +48,7 @@ const KubernetesNamespaceSelect = (props: IProps) => { showSearch // onSearch={(val) => handleUserSearch(val)} allowClear - notFoundContent={getUser?.loading ? : null} + notFoundContent={getNamespaceList?.loading ? : null} filterOption={false} onChange={onChange} placeholder={placeholder} diff --git a/chaosmeta-platform-frontend/src/components/Select/KubernetesPodSelect/index.tsx b/chaosmeta-platform-frontend/src/components/Select/KubernetesPodSelect/index.tsx index 2523720..31c827f 100644 --- a/chaosmeta-platform-frontend/src/components/Select/KubernetesPodSelect/index.tsx +++ b/chaosmeta-platform-frontend/src/components/Select/KubernetesPodSelect/index.tsx @@ -1,6 +1,6 @@ -import { queryNamespaceList, queryPodLIst } from '@/services/chaosmeta/KubernetesController'; +import { queryPodLIst } from '@/services/chaosmeta/KubernetesController'; import { useRequest } from '@umijs/max'; -import { Select, Spin, message } from 'antd'; +import { Empty, Select, Spin, message } from 'antd'; import { useEffect, useState } from 'react'; interface IProps { @@ -11,10 +11,21 @@ interface IProps { mode?: 'multiple' | 'tags'; placeholder?: string; style?: any; + form?: any; + kubernetesNamespace?: any; } const KubernetesPodSelect = (props: IProps) => { - const { value, onChange, list, mode, placeholder = '请选择', style } = props; + const { + value, + onChange, + list, + mode, + placeholder = '请选择', + style, + form, + kubernetesNamespace, + } = props; const [namespaceList, setNamespaceList] = useState([]); const { Option } = Select; @@ -24,7 +35,7 @@ const KubernetesPodSelect = (props: IProps) => { } }, [list]); - const getUser = useRequest(queryPodLIst, { + const getPodList = useRequest(queryPodLIst, { manual: true, formatResult: (res: any) => res, debounceInterval: 300, @@ -37,29 +48,40 @@ const KubernetesPodSelect = (props: IProps) => { }, }); - // 输入有值时进行搜索 - // const handleUserSearch = (val: string) => { - // if (val) { - // getUser?.run({ identifier: val }); - // } - // }; - useEffect(() => { - getUser?.run({ page: 1, page_size: 500 }); - }, []); + // 此项的展示是要依赖namespace的值进行检索,所以当namespace值改变时需要清空列表项和值 + setNamespaceList([]); + form.setFieldValue(['exec_range', 'target_name'], undefined); + }, [kubernetesNamespace]); return ( { const value = event?.target?.value; - getSpaceList?.run({ name: value }); + getSpaceList?.run({ + name: value, + namespaceClass: 'relevant', + }); }} suffix={ { - getSpaceList?.run(); + getSpaceList?.run({ namespaceClass: 'relevant' }); }} /> } @@ -158,11 +159,16 @@ export default () => { 新建空间 - {menu ? ( - React.cloneElement(menu as React.ReactElement) - ) : ( - - )} + +
+ {menu ? ( + React.cloneElement(menu as React.ReactElement) + ) : ( + + )} +
+
+
没有相关空间?查看{' '} diff --git a/chaosmeta-platform-frontend/src/components/SpaceDropdown/style.ts b/chaosmeta-platform-frontend/src/components/SpaceDropdown/style.ts index dc8ca10..53f6abb 100644 --- a/chaosmeta-platform-frontend/src/components/SpaceDropdown/style.ts +++ b/chaosmeta-platform-frontend/src/components/SpaceDropdown/style.ts @@ -5,7 +5,7 @@ export const SpaceMenu = styled.div` border-radius: 6px; background-color: #fff; padding: 8px 0; - div:first-child { + .search { /* width: 180px; */ padding: 0 16px; } @@ -26,6 +26,9 @@ export const SpaceMenu = styled.div` color: rgba(0, 10, 26, 0.47); } } + .ant-spin-container { + padding: 0; + } `; export const SpaceContent = styled.div` diff --git a/chaosmeta-platform-frontend/src/constants/index.ts b/chaosmeta-platform-frontend/src/constants/index.ts index 38e9b96..856251d 100644 --- a/chaosmeta-platform-frontend/src/constants/index.ts +++ b/chaosmeta-platform-frontend/src/constants/index.ts @@ -41,7 +41,7 @@ export const tagColors = [ export const arrangeNodeTypeColors: any = { fault: '#F5E2CC', measure: '#C6F8E0', - pressure: '#FFD5D5', + flow: '#FFD5D5', other: '#D4E3F1', }; diff --git a/chaosmeta-platform-frontend/src/pages/GlobalSetting/Space/SpaceList.tsx b/chaosmeta-platform-frontend/src/pages/GlobalSetting/Space/SpaceList.tsx index 60eb88f..f4cd540 100644 --- a/chaosmeta-platform-frontend/src/pages/GlobalSetting/Space/SpaceList.tsx +++ b/chaosmeta-platform-frontend/src/pages/GlobalSetting/Space/SpaceList.tsx @@ -36,42 +36,42 @@ const SpaceList: React.FC = (props) => { /** * 渲染读写权限成员 */ - // const renderAdmin = (userData: any) => { - // const users = userData?.user?.filter((item) => item?.permission === 1); - // const text = users?.map((item) => item); - // }; + const renderAdmin = (users: any) => { + const newUsers = users?.filter( + (item: { permission: number }) => item?.permission === 1, + ); + + if (newUsers?.length > 0) { + const renderText = newUsers?.map((item: any, index: number) => { + return ( + + {item?.user_name} + {index !== newUsers?.length - 1 && ','} + + ); + }); + return ( + + {renderText} + + ); + } + return '--'; + }; // 当前用户相对应某个空间是否有权限 - const getPermission = (userData: any) => { - // permission 0 = 只读, 1 = 读写, 2 = 未加入 - let permission = 2; + const getPermission = (userPermission: any) => { + // permission 0 = 只读, 1 = 读写, -1 = 未加入 + let permission = 0; // 全局管理员角色,默认拥有所有空间权限 if (userInfo?.role === 'admin') { permission = 1; } else { - permission = userData?.users?.filter( - (item) => item?.user_id === userInfo?.id, - )[0]?.permission; + permission = userPermission || 0; } - return permission || permission === 0 ? permission : 2; + return permission; }; - // const handleUpdateSpaceId = (id: any) => { - // if (id) { - // const name = form.getFieldValue('name'); - // history.push({ - // pathname: history.location.pathname, - // query: { - // ...history.location.query, - // spaceId: id, - // }, - // }); - // setCurSpace([id]); - // sessionStorage.setItem('spaceId', id); - // sessionStorage.setItem('spaceName', name); - // } - // }; - /** * 点击卡片跳转到对应空间 * @param record @@ -94,26 +94,28 @@ const SpaceList: React.FC = (props) => { return ( {pageData?.namespaces?.map((item: any, index: number) => { - const permission = getPermission(item?.userData); + const permission = getPermission(item?.permission); return (
- {permission !== 1 ? ( - - ) : ( + {permission !== -1 ? ( + ) : ( + )}
{ // 未加入不允许进入 - if (permission !== 2) { + if (permission !== -1) { handleClickSpace(item?.namespaceInfo); } }} @@ -129,7 +131,7 @@ const SpaceList: React.FC = (props) => { disabled={permission !== 1} placement="bottomRight" menu={{ - items: items(item.namespaceInfo?.namespaceInfo?.id), + items: items(item.namespaceInfo?.id), }} > = (props) => {
描述:
- + {item?.namespaceInfo?.description}
-
-
+ + - {/* {renderAdmin(item?.userData)} */} -
+ {renderAdmin(item?.users)} + -
+ - {item?.experimentrData?.toTal} + {item?.experimentTotal || 0} -
+ -
+ - {item?.userData?.toTal} + {item?.userTotal || 0} -
-
+ + ); diff --git a/chaosmeta-platform-frontend/src/pages/GlobalSetting/Space/index.tsx b/chaosmeta-platform-frontend/src/pages/GlobalSetting/Space/index.tsx index 4bd42c4..9caa2d9 100644 --- a/chaosmeta-platform-frontend/src/pages/GlobalSetting/Space/index.tsx +++ b/chaosmeta-platform-frontend/src/pages/GlobalSetting/Space/index.tsx @@ -44,7 +44,7 @@ const SpaceManage: React.FC = () => { const [form] = Form.useForm(); const [pageData, setPageData] = useState({ page: 1, - pageSize: 10, + pageSize: 12, total: 0, namespaces: [], }); @@ -85,7 +85,7 @@ const SpaceManage: React.FC = () => { } const params = { page: page || pageData.page || 1, - page_size: pageSize || pageData.pageSize || 10, + page_size: pageSize || pageData.pageSize || 12, sort, name: spaceName, namespaceClass: namespaceClass || spaceType, @@ -111,8 +111,8 @@ const SpaceManage: React.FC = () => { key: 'all', }, { - label: '我管理的空间', - key: 'myAdmin', + label: '我相关的', + key: 'relevant', }, ]; @@ -136,10 +136,10 @@ const SpaceManage: React.FC = () => { label: '全部', value: 'all', }, - { - label: '未加入', - value: 'not', - }, + // { + // label: '未加入', + // value: 'not', + // }, { label: '只读', value: 'read', @@ -165,7 +165,7 @@ const SpaceManage: React.FC = () => { useEffect(() => { handlePageSearch(); }, []); - + return ( @@ -175,7 +175,8 @@ const SpaceManage: React.FC = () => { activeKey={tabKey} onChange={(val) => { setTabKey(val); - const namespaceClass = val === 'myAdmin' ? 'write' : undefined; + const namespaceClass = + val === 'relevant' ? 'relevant' : undefined; handlePageSearch({ namespaceClass }); }} tabBarExtraContent={ @@ -287,6 +288,7 @@ const SpaceManage: React.FC = () => { pageSize={pageData.pageSize} current={pageData.page} total={pageData.total} + pageSizeOptions={[12, 20, 50, 100]} onChange={(page, pageSize) => { handlePageSearch({ page, pageSize }); }} diff --git a/chaosmeta-platform-frontend/src/pages/GlobalSetting/Space/style.ts b/chaosmeta-platform-frontend/src/pages/GlobalSetting/Space/style.ts index 5182602..be94cc7 100644 --- a/chaosmeta-platform-frontend/src/pages/GlobalSetting/Space/style.ts +++ b/chaosmeta-platform-frontend/src/pages/GlobalSetting/Space/style.ts @@ -22,9 +22,8 @@ export const Container = styled.div` `; export const SpaceCard = styled.div<{ $permission: number }>` - /* height: 175px; */ background-color: ${(props) => { - if (props?.$permission === 1) { + if (props?.$permission !== -1) { return '#fff'; } return 'rgba(0,0,0,0.05)'; @@ -66,12 +65,14 @@ export const SpaceCard = styled.div<{ $permission: number }>` color: rgba(0, 0, 0, 0.45); } span { + flex: 1; color: rgba(0, 0, 0, 0.65); position: relative; overflow: hidden; text-overflow: ellipsis; word-break: keep-all; - display: -webkit-box; + /* display: -webkit-box; */ + display: inline-block; -webkit-box-orient: vertical; -webkit-line-clamp: 2; } diff --git a/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/ArrangeContent.tsx b/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/ArrangeContent.tsx index 943bbca..c9f0fbe 100644 --- a/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/ArrangeContent.tsx +++ b/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/ArrangeContent.tsx @@ -381,7 +381,7 @@ const ArrangeContent: React.FC = (props) => { ...activeItem, // 暂时将uuid设置为当前节点的id用于拖拽,拖拽结束后这里的uuid需要重新生成,避免拖拽绑定重复id uuid: active.id, - duration: '30s', + duration: '60s', dragtype: 'item', exec_id: activeItem?.id, name: activeItem?.nameCn, @@ -397,7 +397,7 @@ const ArrangeContent: React.FC = (props) => { ...activeItem, uuid: active.id, // 拖入时长默认15m - duration: '30s', + duration: '60s', dragtype: 'item', // 将节点库id保存 exec_id: activeItem?.id, diff --git a/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/components/Arrange.tsx b/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/components/Arrange.tsx index 4dfd4c1..3b80392 100644 --- a/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/components/Arrange.tsx +++ b/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/components/Arrange.tsx @@ -222,12 +222,12 @@ const Arrange: React.FC = (props) => { type: 'fault', }, { - name: '度量节点', + name: '度量引擎', type: 'measure', }, { - name: '压测节点', - type: 'pressure', + name: '流量注入', + type: 'flow', }, { name: '其他节点', diff --git a/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/components/InfoDrawer.tsx b/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/components/InfoDrawer.tsx index 2bb3f2f..a9963d6 100644 --- a/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/components/InfoDrawer.tsx +++ b/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/components/InfoDrawer.tsx @@ -1,6 +1,7 @@ import ShowText from '@/components/ShowText'; import { triggerTypes } from '@/constants'; import { formatTime } from '@/utils/format'; +import { renderScheduleType, renderTags } from '@/utils/renderItem'; import { history } from '@umijs/max'; import { Button, DatePicker, Drawer, Form, Input, Radio, Space } from 'antd'; import moment from 'moment'; @@ -39,15 +40,11 @@ const InfoDrawer: React.FC = (props) => { - - - - - - - + + {renderTags(baseInfo?.labels)} + {renderScheduleType(baseInfo)}
); }; @@ -131,6 +128,7 @@ const InfoDrawer: React.FC = (props) => { name={'schedule_type'} label="触发方式" rules={[{ required: true, message: '请选择' }]} + initialValue={'manual'} > {triggerTypes?.map((item) => { diff --git a/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/components/NodeConfig.tsx b/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/components/NodeConfig.tsx index 144cc28..e07be3a 100644 --- a/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/components/NodeConfig.tsx +++ b/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/components/NodeConfig.tsx @@ -50,6 +50,7 @@ const NodeConfig: React.FC = (props) => { const [editTitleState, setEditTitleState] = useState(false); const [fieldList, setFieldList] = useState([]); const [durationType, setDurationType] = useState('second'); + const [kubernetesNamespace, setKubernetesNamespace] = useState(''); /** * 更新节点属性的方法 @@ -143,6 +144,7 @@ const NodeConfig: React.FC = (props) => { const target_name = activeCol?.exec_range?.target_name ? activeCol?.exec_range?.target_name?.split(',') : undefined; + setKubernetesNamespace(activeCol?.exec_range?.target_namespace); form.setFieldsValue({ ...activeCol, duration: initSecond, @@ -194,6 +196,7 @@ const NodeConfig: React.FC = (props) => { const target_name = activeCol?.exec_range?.target_name ? activeCol?.exec_range?.target_name?.split(',') : undefined; + setKubernetesNamespace(activeCol?.exec_range?.target_namespace); form.setFieldsValue({ ...activeCol, duration: initSecond, @@ -319,7 +322,11 @@ const NodeConfig: React.FC = (props) => { name={['exec_range', 'target_namespace']} rules={[{ required: true, message: '请输入' }]} > - + { + setKubernetesNamespace(val); + }} + /> = (props) => { */} - - - - + - + + + + + )} + {/* - + */} )}
diff --git a/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/components/NodeLibrary.tsx b/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/components/NodeLibrary.tsx index 8cfce3b..7e1e311 100644 --- a/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/components/NodeLibrary.tsx +++ b/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/components/NodeLibrary.tsx @@ -158,13 +158,6 @@ const NodeLibrary: React.FC = (props) => { }; const newFaults = faults?.map((item: any) => { return { ...item, key: `${key}-${item.id}`, ...params }; - // item = { ...item, key: `${key}-${item.id}`, ...params }; - // item.key = `${key}-${item.id}`; - // item.isLeaf = true; - // item.scope_id = scopeId; - // item.target_id = id; - // item.exec_type = 'fault'; - // item.exec_type_name = '故障节点'; }); setTreeData((origin) => { return updateTreeData(origin, key, newFaults); diff --git a/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/index.tsx b/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/index.tsx index 8545abd..49c712e 100644 --- a/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/index.tsx +++ b/chaosmeta-platform-frontend/src/pages/Space/AddExperiment/index.tsx @@ -1,19 +1,20 @@ import ShowText from '@/components/ShowText'; import { createExperiment, + deleteExperiment, queryExperimentDetail, updateExperiment, } from '@/services/chaosmeta/ExperimentController'; -import { getSpaceUserList } from '@/services/chaosmeta/UserController'; +import { querySpaceUserPermission } from '@/services/chaosmeta/SpaceController'; import { arrangeDataOriginTranstion, arrangeDataResultTranstion, } from '@/utils/format'; -import { renderScheduleType } from '@/utils/renderItem'; -import { EditOutlined } from '@ant-design/icons'; +import { renderScheduleType, renderTags } from '@/utils/renderItem'; +import { EditOutlined, ExclamationCircleFilled } from '@ant-design/icons'; import { PageContainer } from '@ant-design/pro-components'; import { history, useModel, useRequest } from '@umijs/max'; -import { Button, Form, Space, Spin, message } from 'antd'; +import { Button, Form, Modal, Space, Spin, message } from 'antd'; import { useEffect, useState } from 'react'; import ArrangeContent from './ArrangeContent'; import InfoDrawer from './components/InfoDrawer'; @@ -22,7 +23,7 @@ import { Container } from './style'; const AddExperiment = () => { const [form] = Form.useForm(); // 用户权限 - const { userInfo, setSpacePermission, spacePermission } = useModel('global'); + const { setSpacePermission, spacePermission } = useModel('global'); // 编排的数据 const [arrangeList, setArrangeList] = useState([]); // 编辑基本信息抽屉 @@ -85,17 +86,13 @@ const AddExperiment = () => { /** * 根据成员名称和空间id获取成员空间内权限信息 */ - const getUserSpaceAuth = useRequest(getSpaceUserList, { + const getUserSpaceAuth = useRequest(querySpaceUserPermission, { manual: true, formatResult: (res) => res, onSuccess: (res) => { if (res.code === 200) { // 存储用户空间权限 - const curUserName = userInfo?.name || localStorage.getItem('userName'); - const curUserInfo = res?.data?.users?.filter( - (item: { name: string }) => item.name === curUserName, - )[0]; - setSpacePermission(curUserInfo?.permission); + setSpacePermission(res?.data); } }, }); @@ -128,9 +125,7 @@ const AddExperiment = () => { )} - - - + {renderTags(baseInfo?.labels)} ); }; @@ -141,7 +136,7 @@ const AddExperiment = () => { const handleSubmit = () => { form.validateFields().then((values) => { const arrangeResult = arrangeDataResultTranstion(arrangeList); - if (!values?.name || !values?.schedule_type) { + if (!baseInfo?.name || !baseInfo?.schedule_type) { message.info('请完善基本信息'); return; } @@ -152,7 +147,9 @@ const AddExperiment = () => { message.info('请完善节点信息'); return; } - const newLabels = values?.labels?.map((item: { id: number }) => item?.id); + const newLabels = baseInfo?.labels?.map( + (item: { id: number }) => item?.id, + ); const newList = arrangeResult?.map((item) => { const { args_value, @@ -167,10 +164,16 @@ const AddExperiment = () => { exec_type, name, } = item; + // return; + let target_name = exec_range?.target_name; + if (Array.isArray(target_name)) { + target_name = exec_range?.target_name?.join(','); + } const newExecRange = { ...exec_range, - target_name: exec_range?.target_name?.join(',') || undefined, + target_name: target_name || undefined, }; + return { name, args_value, @@ -193,7 +196,6 @@ const AddExperiment = () => { workflow_nodes: newList, }; const experimentId = history?.location?.query?.experimentId; - // return; if (experimentId) { editExperiment?.run({ ...params, uuid: experimentId }); } else { @@ -202,6 +204,37 @@ const AddExperiment = () => { }); }; + /** + * 删除实验接口 + */ + const handleDeleteExperiment = useRequest(deleteExperiment, { + manual: true, + formatResult: (res) => res, + onSuccess: (res) => { + if (res?.code === 200) { + message.success('删除成功!'); + history.push('/space/experiment'); + } + }, + }); + + /** + * 确认删除实验 + */ + const handleDeleteConfirm = () => { + const uuid = history?.location?.query?.experimentId as string; + if (uuid) { + Modal.confirm({ + title: '确认要删除这个实验吗?', + icon: , + content: '删除实验将会删除该实验的配置,但不会删除历史实验结果!', + onOk() { + handleDeleteExperiment?.run({ uuid }); + }, + }); + } + }; + const headerExtra = () => { return (
@@ -214,21 +247,29 @@ const AddExperiment = () => {
- - - - + {spacePermission === 1 && ( + + + + + )}
); @@ -249,7 +290,6 @@ const AddExperiment = () => { if (spaceId) { getUserSpaceAuth?.run({ id: spaceId as string, - name: userInfo?.name || localStorage.getItem('userName'), }); } if (experimentId) { diff --git a/chaosmeta-platform-frontend/src/pages/Space/Experiment/ExperimentList.tsx b/chaosmeta-platform-frontend/src/pages/Space/Experiment/ExperimentList.tsx index e0ef59f..fbb344a 100644 --- a/chaosmeta-platform-frontend/src/pages/Space/Experiment/ExperimentList.tsx +++ b/chaosmeta-platform-frontend/src/pages/Space/Experiment/ExperimentList.tsx @@ -264,7 +264,7 @@ const ExperimentList: React.FC = () => { title: '实验次数', width: 120, dataIndex: 'number', - sorter: true, + // sorter: true, render: (text: number, record: { uuid: string }) => { if (text > 0) { return ( @@ -316,7 +316,7 @@ const ExperimentList: React.FC = () => { {' '} {/* 这里展示时间 -- 后端没有相应字段 --todo */} - -- + {formatTime(record?.last_instance)} ); @@ -481,23 +481,44 @@ const ExperimentList: React.FC = () => { locale={{ emptyText: ( - + {spacePermission === 1 ? ( + + ) : ( + + )} {/* + {/* */} {resultDetail?.status === 'Running' && ( - ) - } + // action={ + // (resultDetail?.status === 'error' || + // resultDetail?.status === 'Failed') && ( + // + // ) + // } showIcon /> )} diff --git a/chaosmeta-platform-frontend/src/pages/Space/SpaceSetting/BasicInfo.tsx b/chaosmeta-platform-frontend/src/pages/Space/SpaceSetting/BasicInfo.tsx index db32e4c..1fe077e 100644 --- a/chaosmeta-platform-frontend/src/pages/Space/SpaceSetting/BasicInfo.tsx +++ b/chaosmeta-platform-frontend/src/pages/Space/SpaceSetting/BasicInfo.tsx @@ -10,9 +10,7 @@ import { Button, Form, Input, Space, Spin } from 'antd'; import React, { useEffect, useState } from 'react'; import { BasicInfoContainer } from './style'; -interface IProps {} - -const BasicInfo: React.FC = () => { +const BasicInfo: React.FC = () => { const [form] = Form.useForm(); const [saveDisabled, setSaveDisabled] = useState(true); const [spaceInfo, setSpaceInfo] = useState({}); @@ -26,7 +24,9 @@ const BasicInfo: React.FC = () => { manual: true, formatResult: (res) => res, onSuccess: (res) => { - setSaveDisabled(true); + if (res?.code === 200) { + setSaveDisabled(true); + } }, }); diff --git a/chaosmeta-platform-frontend/src/pages/Space/SpaceSetting/TagManage/index.tsx b/chaosmeta-platform-frontend/src/pages/Space/SpaceSetting/TagManage/index.tsx index 6f198e5..906f2ad 100644 --- a/chaosmeta-platform-frontend/src/pages/Space/SpaceSetting/TagManage/index.tsx +++ b/chaosmeta-platform-frontend/src/pages/Space/SpaceSetting/TagManage/index.tsx @@ -168,7 +168,8 @@ const TagManage: React.FC = () => { useEffect(() => { handlePageSearch(); - }, []); + }, [spaceIdChange]); + return (
@@ -277,7 +278,7 @@ const TagManage: React.FC = () => { { - if (spacePermission === 0) { + if (spacePermission === 1) { return ( ( - `/chaosmeta/api/v1/kubernetes/cluster/${envType}/namespace/chaosmeta/pods`, + `/chaosmeta/api/v1/kubernetes/cluster/${envType}/namespace/${params?.namespace}/pods`, { method: 'GET', params, diff --git a/chaosmeta-platform-frontend/src/services/chaosmeta/SpaceController.ts b/chaosmeta-platform-frontend/src/services/chaosmeta/SpaceController.ts index d0e0832..c317ded 100644 --- a/chaosmeta-platform-frontend/src/services/chaosmeta/SpaceController.ts +++ b/chaosmeta-platform-frontend/src/services/chaosmeta/SpaceController.ts @@ -172,6 +172,25 @@ export async function querySpaceUserList( }); } +/** + * 获取空间内成员权限 + * @param params + * @param options + * @returns + */ +export async function querySpaceUserPermission( + params: { + id: number | string; // 空间id + }, + options?: { [key: string]: any }, +) { + return request(`/chaosmeta/api/v1/namespaces/${params.id}/permission`, { + method: 'GET', + params, + ...(options || {}), + }); +} + /** * 空间下批量添加成员 * @param body