diff --git a/src/app/app-root/admin-starter/admin-starter.component.spec.ts b/src/app/app-root/admin-starter/admin-starter.component.spec.ts index f617ed0d82df678ae015d4725b5ae116cc0dd141..88ba4e858719d9aeeccbcb1160016cb642a3b8ad 100644 --- a/src/app/app-root/admin-starter/admin-starter.component.spec.ts +++ b/src/app/app-root/admin-starter/admin-starter.component.spec.ts @@ -1,14 +1,26 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { AdminStarterComponent } from './admin-starter.component'; +import {AppRoutingModule} from "../../app-routing.module"; +import {HttpClientModule} from "@angular/common/http"; +import {IqbComponentsModule} from "iqb-components"; +import {BackendService} from "../../backend.service"; -describe('WorkspaceAdminStarterComponent', () => { +describe('AdminStarterComponent', () => { let component: AdminStarterComponent; let fixture: ComponentFixture<AdminStarterComponent>; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ AdminStarterComponent ] + declarations: [ AdminStarterComponent ], + imports: [ + HttpClientModule, + AppRoutingModule, + IqbComponentsModule + ], + providers: [ + BackendService + ] }) .compileComponents(); })); diff --git a/src/app/app-root/admin-starter/admin-starter.component.ts b/src/app/app-root/admin-starter/admin-starter.component.ts index c49e095507e1d1c9613ef2f5e8c57c646643f96a..956f5d60dae1be4de4e54cce6a9799fba6e79ffd 100644 --- a/src/app/app-root/admin-starter/admin-starter.component.ts +++ b/src/app/app-root/admin-starter/admin-starter.component.ts @@ -35,7 +35,7 @@ export class AdminStarterComponent implements OnInit { } resetLogin() { - this.mds.setNewLoginData(); + this.mds.setAuthData(); this.router.navigate(['/']); } } diff --git a/src/app/app-root/code-input/code-input.component.spec.ts b/src/app/app-root/code-input/code-input.component.spec.ts index fbcbd63c2f1eed5ebcbe8e5cbe047ceb440ad7ae..786fcfedda1d7e6aacb4a498a205dac2f73cbd83 100644 --- a/src/app/app-root/code-input/code-input.component.spec.ts +++ b/src/app/app-root/code-input/code-input.component.spec.ts @@ -1,14 +1,28 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { CodeInputComponent } from './code-input.component'; +import {AppRoutingModule} from "../../app-routing.module"; +import {HttpClientModule} from "@angular/common/http"; +import {ReactiveFormsModule} from "@angular/forms"; +import {IqbComponentsModule} from "iqb-components"; +import {BackendService} from "../../backend.service"; -describe('AppStatusComponent', () => { +describe('CodeInputComponent', () => { let component: CodeInputComponent; let fixture: ComponentFixture<CodeInputComponent>; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ CodeInputComponent ] + declarations: [ CodeInputComponent ], + imports: [ + HttpClientModule, + ReactiveFormsModule, + AppRoutingModule, + IqbComponentsModule + ], + providers: [ + BackendService + ] }) .compileComponents(); })); diff --git a/src/app/app-root/code-input/code-input.component.ts b/src/app/app-root/code-input/code-input.component.ts index 90d5afcdef2e30afb7197c503a6968ab940baeea..62ca3a7beec6f69390be84ba78ea6408580b8a1d 100644 --- a/src/app/app-root/code-input/code-input.component.ts +++ b/src/app/app-root/code-input/code-input.component.ts @@ -52,7 +52,7 @@ export class CodeInputComponent { } resetLogin() { - this.mds.setNewLoginData(); + this.mds.setAuthData(); this.router.navigate(['/']); } } diff --git a/src/app/app-root/login/login.component.ts b/src/app/app-root/login/login.component.ts index 1a449c6abd38bdb68249064a8ed6cd1b909aa38e..4516aa0170d509d1881f4e34d0ad8ea09fd10180 100644 --- a/src/app/app-root/login/login.component.ts +++ b/src/app/app-root/login/login.component.ts @@ -40,18 +40,19 @@ export class LoginComponent implements OnInit, OnDestroy { } login() { - this.mds.incrementDelayedProcessesCount(); const loginData = this.loginForm.value; LoginComponent.oldLoginName = loginData['name']; this.bs.login(loginData['name'], loginData['pw']).subscribe( loginData => { if (loginData instanceof ServerError) { const e = loginData as ServerError; - this.mds.appError$.next({ - label: e.labelNice, - description: e.labelSystem + ' (' + e.code.toString + ')', - category: "PROBLEM" - }); + if (e.code === 400) { + this.mds.appError$.next({ + label: 'Diese Anmeldedaten sind für diesen Server nicht gültig.', + description: e.labelSystem + ' (' + e.code.toString + ')', + category: "PROBLEM" + }); + } this.mds.addCustomtextsFromDefList(appconfig.customtextsLogin); // no change in other data } else { @@ -64,11 +65,11 @@ export class LoginComponent implements OnInit, OnDestroy { this.router.navigateByUrl(this.returnTo); } else { if (this.mds.adminToken) { - this.router.navigate(['../admin-starter'], {relativeTo: this.route}); + this.router.navigate(['/r/admin-starter']); } else if (this.mds.loginToken) { - this.router.navigate(['../code-input'], {relativeTo: this.route}); + this.router.navigate(['/r/code-input']); } else if (this.mds.personToken) { - this.router.navigate(['../test-starter'], {relativeTo: this.route}); + this.router.navigate(['/r/test-starter']); } else { this.mds.appError$.next({ label: 'Keine Berechtigung für diese Anmeldedaten gefunden.', @@ -78,7 +79,6 @@ export class LoginComponent implements OnInit, OnDestroy { } } } - this.mds.decrementDelayedProcessesCount(); } ); } diff --git a/src/app/app-root/route-dispatcher/route-dispatcher.component.spec.ts b/src/app/app-root/route-dispatcher/route-dispatcher.component.spec.ts index f26f5c7d2cc2a00b0e55310c9d6ca289016c2517..0786b25548f0708150c51b01fc3fdbdfa561d648 100644 --- a/src/app/app-root/route-dispatcher/route-dispatcher.component.spec.ts +++ b/src/app/app-root/route-dispatcher/route-dispatcher.component.spec.ts @@ -1,6 +1,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { RouteDispatcherComponent } from './route-dispatcher.component'; +import {AppRoutingModule} from "../../app-routing.module"; describe('RouteDispatcherComponent', () => { let component: RouteDispatcherComponent; @@ -8,7 +9,8 @@ describe('RouteDispatcherComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ RouteDispatcherComponent ] + declarations: [ RouteDispatcherComponent ], + imports: [AppRoutingModule] }) .compileComponents(); })); diff --git a/src/app/app-root/route-dispatcher/route-dispatcher.component.ts b/src/app/app-root/route-dispatcher/route-dispatcher.component.ts index a01dfbd145e636b2c3b02c247318a7ebdd112d27..f9f665ff41e99a08a6dc8d63492fdb4fbba4d3cb 100644 --- a/src/app/app-root/route-dispatcher/route-dispatcher.component.ts +++ b/src/app/app-root/route-dispatcher/route-dispatcher.component.ts @@ -15,7 +15,7 @@ export class RouteDispatcherComponent implements OnInit { constructor( public cts: CustomtextService, - router: Router) { + private router: Router) { const state: RouterState = router.routerState; const snapshot: RouterStateSnapshot = state.snapshot; diff --git a/src/app/app-root/status-card/status-card.component.spec.ts b/src/app/app-root/status-card/status-card.component.spec.ts index a70fcee0a1fbb675b79b490ae729b863b0b60a87..d3898254cb0246fa476e4a770fec08cb5d491b3b 100644 --- a/src/app/app-root/status-card/status-card.component.spec.ts +++ b/src/app/app-root/status-card/status-card.component.spec.ts @@ -1,6 +1,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { StatusCardComponent } from './status-card.component'; +import {IqbComponentsModule} from "iqb-components"; describe('StatusCardComponent', () => { let component: StatusCardComponent; @@ -8,7 +9,8 @@ describe('StatusCardComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ StatusCardComponent ] + declarations: [ StatusCardComponent ], + imports: [IqbComponentsModule] }) .compileComponents(); })); diff --git a/src/app/app-root/sys-check-starter/sys-check-starter.component.spec.ts b/src/app/app-root/sys-check-starter/sys-check-starter.component.spec.ts index e8a145d87a90bee21af1b02c569b145f49ecd026..12286d34cb18f85e8767f062c9464b6a63a6804f 100644 --- a/src/app/app-root/sys-check-starter/sys-check-starter.component.spec.ts +++ b/src/app/app-root/sys-check-starter/sys-check-starter.component.spec.ts @@ -1,6 +1,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { SysCheckStarterComponent } from './sys-check-starter.component'; +import {HttpClientModule} from "@angular/common/http"; +import {AppRoutingModule} from "../../app-routing.module"; +import {IqbComponentsModule} from "iqb-components"; +import {BackendService} from "../../backend.service"; describe('SysCheckStarterComponent', () => { let component: SysCheckStarterComponent; @@ -8,7 +12,15 @@ describe('SysCheckStarterComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ SysCheckStarterComponent ] + declarations: [ SysCheckStarterComponent ], + imports: [ + HttpClientModule, + AppRoutingModule, + IqbComponentsModule + ], + providers: [ + BackendService + ] }) .compileComponents(); })); diff --git a/src/app/app-root/sys-check-starter/sys-check-starter.component.ts b/src/app/app-root/sys-check-starter/sys-check-starter.component.ts index 98606e0c8a9974cce91d34a167eec6abba32b58f..3bd785f550dcde6a084e4200bcac4fb2e6dfea1d 100644 --- a/src/app/app-root/sys-check-starter/sys-check-starter.component.ts +++ b/src/app/app-root/sys-check-starter/sys-check-starter.component.ts @@ -23,7 +23,6 @@ export class SysCheckStarterComponent implements OnInit { ngOnInit() { setTimeout(() => { this.loading = true; - this.mds.incrementDelayedProcessesCount(); this.bs.getSysCheckInfo().subscribe(myConfigs => { if (myConfigs) { this.checkConfigList = myConfigs; @@ -44,7 +43,6 @@ export class SysCheckStarterComponent implements OnInit { ] } this.loading = false; - this.mds.decrementDelayedProcessesCount(); }); }) } diff --git a/src/app/app-routing-guards.ts b/src/app/app-routing-guards.ts index 49b862dcfc2c427411f5269f03b7528e09ebf37c..55172a1d9a21cd26f5bd5c854b3221e905034b39 100644 --- a/src/app/app-routing-guards.ts +++ b/src/app/app-routing-guards.ts @@ -16,16 +16,12 @@ export class RouteDispatcherActivateGuard implements CanActivate { state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean { if (this.mds.adminToken.length > 0) { - console.log('as'); this.router.navigate(['/r/admin-starter']); } else if (this.mds.personToken.length > 0) { - console.log('ts'); this.router.navigate(['/r/test-starter']); } else if (this.mds.loginToken.length > 0) { - console.log('ci'); this.router.navigate(['/r/code-input']); } else { - console.log('login'); this.router.navigate(['/r/login', '']); } return false; diff --git a/src/app/app.component.html b/src/app/app.component.html index 5cbd9ed0f6ee314acbfd1abf1b8addb56ad8f39e..4d86fd662e1988c4a6c0f36921ed228d89de0bd5 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -10,7 +10,7 @@ <mat-icon>clear</mat-icon> </button> </div> -<div class="spinner" *ngIf="(mds.delayedProcessesCount$ | async) > 0"> +<div class="spinner" *ngIf="showSpinner"> <mat-spinner></mat-spinner> </div> <router-outlet></router-outlet> diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 2216949f9a8ab5dc8a650cf1a2b32d545b0b3d97..e10d4c00a274377e3ae44f6ee31b3c797f40f520 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -5,6 +5,7 @@ import { LoginData } from './app.interfaces'; import {CustomtextService, ServerError} from 'iqb-components'; import { appconfig } from './app.config'; import {Subscription} from "rxjs"; +import {debounceTime} from "rxjs/operators"; @Component({ selector: 'tc-root', @@ -16,6 +17,8 @@ import {Subscription} from "rxjs"; export class AppComponent implements OnInit, OnDestroy { private appErrorSubscription: Subscription = null; showError = false; + private appDelayedProcessesSubscription: Subscription = null; + showSpinner = false; constructor ( public mds: MainDataService, @@ -45,10 +48,17 @@ export class AppComponent implements OnInit, OnDestroy { this.appErrorSubscription = this.mds.appError$.subscribe(err => { if (err) { + console.warn(err.description); this.showError = true; } }); + this.appDelayedProcessesSubscription = this.mds.delayedProcessesCount$.pipe( + debounceTime(500) + ).subscribe( c => { + this.showSpinner = c > 0; + }); + window.addEventListener('message', (event: MessageEvent) => { const msgData = event.data; const msgType = msgData['type']; @@ -111,5 +121,8 @@ export class AppComponent implements OnInit, OnDestroy { if (this.appErrorSubscription !== null) { this.appErrorSubscription.unsubscribe(); } + if (this.appDelayedProcessesSubscription !== null) { + this.appDelayedProcessesSubscription.unsubscribe(); + } } } diff --git a/src/app/app.interceptor.ts b/src/app/app.interceptor.ts index 063f8c2c19016f73436f2eaa1c00e3d7885a7d87..c1f4e7563608ab19e5276779ff66c1f00b1218fb 100644 --- a/src/app/app.interceptor.ts +++ b/src/app/app.interceptor.ts @@ -1,12 +1,18 @@ import { MainDataService } from './maindata.service'; import { Injectable } from '@angular/core'; -import { HttpInterceptor, HttpRequest, - HttpHandler, HttpEvent } from '@angular/common/http'; -import { Observable } from 'rxjs'; +import { + HttpInterceptor, HttpRequest, + HttpHandler, HttpEvent, HttpErrorResponse +} from '@angular/common/http'; +import {Observable, of} from 'rxjs'; +import {catchError, tap} from "rxjs/operators"; +import {Router, RouterState, RouterStateSnapshot} from "@angular/router"; @Injectable() export class AuthInterceptor implements HttpInterceptor { - constructor(public mds: MainDataService) {} + constructor( + private mds: MainDataService, + private router: Router) {} intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { @@ -25,6 +31,67 @@ export class AuthInterceptor implements HttpInterceptor { } }); - return next.handle(requestA); + this.mds.incrementDelayedProcessesCount(); + return next.handle(requestA).pipe( + tap(requ => { + // filter out OPTIONS request + if (requ.type > 0) { + this.mds.decrementDelayedProcessesCount(); + } + }), + catchError(e => { + this.mds.decrementDelayedProcessesCount(); + console.log('err dec'); + if (e instanceof HttpErrorResponse) { + const httpError = e as HttpErrorResponse; + if (httpError.error instanceof ErrorEvent) { + this.mds.appError$.next({ + label: 'Fehler in der Netzwerk-Verbindung', + description: httpError.message, + category: "PROBLEM" + }) + } else { + let goToLoginPage = false; + let label = 'Unbekanntes Verbindungsproblem'; + switch (httpError.status) { + case 401: { + goToLoginPage = true; + label = 'Bitte für diese Aktion erst anmelden!'; + break; + } + case 403: { + label = 'Für diese Funktion haben Sie keine Berechtigung.'; + break; + } + case 404: { + label = 'Daten/Objekt nicht gefunden.'; + break; + } + case 410: { + goToLoginPage = true; + label = 'Anmeldung abgelaufen. Bitte erneut anmelden!'; + break; + } + case 500: { + label = 'Allgemeines Server-Problem.'; + break; + } + } + this.mds.appError$.next({ + label: label, + description: httpError.message, + category: "PROBLEM" + }); + if (goToLoginPage) { + const state: RouterState = this.router.routerState; + const snapshot: RouterStateSnapshot = state.snapshot; + this.router.navigate(['/r/login', snapshot.url]); + } + } + } + + return of(e); + }) + ) } } diff --git a/src/app/backend.service.ts b/src/app/backend.service.ts index 833e9d57126467125b4bca5969cbc2b61afee040..3cb64679d6c45c4e5b50c6fe33e9446a05bce0ea 100644 --- a/src/app/backend.service.ts +++ b/src/app/backend.service.ts @@ -21,14 +21,14 @@ export class BackendService { login(name: string, password: string): Observable<LoginData | ServerError> { return this.http - .put<LoginData>(this.serverUrl + 'session/login', {name, password}) + .put<LoginData>(this.serverUrl + 'session/admin', {name, password}) .pipe( catchError(ErrorHandler.handle), switchMap(myLoginData => { if (myLoginData instanceof ServerError) { if ((myLoginData as ServerError).code === 401) { return this.http - .put<LoginData>(this.serverUrl + 'session/admin', {name, password}) + .put<LoginData>(this.serverUrl + 'session/login', {name, password}) .pipe(catchError(ErrorHandler.handle)); } else { return of(myLoginData); diff --git a/src/app/superadmin/users/users.component.ts b/src/app/superadmin/users/users.component.ts index 0f6c062ee936278d7ca66bf69101de5d46118211..2b1c2f0520ec25aee0e1ae27852a76331ba4be93 100644 --- a/src/app/superadmin/users/users.component.ts +++ b/src/app/superadmin/users/users.component.ts @@ -75,7 +75,6 @@ export class UsersComponent implements OnInit { dialogRef.afterClosed().subscribe(result => { if (typeof result !== 'undefined') { if (result !== false) { - this.mds.incrementDelayedProcessesCount(); this.bs.addUser((<FormGroup>result).get('name').value, (<FormGroup>result).get('pw').value).subscribe( respOk => { @@ -85,7 +84,6 @@ export class UsersComponent implements OnInit { } else { this.snackBar.open('Konnte Nutzer nicht hinzufügen', 'Fehler', {duration: 1000}); } - this.mds.decrementDelayedProcessesCount(); }); } } @@ -128,7 +126,6 @@ export class UsersComponent implements OnInit { passwdDialogRef.afterClosed().subscribe(result => { if (typeof result !== 'undefined') { if (result !== false) { - this.mds.incrementDelayedProcessesCount(); this.bs.setSuperUserStatus( selectedRows[0]['id'], userObject.is_superadmin === '0', @@ -139,7 +136,6 @@ export class UsersComponent implements OnInit { } else { this.snackBar.open('Konnte Status nicht ändern', 'Fehler', {duration: 1000}); } - this.mds.decrementDelayedProcessesCount(); }); } } @@ -172,7 +168,6 @@ export class UsersComponent implements OnInit { dialogRef.afterClosed().subscribe(result => { if (typeof result !== 'undefined') { if (result !== false) { - this.mds.incrementDelayedProcessesCount(); this.bs.changePassword(selectedRows[0]['id'], (<FormGroup>result).get('pw').value).subscribe( respOk => { @@ -181,7 +176,6 @@ export class UsersComponent implements OnInit { } else { this.snackBar.open('Konnte Kennwort nicht ändern', 'Fehler', {duration: 1000}); } - this.mds.decrementDelayedProcessesCount(); }); } } @@ -223,7 +217,6 @@ export class UsersComponent implements OnInit { dialogRef.afterClosed().subscribe(result => { if (result !== false) { // ========================================================= - this.mds.incrementDelayedProcessesCount(); const usersToDelete = []; selectedRows.forEach((r: UserData) => usersToDelete.push(r.id)); this.bs.deleteUsers(usersToDelete).subscribe( @@ -234,7 +227,6 @@ export class UsersComponent implements OnInit { } else { this.snackBar.open('Konnte Nutzer nicht löschen', 'Fehler', {duration: 2000}); } - this.mds.decrementDelayedProcessesCount(); }); } }); @@ -245,7 +237,6 @@ export class UsersComponent implements OnInit { updateWorkspaceList() { this.pendingWorkspaceChanges = false; if (this.selectedUser > -1) { - this.mds.incrementDelayedProcessesCount(); this.bs.getWorkspacesByUser(this.selectedUser).subscribe(dataresponse => { if (dataresponse instanceof ServerError) { this.mds.appError$.next({ @@ -256,7 +247,6 @@ export class UsersComponent implements OnInit { } else { this.WorkspacelistDatasource = new MatTableDataSource(dataresponse); } - this.mds.decrementDelayedProcessesCount() }) } else { this.WorkspacelistDatasource = null; @@ -275,7 +265,6 @@ export class UsersComponent implements OnInit { saveWorkspaces() { this.pendingWorkspaceChanges = false; if (this.selectedUser > -1) { - this.mds.incrementDelayedProcessesCount(); this.bs.setWorkspacesByUser(this.selectedUser, this.WorkspacelistDatasource.data).subscribe( respOk => { if (respOk !== false) { @@ -283,7 +272,6 @@ export class UsersComponent implements OnInit { } else { this.snackBar.open('Konnte Zugriffsrechte nicht ändern', 'Fehler', {duration: 2000}); } - this.mds.decrementDelayedProcessesCount(); }); } else { this.WorkspacelistDatasource = null; @@ -292,7 +280,6 @@ export class UsersComponent implements OnInit { // *********************************************************************************** updateObjectList() { - this.mds.incrementDelayedProcessesCount(); this.tableselectionCheckbox.clear(); this.tableselectionRow.clear(); this.bs.getUsers().subscribe(dataresponse => { @@ -306,7 +293,6 @@ export class UsersComponent implements OnInit { this.objectsDatasource = new MatTableDataSource(dataresponse); this.objectsDatasource.sort = this.sort; } - this.mds.decrementDelayedProcessesCount(); }); } diff --git a/src/app/superadmin/workspaces/workspaces.component.ts b/src/app/superadmin/workspaces/workspaces.component.ts index 751de16f1ae04538e60b918f1f0f81cf8f3832f8..7f908b61648e37fe75ccf75427097978e6afbd46 100644 --- a/src/app/superadmin/workspaces/workspaces.component.ts +++ b/src/app/superadmin/workspaces/workspaces.component.ts @@ -73,7 +73,6 @@ export class WorkspacesComponent implements OnInit { dialogRef.afterClosed().subscribe(result => { if (typeof result !== 'undefined') { if (result !== false) { - this.mds.incrementDelayedProcessesCount(); this.bs.addWorkspace((<FormGroup>result).get('name').value).subscribe( respOk => { if (respOk !== false) { @@ -82,7 +81,6 @@ export class WorkspacesComponent implements OnInit { } else { this.snackBar.open('Konnte Arbeitsbereich nicht hinzufügen', 'Fehler', {duration: 1000}); } - this.mds.decrementDelayedProcessesCount(); }); } } @@ -112,7 +110,6 @@ export class WorkspacesComponent implements OnInit { dialogRef.afterClosed().subscribe(result => { if (typeof result !== 'undefined') { if (result !== false) { - this.mds.incrementDelayedProcessesCount(); this.bs.renameWorkspace(selectedRows[0].id, (<FormGroup>result).get('name').value).subscribe( respOk => { @@ -122,7 +119,6 @@ export class WorkspacesComponent implements OnInit { } else { this.snackBar.open('Konnte Arbeitsbereich nicht ändern', 'Fehler', {duration: 2000}); } - this.mds.decrementDelayedProcessesCount(); }); } } @@ -164,7 +160,6 @@ export class WorkspacesComponent implements OnInit { dialogRef.afterClosed().subscribe(result => { if (result !== false) { // ========================================================= - this.mds.incrementDelayedProcessesCount(); const workspacesToDelete = []; selectedRows.forEach((r: IdAndName) => workspacesToDelete.push(r.id)); this.bs.deleteWorkspaces(workspacesToDelete).subscribe( @@ -175,7 +170,6 @@ export class WorkspacesComponent implements OnInit { } else { this.snackBar.open('Konnte Arbeitsbereich/e nicht löschen', 'Fehler', {duration: 1000}); } - this.mds.decrementDelayedProcessesCount(); }); } }); @@ -186,10 +180,8 @@ export class WorkspacesComponent implements OnInit { updateUserList() { this.pendingUserChanges = false; if (this.selectedWorkspaceId > 0) { - this.mds.incrementDelayedProcessesCount(); this.bs.getUsersByWorkspace(this.selectedWorkspaceId).subscribe(dataresponse => { this.UserlistDatasource = new MatTableDataSource(dataresponse); - this.mds.decrementDelayedProcessesCount(); }); } else { this.UserlistDatasource = null; @@ -208,7 +200,6 @@ export class WorkspacesComponent implements OnInit { saveUsers() { this.pendingUserChanges = false; if (this.selectedWorkspaceId > 0) { - this.mds.incrementDelayedProcessesCount(); this.bs.setUsersByWorkspace(this.selectedWorkspaceId, this.UserlistDatasource.data).subscribe( respOk => { if (respOk !== false) { @@ -216,7 +207,6 @@ export class WorkspacesComponent implements OnInit { } else { this.snackBar.open('Konnte Zugriffsrechte nicht ändern', 'Fehler', {duration: 2000}); } - this.mds.decrementDelayedProcessesCount(); }); } else { this.UserlistDatasource = null; @@ -225,13 +215,11 @@ export class WorkspacesComponent implements OnInit { // *********************************************************************************** updateObjectList() { - this.mds.incrementDelayedProcessesCount(); this.bs.getWorkspaces().subscribe(dataresponse => { this.objectsDatasource = new MatTableDataSource(dataresponse); this.objectsDatasource.sort = this.sort; this.tableselectionCheckbox.clear(); this.tableselectionRow.clear(); - this.mds.decrementDelayedProcessesCount(); }); } diff --git a/src/app/sys-check/network-check/network-check.component.ts b/src/app/sys-check/network-check/network-check.component.ts index e6998619741bd3d69f2ea77760be8262f1e6f9d7..ed20b077be6e08396aba4490c45e75ae4baecb88 100644 --- a/src/app/sys-check/network-check/network-check.component.ts +++ b/src/app/sys-check/network-check/network-check.component.ts @@ -78,9 +78,7 @@ export class NetworkCheckComponent implements OnInit { avgDownloadSpeedBytesPerSecond: -1 }; - console.log('start the loop: '); - const myConfig = this.ds.checkConfig$.getValue(); - console.log(myConfig); + // ?? const myConfig = this.ds.checkConfig$.getValue(); this.plotPrepare(true); this.plotPrepare(false); @@ -131,8 +129,6 @@ export class NetworkCheckComponent implements OnInit { .then(results => { const averageBytesPerSecond = NetworkCheckComponent.calculateAverageSpeedBytePerSecond(results); const averageOfPreviousLoops = this.getAverageNetworkStat(isDownloadPart); - - console.log({type: isDownloadPart ? 'download' : 'upload', results: results, avg: averageBytesPerSecond}); const errors = results.reduce((a, r) => a + ((r.error !== null) ? 1 : 0), 0); let statsLength; if (isDownloadPart) { @@ -145,12 +141,12 @@ export class NetworkCheckComponent implements OnInit { this.showBenchmarkSequenceResults(isDownloadPart, this.getAverageNetworkStat(isDownloadPart), results); if (errors > benchmarkDefinition.maxErrorsPerSequence) { - console.warn('some errors occurred', results); + console.warn('network check: some errors occurred during', results); return reject(errors); } if (statsLength > benchmarkDefinition.maxSequenceRepetitions) { - console.warn(`looped ${benchmarkDefinition.maxSequenceRepetitions} times, but could not get reliable average`); + console.warn(`network check: looped ${benchmarkDefinition.maxSequenceRepetitions} times, but could not get reliable average`); return resolve(); } @@ -189,8 +185,6 @@ export class NetworkCheckComponent implements OnInit { private benchmark(isDownloadPart: boolean, requestSize: number): Promise<NetworkRequestTestResult> { - - // console.log(`run benchmark ${benchmarkType} for ${requestSize}`); const testRound = (isDownloadPart) ? (this.networkStatsDownload.length + 1) : (this.networkStatsUpload.length + 1); const testPackage = this.humanReadableBytes(requestSize); if (isDownloadPart) { @@ -295,7 +289,6 @@ export class NetworkCheckComponent implements OnInit { avgDownloadSpeed: this.getAverageNetworkStat(true), avgUploadSpeed: this.getAverageNetworkStat(false), }; - console.log('measured averages', nd); // the ratings are calculated individually, by a "how low can you go" approach @@ -331,7 +324,6 @@ export class NetworkCheckComponent implements OnInit { private getBrowsersNativeNetworkInformation() { const connection = navigator['connection'] || navigator['mozConnection'] || navigator['webkitConnection']; - console.log('connection', connection); if (connection) { this.detectedNetworkInformations = { available: true, diff --git a/src/app/sys-check/sys-check.component.ts b/src/app/sys-check/sys-check.component.ts index 700a3431b0438d5ca4e845dcc0d57f7363f3f7f4..2c8b26d90bd735a900a0e355607a744f89920d30 100644 --- a/src/app/sys-check/sys-check.component.ts +++ b/src/app/sys-check/sys-check.component.ts @@ -38,7 +38,6 @@ export class SysCheckComponent implements OnInit, OnDestroy { const sysCheckName = params.get('sys-check-name'); const workspaceId = parseInt(params.get('workspace-id')); setTimeout(() => { - this.mds.incrementDelayedProcessesCount(); this.loading = true; this.bs.getCheckConfigData(workspaceId, sysCheckName).subscribe(checkConfig => { this.ds.checkConfig$.next(checkConfig); @@ -65,13 +64,9 @@ export class SysCheckComponent implements OnInit, OnDestroy { this.ds.nextTask(); this.taskSubscription = this.ds.task$.subscribe(task => { this.loading = (typeof task !== 'undefined') && (this.ds.taskQueue.length > 0); - if (!this.loading) { - this.mds.decrementDelayedProcessesCount(); - } }); this.isError = false; } else { - this.mds.decrementDelayedProcessesCount(); this.title = 'Fehler beim Laden der Daten für den System-Check'; this.loading = false; this.isError = true; diff --git a/src/app/workspace-admin/backend.service.spec.ts b/src/app/workspace-admin/backend.service.spec.ts index ffdc1397ca5ced3a08516d7183bbc820c1001627..7d5789ab6b2884621c702ca26fb5d3dc8b8f9f62 100644 --- a/src/app/workspace-admin/backend.service.spec.ts +++ b/src/app/workspace-admin/backend.service.spec.ts @@ -2,13 +2,16 @@ import { TestBed, inject } from '@angular/core/testing'; import { BackendService } from './backend.service'; import {HttpClientModule} from "@angular/common/http"; +import {WorkspaceDataService} from "./workspacedata.service"; describe('HttpClient testing', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientModule], - providers: [BackendService] + providers: [ + BackendService, + WorkspaceDataService] }); }); it('should be created', inject([BackendService], (service: BackendService) => { diff --git a/src/app/workspace-admin/files/files.component.ts b/src/app/workspace-admin/files/files.component.ts index 767a8c0871f6479372cc1d81c8ff44b5153e2d24..6bda73131f3213e3fbf5cfb3f887ab94bc6af10a 100644 --- a/src/app/workspace-admin/files/files.component.ts +++ b/src/app/workspace-admin/files/files.component.ts @@ -89,7 +89,6 @@ export class FilesComponent implements OnInit { dialogRef.afterClosed().subscribe(result => { if (result !== false) { // ========================================================= - this.mds.incrementDelayedProcessesCount(); this.bs.deleteFiles(filesToDelete).subscribe((fileDeletionReport: FileDeletionReport|ServerError) => { if (fileDeletionReport instanceof ServerError) { this.mds.appError$.next({ @@ -108,7 +107,6 @@ export class FilesComponent implements OnInit { this.snackBar.open(message.join('<br>'), message.length > 1 ? 'Achtung' : '', {duration: 1000}); this.updateFileList(); } - this.mds.decrementDelayedProcessesCount(); }); // ========================================================= } @@ -135,19 +133,16 @@ export class FilesComponent implements OnInit { if (empty || this.wds.wsRole === 'MO') { this.serverfiles = new MatTableDataSource([]); } else { - this.mds.incrementDelayedProcessesCount(); this.bs.getFiles().subscribe( (filedataresponse: GetFileResponseData[]) => { this.serverfiles = new MatTableDataSource(filedataresponse); this.serverfiles.sort = this.sort; - this.mds.decrementDelayedProcessesCount(); }, (err: ServerError) => { this.mds.appError$.next({ label: err.labelNice, description: err.labelSystem, category: "PROBLEM" }); - this.mds.decrementDelayedProcessesCount(); } ); } @@ -156,7 +151,6 @@ export class FilesComponent implements OnInit { download(element: GetFileResponseData): void { - this.mds.incrementDelayedProcessesCount(); this.bs.downloadFile(element.type, element.filename) .subscribe( (fileData: Blob|ServerError) => { @@ -166,10 +160,8 @@ export class FilesComponent implements OnInit { description: (fileData as ServerError).labelSystem, category: "PROBLEM" }); - this.mds.decrementDelayedProcessesCount(); } else { saveAs(fileData, element.filename); - this.mds.decrementDelayedProcessesCount(); } } ); @@ -181,20 +173,17 @@ export class FilesComponent implements OnInit { this.checkWarnings = []; this.checkInfos = []; - this.mds.incrementDelayedProcessesCount(); this.bs.checkWorkspace().subscribe( (checkResponse: CheckWorkspaceResponseData) => { this.checkErrors = checkResponse.errors; this.checkWarnings = checkResponse.warnings; this.checkInfos = checkResponse.infos; - this.mds.decrementDelayedProcessesCount(); }, (err: ServerError) => { this.mds.appError$.next({ label: err.labelNice, description: err.labelSystem, category: "PROBLEM" }); - this.mds.decrementDelayedProcessesCount(); } ); } diff --git a/src/app/workspace-admin/results/results.component.ts b/src/app/workspace-admin/results/results.component.ts index 87c2a28bf5e624ab815069135547688fffa3da36..3af6bbc3e49170bf8df30f3fa95e77f2cdfb9351 100644 --- a/src/app/workspace-admin/results/results.component.ts +++ b/src/app/workspace-admin/results/results.component.ts @@ -44,10 +44,8 @@ export class ResultsComponent implements OnInit { if (this.wds.wsRole === 'MO') { this.resultDataSource = new MatTableDataSource<ResultData>([]); } else { - this.mds.incrementDelayedProcessesCount(); this.bs.getResultData().subscribe( (resultData: ResultData[]) => { - this.mds.decrementDelayedProcessesCount(); this.resultDataSource = new MatTableDataSource<ResultData>(resultData); this.resultDataSource.sort = this.sort; }, (err: ServerError) => { @@ -56,7 +54,6 @@ export class ResultsComponent implements OnInit { description: err.labelSystem, category: "PROBLEM" }); - this.mds.decrementDelayedProcessesCount(); } ); } @@ -77,7 +74,6 @@ export class ResultsComponent implements OnInit { // 444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 downloadResponsesCSV() { if (this.tableselectionCheckbox.selected.length > 0) { - this.mds.incrementDelayedProcessesCount(); const selectedGroups: string[] = []; this.tableselectionCheckbox.selected.forEach(element => { selectedGroups.push(element.groupname); @@ -132,14 +128,12 @@ export class ResultsComponent implements OnInit { this.snackBar.open('Keine Daten verfügbar.', 'Fehler', {duration: 3000}); } this.tableselectionCheckbox.clear(); - this.mds.decrementDelayedProcessesCount(); }, (err: ServerError) => { this.mds.appError$.next({ label: err.labelNice, description: err.labelSystem, category: "PROBLEM" }); - this.mds.decrementDelayedProcessesCount(); }); } } @@ -147,7 +141,6 @@ export class ResultsComponent implements OnInit { // 444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 downloadReviewsCSV() { if (this.tableselectionCheckbox.selected.length > 0) { - this.mds.incrementDelayedProcessesCount(); const selectedGroups: string[] = []; this.tableselectionCheckbox.selected.forEach(element => { selectedGroups.push(element.groupname); @@ -201,14 +194,12 @@ export class ResultsComponent implements OnInit { this.snackBar.open('Keine Daten verfügbar.', 'Fehler', {duration: 3000}); } this.tableselectionCheckbox.clear(); - this.mds.decrementDelayedProcessesCount(); }, (err: ServerError) => { this.mds.appError$.next({ label: err.labelNice, description: err.labelSystem, category: "PROBLEM" }); - this.mds.decrementDelayedProcessesCount(); }); } } @@ -216,7 +207,6 @@ export class ResultsComponent implements OnInit { // 444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 downloadLogsCSV() { if (this.tableselectionCheckbox.selected.length > 0) { - this.mds.incrementDelayedProcessesCount(); const selectedGroups: string[] = []; this.tableselectionCheckbox.selected.forEach(element => { selectedGroups.push(element.groupname); @@ -242,14 +232,12 @@ export class ResultsComponent implements OnInit { this.snackBar.open('Keine Daten verfügbar.', 'Fehler', {duration: 3000}); } this.tableselectionCheckbox.clear(); - this.mds.decrementDelayedProcessesCount(); }, (err: ServerError) => { this.mds.appError$.next({ label: err.labelNice, description: err.labelSystem, category: "PROBLEM" }); - this.mds.decrementDelayedProcessesCount(); }); } } @@ -281,10 +269,8 @@ export class ResultsComponent implements OnInit { dialogRef.afterClosed().subscribe(result => { if (result !== false) { // ========================================================= - this.mds.incrementDelayedProcessesCount(); this.bs.deleteData(selectedGroups).subscribe(() => { this.tableselectionCheckbox.clear(); - this.mds.decrementDelayedProcessesCount(); // TODO refresh list! }, (err: ServerError) => { this.mds.appError$.next({ @@ -292,7 +278,6 @@ export class ResultsComponent implements OnInit { description: err.labelSystem, category: "PROBLEM" }); - this.mds.decrementDelayedProcessesCount(); }); } }); diff --git a/src/app/workspace-admin/syscheck/syscheck.component.ts b/src/app/workspace-admin/syscheck/syscheck.component.ts index 5a63d9fb2502923ee40230b2e32c0a6de0290d47..503a85051904d79a599907eb636a0a6411af2727 100644 --- a/src/app/workspace-admin/syscheck/syscheck.component.ts +++ b/src/app/workspace-admin/syscheck/syscheck.component.ts @@ -38,11 +38,9 @@ export class SyscheckComponent implements OnInit { } updateTable() { - this.mds.incrementDelayedProcessesCount(); this.tableselectionCheckbox.clear(); this.bs.getSysCheckReportList().subscribe( (resultData: SysCheckStatistics[]) => { - this.mds.decrementDelayedProcessesCount(); this.resultDataSource = new MatTableDataSource<SysCheckStatistics>(resultData); this.resultDataSource.sort = this.sort; }, (err: ServerError) => { @@ -51,7 +49,6 @@ export class SyscheckComponent implements OnInit { description: err.labelSystem, category: "PROBLEM" }); - this.mds.decrementDelayedProcessesCount(); } ); } @@ -71,7 +68,6 @@ export class SyscheckComponent implements OnInit { downloadReportsCSV() { if (this.tableselectionCheckbox.selected.length > 0) { - this.mds.incrementDelayedProcessesCount(); const selectedReports: string[] = []; this.tableselectionCheckbox.selected.forEach(element => { selectedReports.push(element.id); @@ -85,14 +81,12 @@ export class SyscheckComponent implements OnInit { this.snackBar.open('Keine Daten verfügbar.', 'Fehler', {duration: 3000}); } this.tableselectionCheckbox.clear(); - this.mds.decrementDelayedProcessesCount(); }, (err: ServerError) => { this.mds.appError$.next({ label: err.labelNice, description: err.labelSystem, category: "PROBLEM" }); - this.mds.decrementDelayedProcessesCount(); }); } } @@ -123,7 +117,6 @@ export class SyscheckComponent implements OnInit { dialogRef.afterClosed().subscribe(result => { if (result !== false) { - this.mds.incrementDelayedProcessesCount(); this.bs.deleteSysCheckReports(selectedReports).subscribe((fileDeletionReport) => { if (fileDeletionReport instanceof ServerError) { this.mds.appError$.next({ @@ -131,7 +124,6 @@ export class SyscheckComponent implements OnInit { description: (fileDeletionReport as ServerError).labelSystem, category: "PROBLEM" }); - this.mds.decrementDelayedProcessesCount(); } else { const message = []; if (fileDeletionReport.deleted.length > 0) { @@ -142,7 +134,6 @@ export class SyscheckComponent implements OnInit { } this.snackBar.open(message.join('<br>'), message.length > 1 ? 'Achtung' : '', {duration: 1000}); this.updateTable(); - this.mds.decrementDelayedProcessesCount(); } }); }