Browse Source

[DS-6417][feat] add ‘view log' in the task instance context menu (#6421)

2.0.7-release
wangyizhi 3 years ago committed by GitHub
parent
commit
a9d805d791
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/canvas/contextMenu.vue
  2. 81
      dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.vue
  3. 7
      dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/log.vue
  4. 7
      dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskInstance/_source/list.vue

12
dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/canvas/contextMenu.vue

@ -35,6 +35,9 @@
<menu-item :disabled="readOnly" @on-click="onDelete"> <menu-item :disabled="readOnly" @on-click="onDelete">
{{ $t("Delete") }} {{ $t("Delete") }}
</menu-item> </menu-item>
<menu-item v-if="dagChart.type === 'instance'" :disabled="!logMenuVisible" @on-click="showLog">
{{ $t('View log') }}
</menu-item>
</div> </div>
</template> </template>
@ -72,6 +75,12 @@
}, },
readOnly () { readOnly () {
return this.isDetails return this.isDetails
},
logMenuVisible () {
if (this.dagChart.taskInstances.length > 0) {
return !!this.dagChart.taskInstances.find(taskInstance => taskInstance.taskCode === this.currentTask.code)
}
return true
} }
}, },
mounted () { mounted () {
@ -136,6 +145,9 @@
onDelete () { onDelete () {
this.dagCanvas.removeNode(this.currentTask.code) this.dagCanvas.removeNode(this.currentTask.code)
}, },
showLog () {
this.dagChart.showLogDialog(this.currentTask.code)
},
show (x = 0, y = 0) { show (x = 0, y = 0) {
this.dagCanvas.lockScroller() this.dagCanvas.lockScroller()
this.visible = true this.visible = true

81
dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.vue

@ -25,7 +25,7 @@
:wrapperClosable="false" :wrapperClosable="false"
> >
<!-- fix the bug that Element-ui(2.13.2) auto focus on the first input --> <!-- fix the bug that Element-ui(2.13.2) auto focus on the first input -->
<div style="width:0px;height:0px;overflow:hidden;"> <div style="width: 0px; height: 0px; overflow: hidden">
<el-input type="text" /> <el-input type="text" />
</div> </div>
<m-form-model <m-form-model
@ -69,6 +69,13 @@
@closeVersion="closeVersion" @closeVersion="closeVersion"
></m-versions> ></m-versions>
</el-drawer> </el-drawer>
<m-log
v-if="type === 'instance' && logDialog"
:item="logTaskInstance"
source='dag'
:task-instance-id="logTaskInstance.id"
@close="closeLogDialog"
></m-log>
</div> </div>
</template> </template>
@ -82,6 +89,7 @@
import mStart from '../../projects/pages/definition/pages/list/_source/start.vue' import mStart from '../../projects/pages/definition/pages/list/_source/start.vue'
import edgeEditModel from './canvas/edgeEditModel.vue' import edgeEditModel from './canvas/edgeEditModel.vue'
import mVersions from '../../projects/pages/definition/pages/list/_source/versions.vue' import mVersions from '../../projects/pages/definition/pages/list/_source/versions.vue'
import mLog from './formModel/log.vue'
const DEFAULT_NODE_DATA = { const DEFAULT_NODE_DATA = {
id: null, id: null,
@ -99,7 +107,8 @@
mUdp, mUdp,
mStart, mStart,
edgeEditModel, edgeEditModel,
mVersions mVersions,
mLog
}, },
provide () { provide () {
return { return {
@ -140,7 +149,11 @@
// the task status refresh timer // the task status refresh timer
statusTimer: null, statusTimer: null,
// the process instance id // the process instance id
instanceId: -1 instanceId: -1,
// log dialog
logDialog: false,
logTaskInstance: null,
taskInstances: []
} }
}, },
mounted () { mounted () {
@ -294,7 +307,8 @@
tasks: tasks, tasks: tasks,
locations: locations locations: locations
}) })
}).then((res) => { })
.then((res) => {
if (this.verifyConditions(res.tasks)) { if (this.verifyConditions(res.tasks)) {
this.loading(true) this.loading(true)
const definitionCode = this.definitionCode const definitionCode = this.definitionCode
@ -345,8 +359,9 @@
}) })
} }
} }
}).catch((err) => { })
let msg = typeof err === 'string' ? err : (err.msg || '') .catch((err) => {
let msg = typeof err === 'string' ? err : err.msg || ''
this.$message.error(msg) this.$message.error(msg)
}) })
}, },
@ -432,7 +447,9 @@
tasksMap[task.code] = task tasksMap[task.code] = task
}) })
const headEdges = tasks.filter(task => !preTaskMap[task.code]).map((task) => { const headEdges = tasks
.filter((task) => !preTaskMap[task.code])
.map((task) => {
return { return {
name: '', name: '',
preTaskCode: 0, preTaskCode: 0,
@ -445,7 +462,8 @@
} }
}) })
return edges.map(edge => { return edges
.map((edge) => {
return { return {
name: edge.label, name: edge.label,
preTaskCode: edge.sourceId, preTaskCode: edge.sourceId,
@ -456,7 +474,8 @@
conditionType: 0, conditionType: 0,
conditionParams: {} conditionParams: {}
} }
}).concat(headEdges) })
.concat(headEdges)
}, },
backfill () { backfill () {
const tasks = this.tasks const tasks = this.tasks
@ -479,8 +498,10 @@
}) })
}, },
toSubProcess ({ subProcessCode, subInstanceId }) { toSubProcess ({ subProcessCode, subInstanceId }) {
const tarIdentifier = this.type === 'instance' ? subInstanceId : subProcessCode const tarIdentifier =
const curIdentifier = this.type === 'instance' ? this.instanceId : this.definitionCode this.type === 'instance' ? subInstanceId : subProcessCode
const curIdentifier =
this.type === 'instance' ? this.instanceId : this.definitionCode
let subs = [] let subs = []
let olds = this.$route.query.subs let olds = this.$route.query.subs
if (olds) { if (olds) {
@ -532,6 +553,7 @@
this.$message(this.$t('Refresh status succeeded')) this.$message(this.$t('Refresh status succeeded'))
const { taskList } = res.data const { taskList } = res.data
if (taskList) { if (taskList) {
this.taskInstances = taskList
taskList.forEach((taskInstance) => { taskList.forEach((taskInstance) => {
this.$refs.canvas.setNodeStatus({ this.$refs.canvas.setNodeStatus({
code: taskInstance.taskCode, code: taskInstance.taskCode,
@ -598,11 +620,13 @@
this.switchProcessDefinitionVersion({ this.switchProcessDefinitionVersion({
version: version, version: version,
code: processDefinitionCode code: processDefinitionCode
}).then(res => { })
.then((res) => {
this.$message.success($t('Switch Version Successfully')) this.$message.success($t('Switch Version Successfully'))
this.closeVersion() this.closeVersion()
this.definitionDetails.init() this.definitionDetails.init()
}).catch(e => { })
.catch((e) => {
this.$message.error(e.msg || '') this.$message.error(e.msg || '')
}) })
}, },
@ -611,12 +635,14 @@
pageNo: pageNo, pageNo: pageNo,
pageSize: pageSize, pageSize: pageSize,
code: processDefinitionCode code: processDefinitionCode
}).then(res => { })
.then((res) => {
this.versionData.processDefinitionVersions = res.data.totalList this.versionData.processDefinitionVersions = res.data.totalList
this.versionData.total = res.data.total this.versionData.total = res.data.total
this.versionData.pageSize = res.data.pageSize this.versionData.pageSize = res.data.pageSize
this.versionData.pageNo = res.data.currentPage this.versionData.pageNo = res.data.currentPage
}).catch(e => { })
.catch((e) => {
this.$message.error(e.msg || '') this.$message.error(e.msg || '')
}) })
}, },
@ -624,16 +650,37 @@
this.deleteProcessDefinitionVersion({ this.deleteProcessDefinitionVersion({
version: version, version: version,
code: processDefinitionCode code: processDefinitionCode
}).then(res => { })
.then((res) => {
this.$message.success(res.msg || '') this.$message.success(res.msg || '')
this.getProcessVersions({ this.getProcessVersions({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
processDefinitionCode: processDefinitionCode processDefinitionCode: processDefinitionCode
}) })
}).catch(e => { })
.catch((e) => {
this.$message.error(e.msg || '') this.$message.error(e.msg || '')
}) })
},
/**
* Log dialog
*/
closeLogDialog () {
this.logDialog = false
this.logTaskInstance = null
},
showLogDialog (taskDefinitionCode) {
const taskInstance = this.taskInstances.find(taskInstance => {
return taskInstance.taskCode === taskDefinitionCode
})
if (taskInstance) {
this.logTaskInstance = {
id: taskInstance.id,
type: taskInstance.taskType
}
this.logDialog = true
}
} }
} }
} }

7
dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/log.vue

@ -94,7 +94,6 @@
type: String, type: String,
default: 'from' default: 'from'
}, },
logId: Number,
taskInstanceId: { taskInstanceId: {
type: Number, type: Number,
default: 0 default: 0
@ -172,7 +171,7 @@
*/ */
_downloadLog () { _downloadLog () {
downloadFile('log/download-log', { downloadFile('log/download-log', {
taskInstanceId: this.taskInstanceId || this.logId taskInstanceId: this.taskInstanceId
}) })
}, },
/** /**
@ -233,7 +232,7 @@
watch: {}, watch: {},
created () { created () {
// Source is a task instance // Source is a task instance
if (this.source === 'list') { if (this.source === 'list' || this.source === 'dag') {
this.$message.info(`${i18n.$t('Loading Log...')}`) this.$message.info(`${i18n.$t('Loading Log...')}`)
this._ckLog() this._ckLog()
} }
@ -246,7 +245,7 @@
computed: { computed: {
_rtParam () { _rtParam () {
return { return {
taskInstanceId: this.taskInstanceId || this.logId, taskInstanceId: this.taskInstanceId,
skipLineNum: parseInt(`${this.loadingIndex ? this.loadingIndex + '000' : 0}`), skipLineNum: parseInt(`${this.loadingIndex ? this.loadingIndex + '000' : 0}`),
limit: parseInt(`${this.loadingIndex ? this.loadingIndex + 1 : 1}000`) limit: parseInt(`${this.loadingIndex ? this.loadingIndex + 1 : 1}000`)
} }

7
dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/taskInstance/_source/list.vue

@ -90,7 +90,7 @@
:show-close="false" :show-close="false"
:visible.sync="logDialog" :visible.sync="logDialog"
width="auto"> width="auto">
<m-log :key="logId" :item="item" :source="source" :logId="logId" @ok="ok" @close="close"></m-log> <m-log :key="taskInstanceId" :item="item" :source="source" :taskInstanceId="taskInstanceId" @close="close"></m-log>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
@ -110,7 +110,7 @@
logDialog: false, logDialog: false,
item: {}, item: {},
source: '', source: '',
logId: null taskInstanceId: null
} }
}, },
props: { props: {
@ -127,10 +127,9 @@
_refreshLog (item) { _refreshLog (item) {
this.item = item this.item = item
this.source = 'list' this.source = 'list'
this.logId = item.id this.taskInstanceId = item.id
this.logDialog = true this.logDialog = true
}, },
ok () {},
close () { close () {
this.logDialog = false this.logDialog = false
}, },

Loading…
Cancel
Save