[ARVADOS-WORKBENCH2] updated: 1.1.4-585-g812e47f

Git user git at public.curoverse.com
Mon Aug 13 06:06:57 EDT 2018


Summary of changes:
 src/services/collection-service/collection-service.ts | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

       via  812e47f58549b4801a8fc5279bcf6cc6eec7925b (commit)
      from  c4e503180948300c3a6ef99e338d2e56b2931236 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 812e47f58549b4801a8fc5279bcf6cc6eec7925b
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Mon Aug 13 12:06:40 2018 +0200

    Implement simple sorting of files list
    
    Feature #13990
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/services/collection-service/collection-service.ts b/src/services/collection-service/collection-service.ts
index 4726825..add7ba9 100644
--- a/src/services/collection-service/collection-service.ts
+++ b/src/services/collection-service/collection-service.ts
@@ -7,12 +7,13 @@ import { CollectionResource } from "../../models/collection";
 import axios, { AxiosInstance } from "axios";
 import { KeepService } from "../keep-service/keep-service";
 import { FilterBuilder } from "../../common/api/filter-builder";
-import { CollectionFile, createCollectionFile, createCollectionDirectory, createCollectionFilesTree } from "../../models/collection-file";
+import { CollectionFile, createCollectionFile, createCollectionDirectory, createCollectionFilesTree, CollectionFileType, CollectionDirectory } from "../../models/collection-file";
 import { parseKeepManifestText, stringifyKeepManifest } from "../collection-files-service/collection-manifest-parser";
 import * as _ from "lodash";
 import { KeepManifestStream } from "../../models/keep-manifest";
 import { WebDAV } from "../../common/webdav";
 import { AuthService } from "../auth-service/auth-service";
+import { mapTree, getNodeChildren, getNode, TreeNode } from "../../models/tree";
 
 export type UploadProgress = (fileId: number, loaded: number, total: number, currentTime: number) => void;
 
@@ -24,16 +25,26 @@ export class CollectionService extends CommonResourceService<CollectionResource>
     async files(uuid: string) {
         const request = await this.webdavClient.propfind(`/c=${uuid}`);
         if (request.responseXML != null) {
-            return createCollectionFilesTree(this.extractFilesData(request.responseXML));
+            const files = this.extractFilesData(request.responseXML);
+            const tree = createCollectionFilesTree(files);
+            const sortedTree = mapTree(node => {
+                const children = getNodeChildren(node.id)(tree).map(id => getNode(id)(tree)) as TreeNode<CollectionDirectory | CollectionFile>[];
+                children.sort((a, b) =>
+                    a.value.type !== b.value.type
+                        ? a.value.type === CollectionFileType.DIRECTORY ? -1 : 1
+                        : a.value.name.localeCompare(b.value.name)
+                );
+                return { ...node, children: children.map(child => child.id) };
+            })(tree);
+            return sortedTree;
         }
         return Promise.reject();
     }
 
-    async deleteFile(collectionUuid: string, filePath: string){
+    async deleteFile(collectionUuid: string, filePath: string) {
         return this.webdavClient.delete(`/c=${collectionUuid}${filePath}`);
     }
 
-
     extractFilesData(document: Document) {
         return Array
             .from(document.getElementsByTagName('D:response'))

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list