Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions packages/business/src/components/error-message/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import i18n from '@tap/i18n'
import { copyToClipboard } from '@tap/shared'
import './index.scss'

let lastErrorMessage = ''
let lastErrorAt = 0
const DUPLICATE_ERROR_WINDOW_MS = 1200

function renderDialog(stack: string) {
return (
<div id="error-message-dialog">
Expand Down Expand Up @@ -103,10 +107,20 @@ export function ErrorMessage(stack: string, message: string) {
}

export function showErrorMessage(error: Record<string, any>) {
let message =
error?.message ||
error?.msg ||
const response = error?.response?.data ?? error
const detail =
response?.code === 'Task.ListWarnMessage' && response.data
? Object.values(response.data)
.flatMap((items) => (Array.isArray(items) ? items : [items]))
.find((item: any) => item?.msg || item?.message)
: undefined
const rawMessage =
detail?.msg ||
detail?.message ||
response?.message ||
response?.msg ||
i18n.global.t('public_message_request_error')
let message = rawMessage
let duration = 3000
let showClose = false

Expand All @@ -123,6 +137,16 @@ export function showErrorMessage(error: Record<string, any>) {
showClose = true
}

const now = Date.now()
if (
rawMessage === lastErrorMessage &&
now - lastErrorAt < DUPLICATE_ERROR_WINDOW_MS
) {
return
}
lastErrorMessage = rawMessage
lastErrorAt = now

ElMessage.error({
message,
duration,
Expand Down
26 changes: 25 additions & 1 deletion packages/business/src/views/heartbeat-table/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '@tap/api/src/core/task'
import { requestClient } from '@tap/api/src/request'
import { FilterBar } from '@tap/component/src/filter-bar'
import { showErrorMessage } from '../../components/error-message'
import { useI18n } from '@tap/i18n'
import dayjs from 'dayjs'
import { ElMessage, ElMessageBox } from 'element-plus'
Expand Down Expand Up @@ -178,14 +179,37 @@ const start = (ids: string[]) => {
fetchTasks({ where: { id: ids[0] } }).then(() => {
batchStartTasks(ids)
.then((data: any) => {
const resultList = Array.isArray(data)
? data
: Array.isArray(data?.data)
? data.data
: []
const failed = resultList.filter(
(item) => item?.code && item.code !== 'ok',
)
if (failed.length) {
showErrorMessage({
msg: failed
.map((item) => item.message)
.filter(Boolean)
.join('\n'),
})
table.value?.fetch()
buried?.(taskBuried.start, '', { result: false })
return
}
buried?.(taskBuried.start, '', { result: true })
ElMessage.success(
data?.message || t('public_message_operation_success'),
)
table.value?.fetch()
})
.catch(() => {
.catch((error) => {
buried?.(taskBuried.start, '', { result: false })
showErrorMessage({
msg: error?.message || t('public_message_operation_failed'),
stack: error?.stack,
})
})
})
}
Expand Down
26 changes: 25 additions & 1 deletion packages/business/src/views/shared-cache/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from '@tap/api/src/core/task'
import { requestClient, withPassive } from '@tap/api/src/request'
import { FilterBar } from '@tap/component/src/filter-bar'
import { showErrorMessage } from '../../components/error-message'
import { useI18n } from '@tap/i18n'
import dayjs from 'dayjs'
import { ElMessage, ElMessageBox } from 'element-plus'
Expand Down Expand Up @@ -238,14 +239,37 @@ const start = async (ids: string[], row: any) => {
fetchTasks({ where: { id: ids[0] } }).then(() => {
batchStartTasks(ids)
.then((data: any) => {
const resultList = Array.isArray(data)
? data
: Array.isArray(data?.data)
? data.data
: []
const failed = resultList.filter(
(item) => item?.code && item.code !== 'ok',
)
if (failed.length) {
showErrorMessage({
msg: failed
.map((item) => item.message)
.filter(Boolean)
.join('\n'),
})
table.value?.fetch()
buried?.(taskBuried.start, '', { result: false })
return
}
buried?.(taskBuried.start, '', { result: true })
ElMessage.success(
data?.message || t('public_message_operation_success'),
)
table.value?.fetch()
})
.catch(() => {
.catch((error) => {
buried?.(taskBuried.start, '', { result: false })
showErrorMessage({
msg: error?.message || t('public_message_operation_failed'),
stack: error?.stack,
})
})
})
}
Expand Down
26 changes: 25 additions & 1 deletion packages/business/src/views/shared-mining/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import { requestClient, withPassive } from '@tap/api/src/request'
import { VTable } from '@tap/component/src/base/v-table'
import { FilterBar } from '@tap/component/src/filter-bar'
import { showErrorMessage } from '../../components/error-message'
import { useI18n } from '@tap/i18n'
import { calcTimeUnit, openUrl } from '@tap/shared'
import dayjs from 'dayjs'
Expand Down Expand Up @@ -276,14 +277,37 @@ const start = (ids: string[]) => {
fetchTasks({ where: { id: ids[0] } }).then(() => {
batchStartTasks(ids)
.then((data: any) => {
const resultList = Array.isArray(data)
? data
: Array.isArray(data?.data)
? data.data
: []
const failed = resultList.filter(
(item) => item?.code && item.code !== 'ok',
)
if (failed.length) {
showErrorMessage({
msg: failed
.map((item) => item.message)
.filter(Boolean)
.join('\n'),
})
table.value?.fetch()
buried?.(taskBuried.start, '', { result: false })
return
Comment thread
feynmx marked this conversation as resolved.
}
buried?.(taskBuried.start, '', { result: true })
ElMessage.success(
data?.message || t('public_message_operation_success'),
)
table.value?.fetch()
})
.catch(() => {
.catch((error) => {
buried?.(taskBuried.start, '', { result: false })
showErrorMessage({
msg: error?.message || t('public_message_operation_failed'),
stack: error?.stack,
})
})
})
}
Expand Down
13 changes: 11 additions & 2 deletions packages/business/src/views/task/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,12 @@ export default {
},

responseHandler(data, msg, canNotList = []) {
let failList = data?.filter((t) => t.code !== 'ok') || []
const resultList = Array.isArray(data)
Comment thread
feynmx marked this conversation as resolved.
? data
: Array.isArray(data?.data)
? data.data
: []
let failList = resultList.filter((t) => t.code !== 'ok')
failList = [...failList, ...canNotList]
if (failList.length) {
const findErr = failList.find((t) =>
Expand Down Expand Up @@ -706,8 +711,12 @@ export default {
canNotList,
)
})
.catch(() => {
.catch((error) => {
this.buried(this.taskBuried.start, '', { result: false })
showErrorMessage({
msg: error?.message || this.$t('public_message_operation_failed'),
stack: error?.stack,
})
})
},

Expand Down
16 changes: 14 additions & 2 deletions packages/dag/src/MigrationMonitorSimple.vue
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,8 @@ export default {
isError = true
}
})
isError && (someErrorMsg = this.$t('packages_dag_mixins_editor_suoshuage'))
isError &&
(someErrorMsg = this.$t('packages_dag_mixins_editor_suoshuage'))
}
} else if (accessNodeProcessIdArr.length === 1) {
// 如果画布上仅有一个所属agent,自动设置为任务的agent
Expand Down Expand Up @@ -1049,7 +1050,18 @@ export default {
this.isSaving = true
try {
this.wsAgentLive()
await startTask(this.dataflow.id)
const response = await startTask(this.dataflow.id)
const payload = response?.data ?? response
const businessError = Array.isArray(payload)
? payload.find((item) => item?.code && item.code !== 'ok')
: payload?.code && payload.code !== 'ok'
? payload
: null
if (businessError) {
this.handleError(businessError)
this.isSaving = false
return
}
this.$message.success(this.$t('public_message_operation_success'))
this.isSaving = false
this.isReset = false
Expand Down
1 change: 1 addition & 0 deletions packages/dag/src/components/LeftSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ export default {
connectionName: connection.name,
connectionType: connection.connection_type,
accessNodeProcessId: connection.accessNodeProcessId,
accessNodeProcessIdList: connection.accessNodeProcessIdList || [],
priorityProcessId: connection.priorityProcessId,
pdkType: connection.pdkType,
pdkHash: connection.pdkHash,
Expand Down
Loading
Loading