mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
fix: change get display type (#2553)
This commit is contained in:
parent
d13437afd0
commit
c8eca88f12
2 changed files with 9 additions and 7 deletions
|
@ -9,10 +9,10 @@ import {SyntheticEvent} from "react";
|
||||||
|
|
||||||
export type DisplayType = "table" | "chart" | "code";
|
export type DisplayType = "table" | "chart" | "code";
|
||||||
|
|
||||||
const tabs = [
|
export const displayTypeTabs = [
|
||||||
{value: "chart", icon: <ShowChartIcon/>, label: "Graph"},
|
{value: "chart", icon: <ShowChartIcon/>, label: "Graph", prometheusCode: 0},
|
||||||
{value: "code", icon: <CodeIcon/>, label: "JSON"},
|
{value: "code", icon: <CodeIcon/>, label: "JSON"},
|
||||||
{value: "table", icon: <TableChartIcon/>, label: "Table"}
|
{value: "table", icon: <TableChartIcon/>, label: "Table", prometheusCode: 1}
|
||||||
];
|
];
|
||||||
|
|
||||||
export const DisplayTypeSwitch: FC = () => {
|
export const DisplayTypeSwitch: FC = () => {
|
||||||
|
@ -29,7 +29,7 @@ export const DisplayTypeSwitch: FC = () => {
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
sx={{minHeight: "0", marginBottom: "-1px"}}
|
sx={{minHeight: "0", marginBottom: "-1px"}}
|
||||||
>
|
>
|
||||||
{tabs.map(t =>
|
{displayTypeTabs.map(t =>
|
||||||
<Tab key={t.value}
|
<Tab key={t.value}
|
||||||
icon={t.icon}
|
icon={t.icon}
|
||||||
iconPosition="start"
|
iconPosition="start"
|
||||||
|
@ -37,4 +37,4 @@ export const DisplayTypeSwitch: FC = () => {
|
||||||
sx={{minHeight: "41px"}}
|
sx={{minHeight: "41px"}}
|
||||||
/>)}
|
/>)}
|
||||||
</Tabs>;
|
</Tabs>;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* eslint max-lines: 0 */
|
/* eslint max-lines: 0 */
|
||||||
import {DisplayType} from "../../components/CustomPanel/Configurator/DisplayTypeSwitch";
|
import {DisplayType, displayTypeTabs} from "../../components/CustomPanel/Configurator/DisplayTypeSwitch";
|
||||||
import {TimeParams, TimePeriod} from "../../types";
|
import {TimeParams, TimePeriod} from "../../types";
|
||||||
import {
|
import {
|
||||||
dateFromSeconds,
|
dateFromSeconds,
|
||||||
|
@ -62,10 +62,12 @@ const {duration, endInput, relativeTimeId} = getRelativeTime({
|
||||||
defaultEndInput: new Date(formatDateToLocal(getQueryStringValue("g0.end_input", getDateNowUTC()) as Date)),
|
defaultEndInput: new Date(formatDateToLocal(getQueryStringValue("g0.end_input", getDateNowUTC()) as Date)),
|
||||||
});
|
});
|
||||||
const query = getQueryArray();
|
const query = getQueryArray();
|
||||||
|
const queryTab = getQueryStringValue("g0.tab", 0);
|
||||||
|
const displayType = displayTypeTabs.find(t => t.prometheusCode === queryTab || t.value === queryTab);
|
||||||
|
|
||||||
export const initialState: AppState = {
|
export const initialState: AppState = {
|
||||||
serverUrl: getDefaultServer(),
|
serverUrl: getDefaultServer(),
|
||||||
displayType: getQueryStringValue("g0.tab", "chart") as DisplayType || "chart",
|
displayType: (displayType?.value || "chart") as DisplayType,
|
||||||
query: query, // demo_memory_usage_bytes
|
query: query, // demo_memory_usage_bytes
|
||||||
queryHistory: query.map(q => ({index: 0, values: [q]})),
|
queryHistory: query.map(q => ({index: 0, values: [q]})),
|
||||||
time: {
|
time: {
|
||||||
|
|
Loading…
Reference in a new issue