implement api calls;

This commit is contained in:
Marco Zeisler 2021-01-11 15:43:37 +01:00
parent ac29b5d98a
commit 91161247e8
3 changed files with 40 additions and 11 deletions

View File

@ -1,7 +0,0 @@
import {Observable} from 'rxjs';
export interface WSEvents {
message: Observable<Event>;
error: Observable<Event>;
close: Observable<Event>;
}

View File

@ -7,6 +7,12 @@ import {Observable} from 'rxjs';
@Injectable()
export class RestService {
private currentLocation = 'http://' + environment.location + ':' + environment.port + '/';
private imageUrl = this.currentLocation + 'image/';
private getImageUrl = this.imageUrl + 'get/';
private deleteImageUrl = this.imageUrl + 'delete/';
private postImageUrl = this.imageUrl + 'post$/';
private updateImageUrl = this.imageUrl + 'update/';
private healthCheckUrl = this.currentLocation + 'check';
constructor(
private logger: NGXLogger,
@ -14,9 +20,35 @@ export class RestService {
) {
}
testCall(i: number): Observable<string> {
const url = this.currentLocation + 'test/';
this.logger.debug('Performing ' + i + '. test rest call on', url);
return this.http.get<string>(url);
public getAllImages(): Observable<any> {
return this.http.get<any>(this.getImageUrl + 'all');
}
public getImage(id: string): Observable<any> {
return this.http.get<any>(this.getImageUrl + id);
}
public getImageVersion(id: string, version: string): Observable<any> {
return this.http.get<any>(this.getImageUrl + id + '/version/' + version);
}
public deleteAllImages(): Observable<any> {
return this.http.delete<any>(this.deleteImageUrl + 'all');
}
public deleteImage(id: string): Observable<any> {
return this.http.delete<any>(this.deleteImageUrl + id);
}
public postImage(id: string, image: any): Observable<any> {
return this.http.post<any>(this.postImageUrl + id, image);
}
public updateImage(id: string, image: any): Observable<any> {
return this.http.put<any>(this.updateImageUrl + id, image);
}
public healthCheck(): Observable<any> {
return this.http.get<any>(this.healthCheckUrl);
}
}

View File

@ -7,3 +7,7 @@ body {
width: 95%;
margin: auto;
}
h1 {
margin-top: 1em;
}