Browse Source

[Feature][UI Next][V1.0.0-Alpha] Add the corresponding state for the … (#8870)

* [Feature][UI Next][V1.0.0-Alpha] Add the corresponding state for the saving action.

* [Feature][UI Next][V1.0.0-Alpha] Add the corresponding state for the saving action.
3.0.0/version-upgrade
Amy0104 3 years ago committed by GitHub
parent
commit
13b1ffe12a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 40
      dolphinscheduler-ui-next/src/views/datasource/list/use-detail.ts
  2. 1
      dolphinscheduler-ui-next/src/views/password/use-form.ts
  3. 1
      dolphinscheduler-ui-next/src/views/profile/index.tsx
  4. 1
      dolphinscheduler-ui-next/src/views/profile/use-form.ts
  5. 36
      dolphinscheduler-ui-next/src/views/profile/use-update.ts
  6. 1
      dolphinscheduler-ui-next/src/views/projects/list/components/project-modal.tsx
  7. 25
      dolphinscheduler-ui-next/src/views/projects/list/components/use-form.ts
  8. 6
      dolphinscheduler-ui-next/src/views/projects/task/components/node/detail-modal.tsx
  9. 1
      dolphinscheduler-ui-next/src/views/projects/task/definition/components/move-modal.tsx
  10. 25
      dolphinscheduler-ui-next/src/views/projects/task/definition/components/use-move.ts
  11. 1
      dolphinscheduler-ui-next/src/views/projects/task/definition/index.tsx
  12. 35
      dolphinscheduler-ui-next/src/views/projects/task/definition/use-task.ts
  13. 1
      dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/import-modal.tsx
  14. 1
      dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/start-modal.tsx
  15. 1
      dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/timing-modal.tsx
  16. 7
      dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/use-form.ts
  17. 148
      dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/use-modal.ts
  18. 1
      dolphinscheduler-ui-next/src/views/resource/file/folder/index.tsx
  19. 35
      dolphinscheduler-ui-next/src/views/resource/file/folder/use-folder.ts
  20. 1
      dolphinscheduler-ui-next/src/views/resource/file/folder/use-form.ts
  21. 1
      dolphinscheduler-ui-next/src/views/resource/file/rename/index.tsx
  22. 1
      dolphinscheduler-ui-next/src/views/resource/file/rename/use-form.ts
  23. 31
      dolphinscheduler-ui-next/src/views/resource/file/rename/use-rename.ts
  24. 1
      dolphinscheduler-ui-next/src/views/resource/file/upload/index.tsx
  25. 1
      dolphinscheduler-ui-next/src/views/resource/file/upload/use-form.ts
  26. 39
      dolphinscheduler-ui-next/src/views/resource/file/upload/use-upload.ts
  27. 18
      dolphinscheduler-ui-next/src/views/resource/task-group/option/components/form-modal.tsx
  28. 1
      dolphinscheduler-ui-next/src/views/resource/task-group/option/use-form.ts
  29. 17
      dolphinscheduler-ui-next/src/views/resource/task-group/queue/components/form-modal.tsx
  30. 1
      dolphinscheduler-ui-next/src/views/resource/task-group/queue/use-form.ts
  31. 1
      dolphinscheduler-ui-next/src/views/resource/udf/function/components/function-modal.tsx
  32. 1
      dolphinscheduler-ui-next/src/views/resource/udf/function/components/use-form.ts
  33. 24
      dolphinscheduler-ui-next/src/views/resource/udf/function/components/use-modal.ts
  34. 1
      dolphinscheduler-ui-next/src/views/resource/udf/resource/components/folder-modal.tsx
  35. 1
      dolphinscheduler-ui-next/src/views/resource/udf/resource/components/upload-modal.tsx
  36. 2
      dolphinscheduler-ui-next/src/views/resource/udf/resource/components/use-form.ts
  37. 64
      dolphinscheduler-ui-next/src/views/resource/udf/resource/components/use-modal.ts
  38. 1
      dolphinscheduler-ui-next/src/views/security/alarm-group-manage/components/alarm-group-modal.tsx
  39. 24
      dolphinscheduler-ui-next/src/views/security/alarm-group-manage/components/use-modal.ts
  40. 44
      dolphinscheduler-ui-next/src/views/security/alarm-instance-manage/use-detail.ts
  41. 1
      dolphinscheduler-ui-next/src/views/security/environment-manage/components/environment-modal.tsx
  42. 23
      dolphinscheduler-ui-next/src/views/security/environment-manage/components/use-modal.ts
  43. 1
      dolphinscheduler-ui-next/src/views/security/k8s-namespace-manage/components/k8s-namespace-modal.tsx
  44. 23
      dolphinscheduler-ui-next/src/views/security/k8s-namespace-manage/components/use-modal.ts
  45. 1
      dolphinscheduler-ui-next/src/views/security/tenant-manage/components/tenant-modal.tsx
  46. 21
      dolphinscheduler-ui-next/src/views/security/tenant-manage/components/use-modalData.ts
  47. 1
      dolphinscheduler-ui-next/src/views/security/token-manage/components/token-modal.tsx
  48. 21
      dolphinscheduler-ui-next/src/views/security/token-manage/components/use-modal.ts
  49. 27
      dolphinscheduler-ui-next/src/views/security/user-manage/components/use-user-detail.ts
  50. 24
      dolphinscheduler-ui-next/src/views/security/worker-group-manage/components/use-modal.ts
  51. 1
      dolphinscheduler-ui-next/src/views/security/worker-group-manage/components/worker-group-modal.tsx
  52. 24
      dolphinscheduler-ui-next/src/views/security/yarn-queue-manage/components/use-modal.ts
  53. 1
      dolphinscheduler-ui-next/src/views/security/yarn-queue-manage/components/yarn-queue-modal.tsx

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

@ -56,30 +56,40 @@ export function useDetail(getFieldsValue: Function) {
const testConnect = async () => {
if (status.testing) return
status.testing = true
const res = await connectDataSource(formatParams())
window.$message.success(
res
? res.msg
: `${t('datasource.test_connect')} ${t('datasource.success')}`
)
status.testing = false
try {
const res = await connectDataSource(formatParams())
window.$message.success(
res
? res.msg
: `${t('datasource.test_connect')} ${t('datasource.success')}`
)
status.testing = false
} catch (err) {
status.testing = false
}
}
const createOrUpdate = async (id?: number) => {
const values = getFieldsValue()
if (status.saving || !values.name) return false
status.saving = true
if (PREV_NAME !== values.name) {
await verifyDataSourceName({ name: values.name })
}
try {
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
status.saving = false
return true
} catch (err) {
status.saving = false
return false
}
}
return { status, queryById, testConnect, createOrUpdate }

1
dolphinscheduler-ui-next/src/views/password/use-form.ts

@ -28,6 +28,7 @@ export function useForm() {
password: '',
confirmPassword: ''
},
saving: false,
rules: {
password: {
trigger: ['input', 'blur'],

1
dolphinscheduler-ui-next/src/views/profile/index.tsx

@ -78,6 +78,7 @@ const profile = defineComponent({
!this.profileForm.email ||
!utils.regex.email.test(this.profileForm.email)
}
confirmLoading={this.saving}
>
{{
default: () => (

1
dolphinscheduler-ui-next/src/views/profile/use-form.ts

@ -33,6 +33,7 @@ export function useForm() {
email: userInfo.email,
phone: userInfo.phone
},
saving: false,
rules: {
username: {
trigger: ['input', 'blur'],

36
dolphinscheduler-ui-next/src/views/profile/use-update.ts

@ -23,21 +23,27 @@ export function useUpdate(state: any) {
const userStore = useUserStore()
const userInfo = userStore.userInfo as UserInfoRes
const handleUpdate = () => {
state.profileFormRef.validate(async (valid: any) => {
if (!valid) {
await updateUser({
userPassword: '',
id: userInfo.id,
userName: state.profileForm.username,
tenantId: userInfo.tenantId,
email: state.profileForm.email,
phone: state.profileForm.phone,
state: userInfo.state,
queue: userInfo.queue
})
}
})
const handleUpdate = async () => {
await state.profileFormRef.validate()
if (state.saving === true) return
state.saving = true
try {
await updateUser({
userPassword: '',
id: userInfo.id,
userName: state.profileForm.username,
tenantId: userInfo.tenantId,
email: state.profileForm.email,
phone: state.profileForm.phone,
state: userInfo.state,
queue: userInfo.queue
})
state.saving = false
} catch (err) {
state.saving = false
}
}
return {

1
dolphinscheduler-ui-next/src/views/projects/list/components/project-modal.tsx

@ -101,6 +101,7 @@ const ProjectModal = defineComponent({
onConfirm={this.confirmModal}
onCancel={this.cancelModal}
confirmDisabled={!this.model.projectName || !this.model.userName}
confirmLoading={this.saving}
>
<NForm rules={this.rules} ref='projectFormRef'>
<NFormItem label={t('project.list.project_name')} path='projectName'>

25
dolphinscheduler-ui-next/src/views/projects/list/components/use-form.ts

@ -36,6 +36,7 @@ export function useForm(
description: '',
userName: (userStore.getUserInfo as UserInfoRes).userName
},
saving: false,
rules: {
projectName: {
required: true,
@ -68,16 +69,28 @@ export function useForm(
})
}
const submitProjectModal = () => {
createProject(variables.model).then(() => {
const submitProjectModal = async () => {
if (variables.saving) return
variables.saving = true
try {
await createProject(variables.model)
variables.saving = false
ctx.emit('confirmModal', props.showModalRef)
})
} catch (err) {
variables.saving = false
}
}
const updateProjectModal = () => {
updateProject(variables.model, props.row.code).then(() => {
const updateProjectModal = async () => {
if (variables.saving) return
variables.saving = true
try {
await updateProject(variables.model, props.row.code)
variables.saving = false
ctx.emit('confirmModal', props.showModalRef)
})
} catch (err) {
variables.saving = false
}
}
return { variables, t, handleValidate }

6
dolphinscheduler-ui-next/src/views/projects/task/components/node/detail-modal.tsx

@ -65,6 +65,10 @@ const props = {
},
taskInstance: {
type: Object as PropType<IWorkflowTaskInstance>
},
saving: {
type: Boolean,
default: false
}
}
@ -168,7 +172,7 @@ const NodeDetailModal = defineComponent({
show={props.show}
title={`${t('project.node.current_node_settings')}`}
onConfirm={onConfirm}
confirmLoading={false}
confirmLoading={props.saving}
confirmDisabled={props.readonly}
onCancel={onCancel}
headerLinks={headerLinks}

1
dolphinscheduler-ui-next/src/views/projects/task/definition/components/move-modal.tsx

@ -83,6 +83,7 @@ const MoveModal = defineComponent({
onCancel={cancelModal}
onConfirm={confirmModal}
confirmDisabled={!this.model.targetProcessDefinitionCode}
confirmLoading={this.saving}
>
<NForm
model={this.model}

25
dolphinscheduler-ui-next/src/views/projects/task/definition/components/use-move.ts

@ -37,6 +37,7 @@ export function useMove() {
targetProcessDefinitionCode: ref(''),
generalOptions: []
},
saving: false,
rules: {
targetProcessDefinitionCode: {
required: true,
@ -77,17 +78,23 @@ export function useMove() {
})
}
const moveTask = () => {
const data = {
targetProcessDefinitionCode: variables.model.targetProcessDefinitionCode,
taskCode: variables.taskCode,
processDefinitionCode: variables.processDefinitionCode
}
moveRelation(data, projectCode).then(() => {
const moveTask = async () => {
if (variables.saving) return
variables.saving = true
try {
const data = {
targetProcessDefinitionCode:
variables.model.targetProcessDefinitionCode,
taskCode: variables.taskCode,
processDefinitionCode: variables.processDefinitionCode
}
await moveRelation(data, projectCode)
variables.saving = false
variables.model.targetProcessDefinitionCode = ''
variables.refreshTaskDefinition = true
})
} catch (err) {
variables.saving = false
}
}
return {

1
dolphinscheduler-ui-next/src/views/projects/task/definition/index.tsx

@ -196,6 +196,7 @@ const TaskDefinition = defineComponent({
projectCode={this.projectCode}
from={1}
readonly={this.taskReadonly}
saving={this.taskSaving}
/>
</>
)

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

@ -62,23 +62,28 @@ export function useTask(projectCode: number) {
const onTaskSave = async (data: INodeData) => {
if (task.taskSaving) return
task.taskSaving = true
if (data.id) {
data.code &&
(await updateWithUpstream(
try {
if (data.id) {
data.code &&
(await updateWithUpstream(
projectCode,
data.code,
formatParams({ ...data, code: data.code }, false)
))
} else {
const taskCode = await getTaskCode()
await saveSingle(
projectCode,
data.code,
formatParams({ ...data, code: data.code }, false)
))
} else {
const taskCode = await getTaskCode()
await saveSingle(
projectCode,
formatParams({ ...data, code: taskCode }, true)
)
}
formatParams({ ...data, code: taskCode }, true)
)
}
task.taskSaving = false
return true
task.taskSaving = false
return true
} catch (err) {
task.taskSaving = false
return false
}
}
const onEditTask = async (row: IRecord, readonly: boolean) => {

1
dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/import-modal.tsx

@ -67,6 +67,7 @@ export default defineComponent({
title={t('project.workflow.upload')}
onCancel={this.hideModal}
onConfirm={this.handleImport}
confirmLoading={this.saving}
>
<NForm
rules={this.importRules}

1
dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/start-modal.tsx

@ -217,6 +217,7 @@ export default defineComponent({
title={t('project.workflow.set_parameters_before_starting')}
onCancel={this.hideModal}
onConfirm={this.handleStart}
confirmLoading={this.saving}
>
<NForm ref='startFormRef' label-placement='left' label-width='160'>
<NFormItem

1
dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/timing-modal.tsx

@ -235,6 +235,7 @@ export default defineComponent({
title={t('project.workflow.set_parameters_before_timing')}
onCancel={this.hideModal}
onConfirm={this.handleTiming}
confirmLoading={this.saving}
>
<NForm ref='timingFormRef' label-placement='left' label-width='160'>
<NFormItem

7
dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/use-form.ts

@ -32,6 +32,7 @@ export const useForm = () => {
name: '',
file: ''
},
saving: false,
importRules: {
file: {
required: true,
@ -65,7 +66,8 @@ export const useForm = () => {
startParams: null,
expectedParallelismNumber: '',
dryRun: 0
}
},
saving: false
})
const timingState = reactive({
@ -83,7 +85,8 @@ export const useForm = () => {
warningGroupId: '',
workerGroup: 'default',
environmentCode: null
}
},
saving: false
})
return {
importState,

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

@ -58,81 +58,101 @@ export function useModal(
state.importFormRef.file = ''
}
const handleImportDefinition = () => {
state.importFormRef.validate(async (valid: any) => {
if (!valid) {
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()
}
})
const handleImportDefinition = async () => {
await state.importFormRef.validate()
if (state.saving) return
state.saving = true
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'))
state.saving = false
ctx.emit('updateList')
ctx.emit('update:show')
resetImportForm()
} catch (err) {
state.saving = false
}
}
const handleStartDefinition = (code: number) => {
state.startFormRef.validate(async (valid: any) => {
if (!valid) {
state.startForm.processDefinitionCode = code
if (state.startForm.startEndTime) {
const start = format(
new Date(state.startForm.startEndTime[0]),
'yyyy-MM-dd hh:mm:ss'
)
const end = format(
new Date(state.startForm.startEndTime[1]),
'yyyy-MM-dd hh:mm:ss'
)
state.startForm.scheduleTime = `${start},${end}`
}
const handleStartDefinition = async (code: number) => {
await state.startFormRef.validate()
if (state.saving) return
state.saving = true
try {
state.startForm.processDefinitionCode = code
if (state.startForm.startEndTime) {
const start = format(
new Date(state.startForm.startEndTime[0]),
'yyyy-MM-dd hh:mm:ss'
)
const end = format(
new Date(state.startForm.startEndTime[1]),
'yyyy-MM-dd hh:mm:ss'
)
state.startForm.scheduleTime = `${start},${end}`
}
const startParams = {} as any
for (const item of variables.startParamsList) {
if (item.value !== '') {
startParams[item.prop] = item.value
}
const startParams = {} as any
for (const item of variables.startParamsList) {
if (item.value !== '') {
startParams[item.prop] = item.value
}
state.startForm.startParams = !_.isEmpty(startParams)
? JSON.stringify(startParams)
: ''
await startProcessInstance(state.startForm, variables.projectCode)
window.$message.success(t('project.workflow.success'))
ctx.emit('updateList')
ctx.emit('update:show')
}
})
state.startForm.startParams = !_.isEmpty(startParams)
? JSON.stringify(startParams)
: ''
await startProcessInstance(state.startForm, variables.projectCode)
window.$message.success(t('project.workflow.success'))
state.saving = false
ctx.emit('updateList')
ctx.emit('update:show')
} catch (err) {
state.saving = false
}
}
const handleCreateTiming = (code: number) => {
state.timingFormRef.validate(async (valid: any) => {
if (!valid) {
const data: any = getTimingData()
data.processDefinitionCode = code
const handleCreateTiming = async (code: number) => {
await state.timingFormRef.validate()
await createSchedule(data, variables.projectCode)
window.$message.success(t('project.workflow.success'))
ctx.emit('updateList')
ctx.emit('update:show')
}
})
if (state.saving) return
state.saving = true
try {
const data: any = getTimingData()
data.processDefinitionCode = code
await createSchedule(data, variables.projectCode)
window.$message.success(t('project.workflow.success'))
state.saving = false
ctx.emit('updateList')
ctx.emit('update:show')
} catch (err) {
state.saving = false
}
}
const handleUpdateTiming = (id: number) => {
state.timingFormRef.validate(async (valid: any) => {
if (!valid) {
const data: any = getTimingData()
data.id = id
const handleUpdateTiming = async (id: number) => {
await state.timingFormRef.validate()
await updateSchedule(data, variables.projectCode, id)
window.$message.success(t('project.workflow.success'))
ctx.emit('updateList')
ctx.emit('update:show')
}
})
if (state.saving) return
state.saving = true
try {
const data: any = getTimingData()
data.id = id
await updateSchedule(data, variables.projectCode, id)
window.$message.success(t('project.workflow.success'))
state.saving = false
ctx.emit('updateList')
ctx.emit('update:show')
} catch (err) {
state.saving = false
}
}
const getTimingData = () => {

1
dolphinscheduler-ui-next/src/views/resource/file/folder/index.tsx

@ -61,6 +61,7 @@ export default defineComponent({
onConfirm={this.handleFolder}
confirmClassName='btn-submit'
cancelClassName='btn-cancel'
confirmLoading={this.saving}
>
<NForm
rules={this.rules}

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

@ -27,26 +27,31 @@ export function useFolder(state: any) {
const router: Router = useRouter()
const fileStore = useFileStore()
const handleCreateFolder = (
const handleCreateFolder = async (
emit: IEmit,
hideModal: () => void,
resetForm: () => void
) => {
const pid = router.currentRoute.value.params.id || -1
const currentDir = fileStore.getCurrentDir || '/'
state.folderFormRef.validate(async (valid: any) => {
if (!valid) {
await createDirectory({
...state.folderForm,
...{ pid, currentDir }
})
await state.folderFormRef.validate()
window.$message.success(t('resource.file.success'))
emit('updateList')
hideModal()
resetForm()
}
})
if (state.saving) return
state.saving = true
try {
const pid = router.currentRoute.value.params.id || -1
const currentDir = fileStore.getCurrentDir || '/'
await createDirectory({
...state.folderForm,
...{ pid, currentDir }
})
window.$message.success(t('resource.file.success'))
state.saving = false
emit('updateList')
hideModal()
resetForm()
} catch (err) {
state.saving = false
}
}
return {

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

@ -37,6 +37,7 @@ export function useForm() {
const state = reactive({
folderFormRef: ref(),
folderForm: defaultValue(),
saving: false,
rules: {
name: {
required: true,

1
dolphinscheduler-ui-next/src/views/resource/file/rename/index.tsx

@ -77,6 +77,7 @@ export default defineComponent({
onConfirm={this.handleFile}
confirmClassName='btn-submit'
cancelClassName='btn-cancel'
confirmLoading={this.saving}
>
<NForm
rules={this.rules}

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

@ -36,6 +36,7 @@ export function useForm(name: string, description: string) {
const state = reactive({
renameFormRef: ref(),
renameForm: defaultValue(name, description),
saving: false,
rules: {
name: {
required: true,

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

@ -22,26 +22,31 @@ import { updateResource } from '@/service/modules/resources'
export function useRename(state: any) {
const { t } = useI18n()
const handleRenameFile = (
const handleRenameFile = async (
emit: IEmit,
hideModal: () => void,
resetForm: () => void
) => {
state.renameFormRef.validate(async (valid: any) => {
if (!valid) {
await updateResource(
{
...state.renameForm
},
state.renameForm.id
)
window.$message.success(t('resource.file.success'))
emit('updateList')
}
await state.renameFormRef.validate()
if (state.saving) return
state.saving = true
try {
await updateResource(
{
...state.renameForm
},
state.renameForm.id
)
window.$message.success(t('resource.file.success'))
state.saving = false
emit('updateList')
hideModal()
resetForm()
})
} catch (err) {
state.saving = false
}
}
return {

1
dolphinscheduler-ui-next/src/views/resource/file/upload/index.tsx

@ -67,6 +67,7 @@ export default defineComponent({
onConfirm={this.handleFile}
confirmClassName='btn-submit'
cancelClassName='btn-cancel'
confirmLoading={this.saving}
>
<NForm
rules={this.rules}

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

@ -37,6 +37,7 @@ export function useForm() {
const state = reactive({
uploadFormRef: ref(),
uploadForm: defaultValue(),
saving: false,
rules: {
name: {
required: true,

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

@ -27,31 +27,36 @@ export function useUpload(state: any) {
const router: Router = useRouter()
const fileStore = useFileStore()
const handleUploadFile = (
const handleUploadFile = async (
emit: IEmit,
hideModal: () => void,
resetForm: () => void
) => {
state.uploadFormRef.validate(async (valid: any) => {
await state.uploadFormRef.validate()
if (state.saving) return
state.saving = true
try {
const pid = router.currentRoute.value.params.id || -1
const currentDir = fileStore.getCurrentDir || '/'
if (!valid) {
const formData = new FormData()
formData.append('file', state.uploadForm.file)
formData.append('type', 'FILE')
formData.append('name', state.uploadForm.name)
formData.append('pid', String(pid))
formData.append('currentDir', currentDir)
formData.append('description', state.uploadForm.description)
const formData = new FormData()
formData.append('file', state.uploadForm.file)
formData.append('type', 'FILE')
formData.append('name', state.uploadForm.name)
formData.append('pid', String(pid))
formData.append('currentDir', currentDir)
formData.append('description', state.uploadForm.description)
await createResource(formData as any)
window.$message.success(t('resource.file.success'))
emit('updateList')
await createResource(formData as any)
window.$message.success(t('resource.file.success'))
state.saving = false
emit('updateList')
hideModal()
resetForm()
}
})
hideModal()
resetForm()
} catch (err) {
state.saving = false
}
}
return {

18
dolphinscheduler-ui-next/src/views/resource/task-group/option/components/form-modal.tsx

@ -67,13 +67,18 @@ const FormModal = defineComponent({
}
})
const onConfirm = () => {
;(props.status === 1
? updateTaskGroup(state.formData)
: createTaskGroup(state.formData)
).then(() => {
const onConfirm = async () => {
if (state.saving) return
state.saving = true
try {
props.status === 1
? await updateTaskGroup(state.formData)
: await createTaskGroup(state.formData)
state.saving = false
emit('confirm')
})
} catch (err) {
state.saving = false
}
}
const onCancel = () => {
@ -101,6 +106,7 @@ const FormModal = defineComponent({
!this.formData.groupSize ||
!this.formData.description
}
confirmLoading={this.saving}
>
<NForm rules={this.rules} ref='formRef'>
<NFormItem label={t('resource.task_group_option.name')} path='name'>

1
dolphinscheduler-ui-next/src/views/resource/task-group/option/use-form.ts

@ -33,6 +33,7 @@ export function useForm() {
status: 1,
description: ''
} as TaskGroupUpdateReq,
saving: false,
rules: {
name: {
required: true,

17
dolphinscheduler-ui-next/src/views/resource/task-group/queue/components/form-modal.tsx

@ -43,12 +43,18 @@ const FormModal = defineComponent({
state.formData.priority = props.data.priority
})
const onConfirm = () => {
const value = state.formData.priority + ''
if (value) {
modifyTaskGroupQueuePriority(state.formData).then(() => {
const onConfirm = async () => {
if (state.saving) return
state.saving = true
try {
const value = state.formData.priority + ''
if (value) {
await modifyTaskGroupQueuePriority(state.formData)
emit('confirm')
})
}
state.saving = false
} catch (err) {
state.saving = false
}
}
@ -67,6 +73,7 @@ const FormModal = defineComponent({
show={show}
onConfirm={onConfirm}
onCancel={onCancel}
confirmLoading={this.saving}
>
<NForm rules={this.rules} ref='formRef'>
<NFormItem

1
dolphinscheduler-ui-next/src/views/resource/task-group/queue/use-form.ts

@ -29,6 +29,7 @@ export function useForm() {
queueId: 0,
priority: 0
} as TaskGroupQueuePriorityUpdateReq,
saving: false,
rules: {
priority: {
required: true,

1
dolphinscheduler-ui-next/src/views/resource/udf/function/components/function-modal.tsx

@ -126,6 +126,7 @@ export default defineComponent({
onConfirm={this.row.id ? this.handleRename : this.handleCreate}
confirmClassName='btn-submit'
cancelClassName='btn-cancel'
confirmLoading={this.saving}
>
<NForm
rules={this.rules}

1
dolphinscheduler-ui-next/src/views/resource/udf/function/components/use-form.ts

@ -33,6 +33,7 @@ export const useForm = () => {
description: '',
resourceId: -1
},
saving: false,
rules: {
type: {
required: true,

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

@ -58,15 +58,21 @@ export function useModal(
})
}
const submitRequest = (serviceHandle: any) => {
state.functionFormRef.validate(async (valid: any) => {
if (!valid) {
await serviceHandle()
window.$message.success(t('resource.udf.success'))
ctx.emit('updateList')
ctx.emit('update:show')
}
})
const submitRequest = async (serviceHandle: any) => {
await state.functionFormRef.validate()
if (state.saving) return
state.saving = true
try {
await serviceHandle()
window.$message.success(t('resource.udf.success'))
state.saving = false
ctx.emit('updateList')
ctx.emit('update:show')
} catch (err) {
state.saving = false
}
}
const variables = reactive({

1
dolphinscheduler-ui-next/src/views/resource/udf/resource/components/folder-modal.tsx

@ -81,6 +81,7 @@ export default defineComponent({
onConfirm={this.row.id ? this.handleRename : this.handleCreate}
confirmClassName='btn-submit'
cancelClassName='btn-cancel'
confirmLoading={this.saving}
>
<NForm
rules={this.rules}

1
dolphinscheduler-ui-next/src/views/resource/udf/resource/components/upload-modal.tsx

@ -68,6 +68,7 @@ export default defineComponent({
onConfirm={this.handleFolder}
confirmClassName='btn-submit'
cancelClassName='btn-cancel'
confirmLoading={this.saving}
>
<NForm
rules={this.rules}

2
dolphinscheduler-ui-next/src/views/resource/udf/resource/components/use-form.ts

@ -31,6 +31,7 @@ export const useForm = () => {
description: '',
currentDir: '/'
},
saving: false,
rules: {
name: {
required: true,
@ -53,6 +54,7 @@ export const useForm = () => {
pid: -1,
currentDir: '/'
},
saving: false,
rules: {
name: {
required: true,

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

@ -59,15 +59,21 @@ export function useModal(
})
}
const submitRequest = (serviceHandle: any) => {
state.folderFormRef.validate(async (valid: any) => {
if (!valid) {
await serviceHandle()
window.$message.success(t('resource.udf.success'))
ctx.emit('updateList')
ctx.emit('update:show')
}
})
const submitRequest = async (serviceHandle: any) => {
await state.folderFormRef.validate()
if (state.saving) return
state.saving = true
try {
await serviceHandle()
window.$message.success(t('resource.udf.success'))
state.saving = false
ctx.emit('updateList')
ctx.emit('update:show')
} catch (err) {
state.saving = false
}
}
const resetUploadForm = () => {
@ -76,26 +82,32 @@ export function useModal(
state.uploadForm.description = ''
}
const handleUploadFile = () => {
state.uploadFormRef.validate(async (valid: any) => {
const handleUploadFile = async () => {
await state.uploadFormRef.validate()
if (state.saving) return
state.saving = true
try {
const pid = router.currentRoute.value.params.id || -1
const currentDir = pid === -1 ? '/' : fileStore.getCurrentDir || '/'
if (!valid) {
const formData = new FormData()
formData.append('file', state.uploadForm.file)
formData.append('type', 'UDF')
formData.append('name', state.uploadForm.name)
formData.append('pid', String(pid))
formData.append('currentDir', currentDir)
formData.append('description', state.uploadForm.description)
await createResource(formData as any)
window.$message.success(t('resource.udf.success'))
ctx.emit('updateList')
ctx.emit('update:show')
resetUploadForm()
}
})
const formData = new FormData()
formData.append('file', state.uploadForm.file)
formData.append('type', 'UDF')
formData.append('name', state.uploadForm.name)
formData.append('pid', String(pid))
formData.append('currentDir', currentDir)
formData.append('description', state.uploadForm.description)
await createResource(formData as any)
window.$message.success(t('resource.udf.success'))
ctx.emit('updateList')
ctx.emit('update:show')
resetUploadForm()
} catch (err) {
state.saving = false
}
}
return {

1
dolphinscheduler-ui-next/src/views/security/alarm-group-manage/components/alarm-group-modal.tsx

@ -110,6 +110,7 @@ const AlarmGroupModal = defineComponent({
confirmDisabled={
!this.model.groupName || this.model.alertInstanceIds.length < 1
}
confirmLoading={this.saving}
>
{{
default: () => (

24
dolphinscheduler-ui-next/src/views/security/alarm-group-manage/components/use-modal.ts

@ -41,6 +41,7 @@ export function useModal(
description: ref(''),
generalOptions: []
},
saving: false,
rules: {
groupName: {
required: true,
@ -83,14 +84,21 @@ export function useModal(
return state
}
const handleValidate = (statusRef: number) => {
variables.alertGroupFormRef.validate((errors: any) => {
if (!errors) {
statusRef === 0 ? submitAlertGroupModal() : updateAlertGroupModal()
} else {
return
}
})
const handleValidate = async (statusRef: number) => {
await variables.alertGroupFormRef.validate()
if (variables.saving) return
variables.saving = true
try {
statusRef === 0
? await submitAlertGroupModal()
: await updateAlertGroupModal()
variables.saving = false
} catch (err) {
variables.saving = false
}
}
const submitAlertGroupModal = () => {

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

@ -45,29 +45,35 @@ export function useDetail(getFormValues: Function) {
const values = getFormValues()
if (status.saving) return false
status.saving = true
if (currentRecord?.instanceName !== values.instanceName) {
await verifyAlertInstanceName({
alertInstanceName: values.instanceName
})
}
currentRecord?.id
? await updateAlertPluginInstance(
{
alertPluginInstanceId: values.pluginDefineId,
try {
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({
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
status.saving = false
return true
} catch (err) {
status.saving = false
return false
}
}
return { status, createOrUpdate }

1
dolphinscheduler-ui-next/src/views/security/environment-manage/components/environment-modal.tsx

@ -125,6 +125,7 @@ const EnvironmentModal = defineComponent({
}
confirmClassName='btn-submit'
cancelClassName='btn-cancel'
confirmLoading={this.saving}
>
{{
default: () => (

23
dolphinscheduler-ui-next/src/views/security/environment-manage/components/use-modal.ts

@ -41,6 +41,7 @@ export function useModal(
workerGroups: ref<Array<string>>([]),
generalOptions: []
},
saving: false,
rules: {
name: {
required: true,
@ -90,14 +91,20 @@ export function useModal(
return state
}
const handleValidate = (statusRef: number) => {
variables.environmentFormRef.validate((errors: any) => {
if (!errors) {
statusRef === 0 ? submitEnvironmentModal() : updateEnvironmentModal()
} else {
return
}
})
const handleValidate = async (statusRef: number) => {
await variables.environmentFormRef.validate()
if (variables.saving) return
variables.saving = true
try {
statusRef === 0
? await submitEnvironmentModal()
: await updateEnvironmentModal()
variables.saving = false
} catch (err) {
variables.saving = false
}
}
const submitEnvironmentModal = () => {

1
dolphinscheduler-ui-next/src/views/security/k8s-namespace-manage/components/k8s-namespace-modal.tsx

@ -115,6 +115,7 @@ const K8sNamespaceModal = defineComponent({
onCancel={this.cancelModal}
onConfirm={this.confirmModal}
confirmDisabled={!this.model.namespace || !this.model.k8s}
confirmLoading={this.saving}
>
{{
default: () => (

23
dolphinscheduler-ui-next/src/views/security/k8s-namespace-manage/components/use-modal.ts

@ -40,6 +40,7 @@ export function useModal(
limitsCpu: ref(''),
limitsMemory: ref('')
},
saving: false,
rules: {
namespace: {
required: true,
@ -62,14 +63,20 @@ export function useModal(
}
})
const handleValidate = (statusRef: number) => {
variables.k8sNamespaceFormRef.validate((errors: any) => {
if (!errors) {
statusRef === 0 ? submitK8SNamespaceModal() : updateK8SNamespaceModal()
} else {
return
}
})
const handleValidate = async (statusRef: number) => {
await variables.k8sNamespaceFormRef.validate()
if (variables.saving) return
variables.saving = true
try {
statusRef === 0
? await submitK8SNamespaceModal()
: await updateK8SNamespaceModal()
variables.saving = false
} catch (err) {
variables.saving = false
}
}
const submitK8SNamespaceModal = () => {

1
dolphinscheduler-ui-next/src/views/security/tenant-manage/components/tenant-modal.tsx

@ -103,6 +103,7 @@ const TenantModal = defineComponent({
onConfirm={this.confirmModal}
confirmClassName='btn-submit'
cancelClassName='btn-cancel'
confirmLoading={this.saving}
>
{{
default: () => (

21
dolphinscheduler-ui-next/src/views/security/tenant-manage/components/use-modalData.ts

@ -37,6 +37,7 @@ export function useModalData(
queueId: ref<number>(-1),
generalOptions: []
},
saving: false,
rules: {
tenantCode: {
required: true
@ -64,14 +65,18 @@ export function useModalData(
return state
}
const handleValidate = (statusRef: number) => {
variables.tenantFormRef.validate((errors: any) => {
if (!errors) {
statusRef === 0 ? submitTenantModal() : updateTenantModal()
} else {
return
}
})
const handleValidate = async (statusRef: number) => {
await variables.tenantFormRef.validate()
if (variables.saving) return
variables.saving = true
try {
statusRef === 0 ? await submitTenantModal() : await updateTenantModal()
variables.saving = false
} catch (err) {
variables.saving = false
}
}
const submitTenantModal = () => {

1
dolphinscheduler-ui-next/src/views/security/token-manage/components/token-modal.tsx

@ -141,6 +141,7 @@ const TokenModal = defineComponent({
}
confirmClassName='btn-submit'
cancelClassName='btn-cancel'
confirmLoading={this.saving}
>
{{
default: () => (

21
dolphinscheduler-ui-next/src/views/security/token-manage/components/use-modal.ts

@ -48,6 +48,7 @@ export function useModal(
token: ref(''),
generalOptions: []
},
saving: false,
rules: {
userId: {
required: true,
@ -111,14 +112,18 @@ export function useModal(
)
}
const handleValidate = (statusRef: number) => {
variables.alertGroupFormRef.validate((errors: any) => {
if (!errors) {
statusRef === 0 ? submitTokenModal() : updateTokenModal()
} else {
return
}
})
const handleValidate = async (statusRef: number) => {
await variables.alertGroupFormRef.validate()
if (variables.saving) return
variables.saving = true
try {
statusRef === 0 ? await submitTokenModal() : await updateTokenModal()
variables.saving = false
} catch (err) {
variables.saving = false
}
}
const submitTokenModal = () => {

27
dolphinscheduler-ui-next/src/views/security/user-manage/components/use-user-detail.ts

@ -137,19 +137,24 @@ export function useUserDetail() {
state.formData = { ...initialValues }
}
const onSave = async (id?: number): Promise<boolean> => {
await state.formRef.validate()
if (state.saving) return false
state.saving = true
if (PREV_NAME !== state.formData.userName) {
await verifyUserName({ userName: state.formData.userName })
}
try {
await state.formRef.validate()
if (state.saving) return false
state.saving = true
if (PREV_NAME !== state.formData.userName) {
await verifyUserName({ userName: state.formData.userName })
}
id
? await updateUser({ id, ...state.formData })
: await createUser(state.formData)
id
? await updateUser({ id, ...state.formData })
: await createUser(state.formData)
state.saving = false
return true
state.saving = false
return true
} catch (err) {
state.saving = false
return false
}
}
const onSetValues = (record: IRecord) => {
state.formData = {

24
dolphinscheduler-ui-next/src/views/security/worker-group-manage/components/use-modal.ts

@ -37,6 +37,7 @@ export function useModal(
addrList: ref<Array<number>>([]),
generalOptions: []
},
saving: false,
rules: {
name: {
required: true,
@ -77,14 +78,21 @@ export function useModal(
return state
}
const handleValidate = (statusRef: number) => {
variables.workerGroupFormRef.validate((errors: any) => {
if (!errors) {
statusRef === 0 ? submitWorkerGroupModal() : updateWorkerGroupModal()
} else {
return
}
})
const handleValidate = async (statusRef: number) => {
await variables.workerGroupFormRef.validate()
if (variables.saving) return
variables.saving = true
try {
statusRef === 0
? await submitWorkerGroupModal()
: await updateWorkerGroupModal()
variables.saving = false
} catch (err) {
variables.saving = false
}
}
const submitWorkerGroupModal = () => {

1
dolphinscheduler-ui-next/src/views/security/worker-group-manage/components/worker-group-modal.tsx

@ -102,6 +102,7 @@ const WorkerGroupModal = defineComponent({
confirmDisabled={!this.model.name || this.model.addrList.length < 1}
confirmClassName='btn-submit'
cancelClassName='btn-cancel'
confirmLoading={this.saving}
>
{{
default: () => (

24
dolphinscheduler-ui-next/src/views/security/yarn-queue-manage/components/use-modal.ts

@ -32,6 +32,7 @@ export function useModal(
queue: ref(''),
queueName: ref('')
},
saving: false,
rules: {
queue: {
required: true,
@ -54,14 +55,21 @@ export function useModal(
}
})
const handleValidate = (statusRef: number) => {
variables.yarnQueueFormRef.validate((errors: any) => {
if (!errors) {
statusRef === 0 ? submitYarnQueueModal() : updateYarnQueueModal()
} else {
return
}
})
const handleValidate = async (statusRef: number) => {
await variables.yarnQueueFormRef.validate()
if (variables.saving) return
variables.saving = true
try {
statusRef === 0
? await submitYarnQueueModal()
: await updateYarnQueueModal()
variables.saving = false
} catch (err) {
variables.saving = false
}
}
const submitYarnQueueModal = () => {

1
dolphinscheduler-ui-next/src/views/security/yarn-queue-manage/components/yarn-queue-modal.tsx

@ -95,6 +95,7 @@ const YarnQueueModal = defineComponent({
confirmDisabled={!this.model.queueName || !this.model.queue}
confirmClassName='btn-submit'
cancelClassName='btn-cancel'
confirmLoading={this.saving}
>
{{
default: () => (

Loading…
Cancel
Save