Skip to content

Commit 888f615

Browse files
committed
AppDetail
1 parent 1af9df3 commit 888f615

File tree

2 files changed

+38
-67
lines changed

2 files changed

+38
-67
lines changed

opensergo-dashboard-ui/src/App.tsx

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import React from 'react';
22
import './App.css';
3-
import {IRoutableItemDescriptor} from "@alicloud/console-components-console-menu";
3+
import { IRoutableItemDescriptor } from "@alicloud/console-components-console-menu";
44
import RoutableMenu from "@alicloud/console-components-console-menu/lib/RoutableMenu";
55
import AppLayout from "@alicloud/console-components-app-layout";
66

77

88
import "@alicloud/console-components/dist/wind.css";
9-
import {Redirect, Route, Switch} from "dva/router";
9+
import { Redirect, Route, Switch } from "dva/router";
1010
import AppList from "./AppList";
1111
import AppDetail from "./page/AppDetail";
1212

1313

1414
const items: IRoutableItemDescriptor[] = [
1515
// {key: '/home', to: '/', label: '概览'},
16-
{key: '/application', to: '/application', label: '应用列表'},
16+
{ key: '/application', to: '/application', label: '应用列表' },
1717
];
1818

1919
const Nav = () => (
@@ -25,26 +25,21 @@ const Nav = () => (
2525

2626
function App() {
2727
return (
28-
<Switch>
29-
<Route path="/application/:appName">
30-
<AppDetail />
31-
</Route>
32-
<Route path="/">
33-
<AppLayout
34-
nav={<Nav/>}
35-
>
36-
<Switch>
37-
<Route path="/application">
38-
<AppList/>
39-
</Route>
40-
<Route path="/">
41-
<Redirect to={'/application'}/>
42-
</Route>
43-
</Switch>
44-
</AppLayout>
45-
46-
</Route>
47-
</Switch>
28+
<AppLayout
29+
nav={<Nav />}
30+
>
31+
<Switch>
32+
<Route path="/application/:appName">
33+
<AppDetail />
34+
</Route>
35+
<Route path="/application">
36+
<AppList />
37+
</Route>
38+
<Route path="/">
39+
<Redirect to={'/application'} />
40+
</Route>
41+
</Switch>
42+
</AppLayout>
4843
);
4944
}
5045

opensergo-dashboard-ui/src/page/AppDetail.tsx

Lines changed: 20 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,50 @@
1-
import React, {useEffect, useState} from "react";
1+
import React, { useEffect, useState } from "react";
22
import axios from "axios";
3+
import { useParams } from 'dva/router'
4+
35
import Page from "@alicloud/console-components-page";
46
import Table from "@alicloud/console-components-table";
5-
import {Badge, Button} from "@alicloud/console-components";
6-
import {LinkButton} from "@alicloud/console-components-actions";
7+
import { Badge, Button } from "@alicloud/console-components";
8+
import { LinkButton } from "@alicloud/console-components-actions";
9+
710

811
const AppDetail: React.FC<{}> = () => {
9-
const [appList, setAppList] = useState([]);
12+
console.log("useParams", useParams);
13+
const params = useParams();
14+
console.log("params", params);
15+
16+
const [appItem, setAppItem] = useState("");
1017
useEffect(() => {
1118
fetchAppList();
1219
}, []);
1320
// 这个是分页接口,但是需要拿到全部数据
1421
const fetchAppList = async () => {
15-
const data = await axios.get('/api/application/getApplicationList')
22+
const data = await axios.get('/api/application/describeApplication', { params: { appName: 'example-spring-cloud' } })
1623
.then(function (response) {
17-
return response?.data?.data;
24+
return response?.data;
1825
});
19-
setAppList(data);
26+
setAppItem(data.appName);
2027
};
2128

2229
return (
2330
<Page>
24-
<Page.Header title="应用列表"/>
31+
<Page.Header title="应用详情" />
2532
<Page.Content>
26-
<Table
27-
exact
28-
fixedBarExpandWidth={[24]}
29-
affixActionBar
30-
dataSource={appList}
31-
primaryKey="appName"
32-
search={{
33-
filter: [
34-
{
35-
value: 'AppName',
36-
label: '应用名称',
37-
},
38-
],
39-
defaultValue: 'AppName',
40-
}}
41-
pagination={{
42-
current: 1,
43-
total: 80,
44-
pageSize: 20,
45-
}}
46-
selection={({selectedRowKeys}: any) => (
47-
<>
48-
<Badge count={selectedRowKeys.length}>
49-
<Button disabled={selectedRowKeys.length === 0}>
50-
Delete
51-
</Button>
52-
</Badge>
53-
</>
54-
)}
55-
>
56-
<Table.Column title="应用名" cell={render} width={200}/>
57-
</Table>
33+
{appItem}
5834
</Page.Content>
5935
</Page>
6036
)
6137
}
6238

6339

64-
const render = (value :any, index:any, record:any) => {
40+
const render = (value: any, index: any, record: any) => {
6541
console.log(value, index, record);
6642
return (
6743
<LinkButton
6844
href={`https://baidu.com`}
69-
// onClick={() => {
70-
// alert("on click");
71-
// }}
45+
// onClick={() => {
46+
// alert("on click");
47+
// }}
7248
>
7349
{record.appName}
7450
</LinkButton>

0 commit comments

Comments
 (0)