Skip to content

Commit d433a35

Browse files
Analytics for litmus portal. (#2065)
Adds Analytics section and fixes for the same to litmus portal. Signed-off-by: ishangupta-ds <[email protected]>
1 parent fe57dea commit d433a35

File tree

27 files changed

+2649
-62
lines changed

27 files changed

+2649
-62
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/* eslint-disable react/no-array-index-key */
2+
import { Popover } from '@material-ui/core';
3+
import React, { useState } from 'react';
4+
import { subDays } from 'date-fns';
5+
import 'react-date-range/dist/styles.css'; // main css file
6+
import 'react-date-range/dist/theme/default.css'; // theme css file
7+
import { DateRangePicker } from 'react-date-range';
8+
import { useTheme } from '@material-ui/core/styles';
9+
import useStyles from './styles';
10+
11+
interface RangeCallBackType {
12+
(selectedStartDate: string, selectedEndDate: string): void;
13+
}
14+
15+
interface DateRangeSelectorProps {
16+
anchorEl: HTMLElement;
17+
isOpen: boolean;
18+
onClose: () => void;
19+
callbackToSetRange: RangeCallBackType;
20+
}
21+
22+
const DateRangeSelector: React.FC<DateRangeSelectorProps> = ({
23+
anchorEl,
24+
isOpen,
25+
onClose,
26+
callbackToSetRange,
27+
}) => {
28+
const classes = useStyles();
29+
const { palette } = useTheme();
30+
const id = isOpen ? 'profile-popover' : undefined;
31+
const [state, setState] = useState([
32+
{
33+
startDate: subDays(new Date(), 7),
34+
endDate: new Date(),
35+
key: 'selection',
36+
},
37+
]);
38+
39+
return (
40+
<div>
41+
<Popover
42+
id={id}
43+
open={isOpen}
44+
anchorEl={anchorEl}
45+
onClose={onClose}
46+
anchorOrigin={{
47+
vertical: 'bottom',
48+
horizontal: 'center',
49+
}}
50+
transformOrigin={{
51+
vertical: 'top',
52+
horizontal: 'center',
53+
}}
54+
classes={{
55+
paper: classes.popoverDateRangeSelector,
56+
}}
57+
>
58+
<div className={classes.dateRangeSelectorContainer}>
59+
<DateRangePicker
60+
onChange={(item) => {
61+
setState([(item as any).selection]);
62+
callbackToSetRange(
63+
`${(item as any).selection.startDate}`,
64+
`${(item as any).selection.endDate}`
65+
);
66+
}}
67+
showSelectionPreview
68+
moveRangeOnFirstSelection={false}
69+
months={1}
70+
ranges={state}
71+
direction="vertical"
72+
scroll={{ enabled: true }}
73+
editableDateInputs
74+
rangeColors={[palette.secondary.dark]}
75+
showMonthAndYearPickers
76+
/>
77+
</div>
78+
</Popover>
79+
</div>
80+
);
81+
};
82+
83+
export default DateRangeSelector;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { makeStyles } from '@material-ui/core';
2+
3+
const useStyles = makeStyles((theme) => ({
4+
popoverDateRangeSelector: {
5+
background: theme.palette.secondary.contrastText,
6+
borderRadius: theme.shape.borderRadius,
7+
width: '100%',
8+
maxWidth: '35rem',
9+
},
10+
11+
dateRangeSelectorContainer: {
12+
display: 'flex',
13+
flexDirection: 'column',
14+
alignItems: 'center',
15+
overflowY: 'auto',
16+
maxHeight: '35rem',
17+
},
18+
}));
19+
20+
export default useStyles;

litmus-portal/frontend/src/components/Header/NotificationDropdown.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const NotificationsDropdown: React.FC<NotificationDropdownProps> = ({
3838
const { t } = useTranslation();
3939

4040
function handleClick() {
41-
// setIsOpen(!isOpen); uncomment to activate notifications.
41+
setIsOpen(!isOpen);
4242
}
4343

4444
function handleClickAway() {
@@ -63,8 +63,7 @@ const NotificationsDropdown: React.FC<NotificationDropdownProps> = ({
6363
color="inherit"
6464
>
6565
<Badge
66-
// badgeContent={count === '0' ? messages.length : count}
67-
badgeContent={0}
66+
badgeContent={count === '0' ? messages.length : count}
6867
color="secondary"
6968
>
7069
<NotificationsOutlinedIcon />

litmus-portal/frontend/src/components/Header/index.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useQuery } from '@apollo/client';
22
import { Box, Divider } from '@material-ui/core';
33
import AppBar from '@material-ui/core/AppBar';
44
import Toolbar from '@material-ui/core/Toolbar';
5-
import React, { useCallback, useEffect, useState } from 'react';
5+
import React, { useEffect, useState } from 'react';
66
import { useSelector } from 'react-redux';
77
import { useLocation } from 'react-router-dom';
88
import { GET_USER } from '../../graphql';
@@ -12,13 +12,13 @@ import {
1212
Member,
1313
Project,
1414
} from '../../models/graphql/user';
15-
import { Message, NotificationIds } from '../../models/header';
15+
// import { Message, NotificationIds } from '../../models/header';
1616
import useActions from '../../redux/actions';
1717
import * as UserActions from '../../redux/actions/user';
1818
import configureStore from '../../redux/configureStore';
1919
import { RootState } from '../../redux/reducers';
2020
import CustomBreadCrumbs from '../BreadCrumbs';
21-
import NotificationsDropdown from './NotificationDropdown';
21+
// import NotificationsDropdown from './NotificationDropdown';
2222
import ProfileDropdownSection from './ProfileDropdownSection';
2323
import useStyles from './styles';
2424

@@ -78,6 +78,7 @@ const Header: React.FC = () => {
7878
});
7979
};
8080

81+
/*
8182
// Fetch and Set Notifications from backend.
8283
8384
const [messages, setMessages] = useState<Message[]>([]);
@@ -131,7 +132,7 @@ const Header: React.FC = () => {
131132
messages.reverse();
132133
setMessages(messages);
133134
}, [setMessages]);
134-
135+
/*
135136
const deleteNotification = (notificationIDs: NotificationIds) => {
136137
for (let i = 0; i < messages.length; i += 1) {
137138
if (messages[i].sequenceID === notificationIDs.sequenceID) {
@@ -140,16 +141,18 @@ const Header: React.FC = () => {
140141
}
141142
}
142143
}
144+
143145
// send POST request with #notificationIDs.id to update db with notification
144146
// id marked as disissed from active or persist it in redux or cookie.
145147
setMessages(messages);
146-
setCountOfMessages(messages.length);
148+
//setCountOfMessages(messages.length);
147149
};
148150
149151
useEffect(() => {
150152
fetchRandomMessages();
151153
}, [fetchRandomMessages]);
152154
155+
*/
153156
useEffect(() => {
154157
setSelectedProjectDetails({
155158
selectedProjectID: userData.selectedProjectID,
@@ -168,11 +171,13 @@ const Header: React.FC = () => {
168171
<CustomBreadCrumbs location={useLocation().pathname} />
169172
</Box>
170173
<Box p={1} className={classes.headerFlexPadded}>
171-
<NotificationsDropdown
174+
{/* uncomment to activate notifications.
175+
<NotificationsDropdown
172176
count={`${countOfMessages}`}
173177
messages={messages}
174178
CallbackToHeaderOnDeleteNotification={deleteNotification}
175179
/>
180+
*/}
176181
</Box>
177182
<Box p={1} flexGrow={1} className={classes.headerFlexProfile}>
178183
<ProfileDropdownSection

litmus-portal/frontend/src/components/InfoTooltip/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const InfoTooltip: React.FC<InfoTooltipProps> = ({ value }) => {
4949
onClick={handleTooltipOpen}
5050
>
5151
<img
52-
src="icons/info.svg"
52+
src="/icons/info.svg"
5353
className={classes.infoImg}
5454
alt="info tooltip"
5555
/>

litmus-portal/frontend/src/models/graphql/scheduleData.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface ScheduleWorkflow {
1717
workflow_name: string;
1818
cluster_name: string;
1919
cluster_type: string;
20+
regularity?: string;
2021
}
2122

2223
export interface Schedules {

0 commit comments

Comments
 (0)