Browse Source

[Feature]Unified exposure method class (#9698)

3.0.0/version-upgrade
labbomb 2 years ago committed by GitHub
parent
commit
b276c372d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      dolphinscheduler-ui-next/src/utils/clipboard.ts
  2. 6
      dolphinscheduler-ui-next/src/utils/index.ts
  3. 6
      dolphinscheduler-ui-next/src/utils/tree-format.ts
  4. 4
      dolphinscheduler-ui-next/src/utils/truncate-text.ts
  5. 4
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-main-jar.ts
  6. 4
      dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-resources.ts
  7. 4
      dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-text-copy.ts
  8. 4
      dolphinscheduler-ui-next/src/views/security/user-manage/components/use-authorize.ts

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

@ -15,7 +15,7 @@
* limitations under the License.
*/
export const copy = (text: string): boolean => {
const copy = (text: string): boolean => {
const inp = document.createElement('input')
document.body.appendChild(inp)
inp.value = text
@ -27,3 +27,5 @@ export const copy = (text: string): boolean => {
inp.remove()
return result
}
export default copy

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

@ -20,13 +20,17 @@ import regex from './regex'
import truncateText from './truncate-text'
import log from './log'
import downloadFile from './downloadFile'
import copy from './clipboard'
import removeUselessChildren from './tree-format'
const utils = {
mapping,
regex,
truncateText,
log,
downloadFile
downloadFile,
copy,
removeUselessChildren
}
export default utils

6
dolphinscheduler-ui-next/src/utils/tree-format.ts

@ -15,9 +15,9 @@
* limitations under the License.
*/
export function removeUselessChildren(
const removeUselessChildren = (
list: { children?: []; dirctory?: boolean; disabled?: boolean }[]
) {
) => {
if (!list.length) return
list.forEach((item) => {
if (item.dirctory && item.children?.length === 0) item.disabled = true
@ -29,3 +29,5 @@ export function removeUselessChildren(
removeUselessChildren(item.children)
})
}
export default removeUselessChildren

4
dolphinscheduler-ui-next/src/utils/truncate-text.ts

@ -21,7 +21,7 @@
* @param {string} text
* Each Chinese character is equal to two chars
*/
export default function truncateText(text: string, n: number) {
const truncateText = (text: string, n: number) => {
const exp = /[\u4E00-\u9FA5]/
let res = ''
let len = text.length
@ -49,3 +49,5 @@ export default function truncateText(text: string, n: number) {
}
return res
}
export default truncateText

4
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-main-jar.ts

@ -19,7 +19,7 @@ import { ref, onMounted, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { queryResourceByProgramType } from '@/service/modules/resources'
import { useTaskNodeStore } from '@/store/project/task-node'
import { removeUselessChildren } from '@/utils/tree-format'
import utils from '@/utils'
import type { IJsonItem, ProgramType, IMainJar } from '../types'
export function useMainJar(model: { [field: string]: any }): IJsonItem {
@ -37,7 +37,7 @@ export function useMainJar(model: { [field: string]: any }): IJsonItem {
type: 'FILE',
programType
})
removeUselessChildren(res)
utils.removeUselessChildren(res)
mainJarOptions.value = res || []
taskStore.updateMainJar(programType, res)
}

4
dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-resources.ts

@ -19,7 +19,7 @@ import { ref, onMounted } from 'vue'
import { useI18n } from 'vue-i18n'
import { queryResourceList } from '@/service/modules/resources'
import { useTaskNodeStore } from '@/store/project/task-node'
import { removeUselessChildren } from '@/utils/tree-format'
import utils from '@/utils'
import type { IJsonItem, IResource } from '../types'
export function useResources(): IJsonItem {
@ -38,7 +38,7 @@ export function useResources(): IJsonItem {
if (resourcesLoading.value) return
resourcesLoading.value = true
const res = await queryResourceList({ type: 'FILE' })
removeUselessChildren(res)
utils.removeUselessChildren(res)
resourcesOptions.value = res || []
resourcesLoading.value = false
taskStore.updateResource(res)

4
dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-text-copy.ts

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { copy } from '@/utils/clipboard'
import utils from '@/utils'
import { useMessage } from 'naive-ui'
import { useI18n } from 'vue-i18n'
@ -26,7 +26,7 @@ export function useTextCopy() {
const { t } = useI18n()
const message = useMessage()
const copyText = (text: string) => {
if (copy(text)) {
if (utils.copy(text)) {
message.success(t('project.dag.copy_success'))
}
}

4
dolphinscheduler-ui-next/src/views/security/user-manage/components/use-authorize.ts

@ -40,7 +40,7 @@ import {
grantUDFFunc,
grantNamespaceFunc
} from '@/service/modules/users'
import { removeUselessChildren } from '@/utils/tree-format'
import utils from '@/utils'
import type { TAuthType, IResourceOption, IOption } from '../types'
export function useAuthorize() {
@ -127,7 +127,7 @@ export function useAuthorize() {
authorizedFile({ userId })
])
state.loading = false
removeUselessChildren(resources[0])
utils.removeUselessChildren(resources[0])
const udfResources = [] as IResourceOption[]
const fileResources = [] as IResourceOption[]
resources[0].forEach((item: IResourceOption) => {

Loading…
Cancel
Save