You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by so...@apache.org on 2022/03/15 06:19:53 UTC

[dolphinscheduler] branch dev updated: [Fix-8836][UI Next][V1.0.0-Alpha] Rectify this issue about creating a file or directory with a wrong path. (#8892)

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 c7e80e4  [Fix-8836][UI Next][V1.0.0-Alpha] Rectify this issue about creating a file or directory with a wrong path.  (#8892)
c7e80e4 is described below

commit c7e80e42d79f56e237d296d430386860724588ff
Author: calvin <ji...@163.com>
AuthorDate: Tue Mar 15 14:19:19 2022 +0800

    [Fix-8836][UI Next][V1.0.0-Alpha] Rectify this issue about creating a file or directory with a wrong path.  (#8892)
    
    * fix this issue
    
    * fix this issue
    
    * fix code style
    
    * fix code style
---
 .../api/controller/ResourcesController.java        | 22 ++++++++++++++++++++++
 .../api/service/ResourcesService.java              |  7 +++++++
 .../api/service/impl/ResourcesServiceImpl.java     | 18 ++++++++++++++++++
 .../content/components/timezone/index.module.scss  |  2 +-
 .../src/service/modules/resources/index.ts         |  7 +++++++
 .../src/service/modules/resources/types.ts         |  3 ++-
 .../src/views/resource/file/index.tsx              | 19 ++++++++++++++++++-
 7 files changed, 75 insertions(+), 3 deletions(-)

diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java
index 0073ad0..2ba0bc9 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java
+++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java
@@ -748,4 +748,26 @@ public class ResourcesController extends BaseController {
         Map<String, Object> result = resourceService.authorizedUDFFunction(loginUser, userId);
         return returnDataList(result);
     }
+
+    /**
+     * query resource by resource id
+     *
+     * @param loginUser login user
+     * @param id resource id
+     * @return resource
+     */
+    @ApiOperation(value = "queryResourceById", notes = "QUERY_BY_RESOURCE_NAME")
+    @ApiImplicitParams({
+        @ApiImplicitParam(name = "id", value = "RESOURCE_ID", required = true, dataType = "Int", example = "10")
+    })
+    @GetMapping(value = "/{id}/query")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(RESOURCE_NOT_EXIST)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryResourceById(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+        @PathVariable(value = "id", required = true) Integer id
+    ) {
+
+        return resourceService.queryResourceById(id);
+    }
 }
diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
index 25a5af2..2433e34 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
+++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
@@ -231,4 +231,11 @@ public interface ResourcesService {
      */
     Map<String, Object> authorizedFile(User loginUser, Integer userId);
 
+    /**
+     * get resource by id
+     * @param resourceId resource id
+     * @return resource
+     */
+    Result<Object> queryResourceById(Integer resourceId);
+
 }
diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
index 22621a5..398d182 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
+++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
@@ -816,6 +816,24 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
     }
 
     /**
+     * get resource by id
+     * @param id        resource id
+     * @return resource
+     */
+    @Override
+    public Result<Object> queryResourceById(Integer id) {
+        Result<Object> result = new Result<>();
+        Resource resource = resourcesMapper.selectById(id);
+        if (resource == null) {
+            putMsg(result, Status.RESOURCE_NOT_EXIST);
+            return result;
+        }
+        putMsg(result, Status.SUCCESS);
+        result.setData(resource);
+        return result;
+    }
+
+    /**
      * view resource file online
      *
      * @param resourceId resource id
diff --git a/dolphinscheduler-ui-next/src/layouts/content/components/timezone/index.module.scss b/dolphinscheduler-ui-next/src/layouts/content/components/timezone/index.module.scss
index ec3fa47..f81bc9d 100644
--- a/dolphinscheduler-ui-next/src/layouts/content/components/timezone/index.module.scss
+++ b/dolphinscheduler-ui-next/src/layouts/content/components/timezone/index.module.scss
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
- .icon {
+.icon {
   margin: 0 12px;
 }
 
diff --git a/dolphinscheduler-ui-next/src/service/modules/resources/index.ts b/dolphinscheduler-ui-next/src/service/modules/resources/index.ts
index b4a32bf..28f395f 100644
--- a/dolphinscheduler-ui-next/src/service/modules/resources/index.ts
+++ b/dolphinscheduler-ui-next/src/service/modules/resources/index.ts
@@ -55,6 +55,13 @@ export function queryResourceById(
   })
 }
 
+export function queryCurrentResourceById(id: number): any {
+  return axios({
+    url: `/resources/${id}/query`,
+    method: 'get'
+  })
+}
+
 export function createResource(
   data: CreateReq & FileNameReq & NameReq & ResourceTypeReq
 ): any {
diff --git a/dolphinscheduler-ui-next/src/service/modules/resources/types.ts b/dolphinscheduler-ui-next/src/service/modules/resources/types.ts
index 70d7752..43a532d 100644
--- a/dolphinscheduler-ui-next/src/service/modules/resources/types.ts
+++ b/dolphinscheduler-ui-next/src/service/modules/resources/types.ts
@@ -137,5 +137,6 @@ export {
   ResourceIdReq,
   UdfFuncReq,
   ResourceListRes,
-  ResourceViewRes
+  ResourceViewRes,
+  ResourceFile
 }
diff --git a/dolphinscheduler-ui-next/src/views/resource/file/index.tsx b/dolphinscheduler-ui-next/src/views/resource/file/index.tsx
index 842f481..3b758bf 100644
--- a/dolphinscheduler-ui-next/src/views/resource/file/index.tsx
+++ b/dolphinscheduler-ui-next/src/views/resource/file/index.tsx
@@ -45,6 +45,9 @@ import ResourceRenameModal from './rename'
 import { IRenameFile } from './types'
 import type { Router } from 'vue-router'
 import styles from './index.module.scss'
+import { useFileStore } from '@/store/file/file'
+import { queryCurrentResourceById } from '@/service/modules/resources'
+import { ResourceFile } from '@/service/modules/resources/types'
 
 export default defineComponent({
   name: 'File',
@@ -142,6 +145,7 @@ export default defineComponent({
         serachRef.value
       )
     }
+    const fileStore = useFileStore()
 
     onMounted(() => {
       resourceListRef.value = getResourceListState(fileId.value)
@@ -150,7 +154,20 @@ export default defineComponent({
     watch(
       () => router.currentRoute.value.params.id,
       // @ts-ignore
-      () => reload()
+      () => {
+        reload()
+        const currFileId = Number(router.currentRoute.value.params.id) || -1
+
+        if (currFileId === -1) {
+          fileStore.setCurrentDir('/')
+        } else {
+          queryCurrentResourceById(currFileId).then((res: ResourceFile) => {
+            if (res.fullName) {
+              fileStore.setCurrentDir(res.fullName)
+            }
+          })
+        }
+      }
     )
 
     return {