From bf79d40c00d9f1dc2b33d1d21dda9845f22de334 Mon Sep 17 00:00:00 2001 From: Bai Date: Mon, 15 Jun 2020 15:51:50 +0800 Subject: [PATCH 01/18] =?UTF-8?q?[Update]=20=E8=B5=84=E4=BA=A7=E8=AF=A6?= =?UTF-8?q?=E6=83=85=EF=BC=8C=E6=97=A0=E5=85=B3=E8=81=94=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E6=97=B6=E6=98=BE=E7=A4=BA=E6=97=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/LabelCard/index.vue | 1 + src/i18n/langs/cn.json | 1 + src/i18n/langs/en.json | 1 + 3 files changed, 3 insertions(+) diff --git a/src/components/LabelCard/index.vue b/src/components/LabelCard/index.vue index 28cf21276..eee89c46c 100644 --- a/src/components/LabelCard/index.vue +++ b/src/components/LabelCard/index.vue @@ -1,6 +1,7 @@ @@ -14,6 +14,7 @@ import DetailCard from '@/components/DetailCard/index' import { toSafeLocalDateStr } from '@/utils/common' import RunInfoCard from '../../RunInfoCard' +import { toLastFailureDisplay, toLastSucessDisplay } from '../business' export default { name: 'AdhocDetail', @@ -28,28 +29,35 @@ export default { } }, data() { + const last_success = toLastSucessDisplay(this.object.latest_execution) + const last_failure = toLastFailureDisplay(this.object.latest_execution) + return { - RunSuccessConfig: { - icon: 'fa-info', - title: this.$t('ops.lastRunSuccessHosts'), - content: { - hostname: 'linux', - result: 'api没有该数据,api没有该数据api没有该数据api没有该数据api没有该数据api没有该数据api没有该数据api没有该数据api没有该数据api没有该数据api没有该数据api没有该数据' + RunSuccessConfigs: last_success.map(host => { + return { + icon: 'fa-info', + title: this.$t('ops.lastRunSuccessHosts'), + content: { + hostname: host, + result: '' + } } - }, - RunFailedConfig: { - icon: 'fa-info', - title: this.$t('ops.lastRunFailedHosts'), - content: { - hostname: 'window', - result: 'api没有该数据api没有该数据api没有该数据api没有该数据api没有该数据api没有该数据api没有该数据api没有该数据' + }), + RunFailedConfigs: last_failure.map(([host, msg]) => { + return { + icon: 'fa-info', + title: this.$t('ops.lastRunFailedHosts'), + content: { + hostname: host, + result: msg + } } - } + }) } }, computed: { cardTitle() { - return 'api 没有该数据' + return `${this.object.task_name}: ${this.object.short_id}` }, detailCardItems() { return [ @@ -80,7 +88,7 @@ export default { }, { key: this.$t('common.createBy'), - value: 'api 没有该数据' + value: this.object.created_by }, { key: this.$t('common.dateCreated'), @@ -88,27 +96,34 @@ export default { }, { key: this.$t('ops.runTimes'), - value: 'api 没有该数据' + value: this.object.run_times }, { key: this.$t('ops.lastRun'), - value: 'api 没有该数据' + value: this.object.latest_execution.last_run }, { key: this.$t('ops.timeDelta'), - value: 'api 没有该数据' + value: this.object.latest_execution.timedelta }, { key: this.$t('ops.isFinished'), - value: 'api 没有该数据' + value: this.toBooleanDisplay(this.object.latest_execution.is_finished) }, { key: this.$t('ops.isSuccess'), - value: 'api 没有该数据' + value: this.toBooleanDisplay(this.object.latest_execution.is_success) }, { key: this.$t('ops.tasks'), - value: 'api 没有该数据' + value: this.toContentsDisplay(this.object.tasks), + formatter(row, value) { + return (
{ + value.map((content) => { + return
{ content }
+ })} +
) + } } ] } @@ -122,6 +137,23 @@ export default { }, disPlayOptions(options) { return options.replace(/:/g, '=').replace(/'/g, '').replace('{', '').replace('}', '') + }, + toContentsDisplay(contents) { + const lines = [] + for (let i = 0; i < contents.length; i++) { + const content = contents[i] + lines.push(`${i}. ${content.name} ::: ${content.action.module}`) + } + return lines + }, + toBooleanDisplay(value) { + if (value === true) { + return this.$t('ops.Yes') + } else if (value === false) { + return this.$t('ops.No') + } else { + return this.$t('ops.Unkown') + } } } } diff --git a/src/views/ops/TaskDetail/HistoryExecutionDetail/HistoryExecutionDetail.vue b/src/views/ops/TaskDetail/HistoryExecutionDetail/HistoryExecutionDetail.vue index ee6e3ace5..9bdf3259a 100644 --- a/src/views/ops/TaskDetail/HistoryExecutionDetail/HistoryExecutionDetail.vue +++ b/src/views/ops/TaskDetail/HistoryExecutionDetail/HistoryExecutionDetail.vue @@ -4,8 +4,8 @@ - - + + @@ -14,6 +14,7 @@ import DetailCard from '@/components/DetailCard' import { toSafeLocalDateStr } from '@/utils/common' import RunInfoCard from '../../RunInfoCard' +import { toLastFailureDisplay, toLastSucessDisplay } from '../business' export default { name: 'HistoryExecutionDetail', @@ -28,23 +29,30 @@ export default { } }, data() { + const last_success = toLastSucessDisplay(this.object) + const last_failure = toLastFailureDisplay(this.object) + return { - RunSuccessConfig: { - icon: 'fa-info', - title: this.$t('ops.lastRunSuccessHosts'), - content: { - hostname: 'linux', - result: 'api没有该数据==api没有该数据api没有该数据api没有该数据api没有该数据' + RunSuccessConfigs: last_success.map(host => { + return { + icon: 'fa-info', + title: this.$t('ops.lastRunSuccessHosts'), + content: { + hostname: host, + result: '' + } } - }, - RunFailedConfig: { - icon: 'fa-info', - title: this.$t('ops.lastRunFailedHosts'), - content: { - hostname: 'linux', - result: 'api没有该数据==api没有该数据api没有该数据api没有该数据api没有该数据' + }), + RunFailedConfigs: last_failure.map(([host, msg]) => { + return { + icon: 'fa-info', + title: this.$t('ops.lastRunFailedHosts'), + content: { + hostname: host, + result: msg + } } - } + }) } }, computed: { diff --git a/src/views/ops/TaskDetail/TaskDetail.vue b/src/views/ops/TaskDetail/TaskDetail.vue index 424c3175e..8a053fae9 100644 --- a/src/views/ops/TaskDetail/TaskDetail.vue +++ b/src/views/ops/TaskDetail/TaskDetail.vue @@ -13,6 +13,7 @@