|
1 | 1 | <script setup lang="ts">
|
2 | 2 | import { onMounted, ref } from "vue";
|
| 3 | +import { useTypedFetchFromServiceControl } from "@/composables/serviceServiceControlUrls"; |
3 | 4 | import { type DefaultEdge, MarkerType, VueFlow, type Styles, type Node } from "@vue-flow/core";
|
4 | 5 | import TimeSince from "../TimeSince.vue";
|
5 | 6 | import routeLinks from "@/router/routeLinks";
|
6 | 7 | import Message from "@/resources/Message";
|
7 | 8 | import { NServiceBusHeaders } from "@/resources/Header";
|
| 9 | +import { useRoute } from "vue-router"; |
| 10 | +import { ExtendedFailedMessage } from "@/resources/FailedMessage"; |
8 | 11 | import { Controls } from "@vue-flow/controls";
|
9 |
| -import { useMessageViewStore } from "@/stores/MessageViewStore"; |
10 |
| -import LoadingSpinner from "@/components/LoadingSpinner.vue"; |
11 |
| -import { storeToRefs } from "pinia"; |
| 12 | +
|
| 13 | +const props = defineProps<{ |
| 14 | + message: ExtendedFailedMessage; |
| 15 | +}>(); |
12 | 16 |
|
13 | 17 | enum MessageType {
|
14 | 18 | Event = "Event message",
|
@@ -40,13 +44,11 @@ interface MappedMessage {
|
40 | 44 | const nodeSpacingX = 300;
|
41 | 45 | const nodeSpacingY = 200;
|
42 | 46 |
|
43 |
| -const store = useMessageViewStore(); |
44 |
| -const { state } = storeToRefs(useMessageViewStore()); |
| 47 | +const route = useRoute(); |
45 | 48 |
|
46 | 49 | async function getConversation(conversationId: string) {
|
47 |
| - await store.loadConversation(conversationId); |
48 |
| -
|
49 |
| - return store.conversationData.data; |
| 50 | + const [, data] = await useTypedFetchFromServiceControl<Message[]>(`conversations/${conversationId}`); |
| 51 | + return data; |
50 | 52 | }
|
51 | 53 |
|
52 | 54 | function mapMessage(message: Message): MappedMessage {
|
@@ -159,9 +161,9 @@ function constructEdges(mappedMessages: MappedMessage[]): DefaultEdge[] {
|
159 | 161 | const elements = ref<(Node | DefaultEdge)[]>([]);
|
160 | 162 |
|
161 | 163 | onMounted(async () => {
|
162 |
| - if (!state.value.data.conversation_id) return; |
| 164 | + if (!props.message.conversationId) return; |
163 | 165 |
|
164 |
| - const messages = await getConversation(state.value.data.conversation_id); |
| 166 | + const messages = await getConversation(props.message.conversationId); |
165 | 167 | const mappedMessages = messages.map(mapMessage);
|
166 | 168 |
|
167 | 169 | const assignDescendantLevelsAndWidth = (message: MappedMessage, level = 0) => {
|
@@ -191,28 +193,26 @@ function typeIcon(type: MessageType) {
|
191 | 193 | </script>
|
192 | 194 |
|
193 | 195 | <template>
|
194 |
| - <div v-if="store.conversationData.failed_to_load" class="alert alert-info">FlowDiagram data is unavailable.</div> |
195 |
| - <LoadingSpinner v-else-if="store.conversationData.loading" /> |
196 |
| - <div v-else id="tree-container"> |
| 196 | + <div id="tree-container"> |
197 | 197 | <VueFlow v-model="elements" :min-zoom="0.1" :fit-view-on-init="true">
|
198 | 198 | <Controls />
|
199 |
| - <template #node-message="{ data }: { data: MappedMessage }"> |
200 |
| - <div class="node" :class="{ error: data.isError, 'current-message': data.id === store.state.data.id }"> |
| 199 | + <template #node-message="nodeProps"> |
| 200 | + <div class="node" :class="[nodeProps.data.isError && 'error', nodeProps.data.id === props.message.id && 'current-message']"> |
201 | 201 | <div class="node-text wordwrap">
|
202 |
| - <i v-if="data.isError" class="fa pa-flow-failed" /> |
203 |
| - <i class="fa" :class="typeIcon(data.type)" :title="data.type" /> |
204 |
| - <div class="lead right-side-ellipsis" :title="data.nodeName"> |
| 202 | + <i v-if="nodeProps.data.isError" class="fa pa-flow-failed" /> |
| 203 | + <i class="fa" :class="typeIcon(nodeProps.data.type)" :title="nodeProps.data.type" /> |
| 204 | + <div class="lead righ-side-ellipsis" :title="nodeProps.data.nodeName"> |
205 | 205 | <strong>
|
206 |
| - <RouterLink v-if="data.isError" :to="{ path: routeLinks.messages.failedMessage.link(data.id) }">{{ data.nodeName }}</RouterLink> |
207 |
| - <RouterLink v-else :to="{ path: routeLinks.messages.successMessage.link(data.messageId, data.id) }">{{ data.nodeName }}</RouterLink> |
| 206 | + <RouterLink v-if="nodeProps.data.isError" :to="{ path: routeLinks.messages.failedMessage.link(nodeProps.data.id), query: { back: route.path } }">{{ nodeProps.data.nodeName }}</RouterLink> |
| 207 | + <span v-else>{{ nodeProps.data.nodeName }}</span> |
208 | 208 | </strong>
|
209 | 209 | </div>
|
210 | 210 | <span class="time-sent">
|
211 |
| - <time-since class="time-since" :date-utc="data.timeSent" /> |
| 211 | + <time-since class="time-since" :date-utc="nodeProps.data.timeSent" /> |
212 | 212 | </span>
|
213 |
| - <template v-if="data.sagaName"> |
| 213 | + <template v-if="nodeProps.data.sagaName"> |
214 | 214 | <i class="fa pa-flow-saga" />
|
215 |
| - <div class="saga lead right-side-ellipsis" :title="data.sagaName">{{ data.sagaName }}</div> |
| 215 | + <div class="saga lead righ-side-ellipsis" :title="nodeProps.data.sagaName">{{ nodeProps.data.sagaName }}</div> |
216 | 216 | </template>
|
217 | 217 | </div>
|
218 | 218 | </div>
|
@@ -243,13 +243,14 @@ function typeIcon(type: MessageType) {
|
243 | 243 | padding: 10px;
|
244 | 244 | border-radius: 3px;
|
245 | 245 | font-size: 12px;
|
| 246 | + text-align: center; |
246 | 247 | border-width: 1px;
|
247 | 248 | border-style: solid;
|
248 | 249 | color: var(--vf-node-text);
|
249 | 250 | text-align: left;
|
250 | 251 | }
|
251 | 252 |
|
252 |
| -.right-side-ellipsis { |
| 253 | +.righ-side-ellipsis { |
253 | 254 | direction: rtl;
|
254 | 255 | text-align: left;
|
255 | 256 | }
|
@@ -305,11 +306,6 @@ function typeIcon(type: MessageType) {
|
305 | 306 | width: 182px;
|
306 | 307 | }
|
307 | 308 |
|
308 |
| -.current-message { |
309 |
| - border-color: #cccbcc; |
310 |
| - background-color: #cccbcc !important; |
311 |
| -} |
312 |
| -
|
313 | 309 | .current-message.error {
|
314 | 310 | border-color: #be514a;
|
315 | 311 | background-color: #be514a !important;
|
@@ -350,10 +346,6 @@ function typeIcon(type: MessageType) {
|
350 | 346 | text-decoration: none;
|
351 | 347 | }
|
352 | 348 |
|
353 |
| -.node-text a { |
354 |
| - color: #000; |
355 |
| -} |
356 |
| -
|
357 | 349 | .error .node-text a {
|
358 | 350 | color: #be514a;
|
359 | 351 | }
|
|
0 commit comments