Add the query button on Alerting page (#501)

This commit is contained in:
Fine0830
2025-09-30 10:41:06 +08:00
committed by GitHub
parent a834cdb2eb
commit 4f95dd9807
3 changed files with 21 additions and 11 deletions

View File

@@ -28,7 +28,7 @@ limitations under the License. -->
</div> </div>
<div class="mr-10 ml-10"> <div class="mr-10 ml-10">
<span class="grey">{{ t("searchKeyword") }}: </span> <span class="grey">{{ t("searchKeyword") }}: </span>
<el-input size="small" v-model="keyword" class="alarm-tool-input" @change="refreshAlarms({ pageNum: 1 })" /> <el-input size="small" v-model="keyword" class="alarm-tool-input" />
</div> </div>
<div> <div>
<span class="sm b grey mr-5">{{ t("timeRange") }}:</span> <span class="sm b grey mr-5">{{ t("timeRange") }}:</span>
@@ -57,7 +57,12 @@ limitations under the License. -->
/> />
</div> </div>
</div> </div>
<ConditionTags :type="'ALARM'" @update="(data) => refreshAlarms({ pageNum: 1, tagsMap: data.tagsMap })" /> <div class="flex-h mt-5" style="justify-content: space-between">
<ConditionTags :type="'ALARM'" @update="(data) => changeTags(data.tagsMap)" />
<el-button size="small" type="primary" @click="refreshAlarms({ pageNum: 1 })">
{{ t("runQuery") }}
</el-button>
</div>
</nav> </nav>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@@ -72,7 +77,7 @@ limitations under the License. -->
import timeFormat from "@/utils/timeFormat"; import timeFormat from "@/utils/timeFormat";
import type { DurationTime, Duration } from "@/types/app"; import type { DurationTime, Duration } from "@/types/app";
import { Themes } from "@/constants/data"; import { Themes } from "@/constants/data";
/*global Recordable */ /*global Indexable */
const appStore = useAppStoreWithOut(); const appStore = useAppStoreWithOut();
const alarmStore = useAlarmStore(); const alarmStore = useAlarmStore();
const { t } = useI18n(); const { t } = useI18n();
@@ -83,6 +88,8 @@ limitations under the License. -->
const pageNum = ref<number>(1); const pageNum = ref<number>(1);
const duration = ref<DurationTime>(getDurationTime()); const duration = ref<DurationTime>(getDurationTime());
const durationRow = ref<Duration>(InitializationDurationRow); const durationRow = ref<Duration>(InitializationDurationRow);
const tagsMap = ref<{ key: string; value: string }[]>();
const total = computed(() => const total = computed(() =>
alarmStore.alarms.length === pageSize ? pageSize * pageNum.value + 1 : pageSize * pageNum.value, alarmStore.alarms.length === pageSize ? pageSize * pageNum.value + 1 : pageSize * pageNum.value,
); );
@@ -92,14 +99,14 @@ limitations under the License. -->
refreshAlarms({ pageNum: 1 }); refreshAlarms({ pageNum: 1 });
async function refreshAlarms(param: { pageNum: number; tagsMap?: Recordable }) { async function refreshAlarms(param: { pageNum: number }) {
const params: Recordable = { const params: Indexable = {
duration: duration.value, duration: duration.value,
paging: { paging: {
pageNum: param.pageNum, pageNum: param.pageNum,
pageSize, pageSize,
}, },
tags: param.tagsMap, tags: tagsMap.value,
}; };
params.scope = entity.value || undefined; params.scope = entity.value || undefined;
params.keyword = keyword.value || undefined; params.keyword = keyword.value || undefined;
@@ -114,12 +121,10 @@ limitations under the License. -->
durationRow.value = timeFormat(val); durationRow.value = timeFormat(val);
setDurationRow(durationRow.value); setDurationRow(durationRow.value);
duration.value = getDurationTime(); duration.value = getDurationTime();
refreshAlarms({ pageNum: 1 });
} }
function changeEntity(param: { value: string }[]) { function changeEntity(param: { value: string }[]) {
entity.value = param[0].value; entity.value = param[0].value;
refreshAlarms({ pageNum: 1 });
} }
function changePage(p: number) { function changePage(p: number) {
@@ -127,6 +132,10 @@ limitations under the License. -->
refreshAlarms({ pageNum: p }); refreshAlarms({ pageNum: p });
} }
function changeTags(tags?: { key: string; value: string }[]) {
tagsMap.value = tags || undefined;
}
watch( watch(
() => appStore.coldStageMode, () => appStore.coldStageMode,
() => { () => {

View File

@@ -64,7 +64,7 @@ limitations under the License. -->
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { useAppStoreWithOut } from "@/store/modules/app"; import { useAppStoreWithOut } from "@/store/modules/app";
/*global defineEmits, defineProps, Recordable */ /*global defineEmits, defineProps, Indexable */
const emit = defineEmits(["update"]); const emit = defineEmits(["update"]);
const props = defineProps({ const props = defineProps({
type: { type: String, default: "TRACE" }, type: { type: String, default: "TRACE" },
@@ -112,7 +112,7 @@ limitations under the License. -->
emit("update", { tagsMap, tagsList: tagsList.value }); emit("update", { tagsMap, tagsList: tagsList.value });
} }
async function fetchTagKeys() { async function fetchTagKeys() {
let resp: Recordable = {}; let resp: Indexable = {};
if (props.type === "TRACE") { if (props.type === "TRACE") {
resp = await traceStore.getTagKeys(); resp = await traceStore.getTagKeys();
} }
@@ -139,7 +139,7 @@ limitations under the License. -->
async function fetchTagValues() { async function fetchTagValues() {
const param = tags.value.split("=")[0]; const param = tags.value.split("=")[0];
let resp: Recordable = {}; let resp: Indexable = {};
if (props.type === "TRACE") { if (props.type === "TRACE") {
resp = await traceStore.getTagValues(param); resp = await traceStore.getTagValues(param);
} }

View File

@@ -148,6 +148,7 @@ limitations under the License. -->
const timestamp = new Date().toISOString().replace(/[:.]/g, "-"); const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
const baseFilename = `trace-${trace.traceId}-${timestamp}`; const baseFilename = `trace-${trace.traceId}-${timestamp}`;
const spans = trace.spans.map((span) => { const spans = trace.spans.map((span) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { duration, label, ...newSpan } = span; const { duration, label, ...newSpan } = span;
return newSpan; return newSpan;
}); });