From 8e35d348649e38f203c0d654b8831afd21f79da8 Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Sat, 11 Jan 2020 10:39:49 -0500 Subject: [PATCH] Adds methods to get workflow specs and files --- src/app/_services/api.service.ts | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/app/_services/api.service.ts b/src/app/_services/api.service.ts index 000b9f5..f9c7248 100644 --- a/src/app/_services/api.service.ts +++ b/src/app/_services/api.service.ts @@ -1,7 +1,10 @@ -import {HttpClient} from '@angular/common/http'; +import {HttpClient, HttpParams} from '@angular/common/http'; import {Injectable} from '@angular/core'; import {Observable, throwError} from 'rxjs'; import {catchError} from 'rxjs/operators'; +import {environment} from '../../environments/environment'; +import {WorkflowSpec} from 'sartography-workflow-lib'; +import {FileMeta} from 'sartography-workflow-lib'; export interface ApiError { code: string; @@ -13,9 +16,36 @@ export interface ApiError { }) export class ApiService { + apiUrl: string = environment.api; + constructor(private httpClient: HttpClient) { } + listWorkflowSpecifications(): Observable { + const url = this.apiUrl + '/workflow-specification'; + + return this.httpClient + .get(url) + .pipe(catchError(this._handleError)); + } + + listBpmnFiles(specId: string): Observable { + const url = this.apiUrl + '/file'; + const params = new HttpParams().set('spec_id', specId); + + return this.httpClient + .get(url, {params: params}) + .pipe(catchError(this._handleError)); + } + + getFileData(fileId: number): Observable { + const url = this.apiUrl + '/file/' + fileId + '/data'; + + return this.httpClient + .get(url, {responseType: 'blob'}) + .pipe(catchError(this._handleError)); + } + getBpmnXml(url: string): Observable { return this.httpClient .get(url, {responseType: 'text'})