feat: update config

This commit is contained in:
Fine 2023-12-11 17:18:11 +08:00
parent b8cf8fea4b
commit 57f13f2ac5
6 changed files with 35 additions and 11 deletions

View File

@ -384,5 +384,6 @@ const msg = {
unhealthyExpression: "Unhealthy Expression",
traceDesc:
"The trace segment serves as a representation of a trace portion executed within one single OS process, such as a JVM. It comprises a collection of spans, typically associated with and collected from a single request or execution context.",
tabExpressions: "Tab Expressions",
};
export default msg;

View File

@ -384,5 +384,6 @@ const msg = {
unhealthyExpression: "Unhealthy Expression",
traceDesc:
"The trace segment serves as a representation of a trace portion executed within one single OS process, such as a JVM. It comprises a collection of spans, typically associated with and collected from a single request or execution context.",
tabExpressions: "Tab Expressions",
};
export default msg;

View File

@ -382,5 +382,6 @@ const msg = {
unhealthyExpression: "非健康表达式",
traceDesc:
"Trace Segment代表在单一操作系统进程例如JVM中执行的追踪部分。它包含了一组跨度spans这些跨度通常与单一请求或执行上下文关联。",
tabExpressions: "Tab表达式",
};
export default msg;

View File

@ -36,7 +36,7 @@ export interface LayoutConfig {
expressions?: string[];
metricTypes?: string[];
typesOfMQE?: string[];
children?: { name: string; children: LayoutConfig[] }[];
children?: { name: string; children: LayoutConfig[]; expression?: string }[];
activedTabIndex?: number;
metricConfig?: MetricConfigOpt[];
id?: string;

View File

@ -12,8 +12,11 @@ See the License for the specific language governing permissions and
limitations under the License. -->
<template>
<div class="item">
<span class="label">{{ t("expressions") }}</span>
<el-input class="input" v-model="expressions" size="small" @change="changeConfig" />
<span class="label">{{ t("tabExpressions") }}</span>
<div class="mt-10" v-for="(child, index) in dashboardStore.selectedGrid.children || []" :key="index">
<span class="name">{{ child.name }}</span>
<el-input class="input" size="small" v-model="expressions[child.name]" @change="changeExpression(child.name)" />
</div>
</div>
<div class="footer">
<el-button size="small" @click="cancelConfig">
@ -26,23 +29,31 @@ limitations under the License. -->
</template>
<script lang="ts" setup>
import { useI18n } from "vue-i18n";
import { ref } from "vue";
import { reactive } from "vue";
import { useDashboardStore } from "@/store/modules/dashboard";
import { ElMessage } from "element-plus";
const { t } = useI18n();
const dashboardStore = useDashboardStore();
const originConfig = dashboardStore.selectedGrid;
const expressions = ref<string>(originConfig.expressions);
const expressions = reactive<{ [key: string]: string }>({});
function changeConfig() {
if (!expressions.value.includes("is_present")) {
for (const child of originConfig.children || []) {
expressions[child.name] = child.expression || "";
}
function changeExpression(name: string) {
if (!expressions[name].includes("is_present")) {
ElMessage.error("Only support the is_present function");
return;
}
const { selectedGrid } = dashboardStore;
const children = dashboardStore.selectedGrid.children || [];
dashboardStore.selectWidget({ ...selectedGrid, expressions: expressions.value });
for (const item of children) {
if (item.name === name) {
item.expression = expressions[name];
}
}
dashboardStore.selectWidget({ ...dashboardStore.selectedGrid, children });
}
function applyConfig() {
dashboardStore.setConfigPanel(false);
@ -80,4 +91,9 @@ limitations under the License. -->
width: 100%;
background-color: $theme-background;
}
.name {
width: 180px;
display: inline-block;
}
</style>

View File

@ -149,6 +149,7 @@ limitations under the License. -->
dashboardStore.setCurrentTabItems(dashboardStore.layout[l].children[activeTabIndex.value].children);
dashboardStore.setActiveTabIndex(activeTabIndex.value, props.data.i);
}
console.log(props.data);
// if (props.needQuery || !dashboardStore.currentDashboard.id) {
// queryExpressions();
@ -240,12 +241,16 @@ limitations under the License. -->
}
async function queryExpressions() {
const params = (await useExpressionsQueryProcessor({ metrics: [props.data.expressions] })) || {};
const metrics = [];
for (const child of props.data.children || []) {
child.expression && metrics.push(child.expression);
}
const params = (await useExpressionsQueryProcessor({ metrics })) || {};
console.log(params);
}
watch(
() => props.data.expressions,
() => (props.data.children || []).map((d: { name: string }) => d.name),
() => {
queryExpressions();
},