Skip to content
Snippets Groups Projects
Commit 6d3f8d68 authored by mechtelm's avatar mechtelm
Browse files

test-controller loads booklet data

parent 38ea71c7
No related branches found
No related tags found
No related merge requests found
......@@ -62,7 +62,7 @@ export class TestStarterComponent implements OnInit {
}
startTest(b: BookletData) {
this.bs.startTest(b.label).subscribe(testId => {
this.bs.startTest(b.id).subscribe(testId => {
if (typeof testId === 'number') {
const errCode = testId as number;
if (errCode === 423) {
......
......@@ -37,15 +37,12 @@ export interface MonitorScopeData {
}
export interface BookletData {
id: string;
label: string;
running: boolean;
locked: boolean;
}
export interface StartBookletReturn {
testId: string;
}
export interface SysConfig {
customTexts: KeyValuePairs;
version: string;
......
......@@ -8,7 +8,7 @@ import {
SysCheckInfo,
AuthData,
WorkspaceData,
BookletData, MonitorScopeData, StartBookletReturn
BookletData, MonitorScopeData
} from './app.interfaces';
// ============================================================================
......@@ -101,10 +101,16 @@ export class BackendService {
getBookletData(bookletId: string): Observable<BookletData> {
return this.http
.get<BookletData>(this.serverUrl + 'booklet/' + bookletId + '/state')
.pipe(catchError(() => {
.get<BookletData>(this.serverUrl + 'booklet/' + bookletId)
.pipe(
map(bData => {
bData.id = bookletId;
return bData
}),
catchError(() => {
console.warn('get booklet data failed for ' + bookletId);
return of(<BookletData>{
id: bookletId,
label: bookletId,
locked: true,
running: false
......@@ -112,11 +118,11 @@ export class BackendService {
}));
}
startTest(bookletName: string): Observable<string | number> {
startTest(bookletId: string): Observable<string | number> {
return this.http
.put<StartBookletReturn>(this.serverUrl + 'test', {bookletName})
.put<number>(this.serverUrl + 'test', {bookletId})
.pipe(
map((testId: StartBookletReturn) => String(testId.testId)),
map((testId: number) => String(testId)),
catchError(errCode => of(errCode))
);
}
......
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