-
Notifications
You must be signed in to change notification settings - Fork 705
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Analytics for litmus portal. (#2065)
Adds Analytics section and fixes for the same to litmus portal. Signed-off-by: ishangupta-ds <[email protected]>
- Loading branch information
1 parent
fe57dea
commit d433a35
Showing
27 changed files
with
2,649 additions
and
62 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
litmus-portal/frontend/src/components/DateRangeSelector/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* eslint-disable react/no-array-index-key */ | ||
import { Popover } from '@material-ui/core'; | ||
import React, { useState } from 'react'; | ||
import { subDays } from 'date-fns'; | ||
import 'react-date-range/dist/styles.css'; // main css file | ||
import 'react-date-range/dist/theme/default.css'; // theme css file | ||
import { DateRangePicker } from 'react-date-range'; | ||
import { useTheme } from '@material-ui/core/styles'; | ||
import useStyles from './styles'; | ||
|
||
interface RangeCallBackType { | ||
(selectedStartDate: string, selectedEndDate: string): void; | ||
} | ||
|
||
interface DateRangeSelectorProps { | ||
anchorEl: HTMLElement; | ||
isOpen: boolean; | ||
onClose: () => void; | ||
callbackToSetRange: RangeCallBackType; | ||
} | ||
|
||
const DateRangeSelector: React.FC<DateRangeSelectorProps> = ({ | ||
anchorEl, | ||
isOpen, | ||
onClose, | ||
callbackToSetRange, | ||
}) => { | ||
const classes = useStyles(); | ||
const { palette } = useTheme(); | ||
const id = isOpen ? 'profile-popover' : undefined; | ||
const [state, setState] = useState([ | ||
{ | ||
startDate: subDays(new Date(), 7), | ||
endDate: new Date(), | ||
key: 'selection', | ||
}, | ||
]); | ||
|
||
return ( | ||
<div> | ||
<Popover | ||
id={id} | ||
open={isOpen} | ||
anchorEl={anchorEl} | ||
onClose={onClose} | ||
anchorOrigin={{ | ||
vertical: 'bottom', | ||
horizontal: 'center', | ||
}} | ||
transformOrigin={{ | ||
vertical: 'top', | ||
horizontal: 'center', | ||
}} | ||
classes={{ | ||
paper: classes.popoverDateRangeSelector, | ||
}} | ||
> | ||
<div className={classes.dateRangeSelectorContainer}> | ||
<DateRangePicker | ||
onChange={(item) => { | ||
setState([(item as any).selection]); | ||
callbackToSetRange( | ||
`${(item as any).selection.startDate}`, | ||
`${(item as any).selection.endDate}` | ||
); | ||
}} | ||
showSelectionPreview | ||
moveRangeOnFirstSelection={false} | ||
months={1} | ||
ranges={state} | ||
direction="vertical" | ||
scroll={{ enabled: true }} | ||
editableDateInputs | ||
rangeColors={[palette.secondary.dark]} | ||
showMonthAndYearPickers | ||
/> | ||
</div> | ||
</Popover> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DateRangeSelector; |
20 changes: 20 additions & 0 deletions
20
litmus-portal/frontend/src/components/DateRangeSelector/styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { makeStyles } from '@material-ui/core'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
popoverDateRangeSelector: { | ||
background: theme.palette.secondary.contrastText, | ||
borderRadius: theme.shape.borderRadius, | ||
width: '100%', | ||
maxWidth: '35rem', | ||
}, | ||
|
||
dateRangeSelectorContainer: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
overflowY: 'auto', | ||
maxHeight: '35rem', | ||
}, | ||
})); | ||
|
||
export default useStyles; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.