This is an automated email from the ASF dual-hosted git repository.
songjian pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 5b2a96b830 [Feature][UI Next]Added the method of downloading files
(#9605)
5b2a96b830 is described below
commit 5b2a96b830a22dc70bd6bebe7414303d7df2b1dc
Author: labbomb <[email protected]>
AuthorDate: Wed Apr 20 12:15:39 2022 +0800
[Feature][UI Next]Added the method of downloading files (#9605)
---
.../src/service/modules/resources/index.ts | 5 +-
.../src/service/modules/task-instances/index.ts | 5 +-
dolphinscheduler-ui-next/src/service/service.ts | 43 +---------------
dolphinscheduler-ui-next/src/utils/downloadFile.ts | 58 ++++++++++++++++++++++
dolphinscheduler-ui-next/src/utils/index.ts | 4 +-
.../projects/workflow/components/dag/index.tsx | 4 +-
6 files changed, 70 insertions(+), 49 deletions(-)
diff --git a/dolphinscheduler-ui-next/src/service/modules/resources/index.ts
b/dolphinscheduler-ui-next/src/service/modules/resources/index.ts
index 2acf572ee7..b461f5f3d7 100644
--- a/dolphinscheduler-ui-next/src/service/modules/resources/index.ts
+++ b/dolphinscheduler-ui-next/src/service/modules/resources/index.ts
@@ -15,7 +15,8 @@
* limitations under the License.
*/
-import { axios, downloadFile } from '@/service/service'
+import { axios } from '@/service/service'
+import utils from '@/utils'
import {
ResourceTypeReq,
NameReq,
@@ -211,7 +212,7 @@ export function deleteResource(id: number): any {
}
export function downloadResource(id: number): void {
- downloadFile(`resources/${id}/download`)
+ utils.downloadFile(`resources/${id}/download`)
}
export function viewUIUdfFunction(id: IdReq): any {
diff --git
a/dolphinscheduler-ui-next/src/service/modules/task-instances/index.ts
b/dolphinscheduler-ui-next/src/service/modules/task-instances/index.ts
index def8a8f502..94d8b1635c 100644
--- a/dolphinscheduler-ui-next/src/service/modules/task-instances/index.ts
+++ b/dolphinscheduler-ui-next/src/service/modules/task-instances/index.ts
@@ -15,7 +15,8 @@
* limitations under the License.
*/
-import { axios, downloadFile } from '@/service/service'
+import { axios } from '@/service/service'
+import utils from '@/utils'
import { ProjectCodeReq, IdReq, TaskListReq } from './types'
export function queryTaskListPaging(
@@ -37,5 +38,5 @@ export function forceSuccess(taskId: IdReq, projectCode:
ProjectCodeReq): any {
}
export function downloadLog(id: number): void {
- downloadFile('log/download-log', { taskInstanceId: id })
+ utils.downloadFile('log/download-log', { taskInstanceId: id })
}
diff --git a/dolphinscheduler-ui-next/src/service/service.ts
b/dolphinscheduler-ui-next/src/service/service.ts
index ada15acadb..f2156e9d0f 100644
--- a/dolphinscheduler-ui-next/src/service/service.ts
+++ b/dolphinscheduler-ui-next/src/service/service.ts
@@ -93,46 +93,5 @@ service.interceptors.response.use((res: AxiosResponse) => {
}
}, err)
-const apiPrefix = '/dolphinscheduler'
-const reSlashPrefix = /^\/+/
-const resolveURL = (url: string) => {
- if (url.indexOf('http') === 0) {
- return url
- }
- if (url.charAt(0) !== '/') {
- return `${apiPrefix}/${url.replace(reSlashPrefix, '')}`
- }
-
- return url
-}
-
-/**
- * download file
- */
-const downloadFile = (url: string, obj?: any) => {
- const param: any = {
- url: resolveURL(url),
- obj: obj || {}
- }
-
- const form = document.createElement('form')
- form.action = param.url
- form.method = 'get'
- form.style.display = 'none'
- Object.keys(param.obj).forEach((key) => {
- const input = document.createElement('input')
- input.type = 'hidden'
- input.name = key
- input.value = param.obj[key]
- form.appendChild(input)
- })
- const button = document.createElement('input')
- button.type = 'submit'
- form.appendChild(button)
- document.body.appendChild(form)
- form.submit()
- document.body.removeChild(form)
-}
-
-export { service as axios, downloadFile }
+export { service as axios }
diff --git a/dolphinscheduler-ui-next/src/utils/downloadFile.ts
b/dolphinscheduler-ui-next/src/utils/downloadFile.ts
new file mode 100644
index 0000000000..4410fee4a4
--- /dev/null
+++ b/dolphinscheduler-ui-next/src/utils/downloadFile.ts
@@ -0,0 +1,58 @@
+
+/*
+ * 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 apiPrefix = '/dolphinscheduler'
+const reSlashPrefix = /^\/+/
+
+const resolveURL = (url: string) => {
+ if (url.indexOf('http') === 0) {
+ return url
+ }
+ if (url.charAt(0) !== '/') {
+ return `${apiPrefix}/${url.replace(reSlashPrefix, '')}`
+ }
+
+ return url
+}
+
+const downloadFile = (url: string, obj?: any) => {
+ const param: any = {
+ url: resolveURL(url),
+ obj: obj || {}
+ }
+
+ const form = document.createElement('form')
+ form.action = param.url
+ form.method = 'get'
+ form.style.display = 'none'
+ Object.keys(param.obj).forEach((key) => {
+ const input = document.createElement('input')
+ input.type = 'hidden'
+ input.name = key
+ input.value = param.obj[key]
+ form.appendChild(input)
+ })
+ const button = document.createElement('input')
+ button.type = 'submit'
+ form.appendChild(button)
+ document.body.appendChild(form)
+ form.submit()
+ document.body.removeChild(form)
+}
+
+export default downloadFile
\ No newline at end of file
diff --git a/dolphinscheduler-ui-next/src/utils/index.ts
b/dolphinscheduler-ui-next/src/utils/index.ts
index 2805529def..b38fc75111 100644
--- a/dolphinscheduler-ui-next/src/utils/index.ts
+++ b/dolphinscheduler-ui-next/src/utils/index.ts
@@ -19,12 +19,14 @@ import mapping from './mapping'
import regex from './regex'
import truncateText from './truncate-text'
import log from './log'
+import downloadFile from './downloadFile'
const utils = {
mapping,
regex,
truncateText,
- log
+ log,
+ downloadFile
}
export default utils
diff --git
a/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/index.tsx
b/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/index.tsx
index edcea0fe38..9d8ee44ec1 100644
---
a/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/index.tsx
+++
b/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/index.tsx
@@ -53,7 +53,7 @@ import LogModal from '@/components/log-modal'
import './x6-style.scss'
import { queryLog } from '@/service/modules/log'
import { useAsyncState } from '@vueuse/core'
-import { downloadFile } from '@/service/service'
+import utils from '@/utils'
const props = {
// If this prop is passed, it means from definition detail
@@ -265,7 +265,7 @@ export default defineComponent({
}
const downloadLogs = () => {
- downloadFile('log/download-log', {
+ utils.downloadFile('log/download-log', {
taskInstanceId: nodeVariables.logTaskId
})
}