mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-02 09:34:04 +00:00
fix: calculate widget index and init metrics config (#41)
This commit is contained in:
parent
d733594804
commit
2167b4afd5
@ -76,9 +76,10 @@ export const dashboardStore = defineStore({
|
|||||||
this.currentDashboard = item;
|
this.currentDashboard = item;
|
||||||
},
|
},
|
||||||
addControl(type: string) {
|
addControl(type: string) {
|
||||||
|
const arr = this.layout.map((d: any) => Number(d.i));
|
||||||
const newItem: LayoutConfig = {
|
const newItem: LayoutConfig = {
|
||||||
...NewControl,
|
...NewControl,
|
||||||
i: String(this.layout.length),
|
i: String(Math.max(...arr) + 1),
|
||||||
type,
|
type,
|
||||||
metricTypes: [""],
|
metricTypes: [""],
|
||||||
metrics: [""],
|
metrics: [""],
|
||||||
@ -146,9 +147,10 @@ export const dashboardStore = defineStore({
|
|||||||
}
|
}
|
||||||
const tabIndex = this.layout[idx].activedTabIndex || 0;
|
const tabIndex = this.layout[idx].activedTabIndex || 0;
|
||||||
const { children } = this.layout[idx].children[tabIndex];
|
const { children } = this.layout[idx].children[tabIndex];
|
||||||
|
const arr = children.map((d: any) => Number(d.i));
|
||||||
const newItem: LayoutConfig = {
|
const newItem: LayoutConfig = {
|
||||||
...NewControl,
|
...NewControl,
|
||||||
i: String(children.length),
|
i: String(Math.max(...arr) + 1),
|
||||||
type,
|
type,
|
||||||
metricTypes: [""],
|
metricTypes: [""],
|
||||||
metrics: [""],
|
metrics: [""],
|
||||||
|
@ -17,9 +17,6 @@ limitations under the License. -->
|
|||||||
<div class="graph" v-loading="loading">
|
<div class="graph" v-loading="loading">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<span>{{ dashboardStore.selectedGrid.widget.title }}</span>
|
<span>{{ dashboardStore.selectedGrid.widget.title }}</span>
|
||||||
<span v-show="dashboardStore.selectedGrid.standard.unit" class="unit">
|
|
||||||
({{ dashboardStore.selectedGrid.standard.unit }})
|
|
||||||
</span>
|
|
||||||
<div class="tips" v-show="dashboardStore.selectedGrid.widget.tips">
|
<div class="tips" v-show="dashboardStore.selectedGrid.widget.tips">
|
||||||
<el-tooltip :content="dashboardStore.selectedGrid.widget.tips">
|
<el-tooltip :content="dashboardStore.selectedGrid.widget.tips">
|
||||||
<Icon iconName="info_outline" size="sm" />
|
<Icon iconName="info_outline" size="sm" />
|
||||||
|
@ -159,8 +159,8 @@ states.visTypes = setVisTypes();
|
|||||||
setDashboards();
|
setDashboards();
|
||||||
setMetricType();
|
setMetricType();
|
||||||
|
|
||||||
async function setMetricType() {
|
async function setMetricType(chart?: any) {
|
||||||
const { graph } = dashboardStore.selectedGrid;
|
const graph = chart || dashboardStore.selectedGrid.graph;
|
||||||
const json = await dashboardStore.fetchMetricList();
|
const json = await dashboardStore.fetchMetricList();
|
||||||
if (json.errors) {
|
if (json.errors) {
|
||||||
ElMessage.error(json.errors);
|
ElMessage.error(json.errors);
|
||||||
@ -203,6 +203,7 @@ async function setMetricType() {
|
|||||||
...dashboardStore.selectedGrid,
|
...dashboardStore.selectedGrid,
|
||||||
metrics: states.metrics,
|
metrics: states.metrics,
|
||||||
metricTypes: states.metricTypes,
|
metricTypes: states.metricTypes,
|
||||||
|
graph,
|
||||||
});
|
});
|
||||||
states.metricTypeList = [];
|
states.metricTypeList = [];
|
||||||
for (const metric of metrics) {
|
for (const metric of metrics) {
|
||||||
@ -266,7 +267,6 @@ function setVisTypes() {
|
|||||||
|
|
||||||
function changeChartType(item: Option) {
|
function changeChartType(item: Option) {
|
||||||
const graph = DefaultGraphConfig[item.value];
|
const graph = DefaultGraphConfig[item.value];
|
||||||
dashboardStore.selectWidget({ ...dashboardStore.selectedGrid, graph });
|
|
||||||
states.isList = ListChartTypes.includes(graph.type);
|
states.isList = ListChartTypes.includes(graph.type);
|
||||||
if (states.isList) {
|
if (states.isList) {
|
||||||
dashboardStore.selectWidget({
|
dashboardStore.selectWidget({
|
||||||
@ -278,7 +278,7 @@ function changeChartType(item: Option) {
|
|||||||
states.metricTypes = [""];
|
states.metricTypes = [""];
|
||||||
defaultLen.value = 5;
|
defaultLen.value = 5;
|
||||||
}
|
}
|
||||||
setMetricType();
|
setMetricType(graph);
|
||||||
setDashboards();
|
setDashboards();
|
||||||
states.dashboardName = "";
|
states.dashboardName = "";
|
||||||
defaultLen.value = 10;
|
defaultLen.value = 10;
|
||||||
|
@ -71,7 +71,7 @@ limitations under the License. -->
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from "vue";
|
import { ref, watch } from "vue";
|
||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { SortOrder, CalculationOpts } from "../../../data";
|
import { SortOrder, CalculationOpts } from "../../../data";
|
||||||
@ -104,6 +104,12 @@ function changeConfigs(index: number, param: { [key: string]: string }) {
|
|||||||
});
|
});
|
||||||
emit("update");
|
emit("update");
|
||||||
}
|
}
|
||||||
|
watch(
|
||||||
|
() => props.currentMetricConfig,
|
||||||
|
() => {
|
||||||
|
currentMetric.value = props.currentMetricConfig;
|
||||||
|
}
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.config-panel {
|
.config-panel {
|
||||||
|
@ -19,9 +19,6 @@ limitations under the License. -->
|
|||||||
<span>
|
<span>
|
||||||
{{ data.widget?.title || "" }}
|
{{ data.widget?.title || "" }}
|
||||||
</span>
|
</span>
|
||||||
<span class="unit" v-show="data.standard?.unit">
|
|
||||||
({{ data.standard?.unit }})
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<el-tooltip :content="data.widget?.tips">
|
<el-tooltip :content="data.widget?.tips">
|
||||||
|
@ -67,7 +67,7 @@ export const DefaultGraphConfig: { [key: string]: any } = {
|
|||||||
type: "Card",
|
type: "Card",
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
showUint: true,
|
showUnit: true,
|
||||||
},
|
},
|
||||||
Table: {
|
Table: {
|
||||||
type: "Table",
|
type: "Table",
|
||||||
|
Loading…
Reference in New Issue
Block a user