-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Experiment and Overview Page Improvement
- Loading branch information
hlt01362665
committed
Aug 29, 2023
1 parent
f2b61f0
commit 994d4e5
Showing
25 changed files
with
643 additions
and
269 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
chaosmeta-platform-frontend/src/components/Select/KubernetesNamespaceSelect/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { queryNamespaceList } from '@/services/chaosmeta/KubernetesController'; | ||
import { useRequest } from '@umijs/max'; | ||
import { Select, Spin, message } from 'antd'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
interface IProps { | ||
value?: string; | ||
onChange?: (value?: string) => void; | ||
/**回显时可传入list */ | ||
list?: any[]; | ||
mode?: 'multiple' | 'tags'; | ||
placeholder?: string; | ||
style?: any; | ||
} | ||
|
||
const KubernetesNamespaceSelect = (props: IProps) => { | ||
const { value, onChange, list, mode, placeholder = '请选择', style } = props; | ||
const [namespaceList, setNamespaceList] = useState<string[]>([]); | ||
const { Option } = Select; | ||
|
||
useEffect(() => { | ||
if (list && list?.length > 0) { | ||
setNamespaceList(list); | ||
} | ||
}, [list]); | ||
|
||
const getUser = useRequest(queryNamespaceList, { | ||
manual: true, | ||
formatResult: (res: any) => res, | ||
debounceInterval: 300, | ||
onSuccess: (res) => { | ||
if (res?.success) { | ||
setNamespaceList(res?.data?.list || []); | ||
} else { | ||
message.error(res?.message); | ||
} | ||
}, | ||
}); | ||
|
||
// 输入有值时进行搜索 | ||
// const handleUserSearch = (val: string) => { | ||
// if (val) { | ||
// getUser?.run({ identifier: val }); | ||
// } | ||
// }; | ||
|
||
useEffect(() => { | ||
getUser?.run({ page: 1, page_size: 500 }); | ||
}, []); | ||
|
||
return ( | ||
<Select | ||
mode={mode} | ||
value={value} | ||
showSearch | ||
// onSearch={(val) => handleUserSearch(val)} | ||
allowClear | ||
notFoundContent={getUser?.loading ? <Spin size="small" /> : null} | ||
filterOption={false} | ||
onChange={onChange} | ||
placeholder={placeholder} | ||
style={style} | ||
> | ||
{namespaceList?.map((item: any) => { | ||
return ( | ||
<Option value={item?.metadata?.name} key={item?.metadata?.name}> | ||
{item?.metadata?.name} | ||
</Option> | ||
); | ||
})} | ||
</Select> | ||
); | ||
}; | ||
|
||
export default KubernetesNamespaceSelect; |
75 changes: 75 additions & 0 deletions
75
chaosmeta-platform-frontend/src/components/Select/KubernetesPodSelect/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { queryNamespaceList, queryPodLIst } from '@/services/chaosmeta/KubernetesController'; | ||
import { useRequest } from '@umijs/max'; | ||
import { Select, Spin, message } from 'antd'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
interface IProps { | ||
value?: string; | ||
onChange?: (value?: string) => void; | ||
/**回显时可传入list */ | ||
list?: any[]; | ||
mode?: 'multiple' | 'tags'; | ||
placeholder?: string; | ||
style?: any; | ||
} | ||
|
||
const KubernetesPodSelect = (props: IProps) => { | ||
const { value, onChange, list, mode, placeholder = '请选择', style } = props; | ||
const [namespaceList, setNamespaceList] = useState<string[]>([]); | ||
const { Option } = Select; | ||
|
||
useEffect(() => { | ||
if (list && list?.length > 0) { | ||
setNamespaceList(list); | ||
} | ||
}, [list]); | ||
|
||
const getUser = useRequest(queryPodLIst, { | ||
manual: true, | ||
formatResult: (res: any) => res, | ||
debounceInterval: 300, | ||
onSuccess: (res) => { | ||
if (res?.success) { | ||
setNamespaceList(res?.data?.list || []); | ||
} else { | ||
message.error(res?.message); | ||
} | ||
}, | ||
}); | ||
|
||
// 输入有值时进行搜索 | ||
// const handleUserSearch = (val: string) => { | ||
// if (val) { | ||
// getUser?.run({ identifier: val }); | ||
// } | ||
// }; | ||
|
||
useEffect(() => { | ||
getUser?.run({ page: 1, page_size: 500 }); | ||
}, []); | ||
|
||
return ( | ||
<Select | ||
mode={mode} | ||
value={value} | ||
showSearch | ||
// onSearch={(val) => handleUserSearch(val)} | ||
allowClear | ||
notFoundContent={getUser?.loading ? <Spin size="small" /> : null} | ||
filterOption={false} | ||
onChange={onChange} | ||
placeholder={placeholder} | ||
style={style} | ||
> | ||
{namespaceList?.map((item: any) => { | ||
return ( | ||
<Option value={item?.metadata?.name} key={item?.metadata?.name}> | ||
{item?.metadata?.name} | ||
</Option> | ||
); | ||
})} | ||
</Select> | ||
); | ||
}; | ||
|
||
export default KubernetesPodSelect; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.