mirror of
https://github.com/sartography/cr-connect-bpmn.git
synced 2025-01-11 17:44:32 +00:00
Adds methods to get workflow specs and files
This commit is contained in:
parent
806272d7a8
commit
8e35d34864
@ -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<WorkflowSpec[]> {
|
||||
const url = this.apiUrl + '/workflow-specification';
|
||||
|
||||
return this.httpClient
|
||||
.get<WorkflowSpec[]>(url)
|
||||
.pipe(catchError(this._handleError));
|
||||
}
|
||||
|
||||
listBpmnFiles(specId: string): Observable<FileMeta[]> {
|
||||
const url = this.apiUrl + '/file';
|
||||
const params = new HttpParams().set('spec_id', specId);
|
||||
|
||||
return this.httpClient
|
||||
.get<FileMeta[]>(url, {params: params})
|
||||
.pipe(catchError(this._handleError));
|
||||
}
|
||||
|
||||
getFileData(fileId: number): Observable<Blob> {
|
||||
const url = this.apiUrl + '/file/' + fileId + '/data';
|
||||
|
||||
return this.httpClient
|
||||
.get(url, {responseType: 'blob'})
|
||||
.pipe(catchError(this._handleError));
|
||||
}
|
||||
|
||||
getBpmnXml(url: string): Observable<string> {
|
||||
return this.httpClient
|
||||
.get(url, {responseType: 'text'})
|
||||
|
Loading…
x
Reference in New Issue
Block a user