();
- const [searchParams, setSearchParams] = useState<{ name: string }>();
- const content = (
-
- {
- setSearchParams({ name: value });
- actionRef.current?.reload();
- }}
- />
-
- );
+ const [searchParams, setSearchParams] = useState>();
+ const [loading, setLoading] = useState(false);
+ const [items, setItems] = useState<{ key: string; label: React.JSX.Element }[]>([]);
+
const initSso = (idpInitUrl: string) => {
const div = window.document.createElement('div');
div.innerHTML =
@@ -64,42 +74,40 @@ const CardList = () => {
document.body.removeChild(div);
};
- const renderBadge = (count: number, active = false) => {
- return (
-
- );
- };
+ useAsyncEffect(async () => {
+ setLoading(true);
+ const { result, success } = await getAppGroupList().finally(() => {
+ setLoading(false);
+ });
+ if (success && result) {
+ let data: { key: string; label: React.JSX.Element }[] = [];
+ result.forEach((item) => {
+ data.push({
+ key: item.id,
+ label: (
+
+ {item.name}
+ {renderBadge(item.appCount, currentGroup === item.id)}
+
+ ),
+ });
+ });
+ setItems(data);
+ // 如果有分组,取第一个分组
+ if (data.length > 0) {
+ setSearchParams({ groupId: data[0].key });
+ actionRef.current?.reload();
+ }
+ // 手动请求
+ else {
+ actionRef.current?.reload();
+ }
+ }
+ }, []);
return (
-
-
-
+
rowKey="id"
split
@@ -111,32 +119,34 @@ const CardList = () => {
xl: 4,
xxl: 5,
}}
- request={queryAppList}
- pagination={{}}
- toolbar={{
- menu: {
- type: 'tab',
- activeKey,
- items: [
- {
- key: 'tab1',
- label: 开发分组{renderBadge(99, activeKey === 'tab1')},
- },
- {
- key: 'tab2',
- label: 运维分组{renderBadge(32, activeKey === 'tab2')},
- },
- ],
- onChange(key) {
- setActiveKey(key);
- },
- },
+ loading={loading}
+ onLoadingChange={(loading) => {
+ setLoading(loading);
}}
+ manualRequest
+ request={queryAppList}
+ toolbar={
+ items.length > 0
+ ? {
+ menu: {
+ type: 'tab',
+ activeKey: currentGroup,
+ items: items,
+ onChange(key) {
+ if (key) {
+ setCurrentGroup(key);
+ setSearchParams((values) => {
+ return { ...values, groupId: key };
+ });
+ actionRef.current?.reload();
+ }
+ },
+ },
+ }
+ : {}
+ }
params={searchParams}
actionRef={actionRef}
- tableExtraRender={() => {
- return {content};
- }}
renderItem={(item: AppList) => {
return (
item &&
@@ -147,8 +157,11 @@ const CardList = () => {
hoverable
bordered={false}
onClick={async () => {
- if (item.initLoginType === InitLoginType.PORTAL_OR_APP_INIT_SSO) {
- initSso(item.initLoginUrl);
+ if (
+ item.initLoginType === InitLoginType.portal_or_app_init_sso &&
+ item?.initLoginUrl
+ ) {
+ initSso(item?.initLoginUrl);
return;
}
message.warning(
@@ -175,6 +188,33 @@ const CardList = () => {
)
);
}}
+ tableExtraRender={() => {
+ return (
+
+ {
+ setSearchParams({ ...searchParams, ...values });
+ actionRef.current?.reload();
+ return Promise.resolve();
+ }}
+ onReset={() => {
+ if (items.length > 0) {
+ setSearchParams({ groupId: currentGroup });
+ } else {
+ setSearchParams({});
+ }
+ actionRef.current?.reload();
+ }}
+ >
+
+
+
+ );
+ }}
/>
diff --git a/eiam-portal/src/main/portal-fe/src/pages/Application/data.d.ts b/eiam-portal/src/main/portal-fe/src/pages/Application/data.d.ts
index ad21d5f4..2100eaeb 100644
--- a/eiam-portal/src/main/portal-fe/src/pages/Application/data.d.ts
+++ b/eiam-portal/src/main/portal-fe/src/pages/Application/data.d.ts
@@ -22,8 +22,8 @@ export type AppList = {
template: string;
icon?: string;
name: string;
- initLoginType: InitLoginType;
- initLoginUrl: string;
+ initLoginType: InitLoginType | string;
+ initLoginUrl?: string;
description: string;
};
diff --git a/eiam-portal/src/main/portal-fe/src/pages/Application/locales/zh-CN.ts b/eiam-portal/src/main/portal-fe/src/pages/Application/locales/zh-CN.ts
index 8a3f5ad1..94f0bf6e 100644
--- a/eiam-portal/src/main/portal-fe/src/pages/Application/locales/zh-CN.ts
+++ b/eiam-portal/src/main/portal-fe/src/pages/Application/locales/zh-CN.ts
@@ -16,8 +16,8 @@
* along with this program. If not, see .
*/
export default {
- 'pages.application.search': '请输入',
- 'pages.application.search.enter_button': '搜索',
- 'pages.application.alert': '请点击下方的应用进行单点登录。若希望修改应用内容,请联系管理员。',
+ 'pages.application.search.name': '应用名称',
+ 'pages.application.tab.list': '应用列表',
+ 'pages.application.tab.account': '应用账号',
'pages.application.init.warning': '仅允许应用发起',
};
diff --git a/eiam-portal/src/main/portal-fe/src/pages/Application/style.ts b/eiam-portal/src/main/portal-fe/src/pages/Application/style.ts
index cfc8131c..917f46fb 100644
--- a/eiam-portal/src/main/portal-fe/src/pages/Application/style.ts
+++ b/eiam-portal/src/main/portal-fe/src/pages/Application/style.ts
@@ -24,7 +24,6 @@ const useStyles = createStyles(({ token, css, prefixCls }, prop) => {
border: none;
border-radius: ${token.borderRadius};
.${prefixCls}-pro-table-list-toolbar-container {
- margin-bottom: 10px;
}
&-item-card {