15840: Project panel uses collection attributes for file count and size
[arvados-workbench2.git] / src / services / collection-service / collection-service.ts
index 86b1aded7cf69ac280564a530eb5ebb8a0439f21..6eb9b5ba664f15892d570206051a93803050987b 100644 (file)
@@ -7,12 +7,9 @@ import { AxiosInstance } from "axios";
 import { CollectionFile, CollectionDirectory } from "~/models/collection-file";
 import { WebDAV } from "~/common/webdav";
 import { AuthService } from "../auth-service/auth-service";
-import { mapTreeValues } from "~/models/tree";
-import { parseFilesResponse } from "./collection-service-files-response";
-import { fileToArrayBuffer } from "~/common/file";
+import { extractFilesData } from "./collection-service-files-response";
 import { TrashableResourceService } from "~/services/common-service/trashable-resource-service";
 import { ApiActions } from "~/services/api/api-actions";
-import { snakeCase } from 'lodash';
 
 export type UploadProgress = (fileId: number, loaded: number, total: number, currentTime: number) => void;
 
@@ -24,8 +21,7 @@ export class CollectionService extends TrashableResourceService<CollectionResour
     async files(uuid: string) {
         const request = await this.webdavClient.propfind(`c=${uuid}`);
         if (request.responseXML != null) {
-            const filesTree = parseFilesResponse(request.responseXML);
-            return mapTreeValues(this.extendFileURL)(filesTree);
+            return extractFilesData(request.responseXML);
         }
         return Promise.reject();
     }
@@ -55,7 +51,7 @@ export class CollectionService extends TrashableResourceService<CollectionResour
         );
     }
 
-    private extendFileURL = (file: CollectionDirectory | CollectionFile) => {
+    extendFileURL = (file: CollectionDirectory | CollectionFile) => {
         const baseUrl = this.webdavClient.defaults.baseURL.endsWith('/')
             ? this.webdavClient.defaults.baseURL.slice(0, -1)
             : this.webdavClient.defaults.baseURL;
@@ -82,27 +78,4 @@ export class CollectionService extends TrashableResourceService<CollectionResour
         };
         return this.webdavClient.upload(fileURL, [file], requestConfig);
     }
-
-    update(uuid: string, data: Partial<CollectionResource>) {
-        if (uuid && data && data.properties) {
-            const { properties } = data;
-            const mappedData = {
-                ...TrashableResourceService.mapKeys(snakeCase)(data),
-                properties,
-            };
-            return TrashableResourceService
-                .defaultResponse(
-                    this.serverApi
-                        .put<CollectionResource>(this.resourceType + uuid, mappedData),
-                    this.actions,
-                    false
-                );
-        }
-        return TrashableResourceService
-            .defaultResponse(
-                this.serverApi
-                    .put<CollectionResource>(this.resourceType + uuid, data && TrashableResourceService.mapKeys(snakeCase)(data)),
-                this.actions
-            );
-    }
 }