Skip to content

Commit 1a62acd

Browse files
committed
dashboard增加耗时排行
1 parent e962ffc commit 1a62acd

File tree

3 files changed

+143
-16
lines changed

3 files changed

+143
-16
lines changed

web/src/apps/workflows/module/dispatch/dashboard/index.vue

Lines changed: 139 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,57 @@
5151
</div>
5252
</div>
5353
<div class="row">
54-
<div class="col-md-12 dashboard-module">
54+
<div class="col-md-6 dashboard-module" style="margin-right: 10px">
5555
<div class="chart-title">
56-
<span>工作流实例与成功率统计</span>
57-
<div class="day-change">
58-
<div :class="daySelected === 1?'selected': ''" @click="changeDay(1)">今日</div>
59-
<div :class="daySelected === 2?'selected': ''" @click="changeDay(2)">昨日</div>
60-
</div>
56+
<span>{{$t('message.scheduler.processDefinitionStatistics')}}</span>
6157
</div>
6258
<div class="dashboard-module-content">
63-
<div id="mixedBarLine" style="height: 500px"></div>
59+
<m-define-user-count :project-id="searchParams.projectId" @goToList="goToList">
60+
</m-define-user-count>
61+
<Spin size="large" fix v-if="loading"></Spin>
62+
</div>
63+
</div>
64+
65+
<div class="col-md-6 dashboard-module">
66+
<div class="chart-title">
67+
<span>流程耗时排名</span>
68+
<div class="time-model">
69+
<template>
70+
<Date-picker
71+
style="width: 430px"
72+
v-model="consumptionTime"
73+
type="datetimerange"
74+
@on-change="changeTime"
75+
range-separator="-"
76+
format="yyyy-MM-dd HH:mm:ss">
77+
</Date-picker>
78+
</template>
79+
</div>
80+
<!--<div class="day-change">-->
81+
<!--<div :class="stateSelected === 1?'selected': ''" @click="changeState(1)">运行成功</div>-->
82+
<!--<div :class="stateSelected === 2?'selected': ''" @click="changeState(2)">运行失败</div>-->
83+
<!--</div>-->
84+
</div>
85+
<div class="row dashboard-module-content">
86+
<Table :columns="columns" :data="consumptionList" style="height: 430px;" class="consumption-table">
87+
<!--<template slot-scope="{ row }" slot="operation">-->
88+
<!--</template>-->
89+
</Table>
90+
<Spin size="large" fix v-if="loading"></Spin>
6491
</div>
6592
</div>
6693
</div>
6794
<div class="row">
6895
<div class="col-md-12 dashboard-module">
6996
<div class="chart-title">
70-
<span>{{$t('message.scheduler.processDefinitionStatistics')}}</span>
97+
<span>工作流实例与成功率统计</span>
98+
<div class="day-change">
99+
<div :class="daySelected === 1?'selected': ''" @click="changeDay(1)">今日</div>
100+
<div :class="daySelected === 2?'selected': ''" @click="changeDay(2)">昨日</div>
101+
</div>
71102
</div>
72103
<div class="dashboard-module-content">
73-
<m-define-user-count :project-id="searchParams.projectId" @goToList="goToList">
74-
</m-define-user-count>
75-
<Spin size="large" fix v-if="loading"></Spin>
104+
<div id="mixedBarLine" style="height: 500px"></div>
76105
</div>
77106
</div>
78107
</div>
@@ -90,6 +119,7 @@ import mProcessStateCount from './source/processStateCount'
90119
import mListConstruction from '../components/listConstruction/listConstruction'
91120
import { GetWorkspaceData } from '@/common/service/apiCommonMethod.js'
92121
import {formatDate} from '../convertor'
122+
import { tasksState } from '../config'
93123
94124
import echarts from 'echarts'
95125
@@ -112,13 +142,33 @@ export default {
112142
areaChart: null,
113143
daySelected: 1,
114144
stateSelected: 1,
115-
loading: false
145+
loading: false,
146+
147+
consumptionList: [],
148+
consumptionTime: [],
149+
consumptionParams: {}
116150
}
117151
},
118152
props: {
119153
120154
},
121155
methods: {
156+
getConsumptionData() {
157+
if (!this.projectName) return
158+
api.fetch(`dolphinscheduler/projects/${this.workspaceName}-${this.projectName}/instance/list-order-by-duration`, {
159+
pageSize: 10,
160+
pageNo: 1,
161+
startDate: this.consumptionParams.startDate || '',
162+
endDate: this.consumptionParams.endDate || '',
163+
}, 'get').then((res) => {
164+
this.consumptionList = res.totalList
165+
})
166+
},
167+
changeTime(val) {
168+
this.consumptionParams.startDate = val[0]
169+
this.consumptionParams.endDate = val[1]
170+
this.getConsumptionData()
171+
},
122172
changeState(state) {
123173
if (state) {
124174
this.stateSelected = state
@@ -394,6 +444,29 @@ export default {
394444
]
395445
};
396446
this.mixedBarLineChart.setOption(option)
447+
},
448+
showDuration(seconds) {
449+
let remain = seconds,
450+
dayUnit = 60*60*24,
451+
hourUnit = 60*60,
452+
minuteUnit = 60,
453+
str = ''
454+
if (remain / dayUnit >= 1) {
455+
str += `${parseInt(remain/dayUnit)}`
456+
remain = remain % dayUnit
457+
}
458+
if (remain / hourUnit >= 1) {
459+
str += `${parseInt(remain/hourUnit)}小时`
460+
remain = remain % hourUnit
461+
}
462+
if (remain / minuteUnit >= 1) {
463+
str += `${parseInt(remain/minuteUnit)}`
464+
remain = remain % minuteUnit
465+
}
466+
if (remain >= 1) {
467+
str += `${parseInt(remain)}`
468+
}
469+
return str
397470
}
398471
},
399472
created () {
@@ -410,6 +483,7 @@ export default {
410483
this.$nextTick(() => {
411484
this.changeDay()
412485
this.changeState()
486+
this.getConsumptionData()
413487
})
414488
})
415489
})
@@ -420,6 +494,41 @@ export default {
420494
mDefineUserCount,
421495
mProcessStateCount,
422496
//mTaskStatusCount
497+
},
498+
computed: {
499+
columns() {
500+
return [
501+
{
502+
type: 'index',
503+
width: 60,
504+
align: 'center'
505+
},
506+
{
507+
title: '实例名',
508+
key: 'name',
509+
//width: 240,
510+
align: 'center',
511+
},
512+
{
513+
title: this.$t('message.workflow.projectDetail.status'),
514+
key: 'state',
515+
align: 'center',
516+
width: 80,
517+
render: (h, scope) => {
518+
return h('span', {}, tasksState[scope.row.state].desc);
519+
},
520+
},
521+
{
522+
title: '耗时',
523+
key: 'duration',
524+
width: 210,
525+
align: 'center',
526+
render: (h, scope) => {
527+
return h('span', {}, this.showDuration(scope.row.duration))
528+
},
529+
}
530+
]
531+
}
423532
}
424533
}
425534
</script>
@@ -451,6 +560,16 @@ export default {
451560
@include font-color($workspace-title-color, $dark-workspace-title-color);
452561
}
453562
}
563+
.ivu-picker-panel-body {
564+
span {
565+
font-size: 12px;
566+
}
567+
}
568+
.ivu-btn-primary {
569+
>span {
570+
color: #fff;
571+
}
572+
}
454573
}
455574
.table-small-model {
456575
padding: 0 10px;
@@ -503,4 +622,12 @@ export default {
503622
}
504623
}
505624
}
625+
.consumption-table {
626+
border-top-left-radius: 4px;
627+
border-top-right-radius: 4px;
628+
.ivu-table {
629+
overflow-y: auto;
630+
overflow-x: hidden;
631+
}
632+
}
506633
</style>

web/src/apps/workflows/module/dispatch/dashboard/source/defineUserCount.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<div class="define-user-count-model">
33
<div v-if="msg">
44
<div class="data-area">
5-
<div id="process-definition-bar" style="height:500px"></div>
5+
<div id="process-definition-bar" style="height:430px"></div>
66
</div>
77
</div>
88
<div v-else>
9-
<m-no-data :height="530"></m-no-data>
9+
<m-no-data :height="430"></m-no-data>
1010
</div>
1111
</div>
1212
</template>

web/vue.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ module.exports = {
269269
}
270270
},
271271
"/dolphinscheduler": {
272-
target: "http://***REMOVED***:12345",
273-
//target: "https://dolphin.ctyun.cn:10002",
272+
//target: "http://***REMOVED***:12345",
273+
target: "https://dolphin.ctyun.cn:10002",
274274
changeOrigin: true,
275275
pathRewrite: {
276276
"^/dolphinscheduler": "/dolphinscheduler"

0 commit comments

Comments
 (0)