diff --git a/src/app/shared/backend.service.ts b/src/app/shared/backend.service.ts deleted file mode 100644 index 80291756d08e1c0cde6edd3d0646c12ced5a1c39..0000000000000000000000000000000000000000 --- a/src/app/shared/backend.service.ts +++ /dev/null @@ -1,142 +0,0 @@ -import { Injectable, Inject } from '@angular/core'; -import { HttpClient, HttpHeaders, HttpEvent, HttpErrorResponse } from '@angular/common/http'; -import { Observable, throwError } from 'rxjs'; -import { catchError } from 'rxjs/operators'; - - - - - -@Injectable() -export class BackendService { - - constructor( - @Inject('SERVER_URL') private serverUrl: string, - private http: HttpClient) { } - - /* - getStatus(admintoken: string, logintoken: string, sessiontoken: string): Observable<LoginResponseData> { - const httpOptions = { - headers: new HttpHeaders({ - 'Content-Type': 'application/json' - }) - }; - return this.http - .post<LoginResponseData>(this.serverUrl + 'getStatus.php', {at: admintoken, lt: logintoken, st: sessiontoken}, httpOptions) - .pipe( - catchError(this.handleError) - ); - } */ - - // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - testlogin(name: string, password: string): Observable<string | ServerError> { - const httpOptions = { - headers: new HttpHeaders({ - 'Content-Type': 'application/json' - }) - }; - return this.http - .post<string>(this.serverUrl + 'testlogin.php', {n: name, p: password}, httpOptions) - .pipe( - catchError(this.handleError) - ); - } - - getSessions(token: string): Observable<GetBookletsResponseData | ServerError> { - const httpOptions = { - headers: new HttpHeaders({ - 'Content-Type': 'application/json' - }) - }; - return this.http - .post<GetBookletsResponseData>(this.serverUrl + 'getBooklets.php', {lt: token}, httpOptions) - .pipe( - catchError(this.handleError) - ); - } - - - getBookletStatus(logintoken: string, code: string, bookletId: string): Observable<GetBookletResponseData | ServerError> { - const httpOptions = { - headers: new HttpHeaders({ - 'Content-Type': 'application/json' - }) - }; - return this.http - .post<GetBookletResponseData>(this.serverUrl + 'getBookletStatus.php', { - lt: logintoken, c: code, b: bookletId}, httpOptions) - .pipe( - catchError(this.handleError) - ); - } - - startSession(token: string, code: string, bookletFilename: string): Observable<string | ServerError> { - const httpOptions = { - headers: new HttpHeaders({ - 'Content-Type': 'application/json' - }) - }; - return this.http - .post<string>(this.serverUrl + 'startSession.php', {lt: token, c: code, b: bookletFilename}, httpOptions) - .pipe( - catchError(this.handleError) - ); -} - - // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - - private handleError(errorObj: HttpErrorResponse): Observable<ServerError> { - const myreturn: ServerError = { - label: 'Fehler bei Datenübertragung', - code: errorObj.status - }; - if (errorObj.status === 401) { - myreturn.label = 'Fehler: Zugriff verweigert - bitte (neu) anmelden!'; - } else if (errorObj.status === 503) { - myreturn.label = 'Fehler: Server meldet Datenbankproblem.'; - } else if (errorObj.error instanceof ErrorEvent) { - myreturn.label = 'Fehler: ' + (<ErrorEvent>errorObj.error).message; - } else { - myreturn.label = 'Fehler: ' + errorObj.message; - } - - return throwError(myreturn.label); - } -} - - -// ############################################################################################# - -export interface ServerError { - code: number; - label: string; -} - -export interface LoginResponseData { - t: string; - n: string; - ws: string; -} - -export interface BookletData { - name: string; - filename: string; - title: string; -} - -export interface BookletDataList { - [code: string]: BookletData[]; -} - -export interface GetBookletsResponseData { - mode: string; - ws: string; - booklets: {[code: string]: BookletData[]}; -} - -export interface GetBookletResponseData { - statusLabel: string; - lastUnit: number; - canStart: boolean; -} - diff --git a/src/app/test-controller/backend.service.ts b/src/app/test-controller/backend.service.ts index b384dd988987c9ccf11a030bb1f54b8e37eb0004..0bf91faf2bad259d5e84d5700b0b804b0ee9fbb9 100644 --- a/src/app/test-controller/backend.service.ts +++ b/src/app/test-controller/backend.service.ts @@ -277,7 +277,6 @@ export class BackendService { myreturn.label = 'Fehler: ' + errorObj.message; } -<<<<<<< HEAD return of(myreturn); } @@ -297,9 +296,6 @@ export class ServerError { constructor(code: number, label: string) { this.code = code; this.label = label; -======= - return throwError(myreturn.label); ->>>>>>> 0797e3868c4f5938d1693a6439c48160aa934694 } }