feat: store display type in URL (#1855)

This commit is contained in:
Yury Molodov 2021-11-30 02:06:26 +03:00 committed by Aliaksandr Valialkin
parent b7eb4bb6cb
commit acc05e16c1
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
3 changed files with 10 additions and 6 deletions

View file

@ -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/>&nbsp;Query Range as Chart
<ShowChartIcon/><span>Query Range as Chart</span>
</StylizedToggleButton>
<StylizedToggleButton value="code" aria-label="display as code">
<CodeIcon/>&nbsp;Instant Query as JSON
<CodeIcon/><span>Instant Query as JSON</span>
</StylizedToggleButton>
<StylizedToggleButton value="table" aria-label="display as table">
<TableChartIcon/>&nbsp;Instant Query as Table
<TableChartIcon/><span>Instant Query as Table</span>
</StylizedToggleButton>
</ToggleButtonGroup>;
};

View file

@ -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: {

View file

@ -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.