Skip to content

Commit ca317ea

Browse files
add many pages playground frontend
Co-authored-by: tc-imba <[email protected]> Co-authored-by: Reapor-Yurnero <[email protected]>
1 parent 92af799 commit ca317ea

File tree

17 files changed

+1139
-242
lines changed

17 files changed

+1139
-242
lines changed

apps/genie-brickified/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"scripts": {
2525
"start": "cross-env HOST=0.0.0.0 HTTPS=false PORT=11003 react-scripts start",
26-
"build": "react-scripts build",
26+
"build": "cross-env NODE_OPTIONS=--openssl-legacy-provider react-scripts build",
2727
"test": "react-scripts test",
2828
"eject": "react-scripts eject"
2929
},

projects/sbos-frontend/config/routes.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ export default [
3434
icon: 'smile',
3535
// component: './Domain/DomainList',
3636
routes: [
37+
{
38+
path: '/domain/:domainName',
39+
redirect: '/domain/:domainName/dashboard',
40+
},
3741
{
3842
name: 'dashboard',
3943
path: '/domain/:domainName/dashboard',
@@ -63,17 +67,23 @@ export default [
6367
access: 'isDomainAdmin',
6468
},
6569
{
66-
name: 'apps',
70+
name: 'resources',
6771
path: '/domain/:domainName/resources',
6872
component: './Domain/ResourceList',
6973
access: 'isDomainAdmin',
7074
},
7175
{
72-
name: 'apps',
76+
name: 'policies',
7377
path: '/domain/:domainName/policies',
7478
component: './Domain/PolicyList',
7579
access: 'isDomainAdmin',
7680
},
81+
{
82+
name: 'profiles',
83+
path: '/domain/:domainName/profiles',
84+
component: './Domain/ProfileList',
85+
access: 'isDomainAdmin',
86+
},
7787
{
7888
name: 'app',
7989
path: '/domain/:domainName/app/:appName',
@@ -82,6 +92,27 @@ export default [
8292
},
8393
],
8494
},
95+
{
96+
name: 'developer',
97+
routes: [
98+
{
99+
name: 'apps',
100+
path: '/developer/apps',
101+
component: './Developer/AppList',
102+
},
103+
]
104+
},
105+
{
106+
name: 'admin',
107+
routes: [
108+
{
109+
name: 'apps',
110+
path: '/admin/apps',
111+
component: './Admin/AppList',
112+
access: 'isSiteAdmin',
113+
},
114+
]
115+
},
85116
{
86117
path: '/admin',
87118
name: 'admin',

projects/sbos-frontend/src/app.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { AvatarDropdown, AvatarName, Footer, Question, SelectLang } from '@/comp
22
import { useDomainName } from '@/hooks';
33
import { listDomainsBrickapiV1DomainsGet } from '@/services/brick-server-playground/domains';
44
import { usersCurrentUserBrickapiV1UsersMeGet as queryCurrentUser } from '@/services/brick-server-playground/users';
5-
import { LinkOutlined, SmileOutlined } from '@ant-design/icons';
5+
import {CodeOutlined, LinkOutlined, SmileOutlined, BuildOutlined, ThunderboltOutlined } from '@ant-design/icons';
66
import type { Settings as LayoutSettings, MenuDataItem } from '@ant-design/pro-components';
77
import { SettingDrawer } from '@ant-design/pro-components';
88
import type { RunTimeLayoutConfig } from '@umijs/max';
@@ -22,8 +22,10 @@ hljsDefineTurtle(hljs);
2222
hljsDefineSparql(hljs);
2323

2424
import json from 'highlight.js/lib/languages/json';
25+
import plaintext from 'highlight.js/lib/languages/plaintext';
2526

2627
hljs.registerLanguage('json', json);
28+
hljs.registerLanguage('plaintext', plaintext);
2729

2830
const isDev = process.env.NODE_ENV === 'development';
2931
const loginPath = '/user/login';
@@ -168,15 +170,39 @@ const Layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => {
168170
path: `/domain/${domainName}/policies`,
169171
name: 'policies',
170172
},
173+
{
174+
path: `/domain/${domainName}/profiles`,
175+
name: 'profiles',
176+
},
171177
]);
172178
}
173179
menu.push({
174180
path: `/domain/${domainName}`,
175181
name: 'domain',
176182
children: children,
183+
icon: <BuildOutlined />,
177184
});
178185
}
179-
186+
menu.push({
187+
name: 'developer',
188+
children: [
189+
{
190+
path: '/developer/apps',
191+
name: 'apps'
192+
}
193+
],
194+
icon: <CodeOutlined />,
195+
});
196+
menu.push({
197+
name: 'admin',
198+
children: [
199+
{
200+
path: '/admin/apps',
201+
name: 'apps'
202+
}
203+
],
204+
icon: <ThunderboltOutlined />,
205+
});
180206
return menu;
181207
},
182208
},

projects/sbos-frontend/src/locales/en-US/menu.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ export default {
88
'menu.domain.apps': 'App Management',
99
'menu.domain.resources': 'Resource Management',
1010
'menu.domain.policies': 'Policy Management',
11+
'menu.domain.profiles': 'Profile Management',
12+
'menu.developer': "Developer",
13+
'menu.developer.apps': "App List",
14+
'menu.admin': "Site Admin",
15+
'menu.admin.apps': "App Management",
1116
'menu.welcome': 'Welcome',
1217
'menu.more-blocks': 'More Blocks',
1318
'menu.home': 'Home',
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import {
2+
appsListBrickapiV1AppsGet,
3+
appsApproveBrickapiV1AppsAppApprovePost,
4+
appsBuildBrickapiV1AppsAppBuildPost,
5+
} from '@/services/brick-server-playground/apps';
6+
import {useRequest} from '@@/exports';
7+
import {ModalForm, PageContainer, ProFormInstance} from '@ant-design/pro-components';
8+
import {Button, Card, Col, Flex, message, Row, Typography} from 'antd';
9+
import React, {useRef, useState} from 'react';
10+
import hljs from 'highlight.js/lib/core';
11+
12+
const AppList: React.FC = () => {
13+
14+
const {data: apps, refresh: reloadApps} = useRequest(
15+
async () => {
16+
return await appsListBrickapiV1AppsGet({all_apps: true});
17+
},
18+
{
19+
// manual: true,
20+
onSuccess: (data: API.AppReadResp) => {
21+
console.log(data);
22+
},
23+
},
24+
);
25+
26+
const formRef = useRef<ProFormInstance>();
27+
const [isBuildLogOpen, setIsBuildLogOpen] = useState<boolean>(false);
28+
const [buildLog, setBuildLog] = useState<string>("");
29+
30+
const onCloseBuildLog = async () => {
31+
setIsBuildLogOpen(false);
32+
}
33+
34+
const AppCard = (app: API.AppRead) => {
35+
const handleApproveApp = async () => {
36+
const result = await appsApproveBrickapiV1AppsAppApprovePost({
37+
app: app.id,
38+
});
39+
console.log(result);
40+
if (result.errorCode !== "Success") {
41+
message.error(result.errorCode);
42+
}
43+
44+
reloadApps();
45+
};
46+
47+
const handleBuildApp = async () => {
48+
const result = await appsBuildBrickapiV1AppsAppBuildPost({
49+
app: app.id,
50+
});
51+
console.log(result);
52+
if (result.errorCode === "Success") {
53+
setBuildLog(result?.data?.stderr || "");
54+
setIsBuildLogOpen(true);
55+
} else {
56+
message.error("Build failed!")
57+
}
58+
};
59+
60+
61+
return (
62+
<Col xxl={6} xl={8} lg={8} md={8} sm={12} xs={24} key={app.id}>
63+
<Card title={app.name} bordered={false}>
64+
<Typography.Paragraph>{app.description}</Typography.Paragraph>
65+
<Flex gap="middle" wrap>
66+
{app.approved ? (
67+
<Button disabled>Approved</Button>
68+
) : (
69+
<Button type="primary" onClick={handleApproveApp}>
70+
Approve
71+
</Button>
72+
)}
73+
<Button type="primary" onClick={handleBuildApp}>
74+
Build
75+
</Button>
76+
</Flex>
77+
</Card>
78+
</Col>
79+
);
80+
};
81+
82+
return (
83+
<PageContainer>
84+
<Row gutter={16}>{apps?.results.map((app: API.AppRead) => AppCard(app))}</Row>
85+
<ModalForm
86+
formRef={formRef}
87+
title="Build Log"
88+
open={isBuildLogOpen}
89+
onFinish={onCloseBuildLog}
90+
modalProps={{
91+
destroyOnClose: true,
92+
onCancel: onCloseBuildLog,
93+
// cancelButtonProps: { hidden: true },
94+
}}
95+
96+
>
97+
<pre>
98+
<code
99+
className="hljs"
100+
dangerouslySetInnerHTML={{
101+
__html: hljs.highlight('plaintext', buildLog).value,
102+
}}
103+
/>
104+
</pre>
105+
</ModalForm>
106+
</PageContainer>
107+
);
108+
};
109+
110+
export default AppList;

0 commit comments

Comments
 (0)