Skip to content
Snippets Groups Projects
Commit 1ec2b18d authored by paf's avatar paf
Browse files

use improved endpoint which returns XMl directly

parent afbf30ec
No related branches found
No related tags found
No related merge requests found
......@@ -116,7 +116,7 @@ export class BackendService {
getBookletData(bookletId: string): Observable<BookletData> {
return this.http
.get<BookletData>(this.serverUrl + 'booklet/' + bookletId)
.get<BookletData>(this.serverUrl + 'booklet/' + bookletId + '/data')
.pipe(
map(bData => {
bData.id = bookletId;
......
import {Injectable} from '@angular/core';
import {Observable, of} from 'rxjs';
import {catchError} from 'rxjs/operators';
import {ApiError, BookletData} from '../app.interfaces';
import {GroupData, TestSession} from './group-monitor.interfaces';
import {WebsocketBackendService} from './websocket-backend.service';
import {HttpHeaders} from '@angular/common/http';
@Injectable()
export class BackendService extends WebsocketBackendService<TestSession[]> {
......@@ -20,18 +20,20 @@ export class BackendService extends WebsocketBackendService<TestSession[]> {
}
public getBooklet(bookletName: string): Observable<BookletData | boolean> {
public getBooklet(bookletName: string): Observable<string> {
console.log("load booklet for " + bookletName);
const headers = new HttpHeaders({ 'Content-Type': 'text/xml' }).set('Accept', 'text/xml');
return this.http
.get<BookletData>(this.serverUrl + `booklet/${bookletName}/data`)
.pipe( // TODO useful error handling
catchError((err: ApiError) => {
console.warn(`getTestData Api-Error: ${err.code} ${err.info}`);
return of(false)
})
);
.get(this.serverUrl + `booklet/${bookletName}`, {headers, responseType: 'text'})
// .pipe( // TODO useful error handling
// catchError((err: ApiError) => {
// console.warn(`getTestData Api-Error: ${err.code} ${err.info}`);
// return of(false)
// })
// );
}
......
......@@ -4,7 +4,6 @@ import {BackendService} from './backend.service';
import {Observable, of} from 'rxjs';
import {isDefined} from '@angular/compiler/src/util';
import {map, shareReplay} from 'rxjs/operators';
import {BookletData} from '../app.interfaces';
import {Booklet, BookletMetadata, Restrictions, Testlet, Unit} from './group-monitor.interfaces';
import {BookletConfig} from '../config/booklet-config';
......@@ -39,7 +38,6 @@ export class BookletService {
// console.log('LOADING testletOrUnit data for ' + bookletName + ' not available. loading');
this.booklets[bookletName] = this.bs.getBooklet(bookletName)
.pipe(map((testData: BookletData): string => testData.xml))
.pipe(map(BookletService.parseBookletXml))
.pipe(shareReplay(1));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment