mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
feat: store display type in URL (#1855)
This commit is contained in:
parent
b7eb4bb6cb
commit
acc05e16c1
3 changed files with 10 additions and 6 deletions
|
@ -12,8 +12,12 @@ export type DisplayType = "table" | "chart" | "code";
|
|||
|
||||
const StylizedToggleButton = withStyles({
|
||||
root: {
|
||||
padding: 6,
|
||||
display: "grid",
|
||||
gridTemplateColumns: "18px auto",
|
||||
gridGap: 6,
|
||||
padding: "8px 12px",
|
||||
color: "white",
|
||||
lineHeight: "19px",
|
||||
"&.Mui-selected": {
|
||||
color: "white"
|
||||
}
|
||||
|
@ -34,13 +38,13 @@ export const DisplayTypeSwitch: FC = () => {
|
|||
dispatch({type: "SET_DISPLAY_TYPE", payload: val ?? displayType})
|
||||
}>
|
||||
<StylizedToggleButton value="chart" aria-label="display as chart">
|
||||
<ShowChartIcon/> Query Range as Chart
|
||||
<ShowChartIcon/><span>Query Range as Chart</span>
|
||||
</StylizedToggleButton>
|
||||
<StylizedToggleButton value="code" aria-label="display as code">
|
||||
<CodeIcon/> Instant Query as JSON
|
||||
<CodeIcon/><span>Instant Query as JSON</span>
|
||||
</StylizedToggleButton>
|
||||
<StylizedToggleButton value="table" aria-label="display as table">
|
||||
<TableChartIcon/> Instant Query as Table
|
||||
<TableChartIcon/><span>Instant Query as Table</span>
|
||||
</StylizedToggleButton>
|
||||
</ToggleButtonGroup>;
|
||||
};
|
|
@ -50,7 +50,7 @@ const query = getQueryStringValue("g0.expr", "") as string;
|
|||
|
||||
export const initialState: AppState = {
|
||||
serverUrl: getDefaultServer(),
|
||||
displayType: "chart",
|
||||
displayType: getQueryStringValue("tab", "chart") as DisplayType,
|
||||
query: query, // demo_memory_usage_bytes
|
||||
queryHistory: { index: 0, values: [query] },
|
||||
time: {
|
||||
|
|
|
@ -6,7 +6,7 @@ const stateToUrlParams = {
|
|||
"time.duration": "g0.range_input",
|
||||
"time.period.date": "g0.end_input",
|
||||
"time.period.step": "g0.step_input",
|
||||
"stacked": "g0.stacked",
|
||||
"displayType": "tab"
|
||||
};
|
||||
|
||||
// TODO need function for detect types.
|
||||
|
|
Loading…
Reference in a new issue