feat: update

This commit is contained in:
Fine 2023-12-11 15:54:17 +08:00
parent 15a7ffa241
commit b8cf8fea4b
2 changed files with 24 additions and 0 deletions

View File

@ -28,12 +28,18 @@ limitations under the License. -->
import { useI18n } from "vue-i18n";
import { ref } 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);
function changeConfig() {
if (!expressions.value.includes("is_present")) {
ElMessage.error("Only support the is_present function");
return;
}
const { selectedGrid } = dashboardStore;
dashboardStore.selectWidget({ ...selectedGrid, expressions: expressions.value });

View File

@ -117,6 +117,7 @@ limitations under the License. -->
import controls from "./tab";
import { dragIgnoreFrom } from "../data";
import copy from "@/utils/copy";
import { useExpressionsQueryProcessor } from "@/hooks/useExpressionsProcessor";
const props = {
data: {
@ -124,6 +125,7 @@ limitations under the License. -->
default: () => ({ children: [] }),
},
active: { type: Boolean, default: false },
needQuery: { type: Boolean, default: false },
};
export default defineComponent({
name: "Tab",
@ -148,6 +150,10 @@ limitations under the License. -->
dashboardStore.setActiveTabIndex(activeTabIndex.value, props.data.i);
}
// if (props.needQuery || !dashboardStore.currentDashboard.id) {
// queryExpressions();
// }
function clickTabs(e: Event, idx: number) {
e.stopPropagation();
activeTabIndex.value = idx;
@ -232,6 +238,18 @@ limitations under the License. -->
dashboardStore.setConfigPanel(true);
dashboardStore.selectWidget(props.data);
}
async function queryExpressions() {
const params = (await useExpressionsQueryProcessor({ metrics: [props.data.expressions] })) || {};
console.log(params);
}
watch(
() => props.data.expressions,
() => {
queryExpressions();
},
);
watch(
() => dashboardStore.activedGridItem,
(data) => {