You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/01/12 01:26:51 UTC

[GitHub] [dolphinscheduler] songjianet commented on a change in pull request #7943: [Feature][UI Next] Add file manage

songjianet commented on a change in pull request #7943:
URL: https://github.com/apache/dolphinscheduler/pull/7943#discussion_r782641777



##########
File path: dolphinscheduler-ui-next/src/locales/modules/en_US.ts
##########
@@ -151,6 +151,42 @@ const monitor = {
   },
 }
 
+const resource = {

Review comment:
       resource = {
     file: {
       file_manage: 'File Manage',
       ....
     }
   }

##########
File path: dolphinscheduler-ui-next/src/views/resource/file/table/table-action.tsx
##########
@@ -0,0 +1,192 @@
+/*
+ * 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.
+ */
+
+import { useRouter } from 'vue-router'
+import { defineComponent, PropType } from 'vue'
+import { NSpace, NTooltip, NButton, NIcon, NPopconfirm } from 'naive-ui'
+import {
+  DeleteOutlined,
+  DownloadOutlined,
+  FormOutlined,
+  EditOutlined,
+  InfoCircleFilled,
+} from '@vicons/antd'
+import _ from 'lodash'
+import { useI18n } from 'vue-i18n'
+import { ResourceFileTableData } from '../types'
+import { fileTypeArr } from '@/utils/common'
+import { downloadResource, deleteResource } from '@/service/modules/resources'
+import { IRenameFile, IRtDisb } from '../types'
+import type { Router } from 'vue-router'
+
+const props = {
+  show: {
+    type: Boolean as PropType<boolean>,
+    default: false,
+  },
+  row: {
+    type: Object as PropType<ResourceFileTableData>,
+    default: {
+      id: -1,
+      name: '',
+      description: '',
+    },
+  },
+}
+
+export default defineComponent({
+  name: 'TableAction',
+  props,
+  emits: ['updateList', 'renameResource'],
+  setup(props, { emit }) {
+    const { t } = useI18n()
+    const router: Router = useRouter()
+
+    const rtDisb: IRtDisb = (name, size) => {
+      const i = name.lastIndexOf('.')
+      const a = name.substring(i, name.length)
+      let flag = _.includes(fileTypeArr, _.trimStart(a, '.'))
+      if (flag && size < 1000000) {

Review comment:
       return !flag && size < 1000000

##########
File path: dolphinscheduler-ui-next/src/service/service.ts
##########
@@ -22,6 +22,8 @@ import axios, {
   AxiosRequestHeaders,
 } from 'axios'
 import qs from 'qs'
+import _ from 'lodash'
+import $ from 'jquery'

Review comment:
       To download a file, you can get the corresponding `url` from the corresponding interception in `axios`, and then create a form for downloading. It is not recommended to use `jquery` for this.

##########
File path: dolphinscheduler-ui-next/src/views/resource/file/edit/resource-file-edit.tsx
##########
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+
+import { useRouter } from 'vue-router'
+import { defineComponent, onMounted, ref, toRefs } from 'vue'
+import { NButton, NForm, NFormItem, NSpace } from 'naive-ui'
+import { useI18n } from 'vue-i18n'
+import Card from '@/components/card'
+import MonacoEditor from '@/components/monaco-editor'
+import { useForm } from './use-form'
+import { useEdit } from './use-edit'
+
+import styles from '../index.module.scss'
+import type { Router } from 'vue-router'
+
+export default defineComponent({
+  name: 'ResourceFileEdit',
+  setup() {
+    const router: Router = useRouter()
+
+    const resourceViewRef = ref()
+    const codeEditorRef = ref()
+    const routeNameRef = ref(router.currentRoute.value.name)
+    const idRef = ref(Number(router.currentRoute.value.params.id))
+
+    const { state } = useForm()
+    const { getResourceView, handleUpdateContent } = useEdit(state)
+
+    const handleFileContent = () => {
+      state.fileForm.content = codeEditorRef.value?.getValue()
+      handleUpdateContent(idRef.value)
+    }
+
+    const handleReturn = () => {
+      router.go(-1)
+    }
+
+    onMounted(() => {
+      resourceViewRef.value = getResourceView(idRef.value)
+    })
+
+    return {
+      idRef,
+      routeNameRef,
+      codeEditorRef,
+      resourceViewRef,
+      handleReturn,
+      handleFileContent,
+      ...toRefs(state),
+    }
+  },
+  render() {
+    const { t } = useI18n()
+    return (
+      <Card title={t('resource.file_details')}>
+        <div class={styles['file-edit-content']}>
+          <h2>
+            <span>{this.resourceViewRef?.value.alias}</span>
+          </h2>
+          <NForm
+            rules={this.rules}
+            ref='fileFormRef'
+            class={styles['form-content']}
+          >
+            <NFormItem path='content'>
+              <div
+                class={styles.cont}
+                style={{
+                  width: '90%',
+                }}
+              >
+                <MonacoEditor
+                  ref='codeEditorRef'
+                  modelValue={this.resourceViewRef?.value.content}
+                />
+              </div>
+            </NFormItem>
+            {this.routeNameRef === 'resource-file-edit' ? (

Review comment:
       this.routeNameRef === 'resource-file-edit' && 
   This is fine. It seems that there is no need to use ternary operations in this place.

##########
File path: dolphinscheduler-ui-next/src/views/resource/file/table/use-table.ts
##########
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ */
+
+import { h } from 'vue'
+import { useI18n } from 'vue-i18n'
+import { useRouter } from 'vue-router'
+

Review comment:
       delete entry




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org