add time picker

This commit is contained in:
Fine 2025-05-12 16:21:43 +08:00
parent f0e0156f7c
commit 16094885b0
4 changed files with 39 additions and 3 deletions

View File

@ -50,7 +50,7 @@ limitations under the License. -->
<span> UTC{{ appStore.utcHour >= 0 ? "+" : "" }}{{ `${appStore.utcHour}:${appStore.utcMin}` }} </span> <span> UTC{{ appStore.utcHour >= 0 ? "+" : "" }}{{ `${appStore.utcHour}:${appStore.utcMin}` }} </span>
<span class="ml-5"> <span class="ml-5">
<el-switch <el-switch
v-model="dataMode" v-model="coldStage"
inline-prompt inline-prompt
active-text="Set data to cold" active-text="Set data to cold"
inactive-text="Set data to warm" inactive-text="Set data to warm"
@ -105,7 +105,7 @@ limitations under the License. -->
const pageTitle = ref<string>(""); const pageTitle = ref<string>("");
const theme = ref<boolean>(true); const theme = ref<boolean>(true);
const themeSwitchRef = ref<HTMLElement>(); const themeSwitchRef = ref<HTMLElement>();
const dataMode = ref<boolean>(false); const coldStage = ref<boolean>(false);
const savedTheme = window.localStorage.getItem("theme-is-dark"); const savedTheme = window.localStorage.getItem("theme-is-dark");
if (savedTheme === "false") { if (savedTheme === "false") {
@ -138,7 +138,8 @@ limitations under the License. -->
} }
function changeDataMode() { function changeDataMode() {
if (dataMode.value) { appStore.setColdStageMode(coldStage.value);
if (coldStage.value) {
// const gap = appStore.duration.end.getTime() - appStore.duration.start.getTime(); // const gap = appStore.duration.end.getTime() - appStore.duration.start.getTime();
// const dates: Date[] = [new Date(new Date().getTime() - gap), new Date()]; // const dates: Date[] = [new Date(new Date().getTime() - gap), new Date()];
// appStore.setDuration(timeFormat(dates)); // appStore.setDuration(timeFormat(dates));

View File

@ -37,6 +37,7 @@ interface AppState {
reloadTimer: Nullable<IntervalHandle>; reloadTimer: Nullable<IntervalHandle>;
allMenus: MenuOptions[]; allMenus: MenuOptions[];
theme: string; theme: string;
coldStageMode: boolean;
} }
export const appStore = defineStore({ export const appStore = defineStore({
@ -58,6 +59,7 @@ export const appStore = defineStore({
reloadTimer: null, reloadTimer: null,
allMenus: [], allMenus: [],
theme: Themes.Dark, theme: Themes.Dark,
coldStageMode: false,
}), }),
getters: { getters: {
duration(): Duration { duration(): Duration {
@ -143,6 +145,9 @@ export const appStore = defineStore({
setAutoRefresh(auto: boolean) { setAutoRefresh(auto: boolean) {
this.autoRefresh = auto; this.autoRefresh = auto;
}, },
setColdStageMode(mode: boolean) {
this.coldStageMode = mode;
},
runEventStack() { runEventStack() {
if (this.timer) { if (this.timer) {
clearTimeout(this.timer); clearTimeout(this.timer);

View File

@ -65,6 +65,15 @@ limitations under the License. -->
<span class="grey mr-5">{{ t("traceID") }}:</span> <span class="grey mr-5">{{ t("traceID") }}:</span>
<el-input size="small" v-model="traceId" class="traceId" /> <el-input size="small" v-model="traceId" class="traceId" />
</div> </div>
<div>
<span class="sm b grey mr-5">{{ t("duration") }}:</span>
<TimePicker
:value="[appStore.durationRow.start, appStore.durationRow.end]"
position="bottom"
format="YYYY-MM-DD HH:mm"
@input="changeTimeRange"
/>
</div>
<div class="mr-10"> <div class="mr-10">
<span class="sm b grey mr-5">{{ t("duration") }}:</span> <span class="sm b grey mr-5">{{ t("duration") }}:</span>
<el-input size="small" class="inputs mr-5" v-model="minTraceDuration" type="number" /> <el-input size="small" class="inputs mr-5" v-model="minTraceDuration" type="number" />
@ -85,6 +94,7 @@ limitations under the License. -->
import { useDashboardStore } from "@/store/modules/dashboard"; import { useDashboardStore } from "@/store/modules/dashboard";
import { useAppStoreWithOut } from "@/store/modules/app"; import { useAppStoreWithOut } from "@/store/modules/app";
import { useSelectorStore } from "@/store/modules/selectors"; import { useSelectorStore } from "@/store/modules/selectors";
import timeFormat from "@/utils/timeFormat";
import ConditionTags from "@/views/components/ConditionTags.vue"; import ConditionTags from "@/views/components/ConditionTags.vue";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { EntityType, QueryOrders, Status } from "../../data"; import { EntityType, QueryOrders, Status } from "../../data";
@ -255,6 +265,9 @@ limitations under the License. -->
ElMessage.error(resp.errors); ElMessage.error(resp.errors);
} }
} }
function changeTimeRange(val: Date[]) {
// duration.value = timeFormat(val);
}
onUnmounted(() => { onUnmounted(() => {
traceStore.resetState(); traceStore.resetState();
const config = props.data; const config = props.data;

View File

@ -31,6 +31,12 @@ limitations under the License. -->
@change="changeLatency" @change="changeLatency"
class="ml-10" class="ml-10"
/> />
<TimePicker
:value="[appStore.durationRow.start, appStore.durationRow.end]"
position="bottom"
format="YYYY-MM-DD HH:mm"
@input="changeTimeRange"
/>
<el-popover trigger="hover" width="250" placement="bottom"> <el-popover trigger="hover" width="250" placement="bottom">
<template #reference> <template #reference>
<div class="cp conditions-popup"> <div class="cp conditions-popup">
@ -82,6 +88,7 @@ limitations under the License. -->
import { useDashboardStore } from "@/store/modules/dashboard"; import { useDashboardStore } from "@/store/modules/dashboard";
import { useAppStoreWithOut } from "@/store/modules/app"; import { useAppStoreWithOut } from "@/store/modules/app";
import { useSelectorStore } from "@/store/modules/selectors"; import { useSelectorStore } from "@/store/modules/selectors";
import timeFormat from "@/utils/timeFormat";
import ConditionTags from "@/views/components/ConditionTags.vue"; import ConditionTags from "@/views/components/ConditionTags.vue";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { EntityType, QueryOrders, Status } from "../../data"; import { EntityType, QueryOrders, Status } from "../../data";
@ -107,6 +114,7 @@ limitations under the License. -->
const selectorStore = useSelectorStore(); const selectorStore = useSelectorStore();
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
const traceStore = useTraceStore(); const traceStore = useTraceStore();
const timeRange = ref<number>(NaN);
const tagsList = ref<string[]>([]); const tagsList = ref<string[]>([]);
const tagsMap = ref<Option[]>([]); const tagsMap = ref<Option[]>([]);
const traceId = ref<string>(filters.refId || ""); const traceId = ref<string>(filters.refId || "");
@ -169,6 +177,15 @@ limitations under the License. -->
} }
await queryTraces(); await queryTraces();
} }
function changeTimeRange(val: Date[]) {
timeRange.value = val[1].getTime() - val[0].getTime() > 60 * 24 * 60 * 60 * 1000 ? 1 : 0;
if (timeRange.value) {
return;
}
appStore.setDuration(timeFormat(val));
}
function changeCondition() { function changeCondition() {
if (conditions.value === "latency") { if (conditions.value === "latency") {
currentLatency.value = filters.latency ? filters.latency[0].data : []; currentLatency.value = filters.latency ? filters.latency[0].data : [];