feat: create global actions for setting page title and auto refresh pages (#13)

* fix: update heat map

* feat: update servicelist

* fix: update list

* feat: update page with changing times

* feat: set auto fresh

* feat: set page titles
This commit is contained in:
Fine0830
2022-01-26 12:18:03 +08:00
committed by GitHub
parent 970989100b
commit 7472d70720
22 changed files with 282 additions and 73 deletions

View File

@@ -101,3 +101,24 @@ export const ConfigData2: any = {
},
children: [],
};
export const ConfigData3: any = {
x: 0,
y: 0,
w: 8,
h: 12,
i: "0",
metrics: ["all_heatmap"],
metricTypes: ["readHeatMap"],
type: "Widget",
widget: {
title: "all_heatmap",
tips: "Tooltip",
},
graph: {
type: "HeatMap",
},
standard: {
unit: "min",
},
children: [],
};

View File

@@ -28,6 +28,8 @@ interface AppState {
utcMin: number;
eventStack: (() => unknown)[];
timer: Nullable<any>;
autoRefresh: boolean;
pageTitle: string;
}
export const appStore = defineStore({
@@ -39,6 +41,8 @@ export const appStore = defineStore({
utcMin: 0,
eventStack: [],
timer: null,
autoRefresh: false,
pageTitle: "",
}),
getters: {
duration(): Duration {
@@ -117,6 +121,12 @@ export const appStore = defineStore({
setEventStack(funcs: (() => void)[]): void {
this.eventStack = funcs;
},
setAutoRefresh(auto: boolean) {
this.autoRefresh = auto;
},
setPageTitle(title: string) {
this.pageTitle = title;
},
runEventStack() {
if (this.timer) {
clearTimeout(this.timer);

View File

@@ -18,7 +18,7 @@ import { defineStore } from "pinia";
import { store } from "@/store";
import { LayoutConfig } from "@/types/dashboard";
import graph from "@/graph";
import { ConfigData, ConfigData1, ConfigData2 } from "../data";
import { ConfigData, ConfigData1, ConfigData2, ConfigData3 } from "../data";
import { useAppStoreWithOut } from "@/store/modules/app";
import { useSelectorStore } from "@/store/modules/selectors";
import { NewControl } from "../data";
@@ -146,12 +146,19 @@ export const dashboardStore = defineStore({
},
setEntity(type: string) {
this.entity = type;
// todo
if (type === "ServiceInstance") {
this.layout = [ConfigData1];
}
if (type === "Endpoint") {
this.layout = [ConfigData2];
}
if (type == "All") {
this.layout = [ConfigData3];
}
if (type == "Service") {
this.layout = [ConfigData];
}
},
setConfigs(param: { [key: string]: unknown }) {
const actived = this.activedGridItem.split("-");