Merge branch 'origin/master' into 14478-log-in-into-clusters
[arvados-workbench2.git] / src / services / workflow-service / workflow-service.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { AxiosInstance } from "axios";
6 import { CommonResourceService } from "~/services/common-service/common-resource-service";
7 import { WorkflowResource } from '~/models/workflow';
8 import { ApiActions } from '~/services/api/api-actions';
9 import { LinkService } from '~/services/link-service/link-service';
10 import { FilterBuilder } from '~/services/api/filter-builder';
11 import { LinkClass } from '~/models/link';
12 import { OrderBuilder } from '~/services/api/order-builder';
13
14 export class WorkflowService extends CommonResourceService<WorkflowResource> {
15
16     private linksService = new LinkService(this.serverApi, this.actions);
17
18     constructor(serverApi: AxiosInstance, actions: ApiActions) {
19         super(serverApi, "workflows", actions);
20     }
21
22     async presets(workflowUuid: string) {
23
24         const { items: presetLinks } = await this.linksService.list({
25
26             filters: new FilterBuilder()
27                 .addEqual('tailUuid', workflowUuid)
28                 .addEqual('linkClass', LinkClass.PRESET)
29                 .getFilters()
30
31         });
32
33         const presetUuids = presetLinks.map(link => link.headUuid);
34
35         return this.list({
36
37             filters: new FilterBuilder()
38                 .addIn('uuid', presetUuids)
39                 .getFilters(),
40
41             order: new OrderBuilder<WorkflowResource>()
42                 .addAsc('name')
43                 .getOrder(),
44
45         });
46
47     }
48
49 }