Skip to content
This repository was archived by the owner on Aug 31, 2022. It is now read-only.

Commit 4be9f88

Browse files
author
Anisha1234
committed
fixes dropdown and creates mock JSON objects
1 parent e9b83d4 commit 4be9f88

File tree

5 files changed

+185
-39
lines changed

5 files changed

+185
-39
lines changed

config/router.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ module.exports = [
9595
exact: true,
9696
component: './Profile',
9797
},
98+
{
99+
path: '/private/overview',
100+
name: 'overview',
101+
component: './Overview',
102+
},
98103
],
99104
},
100-
{
101-
path: '/overview',
102-
name: 'overview',
103-
component: './Overview',
104-
},
105105
],
106106
},
107107
];

mock/overview.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
export const expirationLimit = 20;
2+
3+
export const newData = [
4+
{
5+
key: 1,
6+
result: ['fio_2020.09.10T12.42.11', ' virtual506.virt.lab.eng.bos.redhat.com'],
7+
end: '2020-09-10T 11:52:34.552478',
8+
description: 'More content can be added here',
9+
},
10+
{
11+
key: 2,
12+
result: ['fio_2020.09.10T12.42.12', ' virtual506.virt.lab.eng.bos.redhat.com'],
13+
end: '2020-09-10T11:52:34.552478',
14+
description: 'More content can be added here',
15+
},
16+
{
17+
key: 3,
18+
result: ['fio_2020.09.10T12.42.13', ' virtual506.virt.lab.eng.bos.redhat.com'],
19+
end: '2020-09-10T11:52:34.552478',
20+
description: 'More content can be added here',
21+
},
22+
{
23+
key: 4,
24+
result: ['fio_2020.09.10T12.42.14', ' virtual506.virt.lab.eng.bos.redhat.com'],
25+
end: '2020-09-10T11:52:34.552478',
26+
description: 'More content can be added here',
27+
},
28+
];
29+
30+
export const seenData = [
31+
{
32+
key: 1,
33+
result: ['fio_2020.09.10T12.42.11', 'virtual506.virt.lab.eng.bos.redhat.com'],
34+
end: '2020-11-13T11:52:34.552478',
35+
deletion: '2020-11-13T11:52:34.552478',
36+
description: 'More content can be added here',
37+
},
38+
{
39+
key: 2,
40+
result: ['fio_2020.09.10T12.42.12', ' virtual506.virt.lab.eng.bos.redhat.com'],
41+
end: '2020-11-20T11:52:34.552478',
42+
deletion: '2020-11-20T11:52:34.552478',
43+
description: 'More content can be added here',
44+
},
45+
{
46+
key: 3,
47+
result: ['fio_2020.09.10T12.42.13', ' virtual506.virt.lab.eng.bos.redhat.com'],
48+
end: '2020-11-15T11:52:34.552478',
49+
deletion: '2020-11-15T11:52:34.552478',
50+
description: 'More content can be added here',
51+
},
52+
{
53+
key: 4,
54+
result: ['fio_2020.09.10T12.42.14', ' virtual506.virt.lab.eng.bos.redhat.com'],
55+
end: '2020-11-25T11:52:34.552478',
56+
deletion: '2020-11-25T11:52:34.552478',
57+
description: 'More content can be added here',
58+
},
59+
];

src/common/menu.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { isUrl } from '../utils/utils';
22

33
const menuData = [
44
{
5-
name: 'Dashboard',
5+
name: 'Overview',
66
icon: 'dashboard',
77
path: '/private',
88
routes: [
@@ -28,6 +28,11 @@ const menuData = [
2828
},
2929
],
3030
},
31+
{
32+
name: 'Controllers',
33+
icon: 'controllers',
34+
path: '/',
35+
},
3136
{
3237
name: 'Search',
3338
icon: 'search',

src/pages/Overview/index.js

Lines changed: 95 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
} from '@patternfly/react-charts';
2323
import { Icon } from 'antd';
2424
import { connect } from 'dva';
25+
import moment from 'moment';
2526
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
2627
import {
2728
OutlinedClockIcon,
@@ -30,6 +31,7 @@ import {
3031
EllipsisVIcon,
3132
} from '@patternfly/react-icons';
3233
import { faExclamationCircle } from '@fortawesome/free-solid-svg-icons';
34+
import { newData, seenData, expirationLimit } from '../../../mock/overview';
3335
import Table from '@/components/Table';
3436
// import { Table } from 'antd';
3537
import styles from './index.less';
@@ -66,14 +68,19 @@ class Overview extends React.Component {
6668
});
6769
};
6870

69-
showDrowpdown = () => {
70-
console.log('here');
71+
showDrowpdown = id => {
72+
const dropdownElem = document.getElementById(id);
73+
if (dropdownElem.style.display === 'none') {
74+
dropdownElem.style.display = 'block';
75+
} else {
76+
dropdownElem.style.display = 'none';
77+
}
7178
};
7279

7380
render() {
7481
const { activeTabKey, barWidth } = this.state;
7582

76-
const columns = [
83+
const newDataColumns = [
7784
{
7885
title: 'Result',
7986
dataIndex: 'result',
@@ -105,43 +112,98 @@ class Overview extends React.Component {
105112
title: '',
106113
dataIndex: 'action',
107114
key: 'action',
108-
render: () => (
115+
render: (value, row) => {
116+
return (
117+
<div>
118+
<EllipsisVIcon
119+
onClick={() => this.showDrowpdown(`newrun${row.key}`)}
120+
className="dropbtn"
121+
/>
122+
<div className={styles.dropdown} id={`newrun${row.key}`} style={{ display: 'none' }}>
123+
<div className={styles.dropdownContent}>
124+
<div className={styles.dropdownLink} href="#seen">
125+
Mark as seen
126+
</div>
127+
<div className={styles.dropdownLink} href="#delete">
128+
Delete
129+
</div>
130+
</div>
131+
</div>
132+
</div>
133+
);
134+
},
135+
},
136+
];
137+
138+
const seenDataColumns = [
139+
{
140+
title: 'Result',
141+
dataIndex: 'result',
142+
key: 'result',
143+
render: text => (
109144
<div>
110-
<EllipsisVIcon onClick={() => this.showDrowpdown()} />
111-
{/* <div id="Dropdown" className="dropdownmenu-content">
112-
<a href="#Java">Java</a>
113-
<a href="#HTML">HTML</a>
114-
<a href="#CSS">CSS</a>
115-
<a href="#JS">JavaScript</a>
116-
</div> */}
145+
<Button variant="link" isInline style={{ marginBottom: '8px' }}>
146+
{text[0]}
147+
</Button>
148+
<br />
149+
<Text component={TextVariants.p} className={styles.subText}>
150+
<span className={styles.label}>{text[1]}</span>
151+
</Text>
117152
</div>
118153
),
119154
},
120-
];
121-
const data = [
122155
{
123-
key: 1,
124-
result: ['fio_2020.09.10T12.42.11', ' 2020-09-10T 11:52:34:552478'],
125-
end: '2020-09-10T 11:52:34:552478',
126-
description: 'More content can be added here',
156+
title: 'End Time',
157+
dataIndex: 'end',
158+
key: 'end',
127159
},
128160
{
129-
key: 2,
130-
result: ['fio_2020.09.10T12.42.12', ' 2020-09-10T 11:52:34:552478'],
131-
end: '2020-09-10T 11:52:34:552478',
132-
description: 'More content can be added here',
161+
title: 'Scheduled for deletion on',
162+
dataIndex: 'deletion',
163+
key: 'deletion',
164+
render: text => {
165+
const startDate = moment(new Date(Date.parse(text)));
166+
const currDate = moment(new Date());
167+
const currDays = currDate.diff(startDate, 'days');
168+
if (currDays < expirationLimit) {
169+
return (
170+
<Text>
171+
{moment(text)
172+
.add(7, 'days')
173+
.format('YYYY-MM-DDTHH:mm:ss:SSSSSS')}
174+
</Text>
175+
);
176+
}
177+
return (
178+
<span>
179+
{moment(text)
180+
.add(7, 'days')
181+
.format('YYYY-MM-DDTHH:mm:ss:SSSSSS')}
182+
<FontAwesomeIcon
183+
style={{ paddingLeft: '5px', width: '20px' }}
184+
icon={faExclamationCircle}
185+
color="red"
186+
className={styles.icons}
187+
/>
188+
</span>
189+
);
190+
},
133191
},
134192
{
135-
key: 3,
136-
result: ['fio_2020.09.10T12.42.13', ' 2020-09-10T 11:52:34:552478'],
137-
end: '2020-09-10T 11:52:34:552478',
138-
description: 'More content can be added here',
193+
title: '',
194+
dataIndex: 'fav',
195+
key: 'fav',
196+
render: () => <Icon type="star" onClick={() => this.onFavourite()} />,
139197
},
140198
{
141-
key: 4,
142-
result: ['fio_2020.09.10T12.42.14', ' 2020-09-10T 11:52:34:552478'],
143-
end: '2020-09-10T 11:52:34:552478',
144-
description: 'More content can be added here',
199+
title: '',
200+
dataIndex: 'action',
201+
key: 'action',
202+
render: () => (
203+
<div>
204+
<EllipsisVIcon onClick={() => this.showDrowpdown()} />
205+
</div>
206+
),
145207
},
146208
];
147209

@@ -342,12 +404,12 @@ class Overview extends React.Component {
342404
</div>
343405
<div>
344406
<Table
345-
columns={columns}
407+
columns={newDataColumns}
346408
rowSelection={rowSelection}
347409
expandedRowRender={record => (
348410
<p style={{ margin: 0 }}>{record.description}</p>
349411
)}
350-
dataSource={data}
412+
dataSource={newData}
351413
/>
352414
</div>
353415
</Card>
@@ -364,12 +426,12 @@ class Overview extends React.Component {
364426
</div>
365427
<div>
366428
<Table
367-
columns={columns}
429+
columns={seenDataColumns}
368430
rowSelection={rowSelection}
369431
expandedRowRender={record => (
370432
<p style={{ margin: 0 }}>{record.description}</p>
371433
)}
372-
dataSource={data}
434+
dataSource={seenData}
373435
/>
374436
</div>
375437
</Card>

src/pages/Overview/index.less

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,23 @@
7272
font-size: var(--pf-global--FontSize--sm);
7373
color: var(--pf-global--Color--300);
7474
}
75+
76+
.dropdownContent {
77+
position: absolute;
78+
background-color: #f1f1f1;
79+
margin-right: -2%;
80+
min-width: 160px;
81+
overflow: auto;
82+
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
83+
}
84+
85+
.dropdownLink {
86+
color: black;
87+
padding: 12px 16px;
88+
text-decoration: none;
89+
display: block;
90+
}
91+
92+
.dropdownLink:hover {
93+
background-color: #ddd;
94+
}

0 commit comments

Comments
 (0)