mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-09-25 00:13:12 +08:00
Commit uncommitted changes
This commit is contained in:
parent
4bd1790a52
commit
cc6f755f07
@ -36,7 +36,7 @@ const ThemeSwitcherWrapper = styled.div`
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
`
|
`;
|
||||||
const App = () => {
|
const App = () => {
|
||||||
// state = { collapsed: false, isDarkMode: true };
|
// state = { collapsed: false, isDarkMode: true };
|
||||||
const { switcher, currentTheme, status, themes } = useThemeSwitcher();
|
const { switcher, currentTheme, status, themes } = useThemeSwitcher();
|
||||||
@ -67,7 +67,7 @@ const App = () => {
|
|||||||
>
|
>
|
||||||
<div className="logo">
|
<div className="logo">
|
||||||
<ThemeSwitcherWrapper>
|
<ThemeSwitcherWrapper>
|
||||||
<ToggleButton checked={isDarkMode} onChange={toggleTheme} />
|
<ToggleButton checked={isDarkMode} onChange={toggleTheme} />
|
||||||
</ThemeSwitcherWrapper>
|
</ThemeSwitcherWrapper>
|
||||||
<NavLink to="/">
|
<NavLink to="/">
|
||||||
<img
|
<img
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Select, Button, Space, Form } from "antd";
|
import { Select, Button, Space, Form } from "antd";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { withRouter } from "react-router";
|
import { withRouter } from "react-router";
|
||||||
@ -11,7 +11,8 @@ import { StoreState } from "../reducers";
|
|||||||
import FormItem from "antd/lib/form/FormItem";
|
import FormItem from "antd/lib/form/FormItem";
|
||||||
|
|
||||||
import { DateTimeRangeType } from "../actions";
|
import { DateTimeRangeType } from "../actions";
|
||||||
|
import { METRICS_PAGE_QUERY_PARAM } from "../constants/query";
|
||||||
|
import { LOCAL_STORAGE } from "../constants/localStorage";
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
|
|
||||||
const DateTimeWrapper = styled.div`
|
const DateTimeWrapper = styled.div`
|
||||||
@ -25,20 +26,37 @@ interface DateTimeSelectorProps extends RouteComponentProps<any> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const _DateTimeSelector = (props: DateTimeSelectorProps) => {
|
const _DateTimeSelector = (props: DateTimeSelectorProps) => {
|
||||||
|
const defaultTime = "15min";
|
||||||
const [customDTPickerVisible, setCustomDTPickerVisible] = useState(false);
|
const [customDTPickerVisible, setCustomDTPickerVisible] = useState(false);
|
||||||
const [timeInterval, setTimeInterval] = useState("15min");
|
const [timeInterval, setTimeInterval] = useState(defaultTime);
|
||||||
const [refreshButtonHidden, setRefreshButtonHidden] = useState(false);
|
const [refreshButtonHidden, setRefreshButtonHidden] = useState(false);
|
||||||
|
|
||||||
const [form_dtselector] = Form.useForm();
|
const [form_dtselector] = Form.useForm();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const timeDurationInLocalStorage = localStorage.getItem(
|
||||||
|
LOCAL_STORAGE.METRICS_TIME_IN_DURATION,
|
||||||
|
);
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
const timeInQueryParam = urlParams.get(METRICS_PAGE_QUERY_PARAM.time);
|
||||||
|
if (timeInQueryParam) {
|
||||||
|
setMetricsTime(timeInQueryParam);
|
||||||
|
} else if (timeDurationInLocalStorage) {
|
||||||
|
setMetricsTime(timeDurationInLocalStorage);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const setMetricsTime = (value: string) => {
|
||||||
|
props.history.push({
|
||||||
|
search: `?${METRICS_PAGE_QUERY_PARAM.time}=${value}`,
|
||||||
|
}); //pass time in URL query param for all choices except custom in datetime picker
|
||||||
|
props.updateTimeInterval(value);
|
||||||
|
setTimeInterval(value);
|
||||||
|
};
|
||||||
|
|
||||||
const handleOnSelect = (value: string) => {
|
const handleOnSelect = (value: string) => {
|
||||||
if (value === "custom") {
|
if (value === "custom") {
|
||||||
setCustomDTPickerVisible(true);
|
setCustomDTPickerVisible(true);
|
||||||
} else {
|
} else {
|
||||||
props.history.push({
|
|
||||||
search: "?time=" + value,
|
|
||||||
}); //pass time in URL query param for all choices except custom in datetime picker
|
|
||||||
props.updateTimeInterval(value);
|
|
||||||
setTimeInterval(value);
|
setTimeInterval(value);
|
||||||
setRefreshButtonHidden(false); // for normal intervals, show refresh button
|
setRefreshButtonHidden(false); // for normal intervals, show refresh button
|
||||||
}
|
}
|
||||||
@ -86,8 +104,22 @@ const _DateTimeSelector = (props: DateTimeSelectorProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleRefresh = () => {
|
const handleRefresh = () => {
|
||||||
props.updateTimeInterval(timeInterval);
|
window.localStorage.setItem(
|
||||||
|
LOCAL_STORAGE.METRICS_TIME_IN_DURATION,
|
||||||
|
timeInterval,
|
||||||
|
);
|
||||||
|
setMetricsTime(timeInterval);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const options = [
|
||||||
|
{ value: "custom", label: "Custom" },
|
||||||
|
{ value: "15min", label: "Last 15 min" },
|
||||||
|
{ value: "30min", label: "Last 30 min" },
|
||||||
|
{ value: "1hr", label: "Last 1 hour" },
|
||||||
|
{ value: "6hr", label: "Last 6 hour" },
|
||||||
|
{ value: "1day", label: "Last 1 day" },
|
||||||
|
{ value: "1week", label: "Last 1 week" },
|
||||||
|
];
|
||||||
if (props.location.pathname.startsWith("/usage-explorer")) {
|
if (props.location.pathname.startsWith("/usage-explorer")) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
@ -100,17 +132,12 @@ const _DateTimeSelector = (props: DateTimeSelectorProps) => {
|
|||||||
initialValues={{ interval: "15min" }}
|
initialValues={{ interval: "15min" }}
|
||||||
style={{ marginTop: 10, marginBottom: 10 }}
|
style={{ marginTop: 10, marginBottom: 10 }}
|
||||||
>
|
>
|
||||||
<FormItem name="interval">
|
<FormItem></FormItem>
|
||||||
<Select onSelect={handleOnSelect}>
|
<Select onSelect={handleOnSelect} value={timeInterval}>
|
||||||
<Option value="custom">Custom</Option>
|
{options.map(({ value, label }) => (
|
||||||
<Option value="15min">Last 15 min</Option>
|
<Option value={value}>{label}</Option>
|
||||||
<Option value="30min">Last 30 min</Option>
|
))}
|
||||||
<Option value="1hr">Last 1 hour</Option>
|
</Select>
|
||||||
<Option value="6hr">Last 6 hour</Option>
|
|
||||||
<Option value="1day">Last 1 day</Option>
|
|
||||||
<Option value="1week">Last 1 week</Option>
|
|
||||||
</Select>
|
|
||||||
</FormItem>
|
|
||||||
|
|
||||||
<FormItem hidden={refreshButtonHidden} name="refresh_button">
|
<FormItem hidden={refreshButtonHidden} name="refresh_button">
|
||||||
<Button type="primary" onClick={handleRefresh}>
|
<Button type="primary" onClick={handleRefresh}>
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
export enum LOCAL_STORAGE {
|
|
||||||
metricsTimeDuration = "metricsTimeDuration",
|
|
||||||
}
|
|
@ -1,3 +1,3 @@
|
|||||||
export const ENVIRONMENT = {
|
export const ENVIRONMENT = {
|
||||||
baseURL: "http://104.211.113.204:8080"
|
baseURL: "http://104.211.113.204:8080",
|
||||||
}
|
};
|
||||||
|
3
frontend/src/constants/localStorage.ts
Normal file
3
frontend/src/constants/localStorage.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export enum LOCAL_STORAGE {
|
||||||
|
METRICS_TIME_IN_DURATION = "metricsTimeDuration",
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user