[Update] 更改作业中心/任务列表 卡片

This commit is contained in:
xinwen
2020-06-16 11:32:52 +08:00
parent b92d47e5ad
commit bfddc20a16
5 changed files with 63 additions and 90 deletions

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
}