@@ -43,6 +49,7 @@ import Page from '@/layout/components/Page'
import AdhocOpenDialog from './AdhocOpenDialog.vue'
import AdhocSaveDialog from './AdhocSaveDialog.vue'
import VariableHelpDialog from './VariableHelpDialog.vue'
+import setVariableDialog from '@/views/ops/Template/components/setVariableDialog'
import { createJob, getJob, getTaskDetail, StopJob } from '@/api/ops'
export default {
@@ -51,6 +58,7 @@ export default {
VariableHelpDialog,
AdhocSaveDialog,
AdhocOpenDialog,
+ setVariableDialog,
AssetTreeTable,
Page,
QuickJobTerm,
@@ -70,6 +78,7 @@ export default {
showHelpDialog: false,
showOpenAdhocDialog: false,
showOpenAdhocSaveDialog: false,
+ showSetVariableDialog: false,
DataZTree: 0,
runas: '',
runasPolicy: 'skip',
@@ -93,6 +102,10 @@ export default {
type: 'primary'
},
callback: () => {
+ if (this.variableFormData.length !== 0) {
+ this.showSetVariableDialog = true
+ return
+ }
this.execute()
}
},
@@ -297,7 +310,9 @@ export default {
}
}
},
- iShowTree: true
+ iShowTree: true,
+ variableFormData: [],
+ variableQueryParam: ''
}
},
computed: {
@@ -339,6 +354,10 @@ export default {
}
},
onSelectAdhoc(adhoc) {
+ this.variableFormData = adhoc?.variable.map((data) => {
+ return data.form_data
+ })
+ this.variableQueryParam = 'adhoc=' + adhoc.id
this.command = adhoc.args
},
enableWS() {
@@ -432,7 +451,6 @@ export default {
this.$message.error(this.$tc('RequiredRunas'))
return
}
-
const data = {
assets: hosts,
nodes: nodes,
@@ -447,6 +465,9 @@ export default {
if (this.chdir) {
data.chdir = this.chdir
}
+ if (this.parameters) {
+ data.parameters = this.parameters
+ }
createJob(data).then(res => {
this.executionInfo.timeCost = 0
this.executionInfo.status = { value: 'running', label: this.$t('Running') }
@@ -460,7 +481,7 @@ export default {
stop() {
StopJob({ task_id: this.currentTaskId }).then(() => {
this.xterm.write('\x1b[31m' +
- this.$tc('StopLogOutput').replace('currentTaskId', this.currentTaskId) + '\x1b[0m')
+ this.$tc('StopLogOutput').replace('currentTaskId', this.currentTaskId) + '\x1b[0m')
this.xterm.write(this.wrapperError(''))
this.getTaskStatus()
}).catch((e) => {
@@ -476,6 +497,11 @@ export default {
}
this.toolbar.left.run.isVisible = this.executionInfo.status.value === 'running'
this.toolbar.left.stop.isVisible = this.executionInfo.status.value !== 'running'
+ },
+ onSubmitVariable(parameters) {
+ this.parameters = parameters
+ this.showSetVariableDialog = false
+ this.execute()
}
}
}
diff --git a/src/views/ops/File/index.vue b/src/views/ops/File/index.vue
index 8d6be31bb..e23b558e9 100644
--- a/src/views/ops/File/index.vue
+++ b/src/views/ops/File/index.vue
@@ -535,7 +535,7 @@ export default {
.empty-file-tip {
position: absolute;
- right: 20%;
+ right: calc(50% - 230px);
top: 50%;
font-size: 18px;
color: #c5c9cc;
diff --git a/src/views/ops/Job/JobUpdateCreate.vue b/src/views/ops/Job/JobUpdateCreate.vue
index 335146e83..49b073225 100644
--- a/src/views/ops/Job/JobUpdateCreate.vue
+++ b/src/views/ops/Job/JobUpdateCreate.vue
@@ -2,6 +2,13 @@
+
@@ -13,9 +20,13 @@ import i18n from '@/i18n/i18n'
import VariableHelpDialog from '@/views/ops/Adhoc/VariableHelpDialog.vue'
import { Required } from '@/components/Form/DataForm/rules'
import { crontab, interval } from '@/views/accounts/const'
+import LoadTemplateLink from '@/views/ops/Job/components/loadTemplateLink'
+import Variable from '@/views/ops/Template/components/Variable'
+import setVariableDialog from '@/views/ops/Template/components/setVariableDialog.vue'
export default {
components: {
+ setVariableDialog,
GenericCreateUpdatePage,
VariableHelpDialog
},
@@ -27,9 +38,9 @@ export default {
url: '/api/v1/ops/jobs/',
fields: [
[this.$t('Basic'), ['name', 'type', 'instant']],
- [this.$t('Task'), ['module', 'args', 'playbook', 'chdir', 'timeout']],
- [this.$t('Asset'), ['assets', 'runas', 'runas_policy']],
- [this.$t('Plan'), ['run_after_save', 'is_periodic', 'interval', 'crontab']],
+ [this.$t('Asset'), ['assets', 'nodes', 'runas', 'runas_policy']],
+ [this.$t('Task'), ['module', 'argsLoadFromTemplate', 'args', 'playbook', 'variable', 'chdir', 'timeout']],
+ [this.$t('Plan'), ['is_periodic', 'interval', 'crontab', 'periodic_variable']],
[this.$t('Other'), ['comment']]
],
initial: {
@@ -88,13 +99,26 @@ export default {
return { label: item.name, value: item.id }
}
}
+ },
+ on: {
+ change: ([event], updateForm) => {
+ this.queryParam = `playbook=${event.pk}`
+ this.$axios.get(`/api/v1/ops/playbooks/${event.pk}/`,
+ ).then(data => {
+ data?.variable.map(item => {
+ delete item.job
+ delete item.playbook
+ return item
+ })
+ updateForm({ variable: data.variable })
+ })
+ }
}
},
assets: {
type: 'assetSelect',
component: AssetSelect,
label: this.$t('Asset'),
- rules: [Required],
el: {
baseUrl: '/api/v1/perms/users/self/assets/',
baseNodeUrl: '/api/v1/perms/users/self/nodes/',
@@ -102,6 +126,38 @@ export default {
value: []
}
},
+ nodes: {
+ el: {
+ value: [],
+ ajax: {
+ url: '/api/v1/perms/users/self/nodes/',
+ filterOption: (item) => {
+ if (item.value !== 'favorite') {
+ return item
+ }
+ },
+ transformOption: (item) => {
+ return { label: item.full_value || item.name, value: item.id }
+ }
+ }
+ }
+ },
+ argsLoadFromTemplate: {
+ label: this.$t('Templates'),
+ hidden: (formValue) => {
+ return formValue.type !== 'adhoc'
+ },
+ component: LoadTemplateLink,
+ on: {
+ change: ([event], updateForm) => {
+ updateForm({
+ args: event.args,
+ module: event.module.value,
+ variable: event.variable
+ })
+ }
+ }
+ },
args: {
rules: [Required],
hidden: (formValue) => {
@@ -125,6 +181,25 @@ export default {
]
}
},
+ variable: {
+ component: Variable,
+ on: {
+ input: ([event], updateForm) => {
+ this.formData = event.map(item => {
+ return item.form_data
+ })
+ if (event.length > 0) {
+ if (event[0].job) {
+ this.queryParam = `job=${event[0].job}`
+ } else if (event[0].adhoc) {
+ this.queryParam = `adhoc=${event[0].adhoc}`
+ } else if (event[0].playbook) {
+ this.queryParam = `playbook=${event[0].playbook}`
+ }
+ }
+ }
+ }
+ },
timeout: {
helpText: i18n.t('TimeoutHelpText')
},
@@ -149,13 +224,42 @@ export default {
type: 'switch',
hidden: () => {
return this.instantTask
+ },
+ on: {
+ change: ([event], updateForm) => {
+ if (this.formData.length > 0) {
+ this.showVariableDialog = event
+ }
+ }
+ }
+ },
+ periodic_variable: {
+ hidden: () => {
+ return true
}
},
interval,
crontab
},
createSuccessNextRoute: { name: 'JobManagement' },
- updateSuccessNextRoute: { name: 'JobManagement' }
+ updateSuccessNextRoute: { name: 'JobManagement' },
+ cleanFormValue: (data) => {
+ Object.assign(data, { periodic_variable: this.periodicVariableValue })
+ return data
+ },
+ moreButtons: [
+ {
+ title: this.$t('ExecuteAfterSaving'),
+ callback: (value, form, btn) => {
+ form.value.instant = true
+ this.submitForm(form, btn)
+ }
+ }
+ ],
+ formData: [],
+ queryParam: '',
+ showVariableDialog: false,
+ periodicVariableValue: {}
}
},
mounted() {
@@ -192,7 +296,20 @@ export default {
this.ready = true
}
},
- methods: {}
+ methods: {
+ submitForm(form, btn) {
+ form.validate((valid) => {
+ if (valid) {
+ btn.loading = true
+ }
+ })
+ this.$refs.form.$refs.createUpdateForm.$refs.form.$refs.dataForm.submitForm('form', false)
+ },
+ setPeriodicParams(data) {
+ this.showVariableDialog = false
+ this.periodicVariableValue = data
+ }
+ }
}
diff --git a/src/views/ops/Job/components/Adhoc.vue b/src/views/ops/Job/components/Adhoc.vue
index 5d0ae3609..41d0bb83a 100644
--- a/src/views/ops/Job/components/Adhoc.vue
+++ b/src/views/ops/Job/components/Adhoc.vue
@@ -1,129 +1,16 @@
-
-
+
diff --git a/src/views/ops/Job/components/BaseJob.vue b/src/views/ops/Job/components/BaseJob.vue
new file mode 100644
index 000000000..e77d0912c
--- /dev/null
+++ b/src/views/ops/Job/components/BaseJob.vue
@@ -0,0 +1,166 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/views/ops/Job/components/PlayBook.vue b/src/views/ops/Job/components/PlayBook.vue
index 710272cb3..dc9927eb5 100644
--- a/src/views/ops/Job/components/PlayBook.vue
+++ b/src/views/ops/Job/components/PlayBook.vue
@@ -1,136 +1,16 @@
-
-
+
diff --git a/src/views/ops/Job/components/loadTemplateLink.vue b/src/views/ops/Job/components/loadTemplateLink.vue
new file mode 100644
index 000000000..def5c4d26
--- /dev/null
+++ b/src/views/ops/Job/components/loadTemplateLink.vue
@@ -0,0 +1,41 @@
+
+
+
+
+ {{ $t('LoadTemplate') }}
+
+
+
+
+
+
+
diff --git a/src/views/ops/Template/Adhoc/AdhocUpdateCreate.vue b/src/views/ops/Template/Adhoc/AdhocUpdateCreate.vue
index 5331f1240..45e246a7d 100644
--- a/src/views/ops/Template/Adhoc/AdhocUpdateCreate.vue
+++ b/src/views/ops/Template/Adhoc/AdhocUpdateCreate.vue
@@ -5,6 +5,7 @@
+
+
diff --git a/src/views/ops/Template/components/Variable.vue b/src/views/ops/Template/components/Variable.vue
new file mode 100644
index 000000000..c5f26b371
--- /dev/null
+++ b/src/views/ops/Template/components/Variable.vue
@@ -0,0 +1,167 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ $t('Add') }}
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/ops/Template/components/setVariableDialog.vue b/src/views/ops/Template/components/setVariableDialog.vue
new file mode 100644
index 000000000..c1d322d27
--- /dev/null
+++ b/src/views/ops/Template/components/setVariableDialog.vue
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+