Added collection service, reorganized components structure
[arvados-workbench2.git] / src / services / project-service / project-service.ts
index 119cfece4b8fcb130fa69f4ec54304e2f7d270f5..8070a386d1bf7d1226ee1fb5a2c4687b162284e6 100644 (file)
@@ -8,28 +8,22 @@ import actions from "../../store/project/project-action";
 import { Project } from "../../models/project";
 import UrlBuilder from "../../common/api/url-builder";
 import FilterBuilder, { FilterField } from "../../common/api/filter-builder";
+import { ArvadosResource } from "../response";
+
+interface GroupResource extends ArvadosResource {
+    name: string;
+    group_class: string;
+    description: string;
+    writable_by: string[];
+    delete_at: string;
+    trash_at: string;
+    is_trashed: boolean;
+}
 
 interface GroupsResponse {
     offset: number;
     limit: number;
-    items: Array<{
-        href: string;
-        kind: string;
-        etag: string;
-        uuid: string;
-        owner_uuid: string;
-        created_at: string;
-        modified_by_client_uuid: string;
-        modified_by_user_uuid: string;
-        modified_at: string;
-        name: string;
-        group_class: string;
-        description: string;
-        writable_by: string[];
-        delete_at: string;
-        trash_at: string;
-        is_trashed: boolean;
-    }>;
+    items: GroupResource[];
 }
 
 export default class ProjectService {
@@ -40,8 +34,8 @@ export default class ProjectService {
             fb.addLike(FilterField.OWNER_UUID, parentUuid);
             return serverApi.get<GroupsResponse>('/groups', { params: {
                 filters: fb.get()
-            }}).then(groups => {
-                const projects = groups.data.items.map(g => ({
+            }}).then(resp => {
+                const projects = resp.data.items.map(g => ({
                     name: g.name,
                     createdAt: g.created_at,
                     modifiedAt: g.modified_at,