Browse Source

[Feature][UI Next][V1.0.0-Alpha]Unified processing of back-end error messages (#8779)

* Unified processing of back-end error messages

* Fixed the problem of English and Chinese being unified on the front and back ends

* Fix the $message mount problem

* Delete messages that are processed separately

* Delete all try catch related operations
3.0.0/version-upgrade
labbomb 3 years ago committed by GitHub
parent
commit
38fba609cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      dolphinscheduler-ui-next/src/service/service.ts
  2. 4
      dolphinscheduler-ui-next/src/utils/index.ts
  3. 64
      dolphinscheduler-ui-next/src/utils/log.ts
  4. 55
      dolphinscheduler-ui-next/src/views/datasource/list/use-detail.ts
  5. 6
      dolphinscheduler-ui-next/src/views/datasource/list/use-form.ts
  6. 30
      dolphinscheduler-ui-next/src/views/datasource/list/use-table.ts
  7. 7
      dolphinscheduler-ui-next/src/views/login/index.tsx
  8. 2
      dolphinscheduler-ui-next/src/views/login/use-translate.ts
  9. 22
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-child-node.ts
  10. 28
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-datasource-type.ts
  11. 8
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-datasource.ts
  12. 12
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-datax.ts
  13. 62
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-dependent.ts
  14. 28
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-environment-name.ts
  15. 16
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-flink.ts
  16. 16
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-mr.ts
  17. 22
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-process-name.ts
  18. 152
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-rules.ts
  19. 14
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-sea-tunnel.ts
  20. 12
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-shell.ts
  21. 16
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-spark.ts
  22. 14
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-sql-type.ts
  23. 12
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-sql.ts
  24. 20
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-sqoop-datasource.ts
  25. 24
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-switch.ts
  26. 24
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-task-group.ts
  27. 10
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-worker-group.ts
  28. 52
      dolphinscheduler-ui-next/src/views/projects/task/definition/use-task.ts
  29. 3
      dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/dag-save-modal.tsx
  30. 4
      dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-custom-cell-builder.ts
  31. 54
      dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/use-modal.ts
  32. 6
      dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/use-table.ts
  33. 3
      dolphinscheduler-ui-next/src/views/projects/workflow/definition/create/index.tsx
  34. 3
      dolphinscheduler-ui-next/src/views/projects/workflow/definition/detail/index.tsx
  35. 3
      dolphinscheduler-ui-next/src/views/projects/workflow/definition/timing/use-table.ts
  36. 12
      dolphinscheduler-ui-next/src/views/projects/workflow/definition/use-table.ts
  37. 10
      dolphinscheduler-ui-next/src/views/projects/workflow/instance/components/log-modal.tsx
  38. 16
      dolphinscheduler-ui-next/src/views/projects/workflow/instance/use-table.ts
  39. 18
      dolphinscheduler-ui-next/src/views/resource/file/create/use-create.ts
  40. 20
      dolphinscheduler-ui-next/src/views/resource/file/edit/use-edit.ts
  41. 16
      dolphinscheduler-ui-next/src/views/resource/file/folder/use-folder.ts
  42. 20
      dolphinscheduler-ui-next/src/views/resource/file/rename/use-rename.ts
  43. 10
      dolphinscheduler-ui-next/src/views/resource/file/upload/use-upload.ts
  44. 28
      dolphinscheduler-ui-next/src/views/resource/udf/function/components/use-modal.ts
  45. 26
      dolphinscheduler-ui-next/src/views/resource/udf/resource/components/use-modal.ts
  46. 3
      dolphinscheduler-ui-next/src/views/resource/udf/resource/use-table.ts
  47. 44
      dolphinscheduler-ui-next/src/views/security/alarm-instance-manage/use-detail.ts
  48. 30
      dolphinscheduler-ui-next/src/views/security/alarm-instance-manage/use-form.ts
  49. 49
      dolphinscheduler-ui-next/src/views/security/alarm-instance-manage/use-table.ts

17
dolphinscheduler-ui-next/src/service/service.ts

@ -21,9 +21,23 @@ import qs from 'qs'
import _ from 'lodash'
import cookies from 'js-cookie'
import router from '@/router'
import utils from '@/utils'
const userStore = useUserStore()
/**
* @description Log and display errors
* @param {Error} error Error object
*/
const handleError = (res: AxiosResponse<any, any>) => {
// Print to console
if (import.meta.env.MODE === 'development') {
utils.log.capsule('DolphinScheduler', 'UI-NEXT')
utils.log.error(res)
}
window.$message.error(res.data.msg)
}
const baseRequestConfig: AxiosRequestConfig = {
baseURL:
import.meta.env.MODE === 'development'
@ -76,7 +90,8 @@ service.interceptors.response.use((res: AxiosResponse) => {
case 0:
return res.data.data
default:
throw new Error(`${res.data.msg}: ${res.config.url}`)
handleError(res)
throw new Error()
}
}, err)

4
dolphinscheduler-ui-next/src/utils/index.ts

@ -18,11 +18,13 @@
import mapping from './mapping'
import regex from './regex'
import truncateText from './truncate-text'
import log from './log'
const utils = {
mapping,
regex,
truncateText
truncateText,
log
}
export default utils

64
dolphinscheduler-ui-next/src/utils/log.ts

@ -0,0 +1,64 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const log = {
capsule: (title: string, text: string, type?: string) => {},
error: (info: any) => {}
}
/**
* @description Returns the color value of the style
* @param {String} type The style name [ primary | success | warning | error ]
*/
const typeColor = (type = 'primary') => {
let color = ''
switch (type) {
case 'primary': color = '#1890ff'; break
case 'success': color = '#52c41a'; break
case 'warning': color = '#faad14'; break
case 'error': color = '#ff4d4f'; break
default:; break
}
return color
}
/**
* @description capsule
* @param {String} title title text
* @param {String} text info text
* @param {String} type style
*/
log.capsule = (title: string, text: string, type: string = 'primary') => {
console.log(
`%c ${title} %c ${text} %c`,
'background:#35495E; padding: 2px ; border-radius: 3px 0 0 3px; color: #fff;',
`background:${typeColor(type)}; padding: 2px; border-radius: 0 3px 3px 0; color: #fff;`,
'background:transparent'
)
}
/**
* @description Prints text in error style
*/
log.error = function (info) {
console.group('error info')
console.log('responseURL: ', `${info.config.baseURL}${info.config.url}`)
console.log('msg: ', info.data.msg)
console.groupEnd()
}
export default log

55
dolphinscheduler-ui-next/src/views/datasource/list/use-detail.ts

@ -47,33 +47,22 @@ export function useDetail(getFieldsValue: Function) {
const queryById = async (id: number) => {
if (status.loading) return {}
status.loading = true
try {
const dataSourceRes = await queryDataSource(id)
status.loading = false
PREV_NAME = dataSourceRes.name
return dataSourceRes
} catch (e) {
window.$message.error((e as Error).message)
status.loading = false
return {}
}
const dataSourceRes = await queryDataSource(id)
status.loading = false
PREV_NAME = dataSourceRes.name
return dataSourceRes
}
const testConnect = async () => {
if (status.testing) return
status.testing = true
try {
const res = await connectDataSource(formatParams())
window.$message.success(
res
? res.msg
: `${t('datasource.test_connect')} ${t('datasource.success')}`
)
status.testing = false
} catch (e) {
window.$message.error((e as Error).message)
status.testing = false
}
const res = await connectDataSource(formatParams())
window.$message.success(
res
? res.msg
: `${t('datasource.test_connect')} ${t('datasource.success')}`
)
status.testing = false
}
const createOrUpdate = async (id?: number) => {
@ -81,22 +70,16 @@ export function useDetail(getFieldsValue: Function) {
if (status.saving || !values.name) return false
status.saving = true
try {
if (PREV_NAME !== values.name) {
await verifyDataSourceName({ name: values.name })
}
if (PREV_NAME !== values.name) {
await verifyDataSourceName({ name: values.name })
}
id
? await updateDataSource(formatParams(), id)
: await createDataSource(formatParams())
id
? await updateDataSource(formatParams(), id)
: await createDataSource(formatParams())
status.saving = false
return true
} catch (e) {
window.$message.error((e as Error).message)
status.saving = false
return false
}
status.saving = false
return true
}
return { status, queryById, testConnect, createOrUpdate }

6
dolphinscheduler-ui-next/src/views/datasource/list/use-form.ts

@ -123,11 +123,7 @@ export function useForm(id?: number) {
state.showConnectType = type === 'ORACLE'
if (type === 'HIVE' || type === 'SPARK') {
try {
state.showPrincipal = await getKerberosStartupState()
} catch (e) {
window.$message.error((e as Error).message)
}
state.showPrincipal = await getKerberosStartupState()
} else {
state.showPrincipal = false
}

30
dolphinscheduler-ui-next/src/views/datasource/list/use-table.ts

@ -35,20 +35,14 @@ export function useTable() {
if (data.loading) return
data.loading = true
try {
const listRes = await queryDataSourceListPaging({
pageNo: data.page,
pageSize: data.pageSize,
searchVal: data.searchVal
})
data.loading = false
data.list = listRes.totalList
data.itemCount = listRes.total
} catch (e) {
window.$message.error((e as Error).message)
data.loading = false
data.list = []
}
const listRes = await queryDataSourceListPaging({
pageNo: data.page,
pageSize: data.pageSize,
searchVal: data.searchVal
})
data.loading = false
data.list = listRes.totalList
data.itemCount = listRes.total
}
const updateList = () => {
@ -59,12 +53,8 @@ export function useTable() {
}
const deleteRecord = async (id: number) => {
try {
const ignored = await deleteDataSource(id)
updateList()
} catch (e) {
window.$message.error((e as Error).message)
}
const ignored = await deleteDataSource(id)
updateList()
}
const changePage = (page: number) => {

7
dolphinscheduler-ui-next/src/views/login/index.tsx

@ -17,16 +17,19 @@
import { defineComponent, toRefs, withKeys } from 'vue'
import styles from './index.module.scss'
import { NInput, NButton, NSwitch, NForm, NFormItem } from 'naive-ui'
import { NInput, NButton, NSwitch, NForm, NFormItem, useMessage } from 'naive-ui'
import { useForm } from './use-form'
import { useTranslate } from './use-translate'
import { useLogin } from './use-login'
import { useLocalesStore } from '@/store/locales/locales'
import { useThemeStore } from '@/store/theme/theme'
import cookies from 'js-cookie'
const login = defineComponent({
name: 'login',
setup() {
window.$message = useMessage()
const { state, t, locale } = useForm()
const { handleChange } = useTranslate(locale)
const { handleLogin } = useLogin(state)
@ -37,6 +40,8 @@ const login = defineComponent({
themeStore.setDarkTheme()
}
cookies.set('language', localesStore.getLocales, { path: '/' })
return { t, handleChange, handleLogin, ...toRefs(state), localesStore }
},
render() {

2
dolphinscheduler-ui-next/src/views/login/use-translate.ts

@ -18,6 +18,7 @@
import { WritableComputedRef } from 'vue'
import { useLocalesStore } from '@/store/locales/locales'
import type { Locales } from '@/store/locales/types'
import cookies from 'js-cookie'
export function useTranslate(locale: WritableComputedRef<string>) {
const localesStore = useLocalesStore()
@ -25,6 +26,7 @@ export function useTranslate(locale: WritableComputedRef<string>) {
const handleChange = (value: Locales) => {
locale.value = value
localesStore.setLocales(value)
cookies.set('language', locale.value, { path: '/' })
}
return {
handleChange

22
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-child-node.ts

@ -45,23 +45,17 @@ export function useChildNode({
const getProcessList = async () => {
if (loading.value) return
loading.value = true
try {
const res = await querySimpleList(projectCode)
options.value = res.map((option: { name: string; code: number }) => ({
label: option.name,
value: option.code
}))
loading.value = false
} catch (err) {
loading.value = false
}
const res = await querySimpleList(projectCode)
options.value = res.map((option: { name: string; code: number }) => ({
label: option.name,
value: option.code
}))
loading.value = false
}
const getProcessListByCode = async (processCode: number) => {
if (!processCode) return
try {
const res = await queryProcessDefinitionByCode(processCode, projectCode)
getTaskOptions(res)
} catch (err) {}
const res = await queryProcessDefinitionByCode(processCode, projectCode)
getTaskOptions(res)
}
const getTaskOptions = (processDefinition: {
processTaskRelationList: []

28
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-datasource-type.ts

@ -86,22 +86,18 @@ export function useDatasourceType(
const getDatasourceTypes = async () => {
if (loading.value) return
loading.value = true
try {
options.value = datasourceTypes
.filter((item) => {
if (item.disabled) {
return false
}
if (supportedDatasourceType) {
return indexOf(supportedDatasourceType, item.code) !== -1
}
return true
})
.map((item) => ({ label: item.code, value: item.code }))
loading.value = false
} catch (err) {
loading.value = false
}
options.value = datasourceTypes
.filter((item) => {
if (item.disabled) {
return false
}
if (supportedDatasourceType) {
return indexOf(supportedDatasourceType, item.code) !== -1
}
return true
})
.map((item) => ({ label: item.code, value: item.code }))
loading.value = false
}
const onChange = (type: string) => {

8
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-datasource.ts

@ -35,12 +35,8 @@ export function useDatasource(
const getDatasources = async () => {
if (loading.value) return
loading.value = true
try {
await refreshOptions()
loading.value = false
} catch (err) {
loading.value = false
}
await refreshOptions()
loading.value = false
}
const refreshOptions = async () => {

12
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-datax.ts

@ -153,14 +153,10 @@ export function useDataX(model: { [field: string]: any }): IJsonItem[] {
const getDatasourceTypes = async () => {
if (loading.value) return
loading.value = true
try {
datasourceTypeOptions.value = datasourceTypes
.filter((item) => !item.disabled)
.map((item) => ({ label: item.code, value: item.code }))
loading.value = false
} catch (err) {
loading.value = false
}
datasourceTypeOptions.value = datasourceTypes
.filter((item) => !item.disabled)
.map((item) => ({ label: item.code, value: item.code }))
loading.value = false
}
const getDatasourceInstances = async () => {

62
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-dependent.ts

@ -157,52 +157,46 @@ export function useDependent(model: { [field: string]: any }): IJsonItem[] {
}
const getProjectList = async () => {
try {
const result = await queryProjectCreatedAndAuthorizedByUser()
projectList.value = result.map(
(item: { code: number; name: string }) => ({
value: item.code,
label: item.name
})
)
return projectList
} catch (err) {}
const result = await queryProjectCreatedAndAuthorizedByUser()
projectList.value = result.map(
(item: { code: number; name: string }) => ({
value: item.code,
label: item.name
})
)
return projectList
}
const getProcessList = async (code: number) => {
if (processCache[code]) {
return processCache[code]
}
try {
const result = await queryAllByProjectCode(code)
const processList = result.map(
(item: { processDefinition: { code: number; name: string } }) => ({
value: item.processDefinition.code,
label: item.processDefinition.name
})
)
processCache[code] = processList
const result = await queryAllByProjectCode(code)
const processList = result.map(
(item: { processDefinition: { code: number; name: string } }) => ({
value: item.processDefinition.code,
label: item.processDefinition.name
})
)
processCache[code] = processList
return processList
} catch (err) {}
return processList
}
const getTaskList = async (code: number, processCode: number) => {
if (taskCache[processCode]) {
return taskCache[processCode]
}
try {
const result = await getTasksByDefinitionCode(code, processCode)
const taskList = result.map((item: { code: number; name: string }) => ({
value: item.code,
label: item.name
}))
taskList.unshift({
value: 0,
label: 'ALL'
})
taskCache[processCode] = taskList
return taskList
} catch (err) {}
const result = await getTasksByDefinitionCode(code, processCode)
const taskList = result.map((item: { code: number; name: string }) => ({
value: item.code,
label: item.name
}))
taskList.unshift({
value: 0,
label: 'ALL'
})
taskCache[processCode] = taskList
return taskList
}
onMounted(() => {

28
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-environment-name.ts

@ -34,22 +34,18 @@ export function useEnvironmentName(
const getEnvironmentList = async () => {
if (loading.value) return
loading.value = true
try {
const res = await queryAllEnvironmentList()
environmentList = res.map(
(item: { code: string; name: string; workerGroups: string[] }) => ({
label: item.name,
value: item.code,
workerGroups: item.workerGroups
})
)
options.value = environmentList.filter((option: IEnvironmentNameOption) =>
filterByWorkerGroup(option)
)
loading.value = false
} catch (err) {
loading.value = false
}
const res = await queryAllEnvironmentList()
environmentList = res.map(
(item: { code: string; name: string; workerGroups: string[] }) => ({
label: item.name,
value: item.code,
workerGroups: item.workerGroups
})
)
options.value = environmentList.filter((option: IEnvironmentNameOption) =>
filterByWorkerGroup(option)
)
loading.value = false
}
const filterByWorkerGroup = (option: IEnvironmentNameOption) => {

16
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-flink.ts

@ -44,15 +44,13 @@ export function useFlink(model: { [field: string]: any }): IJsonItem[] {
mainJarOptions.value = resources[programType]
return
}
try {
const res = await queryResourceByProgramType({
type: 'FILE',
programType
})
removeUselessChildren(res)
mainJarOptions.value = res || []
resources[programType] = res
} catch (err) {}
const res = await queryResourceByProgramType({
type: 'FILE',
programType
})
removeUselessChildren(res)
mainJarOptions.value = res || []
resources[programType] = res
}
onMounted(() => {

16
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-mr.ts

@ -37,15 +37,13 @@ export function useMr(model: { [field: string]: any }): IJsonItem[] {
mainJarOptions.value = resources[programType]
return
}
try {
const res = await queryResourceByProgramType({
type: 'FILE',
programType
})
removeUselessChildren(res)
mainJarOptions.value = res || []
resources[programType] = res
} catch (err) {}
const res = await queryResourceByProgramType({
type: 'FILE',
programType
})
removeUselessChildren(res)
mainJarOptions.value = res || []
resources[programType] = res
}
onMounted(() => {

22
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-process-name.ts

@ -47,23 +47,17 @@ export function useProcessName({
const getProcessList = async () => {
if (loading.value) return
loading.value = true
try {
const res = await querySimpleList(projectCode)
options.value = res.map((option: { name: string; code: number }) => ({
label: option.name,
value: option.code
}))
loading.value = false
} catch (err) {
loading.value = false
}
const res = await querySimpleList(projectCode)
options.value = res.map((option: { name: string; code: number }) => ({
label: option.name,
value: option.code
}))
loading.value = false
}
const getProcessListByCode = async (processCode: number) => {
if (!processCode) return
try {
const res = await queryProcessDefinitionByCode(processCode, projectCode)
getTaskOptions(res)
} catch (err) {}
const res = await queryProcessDefinitionByCode(processCode, projectCode)
getTaskOptions(res)
}
const getTaskOptions = (processDefinition: {
processTaskRelationList: []

152
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-rules.ts

@ -47,38 +47,30 @@ export function useRules(
const getRuleList = async () => {
if (ruleLoading.value) return
ruleLoading.value = true
try {
const result = await queryRuleList()
rules.value = result.map((item: { id: number; name: string }) => {
let name = ''
if (item.name) {
name = item.name.replace('$t(', '').replace(')', '')
}
return {
value: item.id,
label: name ? t(`project.node.${name}`) : ''
}
})
ruleLoading.value = false
} catch (err) {
ruleLoading.value = false
}
const result = await queryRuleList()
rules.value = result.map((item: { id: number; name: string }) => {
let name = ''
if (item.name) {
name = item.name.replace('$t(', '').replace(')', '')
}
return {
value: item.id,
label: name ? t(`project.node.${name}`) : ''
}
})
ruleLoading.value = false
}
const getRuleById = async (ruleId: number) => {
if (ruleLoading.value) return
ruleLoading.value = true
try {
const result = await getRuleFormCreateJson(ruleId)
const items = JSON.parse(result).map((item: IResponseJsonItem) =>
formatResponseJson(item)
)
updateRules(items, preItemLen)
preItemLen = items.length
ruleLoading.value = false
} catch (err) {
ruleLoading.value = false
}
const result = await getRuleFormCreateJson(ruleId)
const items = JSON.parse(result).map((item: IResponseJsonItem) =>
formatResponseJson(item)
)
updateRules(items, preItemLen)
preItemLen = items.length
ruleLoading.value = false
}
const formatResponseJson = (
@ -138,60 +130,58 @@ export function useRules(
}
const onFieldChange = async (value: string | number, field: string) => {
try {
if (field === 'src_connector_type' && typeof value === 'number') {
const result = await getDatasourceOptionsById(value)
srcDatasourceOptions.value = result || []
srcTableOptions.value = []
model.src_datasource_id = null
model.src_table = null
model.src_field = null
return
}
if (field === 'target_connector_type' && typeof value === 'number') {
const result = await getDatasourceOptionsById(value)
targetDatasourceOptions.value = result || []
targetTableOptions.value = []
model.target_datasource_id = null
model.target_table = null
model.target_field = null
return
}
if (field === 'writer_connector_type' && typeof value === 'number') {
const result = await getDatasourceOptionsById(value)
writerDatasourceOptions.value = result || []
model.writer_datasource_id = null
return
}
if (field === 'src_datasource_id' && typeof value === 'number') {
const result = await getDatasourceTablesById(value)
srcTableOptions.value = result || []
model.src_table = null
model.src_field = null
}
if (field === 'target_datasource_id' && typeof value === 'number') {
const result = await getDatasourceTablesById(value)
targetTableOptions.value = result || []
model.target_table = null
model.target_field = null
}
if (field === 'src_table' && typeof value === 'string') {
const result = await getDatasourceTableColumnsById(
model.src_datasource_id,
value
)
srcTableColumnOptions.value = result || []
model.src_field = null
}
if (field === 'target_table' && typeof value === 'string') {
const result = await getDatasourceTableColumnsById(
model.target_datasource_id,
value
)
targetTableColumnOptions.value = result || []
model.target_field = null
}
} catch (err) {}
if (field === 'src_connector_type' && typeof value === 'number') {
const result = await getDatasourceOptionsById(value)
srcDatasourceOptions.value = result || []
srcTableOptions.value = []
model.src_datasource_id = null
model.src_table = null
model.src_field = null
return
}
if (field === 'target_connector_type' && typeof value === 'number') {
const result = await getDatasourceOptionsById(value)
targetDatasourceOptions.value = result || []
targetTableOptions.value = []
model.target_datasource_id = null
model.target_table = null
model.target_field = null
return
}
if (field === 'writer_connector_type' && typeof value === 'number') {
const result = await getDatasourceOptionsById(value)
writerDatasourceOptions.value = result || []
model.writer_datasource_id = null
return
}
if (field === 'src_datasource_id' && typeof value === 'number') {
const result = await getDatasourceTablesById(value)
srcTableOptions.value = result || []
model.src_table = null
model.src_field = null
}
if (field === 'target_datasource_id' && typeof value === 'number') {
const result = await getDatasourceTablesById(value)
targetTableOptions.value = result || []
model.target_table = null
model.target_field = null
}
if (field === 'src_table' && typeof value === 'string') {
const result = await getDatasourceTableColumnsById(
model.src_datasource_id,
value
)
srcTableColumnOptions.value = result || []
model.src_field = null
}
if (field === 'target_table' && typeof value === 'string') {
const result = await getDatasourceTableColumnsById(
model.target_datasource_id,
value
)
targetTableColumnOptions.value = result || []
model.target_field = null
}
}
onMounted(async () => {

14
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-sea-tunnel.ts

@ -55,15 +55,11 @@ export function useSeaTunnel(model: { [field: string]: any }): IJsonItem[] {
const getResourceList = async () => {
if (loading.value) return
loading.value = true
try {
model.resourceFiles = []
const res = await queryResourceList({ type: 'FILE' })
removeUselessChildren(res)
options.value = res || []
loading.value = false
} catch (err) {
loading.value = false
}
model.resourceFiles = []
const res = await queryResourceList({ type: 'FILE' })
removeUselessChildren(res)
options.value = res || []
loading.value = false
}
function removeUselessChildren(

12
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-shell.ts

@ -29,14 +29,10 @@ export function useShell(model: { [field: string]: any }): IJsonItem[] {
const getResourceList = async () => {
if (loading.value) return
loading.value = true
try {
const res = await queryResourceList({ type: 'FILE' })
removeUselessChildren(res)
options.value = res || []
loading.value = false
} catch (err) {
loading.value = false
}
const res = await queryResourceList({ type: 'FILE' })
removeUselessChildren(res)
options.value = res || []
loading.value = false
}
onMounted(() => {

16
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-spark.ts

@ -44,15 +44,13 @@ export function useSpark(model: { [field: string]: any }): IJsonItem[] {
mainJarOptions.value = resources[programType]
return
}
try {
const res = await queryResourceByProgramType({
type: 'FILE',
programType
})
removeUselessChildren(res)
mainJarOptions.value = res || []
resources[programType] = res
} catch (err) {}
const res = await queryResourceByProgramType({
type: 'FILE',
programType
})
removeUselessChildren(res)
mainJarOptions.value = res || []
resources[programType] = res
}
onMounted(() => {

14
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-sql-type.ts

@ -39,15 +39,11 @@ export function useSqlType(unusedModel: { [field: string]: any }): IJsonItem {
const getSqlTypes = async () => {
if (loading.value) return
loading.value = true
try {
options.value = sqlTypes.map((item) => ({
label: item.code,
value: item.id
}))
loading.value = false
} catch (err) {
loading.value = false
}
options.value = sqlTypes.map((item) => ({
label: item.code,
value: item.id
}))
loading.value = false
}
onMounted(() => {

12
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-sql.ts

@ -28,14 +28,10 @@ export function useSql(model: { [field: string]: any }): IJsonItem[] {
const getResourceList = async () => {
if (loading.value) return
loading.value = true
try {
const res = await queryResourceList({ type: 'FILE' })
removeUselessChildren(res)
options.value = res || []
loading.value = false
} catch (err) {
loading.value = false
}
const res = await queryResourceList({ type: 'FILE' })
removeUselessChildren(res)
options.value = res || []
loading.value = false
}
onMounted(() => {

20
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-sqoop-datasource.ts

@ -33,18 +33,14 @@ export function useDatasource(
const getDataSource = async (type: IDataBase) => {
if (loading.value) return
loading.value = true
try {
const result = await queryDataSourceList({ type })
dataSourceList.value = result.map(
(item: { name: string; id: number }) => ({
label: item.name,
value: item.id
})
)
loading.value = false
} catch (err) {
loading.value = false
}
const result = await queryDataSourceList({ type })
dataSourceList.value = result.map(
(item: { name: string; id: number }) => ({
label: item.name,
value: item.id
})
)
loading.value = false
}
onMounted(() => {
getDataSource('MYSQL')

24
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-switch.ts

@ -32,20 +32,16 @@ export function useSwitch(
if (loading.value) return
loading.value = true
branchFlowOptions.value = []
try {
const res = await queryProcessDefinitionByCode(
model.processName,
projectCode
)
res?.taskDefinitionList.forEach((item: any) => {
if (item.code != model.code) {
branchFlowOptions.value.push({ label: item.name, value: item.code })
}
})
loading.value = false
} catch (err) {
loading.value = false
}
const res = await queryProcessDefinitionByCode(
model.processName,
projectCode
)
res?.taskDefinitionList.forEach((item: any) => {
if (item.code != model.code) {
branchFlowOptions.value.push({ label: item.name, value: item.code })
}
})
loading.value = false
}
watch(

24
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-task-group.ts

@ -33,20 +33,16 @@ export function useTaskGroup(
const getTaskGroupList = async () => {
if (loading.value) return
loading.value = true
try {
const { totalList = [] } = await queryTaskGroupListPagingByProjectCode({
pageNo: 1,
pageSize: 2147483647,
projectCode
})
options.value = totalList.map((item: { id: string; name: string }) => ({
label: item.name,
value: item.id
}))
loading.value = false
} catch (err) {
loading.value = false
}
const { totalList = [] } = await queryTaskGroupListPagingByProjectCode({
pageNo: 1,
pageSize: 2147483647,
projectCode
})
options.value = totalList.map((item: { id: string; name: string }) => ({
label: item.name,
value: item.id
}))
loading.value = false
}
onMounted(() => {

10
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-worker-group.ts

@ -29,13 +29,9 @@ export function useWorkerGroup(): IJsonItem {
const getWorkerGroups = async () => {
if (loading.value) return
loading.value = true
try {
const res = await queryAllWorkerGroups()
options.value = res.map((item: string) => ({ label: item, value: item }))
loading.value = false
} catch (err) {
loading.value = false
}
const res = await queryAllWorkerGroups()
options.value = res.map((item: string) => ({ label: item, value: item }))
loading.value = false
}
onMounted(() => {

52
dolphinscheduler-ui-next/src/views/projects/task/definition/use-task.ts

@ -60,42 +60,32 @@ export function useTask(projectCode: number) {
task.taskShow = show
}
const onTaskSave = async (data: INodeData) => {
try {
if (task.taskSaving) return
task.taskSaving = true
if (data.id) {
data.code &&
(await updateWithUpstream(
projectCode,
data.code,
formatParams({ ...data, code: data.code }, false)
))
} else {
const taskCode = await getTaskCode()
await saveSingle(
if (task.taskSaving) return
task.taskSaving = true
if (data.id) {
data.code &&
(await updateWithUpstream(
projectCode,
formatParams({ ...data, code: taskCode }, true)
)
}
task.taskSaving = false
return true
} catch (e) {
window.$message.error((e as Error).message)
task.taskSaving = false
return false
data.code,
formatParams({ ...data, code: data.code }, false)
))
} else {
const taskCode = await getTaskCode()
await saveSingle(
projectCode,
formatParams({ ...data, code: taskCode }, true)
)
}
task.taskSaving = false
return true
}
const onEditTask = async (row: IRecord, readonly: boolean) => {
try {
const result = await queryTaskDefinitionByCode(row.taskCode, projectCode)
task.taskData = { ...result, processName: row.processDefinitionCode }
task.taskShow = true
task.taskReadonly = readonly
} catch (e) {
window.$message.error((e as Error).message)
}
const result = await queryTaskDefinitionByCode(row.taskCode, projectCode)
task.taskData = { ...result, processName: row.processDefinitionCode }
task.taskShow = true
task.taskReadonly = readonly
}
const onInitTask = () => {

3
dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/dag-save-modal.tsx

@ -133,9 +133,6 @@ export default defineComponent({
) {
verifyName(params, projectCode)
.then(() => context.emit('save', formValue.value))
.catch((error: any) => {
window.$message.error(error.message)
})
} else {
context.emit('save', formValue.value)
}

4
dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-custom-cell-builder.ts

@ -29,9 +29,7 @@ export function useCustomCellBuilder() {
function parseLocationStr(locationStr: string) {
let locations = null
if (!locationStr) return locations
try {
locations = JSON.parse(locationStr)
} catch (error) {}
locations = JSON.parse(locationStr)
return Array.isArray(locations) ? locations : null
}

54
dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/use-modal.ts

@ -61,18 +61,14 @@ export function useModal(
const handleImportDefinition = () => {
state.importFormRef.validate(async (valid: any) => {
if (!valid) {
try {
const formData = new FormData()
formData.append('file', state.importForm.file)
const code = Number(router.currentRoute.value.params.projectCode)
await importProcessDefinition(formData, code)
window.$message.success(t('project.workflow.success'))
ctx.emit('updateList')
ctx.emit('update:show')
resetImportForm()
} catch (error: any) {
window.$message.error(error.message)
}
const formData = new FormData()
formData.append('file', state.importForm.file)
const code = Number(router.currentRoute.value.params.projectCode)
await importProcessDefinition(formData, code)
window.$message.success(t('project.workflow.success'))
ctx.emit('updateList')
ctx.emit('update:show')
resetImportForm()
}
})
}
@ -103,14 +99,10 @@ export function useModal(
? JSON.stringify(startParams)
: ''
try {
await startProcessInstance(state.startForm, variables.projectCode)
window.$message.success(t('project.workflow.success'))
ctx.emit('updateList')
ctx.emit('update:show')
} catch (error: any) {
window.$message.error(error.message)
}
}
})
}
@ -121,14 +113,10 @@ export function useModal(
const data: any = getTimingData()
data.processDefinitionCode = code
try {
await createSchedule(data, variables.projectCode)
window.$message.success(t('project.workflow.success'))
ctx.emit('updateList')
ctx.emit('update:show')
} catch (error: any) {
window.$message.error(error.message)
}
await createSchedule(data, variables.projectCode)
window.$message.success(t('project.workflow.success'))
ctx.emit('updateList')
ctx.emit('update:show')
}
})
}
@ -139,14 +127,10 @@ export function useModal(
const data: any = getTimingData()
data.id = id
try {
await updateSchedule(data, variables.projectCode, id)
window.$message.success(t('project.workflow.success'))
ctx.emit('updateList')
ctx.emit('update:show')
} catch (error: any) {
window.$message.error(error.message)
}
await updateSchedule(data, variables.projectCode, id)
window.$message.success(t('project.workflow.success'))
ctx.emit('updateList')
ctx.emit('update:show')
}
})
}
@ -214,9 +198,6 @@ export function useModal(
.then((res: any) => {
variables.startParamsList = res.processDefinition.globalParamList
})
.catch((error: any) => {
window.$message.error(error.message)
})
}
const getPreviewSchedule = () => {
@ -242,9 +223,6 @@ export function useModal(
.then((res: any) => {
variables.schedulePreviewList = res
})
.catch((error: any) => {
window.$message.error(error.message)
})
}
})
}

6
dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/use-table.ts

@ -178,9 +178,6 @@ export function useTable(
ctx.emit('updateList')
getTableData(variables.row)
})
.catch((error: any) => {
window.$message.error(error.message)
})
}
const handleDeleteVersion = (version: number) => {
@ -190,9 +187,6 @@ export function useTable(
ctx.emit('updateList')
getTableData(variables.row)
})
.catch((error: any) => {
window.$message.error(error.message)
})
}
return {

3
dolphinscheduler-ui-next/src/views/projects/workflow/definition/create/index.tsx

@ -80,9 +80,6 @@ export default defineComponent({
message.success(t('project.dag.success'))
router.push({ path: `/projects/${projectCode}/workflow-definition` })
})
.catch((error: any) => {
window.$message.error(error.message)
})
}
return () => (

3
dolphinscheduler-ui-next/src/views/projects/workflow/definition/detail/index.tsx

@ -99,9 +99,6 @@ export default defineComponent({
message.success(t('project.dag.success'))
router.push({ path: `/projects/${projectCode}/workflow-definition` })
})
.catch((error: any) => {
window.$message.error(error.message)
})
}
onMounted(() => {

3
dolphinscheduler-ui-next/src/views/projects/workflow/definition/timing/use-table.ts

@ -262,9 +262,6 @@ export function useTable() {
searchVal: variables.searchVal
})
})
.catch((error: any) => {
window.$message.error(error.message)
})
}
return {

12
dolphinscheduler-ui-next/src/views/projects/workflow/definition/use-table.ts

@ -200,9 +200,6 @@ export function useTable() {
searchVal: variables.searchVal
})
})
.catch((error: any) => {
window.$message.error(error.message)
})
}
const releaseWorkflow = (row: any) => {
@ -221,9 +218,6 @@ export function useTable() {
searchVal: variables.searchVal
})
})
.catch((error: any) => {
window.$message.error(error.message)
})
}
const copyWorkflow = (row: any) => {
@ -240,9 +234,6 @@ export function useTable() {
searchVal: variables.searchVal
})
})
.catch((error: any) => {
window.$message.error(error.message)
})
}
const downloadBlob = (data: any, fileNameS = 'json') => {
@ -280,9 +271,6 @@ export function useTable() {
.then((res: any) => {
downloadBlob(res, fileName)
})
.catch((error: any) => {
window.$message.error(error.message)
})
}
const gotoTimingManage = (row: any) => {

10
dolphinscheduler-ui-next/src/views/projects/workflow/instance/components/log-modal.tsx

@ -96,10 +96,6 @@ export default defineComponent({
}, 1500)
textareaLog.value.innerHTML = res || t('project.workflow.no_log')
})
.catch((error: any) => {
window.$message.error(error.message || '')
loadingRef.value = false
})
}
const showLog = () => {
@ -126,9 +122,6 @@ export default defineComponent({
}, 800)
}
})
.catch((error: any) => {
window.$message.error(error.message || '')
})
}
const initLog = () => {
@ -259,7 +252,7 @@ export default defineComponent({
render() {
return (
<div>
<span class={styles['log-model']}>
<span>
{this.taskInstanceId && this.taskInstanceType !== 'SUB_PROCESS' && (
<span>
{renderSlot(this.$slots, 'history')}
@ -349,7 +342,6 @@ export default defineComponent({
<div class={styles['content']} ref='logContent'>
<div class={styles['content-log-box']} ref='logContentBox'>
<textarea
class={styles['textarea-ft']}
style={`width: 100%; height: ${this.textareaHeight}px`}
spellcheck='false'
ref='textareaLog'

16
dolphinscheduler-ui-next/src/views/projects/workflow/instance/use-table.ts

@ -285,10 +285,6 @@ export function useTable() {
getTableData()
})
.catch((error: any) => {
window.$message.error(error.message || '')
getTableData()
})
}
const batchDeleteInstance = () => {
@ -310,10 +306,6 @@ export function useTable() {
variables.checkedRowKeys = []
getTableData()
})
.catch((error: any) => {
window.$message.error(error.message || '')
getTableData()
})
}
/**
@ -326,10 +318,6 @@ export function useTable() {
getTableData()
})
.catch((error: any) => {
window.$message.error(error.message || '')
getTableData()
})
}
/**
@ -368,10 +356,6 @@ export function useTable() {
getTableData()
}, index)
})
.catch((error: any) => {
window.$message.error(error.message)
getTableData()
})
}
return {

18
dolphinscheduler-ui-next/src/views/resource/file/create/use-create.ts

@ -31,18 +31,14 @@ export function useCreate(state: any) {
const currentDir = fileStore.getCurrentDir || '/'
state.fileFormRef.validate(async (valid: any) => {
if (!valid) {
try {
await onlineCreateResource({
...state.fileForm,
...{ pid, currentDir }
})
await onlineCreateResource({
...state.fileForm,
...{ pid, currentDir }
})
window.$message.success(t('resource.file.success'))
const name = pid ? 'resource-file-subdirectory' : 'file'
router.push({ name, params: { id: pid } })
} catch (error: any) {
window.$message.error(error.message)
}
window.$message.success(t('resource.file.success'))
const name = pid ? 'resource-file-subdirectory' : 'file'
router.push({ name, params: { id: pid } })
}
})
}

20
dolphinscheduler-ui-next/src/views/resource/file/edit/use-edit.ts

@ -43,19 +43,15 @@ export function useEdit(state: any) {
const handleUpdateContent = (id: number) => {
state.fileFormRef.validate(async (valid: any) => {
if (!valid) {
try {
await updateResourceContent(
{
...state.fileForm
},
id
)
await updateResourceContent(
{
...state.fileForm
},
id
)
window.$message.success(t('resource.file.success'))
router.go(-1)
} catch (error: any) {
window.$message.error(error.message)
}
window.$message.success(t('resource.file.success'))
router.go(-1)
}
})
}

16
dolphinscheduler-ui-next/src/views/resource/file/folder/use-folder.ts

@ -36,17 +36,13 @@ export function useFolder(state: any) {
const currentDir = fileStore.getCurrentDir || '/'
state.folderFormRef.validate(async (valid: any) => {
if (!valid) {
try {
await createDirectory({
...state.folderForm,
...{ pid, currentDir }
})
await createDirectory({
...state.folderForm,
...{ pid, currentDir }
})
window.$message.success(t('resource.file.success'))
emit('updateList')
} catch (error: any) {
window.$message.error(error.message)
}
window.$message.success(t('resource.file.success'))
emit('updateList')
hideModal()
resetForm()
}

20
dolphinscheduler-ui-next/src/views/resource/file/rename/use-rename.ts

@ -29,18 +29,14 @@ export function useRename(state: any) {
) => {
state.renameFormRef.validate(async (valid: any) => {
if (!valid) {
try {
await updateResource(
{
...state.renameForm
},
state.renameForm.id
)
window.$message.success(t('resource.file.success'))
emit('updateList')
} catch (error: any) {
window.$message.error(error.message)
}
await updateResource(
{
...state.renameForm
},
state.renameForm.id
)
window.$message.success(t('resource.file.success'))
emit('updateList')
}
hideModal()

10
dolphinscheduler-ui-next/src/views/resource/file/upload/use-upload.ts

@ -44,13 +44,9 @@ export function useUpload(state: any) {
formData.append('currentDir', currentDir)
formData.append('description', state.uploadForm.description)
try {
await createResource(formData as any)
window.$message.success(t('resource.file.success'))
emit('updateList')
} catch (error: any) {
window.$message.error(error.message)
}
await createResource(formData as any)
window.$message.success(t('resource.file.success'))
emit('updateList')
hideModal()
resetForm()

28
dolphinscheduler-ui-next/src/views/resource/udf/function/components/use-modal.ts

@ -61,14 +61,10 @@ export function useModal(
const submitRequest = (serviceHandle: any) => {
state.functionFormRef.validate(async (valid: any) => {
if (!valid) {
try {
await serviceHandle()
window.$message.success(t('resource.udf.success'))
ctx.emit('updateList')
ctx.emit('update:show')
} catch (error: any) {
window.$message.error(error.message)
}
await serviceHandle()
window.$message.success(t('resource.udf.success'))
ctx.emit('updateList')
ctx.emit('update:show')
}
})
}
@ -160,16 +156,12 @@ export function useModal(
formData.append('currentDir', uploadState.uploadForm.currentDir)
formData.append('description', uploadState.uploadForm.description)
try {
const res = await createResource(formData as any)
window.$message.success(t('resource.function.success'))
variables.uploadShow = false
resetUploadForm()
getUdfList()
state.functionForm.resourceId = res.id
} catch (error: any) {
window.$message.error(error.message)
}
const res = await createResource(formData as any)
window.$message.success(t('resource.function.success'))
variables.uploadShow = false
resetUploadForm()
getUdfList()
state.functionForm.resourceId = res.id
}
})
}

26
dolphinscheduler-ui-next/src/views/resource/udf/resource/components/use-modal.ts

@ -62,14 +62,10 @@ export function useModal(
const submitRequest = (serviceHandle: any) => {
state.folderFormRef.validate(async (valid: any) => {
if (!valid) {
try {
await serviceHandle()
window.$message.success(t('resource.udf.success'))
ctx.emit('updateList')
ctx.emit('update:show')
} catch (error: any) {
window.$message.error(error.message)
}
await serviceHandle()
window.$message.success(t('resource.udf.success'))
ctx.emit('updateList')
ctx.emit('update:show')
}
})
}
@ -93,15 +89,11 @@ export function useModal(
formData.append('currentDir', currentDir)
formData.append('description', state.uploadForm.description)
try {
await createResource(formData as any)
window.$message.success(t('resource.udf.success'))
ctx.emit('updateList')
ctx.emit('update:show')
resetUploadForm()
} catch (error: any) {
window.$message.error(error.message)
}
await createResource(formData as any)
window.$message.success(t('resource.udf.success'))
ctx.emit('updateList')
ctx.emit('update:show')
resetUploadForm()
}
})
}

3
dolphinscheduler-ui-next/src/views/resource/udf/resource/use-table.ts

@ -270,9 +270,6 @@ export function useTable() {
fileStore.setCurrentDir(res.fullName)
router.push({ name: 'resource-sub-manage', params: { id: res.id } })
})
.catch((error: any) => {
window.$message.error(error.message)
})
}
return {

44
dolphinscheduler-ui-next/src/views/security/alarm-instance-manage/use-detail.ts

@ -45,35 +45,29 @@ export function useDetail(getFormValues: Function) {
const values = getFormValues()
if (status.saving) return false
status.saving = true
try {
if (currentRecord?.instanceName !== values.instanceName) {
await verifyAlertInstanceName({
alertInstanceName: values.instanceName
})
}
if (currentRecord?.instanceName !== values.instanceName) {
await verifyAlertInstanceName({
alertInstanceName: values.instanceName
})
}
currentRecord?.id
? await updateAlertPluginInstance(
{
alertPluginInstanceId: values.pluginDefineId,
instanceName: values.instanceName,
pluginInstanceParams: formatParams(json, values)
},
currentRecord.id
)
: await createAlertPluginInstance({
currentRecord?.id
? await updateAlertPluginInstance(
{
alertPluginInstanceId: values.pluginDefineId,
instanceName: values.instanceName,
pluginDefineId: values.pluginDefineId,
pluginInstanceParams: formatParams(json, values)
})
},
currentRecord.id
)
: await createAlertPluginInstance({
instanceName: values.instanceName,
pluginDefineId: values.pluginDefineId,
pluginInstanceParams: formatParams(json, values)
})
status.saving = false
return true
} catch (e) {
window.$message.error((e as Error).message)
status.saving = false
return false
}
status.saving = false
return true
}
return { status, createOrUpdate }

30
dolphinscheduler-ui-next/src/views/security/alarm-instance-manage/use-form.ts

@ -72,33 +72,23 @@ export function useForm() {
const getUiPluginsByType = async () => {
if (state.pluginsLoading) return
state.pluginsLoading = true
try {
const plugins = await queryUiPluginsByType({ pluginType: 'ALERT' })
state.uiPlugins = plugins.map((plugin: IPlugin) => ({
label: plugin.pluginName,
value: plugin.id
}))
state.pluginsLoading = false
} catch (err) {
state.uiPlugins = []
state.pluginsLoading = false
}
const plugins = await queryUiPluginsByType({ pluginType: 'ALERT' })
state.uiPlugins = plugins.map((plugin: IPlugin) => ({
label: plugin.pluginName,
value: plugin.id
}))
state.pluginsLoading = false
}
const changePlugin = async (pluginId: IPluginId) => {
if (state.pluginsLoading) return
state.pluginsLoading = true
state.detailForm.pluginDefineId = pluginId
try {
const { pluginParams } = await queryUiPluginDetailById(pluginId)
if (pluginParams) {
state.json = JSON.parse(pluginParams)
}
state.pluginsLoading = false
} catch (e) {
window.$message.error((e as Error).message)
state.pluginsLoading = false
const { pluginParams } = await queryUiPluginDetailById(pluginId)
if (pluginParams) {
state.json = JSON.parse(pluginParams)
}
state.pluginsLoading = false
}
const initForm = () => {

49
dolphinscheduler-ui-next/src/views/security/alarm-instance-manage/use-table.ts

@ -38,31 +38,24 @@ export function useTable() {
if (data.loading) return
data.loading = true
try {
const { totalList, total } = await queryAlertPluginInstanceListPaging({
pageNo: data.page,
pageSize: data.pageSize,
searchVal: data.searchVal
})
data.loading = false
if (!totalList) throw Error()
data.list = totalList.map((record: IRecord) => {
record.createTime = record.createTime
? format(parseTime(record.createTime), 'yyyy-MM-dd HH:mm:ss')
: ''
record.updateTime = record.updateTime
? format(parseTime(record.updateTime), 'yyyy-MM-dd HH:mm:ss')
: ''
return record
})
const { totalList, total } = await queryAlertPluginInstanceListPaging({
pageNo: data.page,
pageSize: data.pageSize,
searchVal: data.searchVal
})
data.loading = false
if (!totalList) throw Error()
data.list = totalList.map((record: IRecord) => {
record.createTime = record.createTime
? format(parseTime(record.createTime), 'yyyy-MM-dd HH:mm:ss')
: ''
record.updateTime = record.updateTime
? format(parseTime(record.updateTime), 'yyyy-MM-dd HH:mm:ss')
: ''
return record
})
data.itemCount = total
} catch (e) {
if ((e as Error).message) window.$message.error((e as Error).message)
data.loading = false
data.list = []
data.itemCount = 0
}
data.itemCount = total
}
const updateList = () => {
@ -73,12 +66,8 @@ export function useTable() {
}
const deleteRecord = async (id: number) => {
try {
const ignored = await deleteAlertPluginInstance(id)
updateList()
} catch (e) {
window.$message.error((e as Error).message)
}
const ignored = await deleteAlertPluginInstance(id)
updateList()
}
const changePage = (page: number) => {

Loading…
Cancel
Save