Skip to content

Commit bd62142

Browse files
fix: update trigger
1 parent 5b548c1 commit bd62142

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

ui/src/views/trigger/TriggerDrawer.vue

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
shadow="never"
5858
class="mb-16 w-full cursor"
5959
:class="form.trigger_type === 'SCHEDULED' ? 'border-active' : ''"
60-
@click="form.trigger_type = 'SCHEDULED'"
60+
@click="changeTriggerType('SCHEDULED')"
6161
>
6262
<div class="flex align-center line-height-22">
6363
<el-avatar shape="square" :size="32">
@@ -81,7 +81,7 @@
8181
<el-cascader
8282
v-model="scheduled"
8383
:options="triggerCycleOptions"
84-
@change="handleChange"
84+
@change="handleChangeScheduled"
8585
style="width: 100%"
8686
/>
8787
</el-card>
@@ -90,7 +90,7 @@
9090
shadow="never"
9191
class="w-full cursor"
9292
:class="form.trigger_type === 'EVENT' ? 'border-active' : ''"
93-
@click="form.trigger_type = 'EVENT'"
93+
@click="changeTriggerType('EVENT')"
9494
>
9595
<div class="flex align-center line-height-22">
9696
<el-avatar shape="square" class="avatar-orange" :size="32">
@@ -353,7 +353,7 @@
353353
</div>
354354
<div class="w-full" v-if="collapseData.agent">
355355
<template v-for="(item, index) in applicationTask" :key="index">
356-
<div class="border border-r-6 white-bg" style="padding: 2px 8px">
356+
<div class="border border-r-6 white-bg mb-4" style="padding: 2px 8px">
357357
<div class="flex-between">
358358
<div class="flex align-center" style="line-height: 20px">
359359
<el-avatar
@@ -557,15 +557,39 @@ const editPermission = computed(() => {
557557
558558
const triggerFormRef = ref<FormInstance>()
559559
560+
const getDefaultValue = () => {
561+
return {
562+
id: uuidv4(),
563+
name: '',
564+
desc: '',
565+
trigger_task: [],
566+
trigger_type: 'SCHEDULED',
567+
trigger_setting: {
568+
token: uuidv4().replace(/-/g, ''),
569+
body: [],
570+
},
571+
}
572+
}
573+
574+
const form = ref<any>(getDefaultValue())
575+
const is_edit = ref<boolean>(false)
576+
const event_url = computed(() => {
577+
return `${window.origin}${window.MaxKB.prefix}/api/trigger/v1/webhook/${form.value.id}`
578+
})
579+
560580
const addParameter = () => {
561581
form.value.trigger_setting.body.push({ field: '', type: '' })
562582
}
563583
const delParameter = (index: number | string) => {
564584
form.value.trigger_setting.body.splice(index, 1)
565585
}
566-
const handleChange = (v: Array<any>) => {
586+
const handleChangeScheduled = (v: Array<any>) => {
567587
scheduled.value = v
568588
}
589+
590+
const changeTriggerType = (type: string) => {
591+
form.value.trigger_type = type
592+
}
569593
const applicationDetailsDict = ref<any>({})
570594
const toolDetailsDict = ref<any>({})
571595
const applicationRefresh = (application_selected: any) => {
@@ -693,25 +717,6 @@ const scheduled = computed({
693717
}
694718
},
695719
})
696-
const getDefaultValue = () => {
697-
return {
698-
id: uuidv4(),
699-
name: '',
700-
desc: '',
701-
trigger_task: [],
702-
trigger_type: 'SCHEDULED',
703-
trigger_setting: {
704-
token: uuidv4().replace(/-/g, ''),
705-
body: [],
706-
},
707-
}
708-
}
709-
710-
const form = ref<any>(getDefaultValue())
711-
const is_edit = ref<boolean>(false)
712-
const event_url = computed(() => {
713-
return `${window.origin}${window.MaxKB.prefix}/api/trigger/v1/webhook/${form.value.id}`
714-
})
715720
716721
const init = (trigger_id: string) => {
717722
if (current_source_id.value && current_source_type.value) {

0 commit comments

Comments
 (0)