update data

This commit is contained in:
Qiuxia Fan 2022-07-27 15:08:47 +08:00
parent d9eccf1d7c
commit 118c678667
4 changed files with 53 additions and 18 deletions

View File

@ -30,7 +30,7 @@ limitations under the License. -->
</div> </div>
</el-popover> </el-popover>
<div class="header"> <div class="header">
<Header :needQuery="needQuery" /> <Header :needQuery="needQuery" :data="data" />
</div> </div>
<div class="log"> <div class="log">
<List /> <List />
@ -43,12 +43,14 @@ import { useI18n } from "vue-i18n";
import { useDashboardStore } from "@/store/modules/dashboard"; import { useDashboardStore } from "@/store/modules/dashboard";
import Header from "../related/log/Header.vue"; import Header from "../related/log/Header.vue";
import List from "../related/log/List.vue"; import List from "../related/log/List.vue";
import { LayoutConfig } from "@/types/dashboard";
import type { PropType } from "vue";
/*global defineProps */ /*global defineProps */
const props = defineProps({ const props = defineProps({
data: { data: {
type: Object, type: Object as PropType<LayoutConfig>,
default: () => ({}), default: () => ({ graph: {} }),
}, },
activeIndex: { type: String, default: "" }, activeIndex: { type: String, default: "" },
needQuery: { type: Boolean, default: true }, needQuery: { type: Boolean, default: true },

View File

@ -30,7 +30,7 @@ limitations under the License. -->
</div> </div>
</el-popover> </el-popover>
<div class="header"> <div class="header">
<Filter :needQuery="needQuery" /> <Filter :needQuery="needQuery" :data="data" />
</div> </div>
<div class="trace flex-h"> <div class="trace flex-h">
<TraceList /> <TraceList />

View File

@ -130,7 +130,8 @@ limitations under the License. -->
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, reactive, watch, onUnmounted, inject } from "vue"; import { ref, reactive, watch, onUnmounted } from "vue";
import type { PropType } 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";
@ -143,10 +144,13 @@ import { EntityType } from "../../data";
import { ErrorCategory } from "./data"; import { ErrorCategory } from "./data";
import { LayoutConfig } from "@/types/dashboard"; import { LayoutConfig } from "@/types/dashboard";
/*global defineProps */ /*global defineProps, Recordable */
const options: LayoutConfig | undefined = inject("options");
const props = defineProps({ const props = defineProps({
needQuery: { type: Boolean, default: true }, needQuery: { type: Boolean, default: true },
data: {
type: Object as PropType<LayoutConfig>,
default: () => ({ graph: {} }),
},
}); });
const { t } = useI18n(); const { t } = useI18n();
const appStore = useAppStoreWithOut(); const appStore = useAppStoreWithOut();
@ -154,7 +158,7 @@ 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) || "" (props.data.filters && props.data.filters.traceId) || ""
); );
const keywordsOfContent = ref<string[]>([]); const keywordsOfContent = ref<string[]>([]);
const excludingKeywordsOfContent = ref<string[]>([]); const excludingKeywordsOfContent = ref<string[]>([]);
@ -163,7 +167,7 @@ const tagsMap = ref<Option[]>([]);
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 state = reactive<any>({ 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: "" },
@ -253,9 +257,9 @@ function searchLogs() {
}); });
} else { } else {
let segmentId, spanId; let segmentId, spanId;
if (options && options.filters) { if (props.data.filters) {
segmentId = options.filters.segmentId; segmentId = props.data.filters.segmentId;
spanId = options.filters.spanId; spanId = props.data.filters.spanId;
} }
logStore.setLogCondition({ logStore.setLogCondition({
serviceId: selectorStore.currentService serviceId: selectorStore.currentService
@ -337,7 +341,7 @@ function removeExcludeContent(index: number) {
onUnmounted(() => { onUnmounted(() => {
logStore.resetCondition(); logStore.resetCondition();
const item = { const item = {
...options, ...props.data,
filters: undefined, filters: undefined,
}; };
dashboardStore.setWidget(item); dashboardStore.setWidget(item);
@ -368,6 +372,19 @@ watch(
} }
} }
); );
watch(
() => props.data.filters,
(newJson, oldJson) => {
console.log(props.data.filters);
if (props.data.filters) {
if (JSON.stringify(newJson) === JSON.stringify(oldJson)) {
return;
}
traceId.value = props.data.filters.traceId || "";
init();
}
}
);
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.inputs { .inputs {

View File

@ -92,7 +92,8 @@ limitations under the License. -->
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, reactive, watch, inject } from "vue"; import { ref, reactive, watch } from "vue";
import type { PropType } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { Option } from "@/types/app"; import { Option } from "@/types/app";
import { Status } from "../../data"; import { Status } from "../../data";
@ -106,18 +107,21 @@ import { EntityType } from "../../data";
import { LayoutConfig } from "@/types/dashboard"; import { LayoutConfig } from "@/types/dashboard";
/*global defineProps, Recordable */ /*global defineProps, Recordable */
const options: LayoutConfig | undefined = inject("options");
const props = defineProps({ const props = defineProps({
needQuery: { type: Boolean, default: true }, needQuery: { type: Boolean, default: true },
data: {
type: Object as PropType<LayoutConfig>,
default: () => ({ graph: {} }),
},
}); });
const traceId = ref<string>(
(props.data.filters && props.data.filters.traceId) || ""
);
const { t } = useI18n(); const { t } = useI18n();
const appStore = useAppStoreWithOut(); const appStore = useAppStoreWithOut();
const selectorStore = useSelectorStore(); const selectorStore = useSelectorStore();
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
const traceStore = useTraceStore(); const traceStore = useTraceStore();
const traceId = ref<string>(
(options && options.filters && options.filters.traceId) || ""
);
const minTraceDuration = ref<number>(); const minTraceDuration = ref<number>();
const maxTraceDuration = ref<number>(); const maxTraceDuration = ref<number>();
const tagsList = ref<string[]>([]); const tagsList = ref<string[]>([]);
@ -252,6 +256,18 @@ watch(
} }
} }
); );
watch(
() => props.data.filters,
(newJson, oldJson) => {
if (props.data.filters) {
if (JSON.stringify(newJson) === JSON.stringify(oldJson)) {
return;
}
traceId.value = props.data.filters.traceId || "";
init();
}
}
);
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.inputs { .inputs {