[ARVADOS-WORKBENCH2] updated: 1.1.4-577-g571f975

Git user git at public.curoverse.com
Thu Aug 9 12:00:09 EDT 2018


Summary of changes:
 src/common/config.ts                               |  3 +-
 .../collection-service/collection-service.ts       | 42 +++++++++++++++++++++-
 src/services/services.ts                           |  2 +-
 .../collection-panel/collection-panel-action.ts    |  1 +
 4 files changed, 45 insertions(+), 3 deletions(-)

       via  571f9757f7bce4b151921368b4a4d4e97d22d055 (commit)
      from  5a7f3f56fc39ab231982435d29b8f15e819748fe (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 571f9757f7bce4b151921368b4a4d4e97d22d055
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Thu Aug 9 17:59:49 2018 +0200

    Create method for extracting files info from propfind response
    
    Feature #13990
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/common/config.ts b/src/common/config.ts
index 5391927..740f6f7 100644
--- a/src/common/config.ts
+++ b/src/common/config.ts
@@ -21,7 +21,8 @@ export const fetchConfig = () => {
 
 const mapConfig = (config: Config): Config => ({
     ...config,
-    API_HOST: addProtocol(config.API_HOST)
+    API_HOST: addProtocol(config.API_HOST),
+    KEEP_WEB_HOST: addProtocol(config.KEEP_WEB_HOST)
 });
 
 const getDefaultConfig = (): Config => ({
diff --git a/src/services/collection-service/collection-service.ts b/src/services/collection-service/collection-service.ts
index 4d75036..c97307e 100644
--- a/src/services/collection-service/collection-service.ts
+++ b/src/services/collection-service/collection-service.ts
@@ -11,14 +11,54 @@ import { CollectionFile, createCollectionFile } from "../../models/collection-fi
 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";
 
 export type UploadProgress = (fileId: number, loaded: number, total: number, currentTime: number) => void;
 
 export class CollectionService extends CommonResourceService<CollectionResource> {
-    constructor(serverApi: AxiosInstance, private keepService: KeepService) {
+    constructor(serverApi: AxiosInstance, private keepService: KeepService, private webdavClient: WebDAV, private authService: AuthService) {
         super(serverApi, "collections");
     }
 
+    async files(uuid: string) {
+        const request = await this.webdavClient.propfind(`/c=${uuid}`);
+        if (request.responseXML != null) {
+            return this.extractFilesData(request.responseXML);
+        }
+        return Promise.reject();
+    }
+
+    extractFilesData(document: Document) {
+        return Array
+            .from(document.getElementsByTagName('D:response'))
+            .filter(element => {
+                const [resourceTypeElement] = Array.from(element.getElementsByTagName('D:resourcetype'));
+                return resourceTypeElement && resourceTypeElement.innerHTML === '';
+            })
+            .map(element => {
+                const [displayNameElement] = Array.from(element.getElementsByTagName('D:displayname'));
+                const name = displayNameElement ? displayNameElement.innerHTML : undefined;
+
+                const [sizeElement] = Array.from(element.getElementsByTagName('D:getcontentlength'));
+                const size = sizeElement ? sizeElement.innerHTML : undefined;
+
+                const [hrefElement] = Array.from(element.getElementsByTagName('D:href'));
+                const pathname = hrefElement ? hrefElement.innerHTML : undefined;
+                const directory = pathname && pathname.replace(/\/c=[0-9a-zA-Z\-]*/, '').replace(`/${name || ''}`, '');
+
+                const href = this.webdavClient.defaults.baseUrl + pathname + '?api_token=' + this.authService.getApiToken();
+
+                return {
+                    directory,
+                    href,
+                    name,
+                    size,
+                };
+
+            });
+    }
+
     private readFile(file: File): Promise<ArrayBuffer> {
         return new Promise<ArrayBuffer>(resolve => {
             const reader = new FileReader();
diff --git a/src/services/services.ts b/src/services/services.ts
index d2a8ce4..cbf8cc3 100644
--- a/src/services/services.ts
+++ b/src/services/services.ts
@@ -30,7 +30,7 @@ export const createServices = (config: Config) => {
     const projectService = new ProjectService(apiClient);
     const linkService = new LinkService(apiClient);
     const favoriteService = new FavoriteService(linkService, groupsService);
-    const collectionService = new CollectionService(apiClient, keepService);
+    const collectionService = new CollectionService(apiClient, keepService, webdavClient, authService);
     const tagService = new TagService(linkService);
     const collectionFilesService = new CollectionFilesService(collectionService);
 
diff --git a/src/store/collection-panel/collection-panel-action.ts b/src/store/collection-panel/collection-panel-action.ts
index f2774f6..5fe09fb 100644
--- a/src/store/collection-panel/collection-panel-action.ts
+++ b/src/store/collection-panel/collection-panel-action.ts
@@ -36,6 +36,7 @@ export const loadCollection = (uuid: string, kind: ResourceKind) =>
             .get(uuid)
             .then(item => {
                 dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item }));
+                services.collectionService.files(item.uuid).then(console.log);
                 return services.collectionFilesService.getFiles(item.uuid);
             })
             .then(files => {

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list