mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 12:31:07 +01:00
fix: change get display type (#2553)
This commit is contained in:
parent
ff74472621
commit
4e6b483ef1
@ -9,10 +9,10 @@ import {SyntheticEvent} from "react";
|
||||
|
||||
export type DisplayType = "table" | "chart" | "code";
|
||||
|
||||
const tabs = [
|
||||
{value: "chart", icon: <ShowChartIcon/>, label: "Graph"},
|
||||
export const displayTypeTabs = [
|
||||
{value: "chart", icon: <ShowChartIcon/>, label: "Graph", prometheusCode: 0},
|
||||
{value: "code", icon: <CodeIcon/>, label: "JSON"},
|
||||
{value: "table", icon: <TableChartIcon/>, label: "Table"}
|
||||
{value: "table", icon: <TableChartIcon/>, label: "Table", prometheusCode: 1}
|
||||
];
|
||||
|
||||
export const DisplayTypeSwitch: FC = () => {
|
||||
@ -29,7 +29,7 @@ export const DisplayTypeSwitch: FC = () => {
|
||||
onChange={handleChange}
|
||||
sx={{minHeight: "0", marginBottom: "-1px"}}
|
||||
>
|
||||
{tabs.map(t =>
|
||||
{displayTypeTabs.map(t =>
|
||||
<Tab key={t.value}
|
||||
icon={t.icon}
|
||||
iconPosition="start"
|
||||
@ -37,4 +37,4 @@ export const DisplayTypeSwitch: FC = () => {
|
||||
sx={{minHeight: "41px"}}
|
||||
/>)}
|
||||
</Tabs>;
|
||||
};
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* 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 {
|
||||
dateFromSeconds,
|
||||
@ -62,10 +62,12 @@ const {duration, endInput, relativeTimeId} = getRelativeTime({
|
||||
defaultEndInput: new Date(formatDateToLocal(getQueryStringValue("g0.end_input", getDateNowUTC()) as Date)),
|
||||
});
|
||||
const query = getQueryArray();
|
||||
const queryTab = getQueryStringValue("g0.tab", 0);
|
||||
const displayType = displayTypeTabs.find(t => t.prometheusCode === queryTab || t.value === queryTab);
|
||||
|
||||
export const initialState: AppState = {
|
||||
serverUrl: getDefaultServer(),
|
||||
displayType: getQueryStringValue("g0.tab", "chart") as DisplayType || "chart",
|
||||
displayType: (displayType?.value || "chart") as DisplayType,
|
||||
query: query, // demo_memory_usage_bytes
|
||||
queryHistory: query.map(q => ({index: 0, values: [q]})),
|
||||
time: {
|
||||
|
Loading…
Reference in New Issue
Block a user