Skip to content

Commit

Permalink
Merge pull request #1 from sunpu007/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
sunpu007 authored Mar 18, 2022
2 parents 4ddbac8 + d8f1faf commit f77fe90
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"nprogress": "0.2.0",
"path-to-regexp": "2.4.0",
"vue": "2.6.10",
"vue-codemirror": "^4.0.6",
"vue-router": "3.0.6",
"vuex": "3.1.0"
},
Expand Down
82 changes: 77 additions & 5 deletions src/views/task/schedule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<el-button type="text" @click="run(row.job_id)">执行</el-button>
<el-button type="text" @click="showLog(row.job_id)">日志</el-button>
<el-button type="text" @click="handleEdit(row)">编辑</el-button>
<el-button v-if="row.runMode==1" type="text" @click="handleEditShell(row)">编辑Shell</el-button>
<el-button type="text" @click="del(row)">删除</el-button>
</template>
</el-table-column>
Expand All @@ -37,10 +38,22 @@
<el-form-item label="任务名" prop="jobName">
<el-input v-model="fromData.jobName" placeholder="请输入任务名" />
</el-form-item>
<el-form-item label="jobHandler" prop="jobHandler">
<el-form-item label="运行模式" prop="runMode">
<el-select v-model="fromData.runMode" placeholder="请选择">
<el-option label="BEAN模式" :value="0" />
<el-option label="SHELL模式" :value="1" />
</el-select>
</el-form-item>
<el-form-item v-if="fromData.runMode==0" label="jobHandler" prop="jobHandler">
<el-input v-model="fromData.jobHandler" placeholder="请输入jobHandler" />
</el-form-item>
<el-form-item label="参数" prop="params">
<template v-if="fromData.runMode==1" slot="label">
参数
<el-tooltip class="item" effect="dark" content="多个参数请用英文逗号隔开" placement="bottom">
<i class="el-icon-question" />
</el-tooltip>
</template>
<el-input v-model="fromData.params" type="textarea" placeholder="请输入参数" />
</el-form-item>
<el-form-item label="任务描述" prop="description">
Expand Down Expand Up @@ -92,15 +105,30 @@
<div v-html="logDetail" />
<!-- isShowExecutionAnimation -->
</el-dialog>

<!-- 配置脚本 -->
<el-dialog :visible.sync="shellDialogVisible" title="编辑shell">
<i>*由于当前实现原因,接受参数应从第二位开始*</i>
<codemirror v-model="sourceFromData.runSource" :options="cmOptions" />
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="confirmShell">保存</el-button>
</div>
</el-dialog>
</div>
</template>

<script>
import Pagination from '@/components/Pagination'
import waves from '@/directive/waves'
import { codemirror } from 'vue-codemirror'
import 'codemirror/lib/codemirror.css'
import 'codemirror/theme/liquibyte.css'
import 'codemirror/addon/hint/show-hint.css'
import 'codemirror/addon/hint/show-hint.js'
import { scheduleList, editSchedule, deleteSchedule, updateStatusSchedule, runSchedule, scheduleLogList, scheduleLogDetail } from '@/api/task'
export default {
components: { Pagination },
components: { Pagination, codemirror },
directives: { waves },
filters: {
triggerTypeFilter(val) {
Expand All @@ -122,13 +150,19 @@ export default {
dialogVisible: false,
dialogType: 'new',
fromData: {},
fromData: {
runMode: 0
},
rules: {
cron: { required: true, message: '请输入Cron', trigger: 'blur' },
jobName: { required: true, message: '请输入任务名', trigger: 'blur' },
jobHandler: { required: true, message: '请输入jobHandler', trigger: 'blur' }
},
sourceFromData: {
runSource: '#!/bin/bash\necho "hello shell"\nexit 0'
},
// 日志浮窗
logDialogVisible: false,
logListQuery: {
Expand All @@ -144,7 +178,25 @@ export default {
logDetail: '',
timer: null,
// 是否展示执行中动画
isShowExecutionAnimation: false
isShowExecutionAnimation: false,
shellDialogVisible: false,
cmOptions: {
value: '',
mode: 'text/x-sh',
theme: 'liquibyte',
indentWithTabs: true,
smartIndent: true,
lineNumbers: true,
matchBrackets: true,
autofocus: true,
extraKeys: { 'Ctrl-Space': 'autocomplete' },
hintOptions: { tables: {
users: ['name', 'score', 'birthDate'],
countries: ['name', 'population', 'size']
}}
}
}
},
mounted() {
Expand All @@ -164,7 +216,7 @@ export default {
}
},
handleEdit(row) {
this.fromData = {}
this.fromData = { runMode: 0 }
if (row) {
this.fromData = JSON.parse(JSON.stringify(row))
this.dialogType = 'edit'
Expand All @@ -187,6 +239,26 @@ export default {
}
})
},
handleEditShell(row) {
this.sourceFromData = {
...row
}
if (!row.runSource) {
this.sourceFromData.runSource = '#!/bin/bash\n\n# 由于当前实现原因,接受参数应从第二位开始\n\necho "hello shell"\n\nexit 0'
}
this.shellDialogVisible = true
},
async confirmShell() {
const { code } = await editSchedule(this.sourceFromData)
if (code === 0) {
this.$message({
message: '编辑成功',
type: 'success'
})
this.shellDialogVisible = false
this.getList()
}
},
del(row) {
this.$confirm('确定要删除该任务吗?', '提示', {
confirmButtonText: '确定',
Expand Down
18 changes: 18 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2925,6 +2925,11 @@ coa@^2.0.2:
chalk "^2.4.1"
q "^1.1.2"

codemirror@^5.41.0:
version "5.65.2"
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.65.2.tgz#5799a70cb3d706e10f60e267245e3a75205d3dd9"
integrity sha512-SZM4Zq7XEC8Fhroqe3LxbEEX1zUPWH1wMr5zxiBuiUF64iYOUH/JI88v4tBag8MiBS8B8gRv8O1pPXGYXQ4ErA==

collection-visit@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0"
Expand Down Expand Up @@ -3706,6 +3711,11 @@ detect-node@^2.0.4:
resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.0.4.tgz#014ee8f8f669c5c58023da64b8179c083a28c46c"
integrity sha512-ZIzRpLJrOj7jjP2miAtgqIfmzbxa4ZOr5jJc601zklsfEx9oTzmmj2nVpIPRpNlRTIh8lc1kyViIY7BWSGNmKw==

diff-match-patch@^1.0.0:
version "1.0.5"
resolved "https://registry.yarnpkg.com/diff-match-patch/-/diff-match-patch-1.0.5.tgz#abb584d5f10cd1196dfc55aa03701592ae3f7b37"
integrity sha512-IayShXAgj/QMXgB0IWmKx+rOPuGMhqm5w6jvFxmVenXKIzRqTAAsbBPT3kWQeGANj3jGgvcvv4yK6SxqYmikgw==

diff-sequences@^24.9.0:
version "24.9.0"
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-24.9.0.tgz#5715d6244e2aa65f48bba0bc972db0b0b11e95b5"
Expand Down Expand Up @@ -10439,6 +10449,14 @@ vm-browserify@^1.0.1:
resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0"
integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==

vue-codemirror@^4.0.6:
version "4.0.6"
resolved "https://registry.yarnpkg.com/vue-codemirror/-/vue-codemirror-4.0.6.tgz#b786bb80d8d762a93aab8e46f79a81006f0437c4"
integrity sha512-ilU7Uf0mqBNSSV3KT7FNEeRIxH4s1fmpG4TfHlzvXn0QiQAbkXS9lLfwuZpaBVEnpP5CSE62iGJjoliTuA8poQ==
dependencies:
codemirror "^5.41.0"
diff-match-patch "^1.0.0"

vue-eslint-parser@^7.0.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-7.2.0.tgz#1e17ae94ca71e617025e05143c8ac5593aacb6ef"
Expand Down

0 comments on commit f77fe90

Please sign in to comment.