mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-24 12:40:36 +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>
|
||||
<div>
|
||||
<JobRunDialog v-if="showJobRunDialog" :item="item" :visible.sync="showJobRunDialog" @submit="runJob" />
|
||||
<GenericListPage :header-actions="headerActions" :table-config="tableConfig" />
|
||||
</div>
|
||||
<TabPage
|
||||
:active-menu.sync="activeMenu"
|
||||
:submenu="submenu"
|
||||
>
|
||||
<component :is="activeMenu" />
|
||||
</TabPage>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import GenericListPage from '@/layout/components/GenericListPage'
|
||||
import { ActionsFormatter, DateFormatter, DetailFormatter } from '@/components/Table/TableFormatters'
|
||||
import JobRunDialog from '@/views/ops/Job/JobRunDialog'
|
||||
import { openTaskPage } from '@/utils/jms'
|
||||
import Adhoc from './components/Adhoc.vue'
|
||||
import Playbook from './components/PlayBook.vue'
|
||||
import TabPage from '@/layout/components/TabPage/index.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
JobRunDialog,
|
||||
GenericListPage
|
||||
Adhoc,
|
||||
TabPage,
|
||||
Playbook
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
item: {},
|
||||
runtime_parameters: {},
|
||||
showJobRunDialog: false,
|
||||
tableConfig: {
|
||||
url: '/api/v1/ops/jobs/',
|
||||
columnsShow: {
|
||||
min: ['name', 'actions'],
|
||||
default: [
|
||||
'name', 'type', 'asset_amount', 'average_time_cost',
|
||||
'summary', 'date_last_run', 'actions'
|
||||
]
|
||||
activeMenu: 'Adhoc',
|
||||
submenu: [
|
||||
{
|
||||
title: this.$t('AdhocManage'),
|
||||
name: 'Adhoc',
|
||||
hidden: () => !this.$hasPerm('ops.view_adhoc')
|
||||
},
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
{
|
||||
title: this.$t('PlaybookManage'),
|
||||
name: 'Playbook',
|
||||
hidden: () => !this.$hasPerm('ops.view_playbook')
|
||||
}
|
||||
},
|
||||
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>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
|
@@ -49,7 +49,3 @@ export default {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
|
@@ -36,12 +36,6 @@ export default {
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
|
@@ -146,8 +146,7 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
Reference in New Issue
Block a user