Merge branch 'dev' of github.com:jumpserver/lina into dev

This commit is contained in:
Bai
2020-06-16 11:57:55 +08:00
8 changed files with 86 additions and 95 deletions

View File

@@ -208,6 +208,8 @@
"activateSelected": "激活所选",
"bulkDeleteErrorMsg": "批量删除失败: ",
"bulkDeleteSuccessMsg": "批量删除成功",
"bulkRemoveErrorMsg": "批量移除失败: ",
"bulkRemoveSuccessMsg": "批量移除成功",
"createBy": "创建者",
"createErrorMsg": "创建失败",
"createSuccessMsg": "创建成功",
@@ -261,7 +263,8 @@
"updateSuccessMsg": "更新成功",
"SelectProperties": "选择属性",
"ObjectNotFoundOrDeletedMsg": "没有找到对应资源或者已被删除",
"removeSelected": "移除所选"
"removeSelected": "移除所选",
"removeWarningMsg": "你确定要移除"
},
"dashboard": {
"ActiveAsset": "近期被登录过",

View File

@@ -209,6 +209,8 @@
"activateSelected": "Activate selected",
"bulkDeleteErrorMsg": "Bulk delete failed: ",
"bulkDeleteSuccessMsg": "Bulk delete success",
"bulkRemoveErrorMsg": "Bulk remove failed: ",
"bulkRemoveSuccessMsg": "Bulk remove success",
"createBy": "Create by",
"createErrorMsg": "Create error",
"createSuccessMsg": "Create success",
@@ -261,7 +263,8 @@
"updateSuccessMsg": "Update success",
"SelectProperties": "Select properties",
"ObjectNotFoundOrDeletedMsg": "Resource lost or deleted",
"removeSelected": "Remove selected"
"removeSelected": "Remove selected",
"removeWarningMsg": "Are you sure to remove "
},
"dashboard": {
"ActiveAsset": "Asset active",

View File

@@ -1,7 +1,7 @@
<template>
<IBox :fa="icon" :type="type" :title="title" v-bind="$attrs">
<table class="run-info">
<tr>
<tr v-for="content in contents" :key="content.hostname">
<td>{{ content.hostname }}</td>
<td>{{ content.result }}</td>
</tr>
@@ -26,9 +26,9 @@ export default {
type: String,
default: ''
},
content: {
type: Object,
default: () => ({})
contents: {
type: Array,
default: () => ([])
},
url: {
type: String,

View File

@@ -4,8 +4,8 @@
<DetailCard :title="cardTitle" :items="detailCardItems" />
</el-col>
<el-col :span="10">
<RunInfoCard v-for="config in RunSuccessConfigs" :key="config.host" type="info" v-bind="config" />
<RunInfoCard v-for="config in RunFailedConfigs" :key="config.host" type="danger" style="margin-top: 15px" v-bind="config" />
<RunInfoCard type="danger" style="margin-top: 15px" v-bind="RunFailedConfig" />
<RunInfoCard type="info" v-bind="RunSuccessConfig" />
</el-col>
</el-row>
</template>
@@ -29,30 +29,17 @@ export default {
}
},
data() {
const last_success = toLastSucessDisplay(this.object.latest_execution)
const last_failure = toLastFailureDisplay(this.object.latest_execution)
return {
RunSuccessConfigs: last_success.map(host => {
return {
icon: 'fa-info',
title: this.$t('ops.lastRunSuccessHosts'),
content: {
hostname: host,
result: ''
}
}
}),
RunFailedConfigs: last_failure.map(([host, msg]) => {
return {
icon: 'fa-info',
title: this.$t('ops.lastRunFailedHosts'),
content: {
hostname: host,
result: msg
}
}
})
RunSuccessConfig: {
icon: 'fa-info',
title: this.$t('ops.lastRunSuccessHosts'),
contents: toLastSucessDisplay(this.object.latest_execution)
},
RunFailedConfig: {
icon: 'fa-info',
title: this.$t('ops.lastRunFailedHosts'),
contents: toLastFailureDisplay(this.object.latest_execution)
}
}
},
computed: {

View File

@@ -4,8 +4,8 @@
<DetailCard :title="cardTitle" :items="detailCardItems" />
</el-col>
<el-col :span="10">
<RunInfoCard v-for="config in RunSuccessConfigs" :key="config.host" type="info" v-bind="config" />
<RunInfoCard v-for="config in RunFailedConfigs" :key="config.host" type="danger" style="margin-top: 15px" v-bind="config" />
<RunInfoCard type="danger" style="margin-top: 15px" v-bind="RunFailedConfig" />
<RunInfoCard type="info" v-bind="RunSuccessConfig" />
</el-col>
</el-row>
</template>
@@ -29,30 +29,17 @@ export default {
}
},
data() {
const last_success = toLastSucessDisplay(this.object)
const last_failure = toLastFailureDisplay(this.object)
return {
RunSuccessConfigs: last_success.map(host => {
return {
icon: 'fa-info',
title: this.$t('ops.lastRunSuccessHosts'),
content: {
hostname: host,
result: ''
}
}
}),
RunFailedConfigs: last_failure.map(([host, msg]) => {
return {
icon: 'fa-info',
title: this.$t('ops.lastRunFailedHosts'),
content: {
hostname: host,
result: msg
}
}
})
RunSuccessConfig: {
icon: 'fa-info',
title: this.$t('ops.lastRunSuccessHosts'),
contents: toLastSucessDisplay(this.object)
},
RunFailedConfig: {
icon: 'fa-info',
title: this.$t('ops.lastRunFailedHosts'),
contents: toLastFailureDisplay(this.object)
}
}
},
computed: {

View File

@@ -4,8 +4,8 @@
<DetailCard :title="cardTitle" :items="detailCardItems" />
</el-col>
<el-col :span="10">
<RunInfoCard v-for="config in RunSuccessConfigs" :key="config.host" type="info" v-bind="config" />
<RunInfoCard v-for="config in RunFailedConfigs" :key="config.host" type="danger" style="margin-top: 15px" v-bind="config" />
<RunInfoCard type="danger" style="margin-top: 15px" v-bind="RunFailedConfig" />
<RunInfoCard type="info" v-bind="RunSuccessConfig" />
</el-col>
</el-row>
</template>
@@ -28,30 +28,17 @@ export default {
}
},
data() {
const last_success = toLastSucessDisplay(this.object.latest_execution)
const last_failure = toLastFailureDisplay(this.object.latest_execution)
return {
RunSuccessConfigs: last_success.map(host => {
return {
icon: 'fa-info',
title: this.$t('ops.lastRunSuccessHosts'),
content: {
hostname: host,
result: ''
}
}
}),
RunFailedConfigs: last_failure.map(([host, msg]) => {
return {
icon: 'fa-info',
title: this.$t('ops.lastRunFailedHosts'),
content: {
hostname: host,
result: msg
}
}
}),
RunSuccessConfig: {
icon: 'fa-info',
title: this.$t('ops.lastRunSuccessHosts'),
contents: toLastSucessDisplay(this.object.latest_execution)
},
RunFailedConfig: {
icon: 'fa-info',
title: this.$t('ops.lastRunFailedHosts'),
contents: toLastFailureDisplay(this.object.latest_execution)
},
taskData: {}
}
},

View File

@@ -1,24 +1,36 @@
export const toLastSucessDisplay = function(object) {
if (!object) return ['']
const last_success = object.last_success
last_success.length || last_success.push('')
return last_success
const last_success = object && object.last_success
if (!(last_success instanceof Array)) return []
return last_success.map(host => {
return {
hostname: host,
result: ''
}
})
}
export const toLastFailureDisplay = function(object) {
if (!object) return [['', '']]
const last_failure = []
for (const host in object.last_failure) {
const task = object.last_failure[host]
const last_failure = object && object.last_failure
if (!(last_failure instanceof Object)) return []
const ret = []
for (const host in last_failure) {
const task = last_failure[host]
const msgs = []
for (const name in task) {
msgs.push(`${name} => ${task[name].msg}`)
}
last_failure.push([host, msgs.join('\n')])
ret.push(
{
hostname: host,
result: msgs.join('\n')
}
)
}
last_failure.length || last_failure.push(['', ''])
return last_failure
return ret
}

View File

@@ -197,7 +197,11 @@ export default {
})
},
bulkDeleteCallback({ selectedRows, reloadTable }) {
const msg = this.$t('common.deleteWarningMsg') + ' ' + selectedRows.length + ' ' + this.$t('common.rows') + ' ?'
let msgPrefix = this.$t('common.deleteWarningMsg')
if (!this.currentOrgIsDefault) {
msgPrefix = this.$t('common.removeWarningMsg')
}
const msg = msgPrefix + ' ' + selectedRows.length + ' ' + this.$t('common.rows') + ' ?'
const title = this.$t('common.Info')
const performDelete = this.performBulkDelete
this.$alert(msg, title, {
@@ -211,9 +215,17 @@ export default {
await performDelete(selectedRows)
done()
reloadTable()
this.$message.success(this.$t('common.bulkDeleteSuccessMsg'))
let successMsg = this.$t('common.bulkDeleteSuccessMsg')
if (!this.currentOrgIsDefault) {
successMsg = this.$t('common.bulkRemoveSuccessMsg')
}
this.$message.success(successMsg)
} catch (error) {
this.$message.error(this.$t('common.bulkDeleteErrorMsg') + error)
let errorMsg = this.$t('common.bulkDeleteErrorMsg')
if (!this.currentOrgIsDefault) {
errorMsg = this.$t('common.bulkRemoveErrorMsg')
}
this.$message.error(errorMsg + error)
} finally {
instance.confirmButtonLoading = false
}