From 20f584d4656abde39a7ee7de3acceacfaabae90c Mon Sep 17 00:00:00 2001 From: mechtelm <mechtel@iqb.hu-berlin.de> Date: Mon, 27 Jan 2020 14:18:59 +0100 Subject: [PATCH] * usage of iqb-components extended to ServerError und ErrorHandler * response type json removed * logout removed * optical markers deleted --- package-lock.json | 40 +++------ package.json | 6 +- src/app/app.component.ts | 3 +- src/app/app.module.ts | 2 +- src/app/backend.service.ts | 72 ++-------------- src/app/maindata.service.ts | 6 +- src/app/material.module.ts | 25 ------ src/app/start/start.component.ts | 13 ++- src/app/superadmin/backend.service.ts | 46 ++++------ src/app/workspace/backend.service.ts | 83 +++++-------------- src/app/workspace/files/files.component.ts | 21 ++--- .../workspace/monitor/monitor.component.ts | 12 +-- src/app/workspace/workspacedata.service.ts | 50 +---------- src/environments/environment.build.ts | 2 +- src/environments/environment.ts | 2 +- 15 files changed, 85 insertions(+), 298 deletions(-) delete mode 100644 src/app/material.module.ts diff --git a/package-lock.json b/package-lock.json index bdb01631..b567444e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "itc-ng-admin", - "version": "0.0.0", + "version": "1.4.7", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -2101,9 +2101,9 @@ } }, "@types/jasmine": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-3.5.0.tgz", - "integrity": "sha512-kGCRI9oiCxFS6soGKlyzhMzDydfcPix9PpTkr7h11huxOxhWwP37Tg7DYBaQ18eQTNreZEuLkhpbGSqVNZPnnw==", + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-3.5.1.tgz", + "integrity": "sha512-5ZxOWKc0AgTeMcYCnV4RxTZZAClWaHKPR6n14LvUj8ywKDhOfI+YgdtNLXiW4kQmtxS3i1HXVbfAot+pqpJE2A==", "dev": true }, "@types/jasminewd2": { @@ -2122,9 +2122,9 @@ "dev": true }, "@types/node": { - "version": "13.1.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.1.7.tgz", - "integrity": "sha512-HU0q9GXazqiKwviVxg9SI/+t/nAsGkvLDkIdxz+ObejG2nX6Si00TeLqHMoS+a/1tjH7a8YpKVQwtgHuMQsldg==", + "version": "13.5.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.5.0.tgz", + "integrity": "sha512-Onhn+z72D2O2Pb2ql2xukJ55rglumsVo1H6Fmyi8mlU9SvKdBk/pUSUAiBY/d9bAOF7VVWajX3sths/+g6ZiAQ==", "dev": true }, "@types/q": { @@ -5483,26 +5483,6 @@ "integrity": "sha512-d4sze1JNC454Wdo2fkuyzCr6aHcbL6PGGuFAz0Li/NcOm1tCHGnWDRmJP85dh9IhQErTc2svWFEX5xHIOo//kQ==", "dev": true }, - "handlebars": { - "version": "4.5.3", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.3.tgz", - "integrity": "sha512-3yPecJoJHK/4c6aZhSvxOyG4vJKDshV36VHp0iVCDVh7o9w2vwi3NSnL2MMPj3YdduqaBcu7cGbggJQM0br9xA==", - "dev": true, - "requires": { - "neo-async": "^2.6.0", - "optimist": "^0.6.1", - "source-map": "^0.6.1", - "uglify-js": "^3.1.4" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } - }, "har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", @@ -6078,9 +6058,9 @@ "dev": true }, "iqb-components": { - "version": "1.4.7", - "resolved": "https://registry.npmjs.org/iqb-components/-/iqb-components-1.4.7.tgz", - "integrity": "sha512-mOPwBhzC1Pd5TXdrMgpFnoepFiAmN807TEoU3tQZQpPT4TVR03K33noc05gh4ljR7FPvGjVtaUvFxpRiIibXyA==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/iqb-components/-/iqb-components-1.5.0.tgz", + "integrity": "sha512-nQKc3VyD9/Sc8XQA3J2lW640YC5yqN9iFmGYHCy+gUleg/T/3tHz+Ph4paOWzis/OEcXU9hjBNpGk8OQ2SaR/A==", "requires": { "tslib": "^1.9.0" } diff --git a/package.json b/package.json index 4ac4efeb..a6e8d29c 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "@angular/platform-browser-dynamic": "~8.2.14", "@angular/router": "~8.2.14", "@types/file-saver": "^2.0.1", - "iqb-components": "1.4.7", + "iqb-components": "1.5.0", "core-js": "^3.6.4", "file-saver": "^2.0.2", "hammerjs": "^2.0.8", @@ -36,9 +36,9 @@ "@angular/cli": "~8.3.23", "@angular/compiler-cli": "~8.2.14", "@angular/language-service": "~8.2.14", - "@types/jasmine": "~3.5.0", + "@types/jasmine": "^3.5.1", "@types/jasminewd2": "~2.0.8", - "@types/node": "~13.1.7", + "@types/node": "^13.5.0", "codelyzer": "^5.0.1", "jasmine-core": "~3.5.0", "jasmine-spec-reporter": "~4.2.1", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index d7271ddb..3a8614b6 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,5 +1,6 @@ import { LoginData } from './app.interfaces'; -import { BackendService, ServerError } from './backend.service'; +import { BackendService } from './backend.service'; +import { ServerError } from 'iqb-components'; import { Component, OnInit } from '@angular/core'; import { MainDataService } from './maindata.service'; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 72cd984e..9804ce88 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -23,12 +23,12 @@ import { MatTooltipModule } from '@angular/material/tooltip'; import { AppComponent } from './app.component'; import { AppRoutingModule } from './app-routing.module'; -import { IqbComponents } from 'iqb-components'; import { WorkspaceModule } from './workspace'; import { StartComponent } from './start/start.component'; import { SuperadminModule } from './superadmin'; import { FlexLayoutModule } from '@angular/flex-layout'; import { httpInterceptorProviders } from './app.interceptor'; +import {IqbComponents} from "iqb-components"; @NgModule({ declarations: [ diff --git a/src/app/backend.service.ts b/src/app/backend.service.ts index bafd52e2..335305d9 100644 --- a/src/app/backend.service.ts +++ b/src/app/backend.service.ts @@ -1,96 +1,36 @@ import { LoginData } from './app.interfaces'; import { Injectable, Inject } from '@angular/core'; -import { HttpClient, HttpHeaders, HttpEvent, HttpErrorResponse } from '@angular/common/http'; -import { Observable, of } from 'rxjs'; +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; import { catchError } from 'rxjs/operators'; +import {ErrorHandler, ServerError} from "iqb-components"; -// ============================================================================ -// class instead of interface to be able to use instanceof to check type -export class ServerError { - public code: number; - public labelNice: string; - public labelSystem: string; - constructor(code: number, labelNice: string, labelSystem: string) { - this.code = code; - this.labelNice = labelNice; - this.labelSystem = labelSystem; - } -} - -// ============================================================================ -export class ErrorHandler { - public static handle(errorObj: HttpErrorResponse): Observable<ServerError> { - let myreturn: ServerError = null; - if (errorObj.error instanceof ErrorEvent) { - myreturn = new ServerError(500, 'Verbindungsproblem', (<ErrorEvent>errorObj.error).message); - } else { - myreturn = new ServerError(errorObj.status, 'Verbindungsproblem', errorObj.message); - if (errorObj.status === 401) { - myreturn.labelNice = 'Zugriff verweigert - bitte (neu) anmelden!'; - } else if (errorObj.status === 503) { - myreturn.labelNice = 'Achtung: Server meldet Datenbankproblem.'; - } - } - - return of(myreturn); - } -} @Injectable({ providedIn: 'root' }) export class BackendService { - private serverUrlSlim = ''; constructor( @Inject('SERVER_URL') private serverUrl: string, private http: HttpClient) { - this.serverUrlSlim = this.serverUrl + 'php/'; - this.serverUrl = this.serverUrl + 'php_start/'; + this.serverUrl = this.serverUrl + 'php/'; } - // ******************************************************************* login(name: string, password: string): Observable<LoginData | ServerError> { - - const headers = new HttpHeaders().set('Content-Type', 'application/json'); return this.http - .post<LoginData>(this.serverUrlSlim + 'login.php/login', {n: name, p: password}, {headers}) + .post<LoginData>(this.serverUrl + 'login.php/login', {n: name, p: password}) .pipe( catchError(ErrorHandler.handle) ); } - // ******************************************************************* - logout(): Observable<boolean | ServerError> { - return this.http - .post<boolean>(this.serverUrlSlim + 'logout', {}) - .pipe( - catchError(ErrorHandler.handle) - ); - } - - // ******************************************************************* getLoginData(adminToken: string): Observable<LoginData | ServerError> { return this.http - .post<LoginData>(this.serverUrlSlim + 'login.php/login', {at: adminToken}) + .post<LoginData>(this.serverUrl + 'login.php/login', {at: adminToken}) .pipe( catchError(ErrorHandler.handle) ); } - - // // ******************************************************************* - // getAboutText(): Observable<string | ServerError> { - // const httpOptions = { - // headers: new HttpHeaders({ - // 'Content-Type': 'application/json' - // }) - // }; - // return this.http - // .post<string>(this.serverUrl + 'getAboutText.php', httpOptions) - // .pipe( - // catchError(this.handleError) - // ); - // } - } diff --git a/src/app/maindata.service.ts b/src/app/maindata.service.ts index ff8c01fe..26f1a5c4 100644 --- a/src/app/maindata.service.ts +++ b/src/app/maindata.service.ts @@ -1,7 +1,7 @@ import { BehaviorSubject } from 'rxjs'; import { LoginData } from './app.interfaces'; import { Injectable } from '@angular/core'; -import { ServerError } from './backend.service'; +import { ServerError } from 'iqb-components'; @Injectable({ providedIn: 'root' @@ -28,7 +28,6 @@ export class MainDataService { public globalErrorMsg$ = new BehaviorSubject<ServerError>(null); - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ setNewLoginData(logindata?: LoginData) { const myLoginData: LoginData = { admintoken: MainDataService.defaultLoginData.admintoken, @@ -51,12 +50,10 @@ export class MainDataService { localStorage.setItem('at', myLoginData.admintoken); } - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ setNewErrorMsg(err: ServerError = null) { this.globalErrorMsg$.next(err); } - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ getWorkspaceName(ws: number): string { let myreturn = ''; if (ws > 0) { @@ -73,7 +70,6 @@ export class MainDataService { return myreturn; } - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ getWorkspaceRole(ws: number): string { let myreturn = ''; if (ws > 0) { diff --git a/src/app/material.module.ts b/src/app/material.module.ts deleted file mode 100644 index 192e0aa2..00000000 --- a/src/app/material.module.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { NgModule } from '@angular/core'; - -import { MatButtonModule } from '@angular/material/button'; -import { MatCardModule } from '@angular/material/card'; -import { MatIconModule } from '@angular/material/icon'; -import { MatMenuModule } from '@angular/material/menu'; -import { MatToolbarModule } from '@angular/material/toolbar'; - -@NgModule({ - imports: [ - MatButtonModule, - MatMenuModule, - MatToolbarModule, - MatIconModule, - MatCardModule - ], - exports: [ - MatButtonModule, - MatMenuModule, - MatToolbarModule, - MatIconModule, - MatCardModule - ] -}) -export class MaterialModule {} \ No newline at end of file diff --git a/src/app/start/start.component.ts b/src/app/start/start.component.ts index 2192559d..49f61310 100644 --- a/src/app/start/start.component.ts +++ b/src/app/start/start.component.ts @@ -1,9 +1,10 @@ -import { LoginData, WorkspaceData } from './../app.interfaces'; -import { BackendService, ServerError } from './../backend.service'; -import { MainDataService } from './../maindata.service'; +import { LoginData, WorkspaceData } from '../app.interfaces'; +import { BackendService } from '../backend.service'; +import { ServerError } from 'iqb-components'; +import { MainDataService } from '../maindata.service'; import { Router } from '@angular/router'; -import { Component, OnInit, Input, Output, EventEmitter, OnDestroy } from '@angular/core'; -import { FormGroup, FormBuilder, FormArray, FormControl, Validators } from '@angular/forms'; +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { Subscription } from 'rxjs'; @@ -31,7 +32,6 @@ export class StartComponent implements OnInit, OnDestroy { }); } - // ******************************************************************************************************* login() { if (this.adminloginform.valid) { this.bs.login( @@ -56,7 +56,6 @@ export class StartComponent implements OnInit, OnDestroy { } } - // % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % ngOnDestroy() { if (this.loginDataSubscription !== null) { this.loginDataSubscription.unsubscribe(); diff --git a/src/app/superadmin/backend.service.ts b/src/app/superadmin/backend.service.ts index d7c35c3d..bb981740 100644 --- a/src/app/superadmin/backend.service.ts +++ b/src/app/superadmin/backend.service.ts @@ -1,6 +1,6 @@ import { Injectable, Inject } from '@angular/core'; -import { HttpClient, HttpHeaders, HttpEvent, HttpErrorResponse } from '@angular/common/http'; -import { Observable, throwError, of } from 'rxjs'; +import { HttpClient } from '@angular/common/http'; +import { Observable, of } from 'rxjs'; import { catchError } from 'rxjs/operators'; @@ -10,30 +10,24 @@ import { catchError } from 'rxjs/operators'; export class BackendService { constructor( - @Inject('SERVER_URL') private serverUrl: string, + @Inject('SERVER_URL') private readonly serverUrl: string, private http: HttpClient) { this.serverUrl = this.serverUrl + 'php/sys.php/'; } - private errorHandler(error: Error | any): Observable<any> { - return Observable.throw(error); - } - - // ******************************************************************* getUsers(): Observable<NameOnly[]> { return this.http .get<NameOnly[]>(this.serverUrl + 'users') .pipe( - catchError(err => []) + catchError(() => []) ); } - addUser(name: string, password: string): Observable<Boolean> { return this.http .post<Boolean>(this.serverUrl + 'user/add', {n: name, p: password}) .pipe( - catchError(err => of(false)) + catchError(() => of(false)) ); } @@ -41,7 +35,7 @@ export class BackendService { return this.http .post<Boolean>(this.serverUrl + 'user/pw', {n: name, p: password}) .pipe( - catchError(err => of(false)) + catchError(() => of(false)) ); } @@ -49,86 +43,76 @@ export class BackendService { return this.http .post<Boolean>(this.serverUrl + 'users/delete', {u: users}) .pipe( - catchError(err => of(false)) + catchError(() => of(false)) ); } - // ******************************************************************* getWorkspacesByUser(username: string): Observable<IdRoleData[]> { return this.http .get<IdLabelSelectedData[]>(this.serverUrl + 'workspaces?u=' + username) .pipe( - catchError(err => []) + catchError(() => []) ); } - // ******************************************************************* setWorkspacesByUser(user: string, accessTo: IdRoleData[]): Observable<Boolean> { return this.http .post<Boolean>(this.serverUrl + 'user/workspaces', {u: user, ws: accessTo}) .pipe( - catchError(err => of(false)) + catchError(() => of(false)) ); } - // ******************************************************************* - // ******************************************************************* addWorkspace(name: string): Observable<Boolean> { return this.http .post<Boolean>(this.serverUrl + 'workspace/add', {n: name}) .pipe( - catchError(err => of(false)) + catchError(() => of(false)) ); } - // ******************************************************************* renameWorkspace(wsId: number, wsName: string): Observable<Boolean> { return this.http .post<Boolean>(this.serverUrl + 'workspace/rename', {ws: wsId, n: wsName}) .pipe( - catchError(err => of(false)) + catchError(() => of(false)) ); } - // ******************************************************************* deleteWorkspaces(workspaces: number[]): Observable<Boolean> { return this.http .post<Boolean>(this.serverUrl + 'workspaces/delete', {ws: workspaces}) .pipe( - catchError(err => of(false)) + catchError(() => of(false)) ); } - // ******************************************************************* getUsersByWorkspace(workspaceId: number): Observable<IdRoleData[]> { return this.http .get<IdRoleData[]>(this.serverUrl + 'users?ws=' + workspaceId) .pipe( - catchError(err => []) + catchError(() => []) ); } - // ******************************************************************* setUsersByWorkspace(workspace: number, accessing: IdRoleData[]): Observable<Boolean> { return this.http .post<Boolean>(this.serverUrl + 'workspace/users', {ws: workspace, u: accessing}) .pipe( - catchError(err => of(false)) + catchError(() => of(false)) ); } - // ******************************************************************* getWorkspaces(): Observable<IdAndName[]> { return this.http .get<IdAndName[]>(this.serverUrl + 'workspaces') .pipe( - catchError(err => []) + catchError(() => []) ); } } -// / / / / / / export interface NameOnly { name: string; } diff --git a/src/app/workspace/backend.service.ts b/src/app/workspace/backend.service.ts index 9d62ebf5..7e67f5b0 100644 --- a/src/app/workspace/backend.service.ts +++ b/src/app/workspace/backend.service.ts @@ -1,24 +1,24 @@ -import { GetFileResponseData, CheckWorkspaceResponseData, BookletsStarted, SysCheckStatistics, ReviewData, LogData, UnitResponse, ResultData, MonitorData } from './workspace.interfaces'; +import { GetFileResponseData, CheckWorkspaceResponseData, BookletsStarted, SysCheckStatistics, + ReviewData, LogData, UnitResponse, ResultData, MonitorData } from './workspace.interfaces'; import { Injectable, Inject } from '@angular/core'; -import { HttpClient, HttpHeaders, HttpErrorResponse, HttpUrlEncodingCodec } from '@angular/common/http'; -import { Observable, throwError } from 'rxjs'; -// import { BehaviorSubject } from 'rxjs/BehaviorSubject'; +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; import { catchError } from 'rxjs/operators'; -import { ErrorHandler, ServerError } from '../backend.service'; +import { ErrorHandler, ServerError } from "iqb-components"; @Injectable() export class BackendService { private serverUrlSlim = ''; constructor( - @Inject('SERVER_URL') private serverUrl: string, + @Inject('SERVER_URL') private readonly serverUrl: string, private http: HttpClient) { - this.serverUrlSlim = this.serverUrl + 'php/ws.php/' - this.serverUrl = this.serverUrl + 'php/'; + + this.serverUrlSlim = this.serverUrl + 'php/ws.php/'; + this.serverUrl = this.serverUrl + 'php/'; } - // ******************************************************************* getFiles(): Observable<GetFileResponseData[] | ServerError> { return this.http .get<GetFileResponseData[]>(this.serverUrlSlim + 'filelist') @@ -27,7 +27,6 @@ export class BackendService { ); } - // ******************************************************************* deleteFiles(filesToDelete: Array<string>): Observable<string | ServerError> { return this.http .post<string>(this.serverUrlSlim + 'delete', {f: filesToDelete}) @@ -36,7 +35,6 @@ export class BackendService { ); } - // ******************************************************************* checkWorkspace(): Observable<CheckWorkspaceResponseData | ServerError> { return this.http .post<CheckWorkspaceResponseData>(this.serverUrl + 'checkWorkspace.php', {}) @@ -45,7 +43,6 @@ export class BackendService { ); } - /*******************************/ getBookletsStarted(groups: string[]): Observable<BookletsStarted[] | ServerError>{ return this.http .post<BookletsStarted[]>(this.serverUrl + 'getBookletsStarted.php', {g: groups}) @@ -54,7 +51,6 @@ export class BackendService { ); } - /*******************************/ lockBooklets(groups: string[]): Observable<boolean | ServerError>{ return this.http .post<boolean>(this.serverUrlSlim + 'lock', {g: groups}) @@ -63,66 +59,54 @@ export class BackendService { ); } - /*******************************/ unlockBooklets(groups: string[]): Observable<boolean | ServerError>{ return this.http - .post<boolean>(this.serverUrlSlim + 'unlock', {g: groups}) - .pipe( - catchError(ErrorHandler.handle) - ); + .post<boolean>(this.serverUrlSlim + 'unlock', {g: groups}) + .pipe( + catchError(ErrorHandler.handle) + ); } - /*******************************/ getMonitorData(): Observable<MonitorData[] | ServerError>{ - const httpOptions = { - headers: new HttpHeaders({ - 'Content-Type': 'application/json' - }) - }; return this.http - .post<MonitorData[]>(this.serverUrl + 'getMonitorData.php', {}, httpOptions) + .post<MonitorData[]>(this.serverUrl + 'getMonitorData.php', {}) .pipe( catchError(ErrorHandler.handle) ); } - /*******************************/ getResultData(): Observable<ResultData[]>{ return this.http .post<ResultData[]>(this.serverUrl + 'getResultData.php', {}) .pipe( - catchError(err => []) + catchError(() => []) ); } - /*******************************/ getResponses(groups: string[]): Observable<UnitResponse[]>{ return this.http .post<UnitResponse[]>(this.serverUrl + 'getResponses.php', {g: groups}) .pipe( - catchError(err => []) + catchError(() => []) ); } - /*******************************/ getLogs(groups: string[]): Observable<LogData[]>{ return this.http .post<LogData[]>(this.serverUrl + 'getLogs.php', {g: groups}) .pipe( - catchError(err => []) + catchError(() => []) ); } - /*******************************/ getReviews(groups: string[]): Observable<ReviewData[]>{ return this.http .post<ReviewData[]>(this.serverUrl + 'getReviews.php', {g: groups}) .pipe( - catchError(err => []) + catchError(() => []) ); } - /*******************************/ deleteData(groups: string[]): Observable<boolean | ServerError>{ return this.http .post<boolean>(this.serverUrl + 'deleteData.php', {g: groups}) @@ -131,51 +115,30 @@ export class BackendService { ); } - /*******************************/ getSysCheckReportList(): Observable<SysCheckStatistics[] | ServerError> { - const httpOptions = { - headers: new HttpHeaders({ - 'Content-Type': 'application/json' - }) - }; return this.http - .post<SysCheckStatistics[]>(this.serverUrl + 'getSysCheckReportList.php', {}, httpOptions) + .post<SysCheckStatistics[]>(this.serverUrl + 'getSysCheckReportList.php', {}) .pipe( catchError(ErrorHandler.handle) ); } - /*******************************/ - getSysCheckReport(reports: string[], columnDelimiter: string, quoteChar: string): Observable<string[] | ServerError> { - const httpOptions = { - headers: new HttpHeaders({ - 'Content-Type': 'application/json' - }) - }; + getSysCheckReport(reports: string[], columnDelimiter: string, + quoteChar: string): Observable<string[] | ServerError> { return this.http .post<string[]>(this.serverUrl + 'getSysCheckReport.php', - {r: reports, cd: columnDelimiter, q: quoteChar}, httpOptions) + {r: reports, cd: columnDelimiter, q: quoteChar}) .pipe( catchError(ErrorHandler.handle) ); } - /*******************************/ deleteSysCheckReports(reports: string[]): Observable<boolean | ServerError> { - const httpOptions = { - headers: new HttpHeaders({ - 'Content-Type': 'application/json' - }) - }; return this.http .post<boolean>(this.serverUrl + 'deleteSysCheckReports.php', - {r: reports}, httpOptions) + {r: reports}) .pipe( catchError(ErrorHandler.handle) ); } } - - -// ############################################################################################# - diff --git a/src/app/workspace/files/files.component.ts b/src/app/workspace/files/files.component.ts index 35dd0ed6..d9879ac5 100644 --- a/src/app/workspace/files/files.component.ts +++ b/src/app/workspace/files/files.component.ts @@ -1,22 +1,17 @@ -import { LoginData } from './../../app.interfaces'; -import { MainDataService } from './../../maindata.service'; -import { ServerError } from './../../backend.service'; -import { WorkspaceDataService } from './../workspacedata.service'; -import { GetFileResponseData, CheckWorkspaceResponseData } from './../workspace.interfaces'; +import { MainDataService } from '../../maindata.service'; +import { ServerError } from "iqb-components"; +import { WorkspaceDataService } from '../workspacedata.service'; +import { GetFileResponseData, CheckWorkspaceResponseData } from '../workspace.interfaces'; import { ConfirmDialogComponent, ConfirmDialogData, MessageDialogComponent, MessageDialogData, MessageType } from 'iqb-components'; -import { DataSource } from '@angular/cdk/collections'; -import { Observable, BehaviorSubject, Subscription, merge } from 'rxjs'; +import { Subscription } from 'rxjs'; import { MatTableDataSource } from '@angular/material/table'; import { MatSnackBar } from '@angular/material/snack-bar'; import { BackendService } from '../backend.service'; -import { Input, Output, EventEmitter, Component, OnInit, Inject, ElementRef, OnDestroy } from '@angular/core'; -import { NgModule, ViewChild } from '@angular/core'; +import { Component, OnInit, Inject, OnDestroy } from '@angular/core'; +import { ViewChild } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { MatSort } from '@angular/material/sort'; -import { HttpEventType, HttpErrorResponse, HttpEvent } from '@angular/common/http'; -import { IqbFilesUploadQueueComponent, IqbFilesUploadInputForDirective } from '../../iqb-files'; - @Component({ templateUrl: './files.component.html', @@ -52,7 +47,7 @@ export class FilesComponent implements OnInit, OnDestroy { } ngOnInit() { - this.workspaceIdSubscription = this.wds.workspaceId$.subscribe(ws => { + this.workspaceIdSubscription = this.wds.workspaceId$.subscribe(() => { this.updateFileList((this.wds.ws <= 0) || (this.mds.adminToken.length === 0)); }); } diff --git a/src/app/workspace/monitor/monitor.component.ts b/src/app/workspace/monitor/monitor.component.ts index b8987e79..090070ea 100644 --- a/src/app/workspace/monitor/monitor.component.ts +++ b/src/app/workspace/monitor/monitor.component.ts @@ -1,6 +1,6 @@ -import { BookletsStarted } from './../workspace.interfaces'; -import { WorkspaceDataService } from './../workspacedata.service'; -import { BackendService } from './../backend.service'; +import { BookletsStarted } from '../workspace.interfaces'; +import { WorkspaceDataService } from '../workspacedata.service'; +import { BackendService } from '../backend.service'; import { Component, OnInit, ViewChild, OnDestroy } from '@angular/core'; import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSort } from '@angular/material/sort'; @@ -9,7 +9,7 @@ import { SelectionModel } from '@angular/cdk/collections'; import { saveAs } from 'file-saver'; import { MonitorData } from '../workspace.interfaces'; import { Subscription } from 'rxjs'; -import { ServerError } from 'src/app/backend.service'; +import { ServerError } from 'iqb-components'; @Component({ @@ -33,7 +33,7 @@ export class MonitorComponent implements OnInit, OnDestroy { ) { } ngOnInit() { - this.workspaceIdSubscription = this.wds.workspaceId$.subscribe(ws => { + this.workspaceIdSubscription = this.wds.workspaceId$.subscribe(() => { this.updateTable(); }); } @@ -83,7 +83,7 @@ export class MonitorComponent implements OnInit, OnDestroy { myCsvData += '"' + b.groupname + '"' + columnDelimiter + '"' + b.loginname + '"' + columnDelimiter + '"' + b.code + '"' + columnDelimiter + '"' + b.bookletname + '"' + columnDelimiter + '"' + (b.locked ? 'X' : '-') + '"' + columnDelimiter + '"' + b.laststart + '"' + lineDelimiter; }); - var blob = new Blob([myCsvData], {type: "text/csv;charset=utf-8"}); + const blob = new Blob([myCsvData], {type: "text/csv;charset=utf-8"}); saveAs(blob, "iqb-testcenter-bookletsStarted.csv"); } else { this.snackBar.open('Keine Daten verfügbar.', 'Fehler', {duration: 3000}); diff --git a/src/app/workspace/workspacedata.service.ts b/src/app/workspace/workspacedata.service.ts index d35d1cc6..1b91eba5 100644 --- a/src/app/workspace/workspacedata.service.ts +++ b/src/app/workspace/workspacedata.service.ts @@ -1,15 +1,6 @@ -import { MainDataService } from './../maindata.service'; -// import { Observable } from 'rxjs/Observable'; -// import { BehaviorSubject } from 'rxjs/BehaviorSubject'; import { BehaviorSubject } from 'rxjs'; -import { FormGroup } from '@angular/forms'; -import { Injectable, Component, Input, Output, EventEmitter } from '@angular/core'; -import { MatDialog, MatDialogRef } from '@angular/material/dialog'; -import { Router, ActivatedRoute } from '@angular/router'; - -import { BackendService } from './backend.service'; -import { WorkspaceData } from '../app.interfaces'; -import { ServerError } from '../backend.service'; +import { Injectable } from '@angular/core'; +import { ServerError } from "iqb-components"; @Injectable({ providedIn: 'root' @@ -49,47 +40,10 @@ export class WorkspaceDataService { {path: 'monitor', label: 'Monitor'} ]; - // ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc - constructor ( - public confirmDialog: MatDialog, - private bs: BackendService, - private mds: MainDataService, - private route: ActivatedRoute, - private router: Router - ) { } - - // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ setNewErrorMsg(err: ServerError = null) { this.globalErrorMsg$.next(err); } - // ******************************************************************************************************* - logout() { - // const dialogRef = this.confirmDialog.open(ConfirmDialogComponent, { - // width: '400px', - // height: '300px', - // data: <ConfirmDialogData>{ - // title: 'Abmelden', - // content: 'Möchten Sie sich abmelden?', - // confirmbuttonlabel: 'Abmelden' - // } - // }); - // dialogRef.afterClosed().subscribe(result => { - // if (result !== false) { - // this.bs.logout(this.adminToken$.getValue()).subscribe( - // logoutresponse => { - // this.updateAdminStatus('', '', [], false, ''); - // this.router.navigateByUrl('/'); - // }, (err: ServerError) => { - // this.updateAdminStatus('', '', [], false, err.label); - // this.router.navigateByUrl('/'); - // } - // ); - // } - // }); - } - - // ******************************************************************************************************* setWorkspace(newId: number, newRole: string, newName: string) { this._wsName = newName; this._wsRole = newRole; diff --git a/src/environments/environment.build.ts b/src/environments/environment.build.ts index dc0db16e..6d22e96a 100644 --- a/src/environments/environment.build.ts +++ b/src/environments/environment.build.ts @@ -2,7 +2,7 @@ export const environment = { production: false, - testcenterUrl: '/admin/', + testcenterUrl: 'https://www.iqb-testcenter.de/admin/', appName: 'IQB-Testcenter Verwaltung', appPublisher: 'IQB - Institut zur Qualitätsentwicklung im Bildungswesen', appVersion: '1.0 - 8.4.2019' diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 82b5a8a4..0f437486 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -5,7 +5,7 @@ export const environment = { production: false, - testcenterUrl: 'https://itemdb2.iqb.hu-berlin.de/admin/', + testcenterUrl: 'https://www.iqb-testcenter.de/admin/', appName: 'IQB-Testcenter Verwaltung', appPublisher: 'IQB - Institut zur Qualitätsentwicklung im Bildungswesen', appVersion: '0.5 (dev)' -- GitLab