diff --git a/cutejava-front/src/api/devops/pipeline.js b/cutejava-front/src/api/devops/pipeline.js new file mode 100644 index 00000000..980c7d61 --- /dev/null +++ b/cutejava-front/src/api/devops/pipeline.js @@ -0,0 +1,25 @@ +import request from '@/utils/request' + +export function startPipeline() { + return request({ + url: 'api/devops/pipeline/start', + method: 'post' + }) +} + +export function restartPipeline() { + return request({ + url: 'api/devops/pipeline/restart', + method: 'post' + }) +} + +export function queryLastPipelineDetail(instanceId) { + return request({ + url: 'api/devops/pipeline/last', + method: 'post', + data: { + instanceId + } + }) +} diff --git a/cutejava-front/src/utils/myUtil.js b/cutejava-front/src/utils/myUtil.js index 972aa3cf..9f4b1ee0 100644 --- a/cutejava-front/src/utils/myUtil.js +++ b/cutejava-front/src/utils/myUtil.js @@ -75,6 +75,19 @@ const LabelUtil = { } } +const SizeUtil = { + formatBytes: function(value) { + if (typeof value !== 'number' || isNaN(value) || value <= 0) { + return '0 Bytes' + } + const units = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] + const index = Math.floor(Math.log(value) / Math.log(1024)) + const unit = units[Math.min(index, units.length - 1)] + const result = (value / Math.pow(1024, index)).toFixed(2) + return `${result} ${unit}` + } +} + const DateUtil = { formatDate: function(originVal) { if (originVal === undefined) { @@ -119,5 +132,6 @@ export { StringUtil, ObjectUtil, LabelUtil, - DateUtil + DateUtil, + SizeUtil } diff --git a/cutejava-front/src/views/components/dev/CutePipelineNode.vue b/cutejava-front/src/views/components/dev/CutePipelineNode.vue index 55fcc1de..dec42925 100644 --- a/cutejava-front/src/views/components/dev/CutePipelineNode.vue +++ b/cutejava-front/src/views/components/dev/CutePipelineNode.vue @@ -4,13 +4,13 @@ :style="{ borderTopWidth: '5px', borderTopStyle: 'solid', - borderTopColor: statusColorConst[templateData.status].color + borderTopColor: statusColorConst[pipelineData.currentNodeStatus ? pipelineData.currentNodeStatus : statusColorConst.pending.code].color }" >
-
{{ templateData.name }}
+
{{ pipelineData.name }}
-
+
- -
-
- - {{ buttonItem.title }} - -
-
-
+
+ {{ buttonItem.title }} + +
+
+ +
+
+ @@ -128,7 +132,7 @@
- +
这里是明细
@@ -155,28 +159,26 @@ export default { data() { return { statusColorConst: { - pending: { label: '未开始', color: '#C0C4CC' }, - running: { label: '运行中', color: '#67C23A' }, - success: { label: '执行成功', color: '#67C23A' }, - fail: { label: '执行失败', color: '#F56C6C' } + pending: { code: 'pending', label: '未开始', color: '#C0C4CC' }, + running: { code: 'running', label: '运行中', color: '#67C23A' }, + success: { code: 'success', label: '执行成功', color: '#67C23A' }, + fail: { code: 'fail', label: '执行失败', color: '#F56C6C' } }, - executeTimeStr: '' + executeTimeStr: '', + pipelineData: {} } }, watch: { templateData: { handler(newVal, oldVal) { + this.pipelineData = { ...newVal } this.executeTimeStr = this.renderDateTimeStr(newVal) }, deep: true } }, - // computed: { - // formatExecuteTimeStr() { - // return this.renderDateTimeStr(this.templateData) - // } - // }, mounted() { + this.pipelineData = this.templateData this.executeTimeStr = this.renderDateTimeStr(this.templateData) }, methods: { @@ -189,7 +191,20 @@ export default { case 'running': case 'success': case 'fail': - executeTimeStr = this.formatTimeDifference(newVal.startTime, newVal.updateTime) + if (newVal.currentNodeStatus !== this.statusColorConst.pending.code) { + if (newVal.startTime && newVal.finishTime) { + executeTimeStr = this.formatTimeDifference(newVal.startTime, newVal.finishTime) + return executeTimeStr + } + if (newVal.startTime) { + executeTimeStr = this.formatTimeDifference(newVal.startTime, new Date()) + return executeTimeStr + } + if (newVal.createTime) { + executeTimeStr = this.formatTimeDifference(newVal.createTime, new Date()) + return executeTimeStr + } + } break default: executeTimeStr = '' @@ -223,10 +238,11 @@ export default { if (seconds >= 0) { return `${seconds} 秒` } + return `${diffInMilliseconds} 毫秒` }, onCurrentNodeClick() { - const templateData = this.templateData || { click: false } - if (!templateData.click) { + const pipelineData = this.pipelineData || { click: false } + if (!pipelineData.click) { console.warn('当前流水线节点不支持查看明细') return } @@ -234,12 +250,12 @@ export default { this.$refs.detailDrawer.show() }, onNodeRetryClick() { - const templateData = this.templateData || { retry: false } - if (!templateData.retry) { + const pipelineData = this.pipelineData || { retry: false } + if (!pipelineData.retry) { console.warn('当前流水线节点不支持重试') return } - console.error('templateData', this.templateData) + console.error('pipelineData', this.pipelineData) }, onNodeOperationClick(buttonInfo) { console.error('buttonInfo', buttonInfo) @@ -277,7 +293,7 @@ export default { overflow: hidden; text-overflow: ellipsis; text-wrap: nowrap; - font-size: 18px; + font-size: 15px; text-align: center; } diff --git a/cutejava-front/src/views/componentsDemo/CutePipelineNodeDemo.vue b/cutejava-front/src/views/componentsDemo/CutePipelineNodeDemo.vue index fedafb7a..c38f6cc8 100644 --- a/cutejava-front/src/views/componentsDemo/CutePipelineNodeDemo.vue +++ b/cutejava-front/src/views/componentsDemo/CutePipelineNodeDemo.vue @@ -1,19 +1,19 @@