From 610643608686b79b5c0dd169cfe8e98ed84ff6ce Mon Sep 17 00:00:00 2001 From: Fine Date: Mon, 28 Nov 2022 10:51:26 +0800 Subject: [PATCH] update --- src/components/Radio.vue | 4 +- src/components/Selector.vue | 2 +- src/store/modules/network-profiling.ts | 26 ++++++-- .../network-profiling/components/NewTask.vue | 64 +++++++++++-------- .../network-profiling/components/Tasks.vue | 26 ++++---- .../network-profiling/components/data.ts | 37 +---------- 6 files changed, 77 insertions(+), 82 deletions(-) diff --git a/src/components/Radio.vue b/src/components/Radio.vue index 7eafaa4e..2cd786fb 100644 --- a/src/components/Radio.vue +++ b/src/components/Radio.vue @@ -24,8 +24,8 @@ import { ref } from "vue"; import type { PropType } from "vue"; interface Option { - label: string; - value: string; + label: string | number; + value: string | number; } /*global defineProps, defineEmits */ diff --git a/src/components/Selector.vue b/src/components/Selector.vue index f0d25a06..ea1ccd7a 100644 --- a/src/components/Selector.vue +++ b/src/components/Selector.vue @@ -42,7 +42,7 @@ import type { PropType } from "vue"; interface Option { label: string | number; - value: string | number | boolean; + value: string | number; } /*global defineProps, defineEmits*/ diff --git a/src/store/modules/network-profiling.ts b/src/store/modules/network-profiling.ts index 2c45208c..3f62a1a9 100644 --- a/src/store/modules/network-profiling.ts +++ b/src/store/modules/network-profiling.ts @@ -110,13 +110,29 @@ export const networkProfilingStore = defineStore({ this.calls = calls; this.nodes = data.nodes; }, - async createNetworkTask(param: { - serviceId: string; - serviceInstanceId: string; - }) { + async createNetworkTask( + instanceId: string, + params: { + uriRegex: string; + when4xx: string; + when5xx: string; + minDuration: number; + } + ) { const res: AxiosResponse = await graphql .query("newNetworkProfiling") - .params({ request: { instanceId: param.serviceInstanceId } }); + .params({ + request: { + instanceId, + samplings: { + ...params, + settings: { + requireCompleteRequest: true, + requireCompleteResponse: true, + }, + }, + }, + }); if (res.data.errors) { return res.data; diff --git a/src/views/dashboard/related/network-profiling/components/NewTask.vue b/src/views/dashboard/related/network-profiling/components/NewTask.vue index fa1ba1a9..a9feb870 100644 --- a/src/views/dashboard/related/network-profiling/components/NewTask.vue +++ b/src/views/dashboard/related/network-profiling/components/NewTask.vue @@ -20,34 +20,31 @@ limitations under the License. -->
-
{{ t("minThreshold") }} (ms)
- {{ t("minDuration") }} (ms)
+
-
{{ t("monitorTime") }}
-
- -
+
{{ t("when4xx") }}
+
-
{{ t("minThreshold") }} (ms)
- {{ t("when5xx") }}
+
@@ -62,21 +59,36 @@ import { reactive } from "vue"; import { useI18n } from "vue-i18n"; import { InitTaskField } from "./data"; /* global defineEmits */ -const emits = defineEmits(["close"]); +const emits = defineEmits(["create"]); const { t } = useI18n(); -const states = reactive({ +const states = reactive<{ + uriRegex: string; + when4xx: string; + when5xx: string; + minDuration: number; +}>({ uriRegex: "", - when4xx: true, + when4xx: InitTaskField.Whenxx[0].value, + when5xx: InitTaskField.Whenxx[1].value, minDuration: NaN, }); -function changeConfig(params: { [key: string]: unknown }) { - const key = Object.keys(params)[0]; - states[key] = params[key]; +function changeConfig(params: { [key: string]: number | string }) { + const key: string = Object.keys(params)[0]; + (states as any)[key] = params[key]; } async function createTask() { - emits("close"); + const when4xx = + states.when4xx === InitTaskField.Whenxx[0].value ? true : false; + const when5xx = + states.when5xx === InitTaskField.Whenxx[0].value ? true : false; + emits("create", { + uriRegex: states.uriRegex || undefined, + when4xx, + when5xx, + minDuration: isNaN(states.minDuration) ? undefined : states.minDuration, + }); }