vmui: fix layout and add server url by default (#1519)

* fix: change layout for correctly display big query

* fix: set default server from url

* fix: change get default server url
This commit is contained in:
Yury Molodov 2021-08-06 12:06:08 +03:00 committed by Aliaksandr Valialkin
parent d5ca07bd71
commit aca2cb245e
3 changed files with 12 additions and 3 deletions

View file

@ -50,17 +50,18 @@ const HomeLayout: FC = () => {
<UrlCopy url={fetchUrl}/>
</Toolbar>
</AppBar>
<Box display="flex" flexDirection="column" style={{height: "calc(100vh - 64px)"}}>
<Box display="flex" flexDirection="column" style={{minHeight: "calc(100vh - 64px)"}}>
<Box m={2}>
<QueryConfigurator/>
</Box>
<Box flexShrink={1} style={{overflowY: "scroll"}}>
<Box flexShrink={1}>
{isLoading && <Fade in={isLoading} style={{
transitionDelay: isLoading ? "300ms" : "0ms",
}}>
<Box alignItems="center" flexDirection="column" display="flex"
style={{
width: "100%",
maxWidth: "calc(100vh - 32px)",
position: "absolute",
height: "150px",
background: "linear-gradient(rgba(255,255,255,.7), rgba(255,255,255,.7), rgba(255,255,255,0))"

View file

@ -2,6 +2,7 @@ import {DisplayType} from "../../components/Home/Configurator/DisplayTypeSwitch"
import {TimeParams, TimePeriod} from "../../types";
import {dateFromSeconds, getDurationFromPeriod, getTimeperiodForDuration} from "../../utils/time";
import {getFromStorage} from "../../utils/storage";
import {getDefaultServer} from "../../utils/default-server-url";
export interface TimeState {
duration: string;
@ -31,8 +32,9 @@ export type Action =
| { type: "TOGGLE_AUTOREFRESH"}
| { type: "TOGGLE_AUTOCOMPLETE"}
export const initialState: AppState = {
serverUrl: getFromStorage("PREFERRED_URL") as string || "https://", // https://demo.promlabs.com or https://play.victoriametrics.com/select/accounting/1/6a716b0f-38bc-4856-90ce-448fd713e3fe/prometheus",
serverUrl: getFromStorage("PREFERRED_URL") as string || getDefaultServer(), // https://demo.promlabs.com or https://play.victoriametrics.com/select/accounting/1/6a716b0f-38bc-4856-90ce-448fd713e3fe/prometheus",
displayType: "chart",
query: getFromStorage("LAST_QUERY") as string || "\n", // demo_memory_usage_bytes
time: {

View file

@ -0,0 +1,6 @@
export const getDefaultServer = (): string => {
const {href} = window.location;
const regexp = /^http.+\/vmui/;
const [result] = href.match(regexp) || ["https://"];
return result.replace("vmui", "prometheus");
};