mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-02 06:24:05 +00:00
feat: active controls
This commit is contained in:
parent
a94c5ff4cb
commit
7cdd57325a
@ -24,9 +24,10 @@ import { useAppStoreWithOut } from "@/store/modules/app";
|
|||||||
interface DashboardState {
|
interface DashboardState {
|
||||||
showConfig: boolean;
|
showConfig: boolean;
|
||||||
layout: LayoutConfig[];
|
layout: LayoutConfig[];
|
||||||
selectedWidget: Nullable<LayoutConfig>;
|
selectedGrid: Nullable<LayoutConfig>;
|
||||||
entity: string;
|
entity: string;
|
||||||
layerId: string;
|
layerId: string;
|
||||||
|
activedGridItem: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dashboardStore = defineStore({
|
export const dashboardStore = defineStore({
|
||||||
@ -34,9 +35,10 @@ export const dashboardStore = defineStore({
|
|||||||
state: (): DashboardState => ({
|
state: (): DashboardState => ({
|
||||||
layout: [ConfigData],
|
layout: [ConfigData],
|
||||||
showConfig: false,
|
showConfig: false,
|
||||||
selectedWidget: ConfigData,
|
selectedGrid: ConfigData,
|
||||||
entity: "",
|
entity: "",
|
||||||
layerId: "",
|
layerId: "",
|
||||||
|
activedGridItem: "",
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
setLayout(data: LayoutConfig[]) {
|
setLayout(data: LayoutConfig[]) {
|
||||||
@ -100,6 +102,9 @@ export const dashboardStore = defineStore({
|
|||||||
};
|
};
|
||||||
this.layout[idx].children?.push(i);
|
this.layout[idx].children?.push(i);
|
||||||
},
|
},
|
||||||
|
activeGridItem(index: string) {
|
||||||
|
this.activedGridItem = index;
|
||||||
|
},
|
||||||
removeControls(item: LayoutConfig) {
|
removeControls(item: LayoutConfig) {
|
||||||
this.layout = this.layout.filter((d: LayoutConfig) => d.i !== item.i);
|
this.layout = this.layout.filter((d: LayoutConfig) => d.i !== item.i);
|
||||||
},
|
},
|
||||||
@ -113,7 +118,7 @@ export const dashboardStore = defineStore({
|
|||||||
this.showConfig = show;
|
this.showConfig = show;
|
||||||
},
|
},
|
||||||
selectWidget(widget: Nullable<LayoutConfig>) {
|
selectWidget(widget: Nullable<LayoutConfig>) {
|
||||||
this.selectedWidget = ConfigData || widget; //todo
|
this.selectedGrid = ConfigData || widget; //todo
|
||||||
},
|
},
|
||||||
setLayer(id: string) {
|
setLayer(id: string) {
|
||||||
this.layerId = id;
|
this.layerId = id;
|
||||||
|
@ -67,7 +67,7 @@ limitations under the License. -->
|
|||||||
<el-collapse-item :title="t('graphStyles')" name="3">
|
<el-collapse-item :title="t('graphStyles')" name="3">
|
||||||
<component
|
<component
|
||||||
:is="`${chartType}Config`"
|
:is="`${chartType}Config`"
|
||||||
:config="dashboardStore.selectedWidget.graph"
|
:config="dashboardStore.selectedGrid.graph"
|
||||||
/>
|
/>
|
||||||
</el-collapse-item>
|
</el-collapse-item>
|
||||||
<el-collapse-item :title="t('widgetOptions')" name="4">
|
<el-collapse-item :title="t('widgetOptions')" name="4">
|
||||||
@ -118,7 +118,7 @@ export default defineComponent({
|
|||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
const appStoreWithOut = useAppStoreWithOut();
|
const appStoreWithOut = useAppStoreWithOut();
|
||||||
const { loading } = Loading();
|
const { loading } = Loading();
|
||||||
const { selectedWidget } = dashboardStore;
|
const { selectedGrid } = dashboardStore;
|
||||||
const states = reactive<{
|
const states = reactive<{
|
||||||
metrics: string[];
|
metrics: string[];
|
||||||
valueTypes: Option[];
|
valueTypes: Option[];
|
||||||
@ -129,14 +129,14 @@ export default defineComponent({
|
|||||||
source: any;
|
source: any;
|
||||||
index: string;
|
index: string;
|
||||||
}>({
|
}>({
|
||||||
metrics: selectedWidget.metrics || [],
|
metrics: selectedGrid.metrics || [],
|
||||||
valueTypes: [],
|
valueTypes: [],
|
||||||
valueType: "",
|
valueType: "",
|
||||||
metricQueryType: "",
|
metricQueryType: "",
|
||||||
chartType: selectedWidget.graph.type,
|
chartType: selectedGrid.graph.type,
|
||||||
activeNames: "1",
|
activeNames: "1",
|
||||||
source: {},
|
source: {},
|
||||||
index: selectedWidget.i,
|
index: selectedGrid.i,
|
||||||
});
|
});
|
||||||
const widgetOpt = reactive<
|
const widgetOpt = reactive<
|
||||||
| {
|
| {
|
||||||
@ -145,8 +145,8 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
| any
|
| any
|
||||||
>({
|
>({
|
||||||
tips: selectedWidget.widget.tips,
|
tips: selectedGrid.widget.tips,
|
||||||
title: selectedWidget.widget.title,
|
title: selectedGrid.widget.title,
|
||||||
});
|
});
|
||||||
queryMetricType(states.metrics[0]);
|
queryMetricType(states.metrics[0]);
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
async function queryMetrics() {
|
async function queryMetrics() {
|
||||||
const json = await dashboardStore.fetchMetricValue(
|
const json = await dashboardStore.fetchMetricValue(
|
||||||
dashboardStore.selectedWidget
|
dashboardStore.selectedGrid
|
||||||
);
|
);
|
||||||
|
|
||||||
if (json.error) {
|
if (json.error) {
|
||||||
@ -215,8 +215,8 @@ export default defineComponent({
|
|||||||
(d: { value: number }, index: number) => d.value + index // todo
|
(d: { value: number }, index: number) => d.value + index // todo
|
||||||
);
|
);
|
||||||
const m =
|
const m =
|
||||||
dashboardStore.selectedWidget.metrics &&
|
dashboardStore.selectedGrid.metrics &&
|
||||||
dashboardStore.selectedWidget.metrics[0];
|
dashboardStore.selectedGrid.metrics[0];
|
||||||
if (!m) {
|
if (!m) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -229,20 +229,20 @@ export default defineComponent({
|
|||||||
|
|
||||||
function applyConfig() {
|
function applyConfig() {
|
||||||
const opts = {
|
const opts = {
|
||||||
...dashboardStore.selectedWidget,
|
...dashboardStore.selectedGrid,
|
||||||
metrics: states.metrics,
|
metrics: states.metrics,
|
||||||
queryMetricType: states.valueType,
|
queryMetricType: states.valueType,
|
||||||
chart: states.chartType,
|
chart: states.chartType,
|
||||||
widget: {
|
widget: {
|
||||||
...dashboardStore.selectedWidget.widget,
|
...dashboardStore.selectedGrid.widget,
|
||||||
title: widgetOpt.title,
|
title: widgetOpt.title,
|
||||||
tips: widgetOpt.tips,
|
tips: widgetOpt.tips,
|
||||||
},
|
},
|
||||||
graph: {
|
graph: {
|
||||||
...dashboardStore.selectedWidget.graph,
|
...dashboardStore.selectedGrid.graph,
|
||||||
},
|
},
|
||||||
standard: {
|
standard: {
|
||||||
...dashboardStore.selectedWidget.standard,
|
...dashboardStore.selectedGrid.standard,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
dashboardStore.setConfigs(opts);
|
dashboardStore.setConfigs(opts);
|
||||||
|
@ -31,7 +31,7 @@ limitations under the License. -->
|
|||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span class="add-Item" @click="addTabItem">
|
<span class="add-Item" @click="addTabItem">
|
||||||
<Icon size="sm" iconName="add" />
|
<Icon size="middle" iconName="add" />
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="operations">
|
<div class="operations">
|
||||||
@ -71,6 +71,7 @@ const props = defineProps({
|
|||||||
type: Object as PropType<{ type: string; children: any[] }>,
|
type: Object as PropType<{ type: string; children: any[] }>,
|
||||||
default: () => ({ children: [] }),
|
default: () => ({ children: [] }),
|
||||||
},
|
},
|
||||||
|
active: { type: Boolean, default: false },
|
||||||
});
|
});
|
||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
const state = reactive<{ layout: any[]; activeTab: number }>({
|
const state = reactive<{ layout: any[]; activeTab: number }>({
|
||||||
|
@ -51,6 +51,7 @@ const props = {
|
|||||||
type: Object as PropType<LayoutConfig>,
|
type: Object as PropType<LayoutConfig>,
|
||||||
default: () => ({ widget: {} }),
|
default: () => ({ widget: {} }),
|
||||||
},
|
},
|
||||||
|
active: { type: Boolean, default: false },
|
||||||
};
|
};
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "Widget",
|
name: "Widget",
|
||||||
@ -73,6 +74,9 @@ export default defineComponent({
|
|||||||
const json = await dashboardStore.fetchMetricValue(props.data);
|
const json = await dashboardStore.fetchMetricValue(props.data);
|
||||||
|
|
||||||
loadingInstance.close();
|
loadingInstance.close();
|
||||||
|
if (!json) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (json.error) {
|
if (json.error) {
|
||||||
ElMessage.error(json.error);
|
ElMessage.error(json.error);
|
||||||
return;
|
return;
|
||||||
@ -90,11 +94,11 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function removeWidget() {
|
function removeWidget() {
|
||||||
dashboardStore.removeControls(data);
|
dashboardStore.removeControls(props.data);
|
||||||
}
|
}
|
||||||
function setConfig() {
|
function setConfig() {
|
||||||
dashboardStore.setConfigPanel(true);
|
dashboardStore.setConfigPanel(true);
|
||||||
dashboardStore.selectWidget(data);
|
dashboardStore.selectWidget(props.data);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
state,
|
state,
|
||||||
|
@ -29,8 +29,14 @@ limitations under the License. -->
|
|||||||
:h="item.h"
|
:h="item.h"
|
||||||
:i="item.i"
|
:i="item.i"
|
||||||
:key="item.i"
|
:key="item.i"
|
||||||
|
@click="clickGrid(item)"
|
||||||
|
:class="{ active: dashboardStore.activedGridItem === item.i }"
|
||||||
>
|
>
|
||||||
<component :is="item.type" :data="item" />
|
<component
|
||||||
|
:is="item.type"
|
||||||
|
:data="item"
|
||||||
|
:active="dashboardStore.activedGridItem === item.i"
|
||||||
|
/>
|
||||||
</grid-item>
|
</grid-item>
|
||||||
</grid-layout>
|
</grid-layout>
|
||||||
</template>
|
</template>
|
||||||
@ -45,12 +51,16 @@ export default defineComponent({
|
|||||||
components: { Widget, Tab },
|
components: { Widget, Tab },
|
||||||
setup() {
|
setup() {
|
||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
function layoutUpdatedEvent(newLayout: LayoutConfig) {
|
function layoutUpdatedEvent(newLayout: LayoutConfig[]) {
|
||||||
dashboardStore.setLayout(newLayout);
|
dashboardStore.setLayout(newLayout);
|
||||||
}
|
}
|
||||||
|
function clickGrid(item: LayoutConfig) {
|
||||||
|
dashboardStore.activeGridItem(item.i);
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
dashboardStore,
|
dashboardStore,
|
||||||
layoutUpdatedEvent,
|
layoutUpdatedEvent,
|
||||||
|
clickGrid,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -66,4 +76,8 @@ export default defineComponent({
|
|||||||
box-shadow: 0px 1px 4px 0px #00000029;
|
box-shadow: 0px 1px 4px 0px #00000029;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.vue-grid-item.active {
|
||||||
|
border: 1px solid #409eff;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user