Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jacovinus committed Apr 21, 2022
1 parent 1f458c4 commit 8df4d03
Show file tree
Hide file tree
Showing 10 changed files with 188 additions and 203 deletions.
5 changes: 2 additions & 3 deletions src/actions/loadLogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import setMatrixData from "./setMatrixData";
import { nanoid } from "nanoid";
import { setStartTime, setStopTime } from "./";
import { findRangeByLabel } from "../components/StatusBar/components/daterangepicker/utils";
import { createAlert } from "./createAlert";
import { errorHandler } from "./errorHandler";


export default function loadLogs() {
const localStore = store.getState();
Expand Down Expand Up @@ -128,7 +127,7 @@ export default function loadLogs() {
dispatch(setMatrixData([]));

dispatch(setLoading(false));
const handler = errorHandler(url, error, type)


});
};
Expand Down
3 changes: 1 addition & 2 deletions src/components/LabelBrowser/QueryBar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect } from "react";
import { useSelector, useDispatch } from "react-redux";
import { setIsSubmit, setQuery } from "../../actions";
import { setQuery } from "../../actions";
import loadLogs from "../../actions/loadLogs";
import setLoading from "../../actions/setLoading";
import { setLabelsBrowserOpen } from "../../actions/setLabelsBrowserOpen";
Expand Down Expand Up @@ -33,7 +33,6 @@ export const QueryBar = () => {
const apiUrl = useSelector((store) => store.apiUrl);
const historyOpen = useSelector((store) => store.historyOpen);
const isEmbed = useSelector((store) => store.isEmbed)
const apiWarning = useSelector((store) => store.apiWarning)
const [queryInput, setQueryInput] = useState(query);
const [queryValid, setQueryValid] = useState(false);
const [queryValue, setQueryValue] = useState(queryInit(query));
Expand Down
1 change: 0 additions & 1 deletion src/components/LabelBrowser/ValuesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { setQuery } from "../../actions";
import loadLabelValues from "../../actions/loadLabelValues";

import Tooltip from "@mui/material/Tooltip";
import store from "../../store/store";
import styled from "@emotion/styled";
import loadLabels from "../../actions/loadLabels";

Expand Down
2 changes: 0 additions & 2 deletions src/components/LabelBrowser/helpers/querybuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { setQuery } from "../../../actions";
import store from "../../../store/store";

export function queryBuilder(labels) {
const actualLabels = store.getState().labels
const actualQuery = store.getState().query
// console.log(actualLabels)
const preTags = actualQuery.split("{")[0]
const postTags = actualQuery.split("}")[1]
const selectedLabels = [];
Expand Down
104 changes: 50 additions & 54 deletions src/components/StatusBar/components/daterangepicker/defaults.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,51 @@
import {
addDays,
startOfWeek,
endOfWeek,
addWeeks,
startOfMonth,
endOfMonth,
addMonths,
addMinutes,
addHours,
addSeconds,
startOfDay,
endOfDay,
getHours
} from "date-fns";

const getDefaultRanges = (date) => [
{
label: "Today",
dateStart: startOfDay,
dateEnd: endOfDay
},
{
label: "Yesterday",
dateStart: addDays(date, -1),
dateEnd: addDays(date, -1)
},
{
label: "This Week",
dateStart: startOfWeek(date),
dateEnd: endOfWeek(date)
},
{
label: "Last Week",
dateStart: startOfWeek(addWeeks(date, -1)),
dateEnd: endOfWeek(addWeeks(date, -1))
},
{
label: "Last 7 Days",
dateStart: addWeeks(date, -1),
dateEnd: date
},
{
label: "This Month",
dateStart: startOfMonth(date),
dateEnd: endOfMonth(date)
},
{
label: "Last Month",
dateStart: startOfMonth(addMonths(date, -1)),
dateEnd: endOfMonth(addMonths(date, -1))
}
];

import {
addDays,
startOfWeek,
endOfWeek,
addWeeks,
startOfMonth,
endOfMonth,
addMonths,
startOfDay,
endOfDay,
} from "date-fns";

const getDefaultRanges = (date) => [
{
label: "Today",
dateStart: startOfDay,
dateEnd: endOfDay
},
{
label: "Yesterday",
dateStart: addDays(date, -1),
dateEnd: addDays(date, -1)
},
{
label: "This Week",
dateStart: startOfWeek(date),
dateEnd: endOfWeek(date)
},
{
label: "Last Week",
dateStart: startOfWeek(addWeeks(date, -1)),
dateEnd: endOfWeek(addWeeks(date, -1))
},
{
label: "Last 7 Days",
dateStart: addWeeks(date, -1),
dateEnd: date
},
{
label: "This Month",
dateStart: startOfMonth(date),
dateEnd: endOfMonth(date)
},
{
label: "Last Month",
dateStart: startOfMonth(addMonths(date, -1)),
dateEnd: endOfMonth(addMonths(date, -1))
}
];

export const defaultRanges = getDefaultRanges(new Date());
5 changes: 1 addition & 4 deletions src/components/StatusBar/components/daterangepicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,7 @@ export function DateRangePickerMain(props) {
dispatch(setRangeOpen(false));
isOpen(e);
};
const onQueryValid = (query) => {
return query !== "{" && query !== "}" && query !== "{}" && query !== ""; // TODO: make a proper query validation
};
// helpers

const inHoverRange = (day) => {
return (
dateStart &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { TimePickerButtonStyled } from "./styled";
import { useDispatch, useSelector } from "react-redux";
import setTimePickerOpen from "./actions/setTimePickerOpen";
import AccessTimeIcon from "@mui/icons-material/AccessTime";
import { setRangeOpen } from "../../../../actions";

export default function TimePickerButton() {
const dispatch = useDispatch();
const timePickerOpen = useSelector((store) => store.rangeOpen);

function openTimePicker() {
const shouldOpen = timePickerOpen ? false : true;

dispatch(setRangeOpen(shouldOpen));
}
return (
<TimePickerButtonStyled onClick={openTimePicker}>
<AccessTimeIcon />
</TimePickerButtonStyled>
);
}
import { TimePickerButtonStyled } from "./styled";
import { useDispatch, useSelector } from "react-redux";
import AccessTimeIcon from "@mui/icons-material/AccessTime";
import { setRangeOpen } from "../../../../actions";

export default function TimePickerButton() {
const dispatch = useDispatch();
const timePickerOpen = useSelector((store) => store.rangeOpen);

function openTimePicker() {
const shouldOpen = timePickerOpen ? false : true;

dispatch(setRangeOpen(shouldOpen));
}
return (
<TimePickerButtonStyled onClick={openTimePicker}>
<AccessTimeIcon />
</TimePickerButtonStyled>
);
}
Loading

0 comments on commit 8df4d03

Please sign in to comment.