mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-14 00:37:33 +00:00
add multiple conditions
This commit is contained in:
parent
01baea1087
commit
7c3a9407c2
@ -35,7 +35,7 @@ limitations under the License. -->
|
|||||||
class="mb-5"
|
class="mb-5"
|
||||||
:value="states.when4xx"
|
:value="states.when4xx"
|
||||||
:options="InitTaskField.Whenxx"
|
:options="InitTaskField.Whenxx"
|
||||||
@change="changeConfig({ when4xx: $event })"
|
@change="changeConfig({ when4xx: states.when4xx })"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@ -44,7 +44,7 @@ limitations under the License. -->
|
|||||||
class="mb-5"
|
class="mb-5"
|
||||||
:value="states.when5xx"
|
:value="states.when5xx"
|
||||||
:options="InitTaskField.Whenxx"
|
:options="InitTaskField.Whenxx"
|
||||||
@change="changeConfig({ when5xx: $event })"
|
@change="changeConfig({ when5xx: states.when5xx })"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -56,6 +56,8 @@ import type { PropType } from "vue";
|
|||||||
import { InitTaskField } from "./data";
|
import { InitTaskField } from "./data";
|
||||||
import { NetworkProfilingRequest } from "@/types/ebpf";
|
import { NetworkProfilingRequest } from "@/types/ebpf";
|
||||||
|
|
||||||
|
/* global defineEmits */
|
||||||
|
const emits = defineEmits(["change"]);
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
condition: {
|
condition: {
|
||||||
type: Object as PropType<NetworkProfilingRequest>,
|
type: Object as PropType<NetworkProfilingRequest>,
|
||||||
@ -72,6 +74,7 @@ const states = reactive<NetworkProfilingRequest>(props.condition);
|
|||||||
function changeConfig(params: { [key: string]: number | string }) {
|
function changeConfig(params: { [key: string]: number | string }) {
|
||||||
const key: string = Object.keys(params)[0];
|
const key: string = Object.keys(params)[0];
|
||||||
(states as any)[key] = params[key];
|
(states as any)[key] = params[key];
|
||||||
|
emits("change", states, props.key);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -19,8 +19,26 @@ limitations under the License. -->
|
|||||||
<el-collapse-item
|
<el-collapse-item
|
||||||
v-for="(item, index) in conditionsList"
|
v-for="(item, index) in conditionsList"
|
||||||
:key="index"
|
:key="index"
|
||||||
:title="`Condition - ${index + 1}`"
|
:name="index"
|
||||||
>
|
>
|
||||||
|
<template #title>
|
||||||
|
<div>
|
||||||
|
<span class="title">{{ `Condition - ${index + 1}` }}</span>
|
||||||
|
<Icon
|
||||||
|
class="mr-5 cp"
|
||||||
|
iconName="remove_circle_outline"
|
||||||
|
size="middle"
|
||||||
|
@click="removeConditions($event, index)"
|
||||||
|
/>
|
||||||
|
<Icon
|
||||||
|
class="cp"
|
||||||
|
v-show="index === conditionsList.length - 1"
|
||||||
|
iconName="add_circle_outlinecontrol_point"
|
||||||
|
size="middle"
|
||||||
|
@click="createConditions"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
<NewCondition
|
<NewCondition
|
||||||
:name="index"
|
:name="index"
|
||||||
:condition="item"
|
:condition="item"
|
||||||
@ -33,13 +51,6 @@ limitations under the License. -->
|
|||||||
<el-button @click="createTask" type="primary" class="create-task-btn">
|
<el-button @click="createTask" type="primary" class="create-task-btn">
|
||||||
{{ t("createTask") }}
|
{{ t("createTask") }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
|
||||||
@click="createConditions"
|
|
||||||
type="primary"
|
|
||||||
class="create-task-btn"
|
|
||||||
>
|
|
||||||
{{ t("createConditions") }}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -53,7 +64,7 @@ import { NetworkProfilingRequest } from "@/types/ebpf";
|
|||||||
/* global defineEmits */
|
/* global defineEmits */
|
||||||
const emits = defineEmits(["create"]);
|
const emits = defineEmits(["create"]);
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const activeNames = ref([1]);
|
const activeNames = ref([0]);
|
||||||
const conditionsList = ref<NetworkProfilingRequest[]>([
|
const conditionsList = ref<NetworkProfilingRequest[]>([
|
||||||
{
|
{
|
||||||
uriRegex: "",
|
uriRegex: "",
|
||||||
@ -77,14 +88,30 @@ function createTask() {
|
|||||||
uriRegex: d.uriRegex || undefined,
|
uriRegex: d.uriRegex || undefined,
|
||||||
when4xx: d.when4xx === InitTaskField.Whenxx[0].value ? true : false,
|
when4xx: d.when4xx === InitTaskField.Whenxx[0].value ? true : false,
|
||||||
when5xx: d.when5xx === InitTaskField.Whenxx[0].value ? true : false,
|
when5xx: d.when5xx === InitTaskField.Whenxx[0].value ? true : false,
|
||||||
minDuration: isNaN(d.minDuration) ? undefined : d.minDuration,
|
minDuration: isNaN(Number(d.minDuration))
|
||||||
|
? undefined
|
||||||
|
: Number(d.minDuration),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
emits("create", list);
|
emits("create", list);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createConditions() {
|
function createConditions(e: any) {
|
||||||
console.log(conditionsList);
|
e.stopPropagation();
|
||||||
|
conditionsList.value.push({
|
||||||
|
uriRegex: "",
|
||||||
|
when4xx: InitTaskField.Whenxx[0].value,
|
||||||
|
when5xx: InitTaskField.Whenxx[1].value,
|
||||||
|
minDuration: NaN,
|
||||||
|
});
|
||||||
|
activeNames.value = [conditionsList.value.length - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeConditions(e: any, key: number) {
|
||||||
|
e.stopPropagation();
|
||||||
|
conditionsList.value = conditionsList.value.filter(
|
||||||
|
(_, index: number) => index !== key
|
||||||
|
);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@ -97,4 +124,9 @@ function createConditions() {
|
|||||||
width: 300px;
|
width: 300px;
|
||||||
margin-top: 50px;
|
margin-top: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -168,16 +168,19 @@ function createTask() {
|
|||||||
}
|
}
|
||||||
newTask.value = true;
|
newTask.value = true;
|
||||||
}
|
}
|
||||||
async function saveNewTask(params: {
|
async function saveNewTask(
|
||||||
|
params: {
|
||||||
uriRegex: string;
|
uriRegex: string;
|
||||||
when4xx: string;
|
when4xx: string;
|
||||||
when5xx: string;
|
when5xx: string;
|
||||||
minDuration: number;
|
minDuration: number;
|
||||||
}) {
|
}[]
|
||||||
|
) {
|
||||||
|
console.log(params);
|
||||||
newTask.value = false;
|
newTask.value = false;
|
||||||
const instanceId =
|
const instanceId =
|
||||||
(selectorStore.currentPod && selectorStore.currentPod.id) || "";
|
(selectorStore.currentPod && selectorStore.currentPod.id) || "";
|
||||||
if (!instanceId) {
|
if (instanceId) {
|
||||||
return ElMessage.error("No Instance ID");
|
return ElMessage.error("No Instance ID");
|
||||||
}
|
}
|
||||||
const res = await networkProfilingStore.createNetworkTask(instanceId, params);
|
const res = await networkProfilingStore.createNetworkTask(instanceId, params);
|
||||||
|
Loading…
Reference in New Issue
Block a user