mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-24 04:33:06 +00:00
Merge pull request #4179 from jumpserver/pr@dev@fix_split_job
perf: split job management
This commit is contained in:
129
src/views/ops/Job/components/Adhoc.vue
Normal file
129
src/views/ops/Job/components/Adhoc.vue
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<GenericListTable :header-actions="headerActions" :table-config="tableConfig" />
|
||||||
|
<JobRunDialog v-if="showJobRunDialog" :item="item" :visible.sync="showJobRunDialog" @submit="runJob" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import JobRunDialog from '@/views/ops/Job/JobRunDialog'
|
||||||
|
import GenericListTable from '@/layout/components/GenericListTable'
|
||||||
|
|
||||||
|
import { openTaskPage } from '@/utils/jms'
|
||||||
|
import { ActionsFormatter, DateFormatter, DetailFormatter } from '@/components/Table/TableFormatters'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
GenericListTable,
|
||||||
|
JobRunDialog
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
item: {},
|
||||||
|
tableConfig: {
|
||||||
|
url: '/api/v1/ops/jobs/?type=adhoc',
|
||||||
|
columnsShow: {
|
||||||
|
min: ['name', 'actions'],
|
||||||
|
default: [
|
||||||
|
'name', 'type', 'asset_amount', 'average_time_cost',
|
||||||
|
'summary', 'date_last_run', 'actions'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
'name', 'type', 'summary', 'average_time_cost', 'asset_amount',
|
||||||
|
'date_last_run', 'comment', 'date_updated', 'date_created', 'actions'
|
||||||
|
],
|
||||||
|
columnsMeta: {
|
||||||
|
name: {
|
||||||
|
width: '140px',
|
||||||
|
formatter: DetailFormatter,
|
||||||
|
formatterArgs: {
|
||||||
|
can: true,
|
||||||
|
getRoute: ({ row }) => ({
|
||||||
|
name: 'JobDetail',
|
||||||
|
params: { id: row.id }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
type: {
|
||||||
|
width: '96px',
|
||||||
|
formatter: (row) => {
|
||||||
|
return row.type.label
|
||||||
|
}
|
||||||
|
},
|
||||||
|
comment: {
|
||||||
|
width: '240px'
|
||||||
|
},
|
||||||
|
summary: {
|
||||||
|
label: this.$t('Summary'),
|
||||||
|
formatter: (row) => {
|
||||||
|
return row.summary['success'] + '/' + row.summary['total']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
average_time_cost: {
|
||||||
|
formatter: (row) => {
|
||||||
|
return row.average_time_cost.toFixed(2) + 's'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
asset_amount: {
|
||||||
|
label: this.$t('AssetsOfNumber'),
|
||||||
|
formatter: (row) => {
|
||||||
|
return row.assets.length
|
||||||
|
}
|
||||||
|
},
|
||||||
|
date_last_run: {
|
||||||
|
width: '140px',
|
||||||
|
formatter: DateFormatter
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
formatter: ActionsFormatter,
|
||||||
|
formatterArgs: {
|
||||||
|
hasUpdate: true,
|
||||||
|
canUpdate: this.$hasPerm('ops.change_job') && !this.$store.getters.currentOrgIsRoot,
|
||||||
|
updateRoute: 'JobUpdate',
|
||||||
|
hasDelete: true,
|
||||||
|
canDelete: this.$hasPerm('ops.delete_job'),
|
||||||
|
hasClone: false,
|
||||||
|
extraActions: [
|
||||||
|
{
|
||||||
|
title: this.$t('Run'),
|
||||||
|
name: 'run',
|
||||||
|
can: this.$hasPerm('ops.add_jobexecution') && !this.$store.getters.currentOrgIsRoot,
|
||||||
|
callback: ({ row }) => {
|
||||||
|
if (row?.use_parameter_define && row?.parameters_define) {
|
||||||
|
const params = JSON.parse(row.parameters_define)
|
||||||
|
if (Object.keys(params).length > 0) {
|
||||||
|
this.item = row
|
||||||
|
this.showJobRunDialog = true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.runJob(row)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
headerActions: {
|
||||||
|
createRoute: 'JobCreate',
|
||||||
|
hasRefresh: true,
|
||||||
|
hasExport: false,
|
||||||
|
hasImport: false
|
||||||
|
},
|
||||||
|
showJobRunDialog: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
runJob(row, parameters) {
|
||||||
|
this.$axios.post('/api/v1/ops/job-executions/', {
|
||||||
|
job: row.id,
|
||||||
|
parameters: parameters
|
||||||
|
}).then((resp) => {
|
||||||
|
openTaskPage(resp.task_id)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
136
src/views/ops/Job/components/PlayBook.vue
Normal file
136
src/views/ops/Job/components/PlayBook.vue
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<GenericListTable :header-actions="headerActions" :table-config="tableConfig" />
|
||||||
|
<JobRunDialog v-if="showJobRunDialog" :item="item" :visible.sync="showJobRunDialog" @submit="runJob" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import JobRunDialog from '@/views/ops/Job/JobRunDialog'
|
||||||
|
import GenericListTable from '@/layout/components/GenericListTable'
|
||||||
|
|
||||||
|
import { openTaskPage } from '@/utils/jms'
|
||||||
|
import { ActionsFormatter, DateFormatter, DetailFormatter } from '@/components/Table/TableFormatters'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
GenericListTable,
|
||||||
|
JobRunDialog
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
item: {},
|
||||||
|
tableConfig: {
|
||||||
|
url: '/api/v1/ops/jobs/?type=playbook',
|
||||||
|
columnsShow: {
|
||||||
|
min: ['name', 'actions'],
|
||||||
|
default: [
|
||||||
|
'name', 'type', 'asset_amount', 'average_time_cost',
|
||||||
|
'summary', 'date_last_run', 'actions'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
'name', 'type', 'summary', 'average_time_cost', 'asset_amount',
|
||||||
|
'date_last_run', 'comment', 'date_updated', 'date_created', 'actions'
|
||||||
|
],
|
||||||
|
columnsMeta: {
|
||||||
|
name: {
|
||||||
|
width: '140px',
|
||||||
|
formatter: DetailFormatter,
|
||||||
|
formatterArgs: {
|
||||||
|
can: true,
|
||||||
|
getRoute: ({ row }) => ({
|
||||||
|
name: 'JobDetail',
|
||||||
|
params: { id: row.id }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
type: {
|
||||||
|
width: '96px',
|
||||||
|
formatter: (row) => {
|
||||||
|
return row.type.label
|
||||||
|
}
|
||||||
|
},
|
||||||
|
comment: {
|
||||||
|
width: '240px'
|
||||||
|
},
|
||||||
|
summary: {
|
||||||
|
label: this.$t('Summary'),
|
||||||
|
formatter: (row) => {
|
||||||
|
return row.summary['success'] + '/' + row.summary['total']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
average_time_cost: {
|
||||||
|
formatter: (row) => {
|
||||||
|
return row.average_time_cost.toFixed(2) + 's'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
asset_amount: {
|
||||||
|
label: this.$t('AssetsOfNumber'),
|
||||||
|
formatter: (row) => {
|
||||||
|
return row.assets.length
|
||||||
|
}
|
||||||
|
},
|
||||||
|
date_last_run: {
|
||||||
|
width: '140px',
|
||||||
|
formatter: DateFormatter
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
formatter: ActionsFormatter,
|
||||||
|
formatterArgs: {
|
||||||
|
hasUpdate: true,
|
||||||
|
canUpdate: this.$hasPerm('ops.change_job') && !this.$store.getters.currentOrgIsRoot,
|
||||||
|
updateRoute: 'JobUpdate',
|
||||||
|
hasDelete: true,
|
||||||
|
canDelete: this.$hasPerm('ops.delete_job'),
|
||||||
|
hasClone: false,
|
||||||
|
extraActions: [
|
||||||
|
{
|
||||||
|
title: this.$t('Run'),
|
||||||
|
name: 'run',
|
||||||
|
can: this.$hasPerm('ops.add_jobexecution') && !this.$store.getters.currentOrgIsRoot,
|
||||||
|
callback: ({ row }) => {
|
||||||
|
if (row?.use_parameter_define && row?.parameters_define) {
|
||||||
|
const params = JSON.parse(row.parameters_define)
|
||||||
|
if (Object.keys(params).length > 0) {
|
||||||
|
this.item = row
|
||||||
|
this.showJobRunDialog = true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.runJob(row)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
headerActions: {
|
||||||
|
hasRefresh: true,
|
||||||
|
hasExport: false,
|
||||||
|
hasImport: false,
|
||||||
|
createRoute: () => {
|
||||||
|
return {
|
||||||
|
name: 'JobCreate',
|
||||||
|
query: {
|
||||||
|
type: 'playbook'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
showJobRunDialog: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
runJob(row, parameters) {
|
||||||
|
this.$axios.post('/api/v1/ops/job-executions/', {
|
||||||
|
job: row.id,
|
||||||
|
parameters: parameters
|
||||||
|
}).then((resp) => {
|
||||||
|
openTaskPage(resp.task_id)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
@@ -1,151 +1,39 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<TabPage
|
||||||
<JobRunDialog v-if="showJobRunDialog" :item="item" :visible.sync="showJobRunDialog" @submit="runJob" />
|
:active-menu.sync="activeMenu"
|
||||||
<GenericListPage :header-actions="headerActions" :table-config="tableConfig" />
|
:submenu="submenu"
|
||||||
</div>
|
>
|
||||||
|
<component :is="activeMenu" />
|
||||||
|
</TabPage>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import GenericListPage from '@/layout/components/GenericListPage'
|
import Adhoc from './components/Adhoc.vue'
|
||||||
import { ActionsFormatter, DateFormatter, DetailFormatter } from '@/components/Table/TableFormatters'
|
import Playbook from './components/PlayBook.vue'
|
||||||
import JobRunDialog from '@/views/ops/Job/JobRunDialog'
|
import TabPage from '@/layout/components/TabPage/index.vue'
|
||||||
import { openTaskPage } from '@/utils/jms'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
JobRunDialog,
|
Adhoc,
|
||||||
GenericListPage
|
TabPage,
|
||||||
|
Playbook
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
item: {},
|
activeMenu: 'Adhoc',
|
||||||
runtime_parameters: {},
|
submenu: [
|
||||||
showJobRunDialog: false,
|
{
|
||||||
tableConfig: {
|
title: this.$t('AdhocManage'),
|
||||||
url: '/api/v1/ops/jobs/',
|
name: 'Adhoc',
|
||||||
columnsShow: {
|
hidden: () => !this.$hasPerm('ops.view_adhoc')
|
||||||
min: ['name', 'actions'],
|
|
||||||
default: [
|
|
||||||
'name', 'type', 'asset_amount', 'average_time_cost',
|
|
||||||
'summary', 'date_last_run', 'actions'
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
columns: [
|
{
|
||||||
'name', 'type', 'summary', 'average_time_cost', 'asset_amount',
|
title: this.$t('PlaybookManage'),
|
||||||
'date_last_run', 'comment', 'date_updated', 'date_created', 'actions'
|
name: 'Playbook',
|
||||||
],
|
hidden: () => !this.$hasPerm('ops.view_playbook')
|
||||||
columnsMeta: {
|
|
||||||
name: {
|
|
||||||
width: '140px',
|
|
||||||
formatter: DetailFormatter,
|
|
||||||
formatterArgs: {
|
|
||||||
can: true,
|
|
||||||
getRoute: ({ row }) => ({
|
|
||||||
name: 'JobDetail',
|
|
||||||
params: { id: row.id }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
type: {
|
|
||||||
width: '96px',
|
|
||||||
formatter: (row) => {
|
|
||||||
return row.type.label
|
|
||||||
}
|
|
||||||
},
|
|
||||||
comment: {
|
|
||||||
width: '240px'
|
|
||||||
},
|
|
||||||
summary: {
|
|
||||||
label: this.$t('Summary'),
|
|
||||||
formatter: (row) => {
|
|
||||||
return row.summary['success'] + '/' + row.summary['total']
|
|
||||||
}
|
|
||||||
},
|
|
||||||
average_time_cost: {
|
|
||||||
formatter: (row) => {
|
|
||||||
return row.average_time_cost.toFixed(2) + 's'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
asset_amount: {
|
|
||||||
label: this.$t('AssetsOfNumber'),
|
|
||||||
formatter: (row) => {
|
|
||||||
return row.assets.length
|
|
||||||
}
|
|
||||||
},
|
|
||||||
date_last_run: {
|
|
||||||
width: '140px',
|
|
||||||
formatter: DateFormatter
|
|
||||||
},
|
|
||||||
actions: {
|
|
||||||
formatter: ActionsFormatter,
|
|
||||||
formatterArgs: {
|
|
||||||
hasUpdate: true,
|
|
||||||
canUpdate: this.$hasPerm('ops.change_job') && !this.$store.getters.currentOrgIsRoot,
|
|
||||||
updateRoute: 'JobUpdate',
|
|
||||||
hasDelete: true,
|
|
||||||
canDelete: this.$hasPerm('ops.delete_job'),
|
|
||||||
hasClone: false,
|
|
||||||
extraActions: [
|
|
||||||
{
|
|
||||||
title: this.$t('Run'),
|
|
||||||
name: 'run',
|
|
||||||
can: this.$hasPerm('ops.add_jobexecution') && !this.$store.getters.currentOrgIsRoot,
|
|
||||||
callback: ({ row }) => {
|
|
||||||
if (row?.use_parameter_define && row?.parameters_define) {
|
|
||||||
const params = JSON.parse(row.parameters_define)
|
|
||||||
if (Object.keys(params).length > 0) {
|
|
||||||
this.item = row
|
|
||||||
this.showJobRunDialog = true
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.runJob(row)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
]
|
||||||
headerActions: {
|
|
||||||
createRoute: 'JobCreate',
|
|
||||||
hasRefresh: true,
|
|
||||||
hasExport: false,
|
|
||||||
hasImport: false,
|
|
||||||
moreCreates: {
|
|
||||||
callback: (item) => {
|
|
||||||
this.$router.push({
|
|
||||||
name: 'JobCreate',
|
|
||||||
query: { type: item.name }
|
|
||||||
})
|
|
||||||
},
|
|
||||||
dropdown: [
|
|
||||||
{
|
|
||||||
name: 'adhoc',
|
|
||||||
title: this.$t('Command')
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'playbook',
|
|
||||||
title: 'Playbook'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
runJob(row, parameters) {
|
|
||||||
this.$axios.post('/api/v1/ops/job-executions/', {
|
|
||||||
job: row.id,
|
|
||||||
parameters: parameters
|
|
||||||
}).then((resp) => {
|
|
||||||
openTaskPage(resp.task_id)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
@@ -49,7 +49,3 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
@@ -36,12 +36,6 @@ export default {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
@@ -146,8 +146,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
methods: {}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user