From 02ecf688cf8ad52689e8b10881244b33e58af82c Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 1 Apr 2023 19:31:28 +0800 Subject: [PATCH] fix(nc-gui): revise call log structure --- .../nc-gui/components/webhook/CallLog.vue | 69 ++++++++++++------- 1 file changed, 44 insertions(+), 25 deletions(-) diff --git a/packages/nc-gui/components/webhook/CallLog.vue b/packages/nc-gui/components/webhook/CallLog.vue index 1fdf3c0a43..fd1aaa540a 100644 --- a/packages/nc-gui/components/webhook/CallLog.vue +++ b/packages/nc-gui/components/webhook/CallLog.vue @@ -38,13 +38,31 @@ async function loadHookLogs(page = currentPage, limit = currentLimit) { offset: limit * (page - 1), limit, }) - hookLogs.value = list + hookLogs.value = parseHookLog(list) totalRows = pageInfo.totalRows ?? 0 } catch (e: any) { message.error(await extractSdkResponseErrorMsg(e)) } } +function parseHookLog(hookLogs: any) { + for (const hookLog of hookLogs) { + if (hookLog?.response) { + hookLog.response = parseProp(hookLog.response) + } + if (hookLog?.response?.config?.data) { + hookLog.response.config.data = parseProp(hookLog.response.config.data) + } + if (hookLog?.payload) { + hookLog.payload = parseProp(hookLog.payload) + } + if (hookLog?.notification) { + hookLog.notification = parseProp(hookLog.notification) + } + } + return hookLogs +} + onBeforeMount(async () => { if (showLogs.value) { await loadHookLogs(currentPage, currentLimit) @@ -86,52 +104,53 @@ onBeforeMount(async () => {
{{ hookLog.type }}: records.{{ hookLog.event }}.{{ hookLog.operation }} ({{ timeAgo(hookLog.created_at) }})
-
- {{ parseProp(hookLog.response).status }} - {{ parseProp(hookLog.response).statusText }} -
+
ERROR
OK
+
+ {{ hookLog.response?.status }} + {{ hookLog.response?.statusText || (hookLog.response?.status === 200 ? 'OK' : 'ERROR') }} +
- {{ parseProp(hookLog.payload).method }} + {{ hookLog.payload.method }} - {{ parseProp(hookLog.payload).path }} + {{ hookLog.payload.path }}
-
-
+
+ {{ hookLog.error_message }} +
+ +
+
Request
-
{{ parseProp(hookLog.response).config.headers }}
+
{{ hookLog.response.config.headers }}
-
+
Response
-
{{ parseProp(hookLog.response).headers }}
+
{{ hookLog.response.headers }}
-
+
Payload
-
{{ parseProp(parseProp(hookLog.response).config.data) }}
+
{{ hookLog.response.config.data }}
- -
-
- {{ hookLog.error_message }} -
-
+
+
Payload
-
{{ parseProp(hookLog.payload) }}
+
{{ hookLog.payload }}