change logs

This commit is contained in:
Fine 2025-05-15 16:31:20 +08:00
parent 52d3b7d4b7
commit e584b848b3
4 changed files with 40 additions and 20 deletions

View File

@ -21,6 +21,7 @@ import graphql from "@/graphql";
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 { useDashboardStore } from "@/store/modules/dashboard"; import { useDashboardStore } from "@/store/modules/dashboard";
import { useDuration } from "@/hooks/useDuration";
import { EndpointsTopNDefault } from "../data"; import { EndpointsTopNDefault } from "../data";
interface LogState { interface LogState {
@ -33,6 +34,7 @@ interface LogState {
logs: Recordable[]; logs: Recordable[];
loadLogs: boolean; loadLogs: boolean;
} }
const { getDurationTime } = useDuration();
export const logStore = defineStore({ export const logStore = defineStore({
id: "log", id: "log",
@ -41,7 +43,7 @@ export const logStore = defineStore({
instances: [{ value: "0", label: "All" }], instances: [{ value: "0", label: "All" }],
endpoints: [{ value: "0", label: "All" }], endpoints: [{ value: "0", label: "All" }],
conditions: { conditions: {
queryDuration: useAppStoreWithOut().durationTime, queryDuration: getDurationTime(),
paging: { pageNum: 1, pageSize: 15 }, paging: { pageNum: 1, pageSize: 15 },
}, },
supportQueryLogsByKeywords: true, supportQueryLogsByKeywords: true,
@ -56,7 +58,7 @@ export const logStore = defineStore({
resetState() { resetState() {
this.logs = []; this.logs = [];
this.conditions = { this.conditions = {
queryDuration: useAppStoreWithOut().durationTime, queryDuration: getDurationTime(),
paging: { pageNum: 1, pageSize: 15 }, paging: { pageNum: 1, pageSize: 15 },
}; };
}, },

View File

@ -60,10 +60,7 @@ export type Filters = {
dataIndex: number; dataIndex: number;
sourceId: string; sourceId: string;
isRange?: boolean; isRange?: boolean;
duration?: { duration?: DurationTime;
startTime: string;
endTime: string;
};
traceId?: string; traceId?: string;
spanId?: string; spanId?: string;
segmentId?: string; segmentId?: string;

View File

@ -56,6 +56,16 @@ limitations under the License. -->
@change="changeField('category', $event)" @change="changeField('category', $event)"
/> />
</div> </div>
<div>
<span class="sm b grey mr-5">{{ t("timeRange") }}:</span>
<TimePicker
:value="[durationRow.start, durationRow.end]"
:maxRange="maxRange"
position="bottom"
format="YYYY-MM-DD HH:mm"
@input="changeDuration"
/>
</div>
<el-button class="search-btn" size="small" type="primary" @click="searchLogs"> <el-button class="search-btn" size="small" type="primary" @click="searchLogs">
{{ t("search") }} {{ t("search") }}
</el-button> </el-button>
@ -119,20 +129,21 @@ limitations under the License. -->
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, reactive, watch, onUnmounted } from "vue"; import { ref, reactive, watch, onUnmounted, computed } from "vue";
import type { PropType } from "vue"; import type { PropType } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import type { Option } from "@/types/app"; import { ElMessage } from "element-plus";
import { useLogStore } from "@/store/modules/log"; import { useLogStore } from "@/store/modules/log";
import { useDashboardStore } from "@/store/modules/dashboard"; import { useDashboardStore } from "@/store/modules/dashboard";
import { useAppStoreWithOut } from "@/store/modules/app"; import { useAppStoreWithOut, InitializationDurationRow } from "@/store/modules/app";
import { useSelectorStore } from "@/store/modules/selectors"; import { useSelectorStore } from "@/store/modules/selectors";
import { useDuration } from "@/hooks/useDuration";
import ConditionTags from "@/views/components/ConditionTags.vue"; import ConditionTags from "@/views/components/ConditionTags.vue";
import { ElMessage } from "element-plus"; import timeFormat from "@/utils/timeFormat";
import { EntityType } from "../../data"; import { EntityType } from "../../data";
import { ErrorCategory } from "./data"; import { ErrorCategory } from "./data";
import type { LayoutConfig } from "@/types/dashboard"; import type { LayoutConfig } from "@/types/dashboard";
import type { DurationTime } from "@/types/app"; import type { Option, DurationTime, Duration } from "@/types/app";
/*global defineProps, Recordable */ /*global defineProps, Recordable */
const props = defineProps({ const props = defineProps({
@ -147,8 +158,9 @@ limitations under the License. -->
const selectorStore = useSelectorStore(); const selectorStore = useSelectorStore();
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
const logStore = useLogStore(); const logStore = useLogStore();
const { setDurationRow, getDurationTime, getMaxRange } = useDuration();
const traceId = ref<string>((props.data.filters && props.data.filters.traceId) || ""); const traceId = ref<string>((props.data.filters && props.data.filters.traceId) || "");
const duration = ref<DurationTime>((props.data.filters && props.data.filters.duration) || appStore.durationTime); const duration = ref<DurationTime>((props.data.filters && props.data.filters.duration) || getDurationTime());
const keywordsOfContent = ref<string[]>([]); const keywordsOfContent = ref<string[]>([]);
const excludingKeywordsOfContent = ref<string[]>([]); const excludingKeywordsOfContent = ref<string[]>([]);
const tagsList = ref<string[]>([]); const tagsList = ref<string[]>([]);
@ -156,12 +168,16 @@ limitations under the License. -->
const contentStr = ref<string>(""); const contentStr = ref<string>("");
const excludingContentStr = ref<string>(""); const excludingContentStr = ref<string>("");
const isBrowser = ref<boolean>(dashboardStore.layerId === "BROWSER"); const isBrowser = ref<boolean>(dashboardStore.layerId === "BROWSER");
const durationRow = ref<Duration>(InitializationDurationRow);
const state = reactive<Recordable>({ const state = reactive<Recordable>({
instance: { value: "0", label: "All" }, instance: { value: "0", label: "All" },
endpoint: { value: "0", label: "All" }, endpoint: { value: "0", label: "All" },
service: { value: "", label: "" }, service: { value: "", label: "" },
category: { value: "ALL", label: "All" }, category: { value: "ALL", label: "All" },
}); });
const maxRange = computed(() =>
getMaxRange(appStore.coldStageMode ? appStore.recordsTTL.coldSuperDataset : appStore.recordsTTL.superDataset),
);
if (props.needQuery) { if (props.needQuery) {
init(); init();
} }
@ -275,6 +291,11 @@ limitations under the License. -->
ElMessage.error(res.errors); ElMessage.error(res.errors);
} }
} }
function changeDuration(val: Date[]) {
durationRow.value = timeFormat(val);
setDurationRow(durationRow.value);
duration.value = getDurationTime();
}
function changeField(type: string, opt: any) { function changeField(type: string, opt: any) {
state[type] = opt[0]; state[type] = opt[0];
if (type === "service") { if (type === "service") {
@ -352,12 +373,12 @@ limitations under the License. -->
}, },
); );
watch( watch(
() => appStore.durationTime, () => appStore.coldStageMode,
() => { () => {
duration.value = appStore.durationTime; durationRow.value = InitializationDurationRow;
if (dashboardStore.entity === EntityType[1].value) { setDurationRow(durationRow.value);
init(); duration.value = getDurationTime();
} init();
}, },
); );
watch( watch(
@ -368,7 +389,7 @@ limitations under the License. -->
return; return;
} }
traceId.value = props.data.filters.traceId || ""; traceId.value = props.data.filters.traceId || "";
duration.value = props.data.filters.duration || appStore.durationTime; duration.value = props.data.filters.duration || getDurationTime();
init(); init();
} }
}, },

View File

@ -119,7 +119,7 @@ limitations under the License. -->
const { setDurationRow, getDurationTime, getMaxRange } = useDuration(); const { setDurationRow, getDurationTime, getMaxRange } = useDuration();
const filters = reactive<Recordable>(props.data.filters || {}); const filters = reactive<Recordable>(props.data.filters || {});
const traceId = ref<string>(filters.traceId || ""); const traceId = ref<string>(filters.traceId || "");
const duration = ref<DurationTime>(filters.duration || appStore.durationTime); const duration = ref<DurationTime>(filters.duration || getDurationTime());
const minTraceDuration = ref<number>(); const minTraceDuration = ref<number>();
const maxTraceDuration = ref<number>(); const maxTraceDuration = ref<number>();
const tagsList = ref<string[]>([]); const tagsList = ref<string[]>([]);
@ -321,7 +321,7 @@ limitations under the License. -->
return; return;
} }
traceId.value = props.data.filters.traceId || ""; traceId.value = props.data.filters.traceId || "";
duration.value = props.data.filters.duration || appStore.durationTime; duration.value = props.data.filters.duration || getDurationTime();
init(); init();
}, },
); );