diff --git a/src/app/app-root/test-starter/test-starter.component.ts b/src/app/app-root/test-starter/test-starter.component.ts index 8c60a18e4acc988d14a04de2d11d745294373884..c9924e4d2bbf311b139286e252e1920b106be4db 100644 --- a/src/app/app-root/test-starter/test-starter.component.ts +++ b/src/app/app-root/test-starter/test-starter.component.ts @@ -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) { diff --git a/src/app/app.interfaces.ts b/src/app/app.interfaces.ts index ae9886ff446c9adcad669015b4143d8d1f2dec0d..9ca63cd48d36ef67878d237bed1faddc965a1454 100644 --- a/src/app/app.interfaces.ts +++ b/src/app/app.interfaces.ts @@ -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; diff --git a/src/app/backend.service.ts b/src/app/backend.service.ts index fd886fa58cbe05baa8b2ba7449ea88d35ca0e812..8ecf52b2d4b39f511bab36c2a2f5615af9be9047 100644 --- a/src/app/backend.service.ts +++ b/src/app/backend.service.ts @@ -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)) ); }