{{x.hostLog.join("\r\n")}}
@@ -272,6 +251,7 @@ function sseConnect() {
eventSource = new EventSource(serverPaths.ssePush)
eventSource.addEventListener("ERROR", function (e) {
uiUtils.showToast("error", e.data)
+ eventSource.close()
})
eventSource.addEventListener("TASK_EXECUTE_END", function (e) {
uiUtils.showToast("success", e.data)
@@ -316,22 +296,23 @@ function pageChanged(page) {
row.type = item.type
row.cron = item.cron
row.concrete = {}
- if (item.type === 1) {
- row.typeText = "部署任务"
- row.concrete.uploadPath = item.concrete.uploadPath
- row.concrete.appId = item.concrete.appId
- row.concrete.scriptId = item.concrete.scriptId
- row.concrete.hostGroupId = item.concrete.hostGroupId
- }
+ row.concrete.uploadPath = item.concrete.uploadPath
+ row.concrete.appId = item.concrete.appId
+ row.concrete.scriptId = item.concrete.scriptId
+ row.concrete.hostGroupId = item.concrete.hostGroupId
row.status = item.status
if (item.status === 0) {
row.statusText = "未运行"
+ row.statusTagType = "info"
} else if (item.status === 1) {
row.statusText = "运行中"
+ row.statusTagType = "success"
} else if (item.status === 2) {
row.statusText = "已完成"
+ row.statusTagType = "warning"
} else if (item.status === 3) {
row.statusText = "已停止"
+ row.statusTagType = "danger"
}
row.createTime = moment(item.createTime).format("YYYY-MM-DD HH:mm:ss")
rows.push(row)
@@ -353,9 +334,9 @@ function search() {
function addDialog() {
x.taskInfo = {
- concrete: {}
+ concrete: {},
+ type: 1
}
- x.selectedTaskType = 0
x.showAddDialog = true
}
@@ -373,7 +354,6 @@ function doAddTask() {
function updateDialog(task) {
x.taskInfo = JSON.parse(JSON.stringify(task))
- x.selectedTaskType = x.taskInfo.type
x.showUpdateDialog = true
}
@@ -406,13 +386,8 @@ function doDeleteTask() {
})
}
-function onTaskTypeChange(value) {
- x.selectedTaskType = value
-}
-
function startTaskDialog(task) {
x.taskInfo = JSON.parse(JSON.stringify(task))
- x.selectedTaskType = x.taskInfo.type
x.showStartTaskDialog = true
}
@@ -422,7 +397,6 @@ function doStartTask() {
httpUtil.post(serverPaths.taskStart(x.taskInfo.id), null, function () {
x.btnState.unLoading()
x.showStartTaskDialog = false
- uiUtils.showToast("success", "启动成功")
pageChanged(x.currentPage)
}, () => {
x.btnState.unLoading()
@@ -431,7 +405,6 @@ function doStartTask() {
function stopTaskDialog(task) {
x.taskInfo = JSON.parse(JSON.stringify(task))
- x.selectedTaskType = x.taskInfo.type
x.showStopTaskDialog = true
}
@@ -450,7 +423,6 @@ function doStopTask() {
let manifestEs
function manifestEntriesDialog(task) {
x.taskInfo = JSON.parse(JSON.stringify(task))
- x.selectedTaskType = x.taskInfo.type
x.showManifestEntriesDialog = true
x.manifestEntries = []
manifestEs = new EventSource(serverPaths.taskManifestLog(x.taskInfo.id))
@@ -459,6 +431,7 @@ function manifestEntriesDialog(task) {
})
manifestEs.addEventListener("ERROR", function (e) {
uiUtils.showToast("error", e.data)
+ manifestEs.close()
})
manifestEs.addEventListener("MANIFEST_ENTRY", function (e) {
let res = JSON.parse(e.data);
@@ -479,6 +452,11 @@ function manifestEntriesDialog(task) {
}
}
+function handleManifestLogClose(done) {
+ closeManifestConn()
+ done()
+}
+
function closeManifestConn() {
if (manifestEs) {
manifestEs.close()
@@ -495,9 +473,14 @@ function logDialog(manifestEntry) {
})
hostEs.addEventListener("ERROR", function (e) {
uiUtils.showToast("error", e.data)
+ hostEs.close()
})
hostEs.addEventListener("HOST_LOG", function (e) {
x.hostLog.push(e.data)
+ let diff = x.hostLog.length - 1000
+ if (diff > 0) {
+ x.hostLog.splice(0, diff)
+ }
})
manifestEs.onerror = function (e) {
console.error(e, "SSE连接断开")
@@ -505,6 +488,11 @@ function logDialog(manifestEntry) {
}
}
+function handleHostLogClose(done) {
+ closeHostLogConn()
+ done()
+}
+
function closeHostLogConn() {
if (hostEs) {
hostEs.close()
diff --git a/src/views/devops/task/script-task/index.vue b/src/views/devops/task/script-task/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..d9d379f814e3e41ae5fb7b76b4c2f4573bf64830
--- /dev/null
+++ b/src/views/devops/task/script-task/index.vue
@@ -0,0 +1,553 @@
+