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", unhealthyExpression: "Unhealthy Expression",
traceDesc: 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.", "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; export default msg;

View File

@ -384,5 +384,6 @@ const msg = {
unhealthyExpression: "Unhealthy Expression", unhealthyExpression: "Unhealthy Expression",
traceDesc: 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.", "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; export default msg;

View File

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

View File

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

View File

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

View File

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