query logs with trace id

This commit is contained in:
Qiuxia Fan 2022-07-26 17:15:27 +08:00
parent 7ae484671b
commit 19b85285ba
3 changed files with 17 additions and 6 deletions

View File

@ -47,6 +47,7 @@ export interface LayoutConfig {
startTime: string; startTime: string;
endTime: string; endTime: string;
}; };
traceId?: string;
}; };
} }

View File

@ -130,7 +130,7 @@ 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, inject } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { Option } from "@/types/app"; import { Option } from "@/types/app";
import { useLogStore } from "@/store/modules/log"; import { useLogStore } from "@/store/modules/log";
@ -141,8 +141,10 @@ import ConditionTags from "@/views/components/ConditionTags.vue";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { EntityType } from "../../data"; import { EntityType } from "../../data";
import { ErrorCategory } from "./data"; import { ErrorCategory } from "./data";
import { LayoutConfig } from "@/types/dashboard";
/*global defineProps */ /*global defineProps */
const options: LayoutConfig | undefined = inject("options");
const props = defineProps({ const props = defineProps({
needQuery: { type: Boolean, default: true }, needQuery: { type: Boolean, default: true },
}); });
@ -151,7 +153,9 @@ const appStore = useAppStoreWithOut();
const selectorStore = useSelectorStore(); const selectorStore = useSelectorStore();
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
const logStore = useLogStore(); const logStore = useLogStore();
const traceId = ref<string>(""); const traceId = ref<string>(
(options && options.filters && options.filters.traceId) || ""
);
const keywordsOfContent = ref<string[]>([]); const keywordsOfContent = ref<string[]>([]);
const excludingKeywordsOfContent = ref<string[]>([]); const excludingKeywordsOfContent = ref<string[]>([]);
const tagsList = ref<string[]>([]); const tagsList = ref<string[]>([]);
@ -325,6 +329,12 @@ function removeExcludeContent(index: number) {
} }
onUnmounted(() => { onUnmounted(() => {
logStore.resetCondition(); logStore.resetCondition();
const item = {
...options,
filters: undefined,
};
dashboardStore.setWidget(item);
traceId.value = "";
}); });
watch( watch(
() => selectorStore.currentService, () => selectorStore.currentService,

View File

@ -140,8 +140,8 @@ export default defineComponent({
LogTable, LogTable,
}, },
setup() { setup() {
/*global Nullable */ /*global Nullable, Recordable */
const options: LayoutConfig | undefined = inject("options"); const options: Recordable<LayoutConfig> = inject("options") || {};
const { t } = useI18n(); const { t } = useI18n();
const traceStore = useTraceStore(); const traceStore = useTraceStore();
const loading = ref<boolean>(false); const loading = ref<boolean>(false);
@ -189,7 +189,7 @@ export default defineComponent({
}; };
dashboardStore.setWidget(item); dashboardStore.setWidget(item);
const logTabIndex = widget.id.split("-"); const logTabIndex = widget.id.split("-");
const traceTabindex = options?.id?.split("-") || []; const traceTabindex = (options.id as any).split("-") || [];
let container: Nullable<Element>; let container: Nullable<Element>;
if (logTabIndex[1] === undefined) { if (logTabIndex[1] === undefined) {