Skip to content

Commit

Permalink
Merge pull request #581 from akto-api-security/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
avneesh-akto authored Sep 20, 2023
2 parents 6f47394 + e1626cf commit d39b9b9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ function DateRangePicker(props) {
setDate({ month, year });
}
function handleCalendarChange({ start, end }) {
setInputValues({since: formatDate(start), until: formatDate(end)})
const newDateRange = ranges.find((range) => {
return (
range.period.since.valueOf() === start.valueOf() &&
Expand All @@ -127,16 +128,17 @@ function DateRangePicker(props) {
setActiveDateRange(newDateRange);
}
function apply() {
props.dispatch({type: "update", period: activeDateRange})
const newUntil = new Date(activeDateRange.period.until).setHours(23, 59, 59, 999);
let newPeriod = { ...activeDateRange};
newPeriod.period.until = new Date(newUntil);
props.dispatch({type: "update", period: newPeriod})
props.setPopoverState(false);
}
function cancel() {
setActiveDateRange(props.initialDispatch)
props.setPopoverState(false);
}

console.log(month)

return (
<Box>
<Popover.Pane fixed>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function GithubServerTable(props) {
let filterOperators = props.headers.reduce((map, e) => { map[e.sortKey || e.value] = 'OR'; return map }, {})
const [selectedIndex, setSelectedIndex] = useState(-1)

const [currDateRange, dispatchCurrDateRange] = useReducer(produce((draft, action) => func.dateRangeReducer(draft, action)), values.ranges[2]);
const [currDateRange, dispatchCurrDateRange] = useReducer(produce((draft, action) => func.dateRangeReducer(draft, action)), values.ranges[3]);

useEffect(() => {
let [sortKey, sortOrder] = sortSelected.length == 0 ? ["", ""] : sortSelected[0].split(" ");
Expand All @@ -59,7 +59,11 @@ function GithubServerTable(props) {
temp.push(defaultAppliedFilter)
}
})
setAppliedFilters(temp);
if (key == "dateRange") {
getDate({ type: "update", period: values.ranges[3] });
} else {
setAppliedFilters(temp);
}
}

const changeAppliedFilters = (key, value) => {
Expand Down Expand Up @@ -139,6 +143,7 @@ function GithubServerTable(props) {

const handleFiltersClearAll = useCallback(() => {
setAppliedFilters(props.appliedFilters || [])
getDate({ type: "update", period: values.ranges[3] });
}, []);

const resourceIDResolver = (data) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function convertToCollectionData(c) {
return {
...c,
endpoints: c["urlsCount"] || 0,
detected: "Last seen " + func.prettifyEpoch(c.startTs),
detected: "Discovered " + func.prettifyEpoch(c.startTs),
icon: CircleTickMajor,
nextUrl: "/dashboard/observe/inventory/"+ c.id
}
Expand Down
17 changes: 11 additions & 6 deletions apps/dashboard/web/polaris_web/web/src/util/values.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,42 @@
const today = new Date(new Date().setHours(0, 0, 0, 0));
const todayDayEnd = new Date(new Date().setHours(23, 59, 59, 999));
const yesterday = new Date(
new Date(new Date().setDate(today.getDate() - 1)).setHours(0, 0, 0, 0)
);
const yesterdayDayEnd = new Date(
new Date(new Date().setDate(today.getDate() - 1)).setHours(23, 59, 59, 999)
);

const ranges = [
{
title: "Today",
alias: "today",
period: {
since: today,
until: today,
until: todayDayEnd,
},
},
{
title: "Yesterday",
alias: "yesterday",
period: {
since: yesterday,
until: yesterday,
until: yesterdayDayEnd,
},
},
{
title: "Last 7 days",
alias: "last7days",
period: {
since: new Date(
new Date(new Date().setDate(today.getDate() - 7)).setHours(
new Date(new Date().setDate(today.getDate() - 6)).setHours(
0,
0,
0,
0
)
),
until: yesterday,
until: todayDayEnd,
},
},
{
Expand All @@ -46,9 +51,9 @@ const ranges = [
0
)
),
until: today,
until: todayDayEnd,
}
}
];

export default { today, yesterday, ranges };
export default { today, yesterday, ranges, yesterdayDayEnd, todayDayEnd };

0 comments on commit d39b9b9

Please sign in to comment.