aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app/app-routing.module.ts2
-rw-r--r--src/app/app.module.ts67
-rw-r--r--src/app/guards/auth.guard.ts4
-rw-r--r--src/app/guards/edit-user.can-activate.guard.ts4
-rw-r--r--src/app/guards/has-permissions.guard.ts4
-rw-r--r--src/app/helpers/helpers.ts12
-rw-r--r--src/app/modules/dashboard/apps/user-last-action-tile/user-last-action-tile.component.ts4
-rw-r--r--src/app/modules/i18n/i18n.module.ts2
-rw-r--r--src/app/modules/user-administration/user-administration-form/user-administration-form.component.ts34
-rw-r--r--src/app/services/tileservice/tiles.service.ts14
-rw-r--r--src/app/services/user-settings.service.ts14
-rw-r--r--src/test.ts15
12 files changed, 81 insertions, 95 deletions
diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index 0f5a50e..d4e4d7c 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -49,7 +49,7 @@ const routes: Routes = [
];
@NgModule({
- imports: [RouterModule.forRoot(routes, { relativeLinkResolution: 'legacy', onSameUrlNavigation: 'reload' })],
+ imports: [RouterModule.forRoot(routes, { onSameUrlNavigation: 'reload' })],
exports: [RouterModule],
})
export class AppRoutingModule {}
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index faeb566..854c8fc 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -65,39 +65,38 @@ export function changeConfig() {
}
@NgModule({
- declarations: [
- AppComponent,
- HeaderComponent,
- ModalContentComponent,
- SidemenuComponent,
- PageNotFoundComponent,
- ConfirmationModalComponent,
- StatusPageComponent,
- ],
- imports: [
- BrowserModule,
- AppRoutingModule,
- HttpClientModule,
- AuthConfigModule,
- AlertModule,
- AuthConfigModule,
- ApiModule.forRoot(changeConfig),
- OAuthModule.forRoot({ resourceServer: { sendAccessToken: false } }),
- BrowserAnimationsModule,
- UserAdministrationModule,
- DashboardModule,
- SharedModule,
- AppStarterModule,
- ],
- // { provide: ErrorHandler, useClass: SentryErrorHandler },
- providers: [
- { provide: RequestCache, useClass: RequestCacheService },
- httpInterceptorProviders,
- { provide: OAuthStorage, useValue: localStorage },
- LoadingIndicatorService,
- { provide: RouteReuseStrategy, useClass: AppRouteReuseStrategy },
- ],
- bootstrap: [AppComponent],
- entryComponents: [ModalContentComponent, ConfirmationModalComponent],
+ declarations: [
+ AppComponent,
+ HeaderComponent,
+ ModalContentComponent,
+ SidemenuComponent,
+ PageNotFoundComponent,
+ ConfirmationModalComponent,
+ StatusPageComponent,
+ ],
+ imports: [
+ BrowserModule,
+ AppRoutingModule,
+ HttpClientModule,
+ AuthConfigModule,
+ AlertModule,
+ AuthConfigModule,
+ ApiModule.forRoot(changeConfig),
+ OAuthModule.forRoot({ resourceServer: { sendAccessToken: false } }),
+ BrowserAnimationsModule,
+ UserAdministrationModule,
+ DashboardModule,
+ SharedModule,
+ AppStarterModule,
+ ],
+ // { provide: ErrorHandler, useClass: SentryErrorHandler },
+ providers: [
+ { provide: RequestCache, useClass: RequestCacheService },
+ httpInterceptorProviders,
+ { provide: OAuthStorage, useValue: localStorage },
+ LoadingIndicatorService,
+ { provide: RouteReuseStrategy, useClass: AppRouteReuseStrategy },
+ ],
+ bootstrap: [AppComponent]
})
export class AppModule {}
diff --git a/src/app/guards/auth.guard.ts b/src/app/guards/auth.guard.ts
index 54ede0f..645819c 100644
--- a/src/app/guards/auth.guard.ts
+++ b/src/app/guards/auth.guard.ts
@@ -18,7 +18,7 @@
import { Injectable } from '@angular/core';
-import { CanActivate, UrlTree } from '@angular/router';
+import { UrlTree } from '@angular/router';
import { Observable } from 'rxjs';
import { AuthService } from '../services/auth.service';
@@ -28,7 +28,7 @@ import { AuthService } from '../services/auth.service';
@Injectable({
providedIn: 'root',
})
-export class AuthGuard implements CanActivate {
+export class AuthGuard {
roles: string = '';
constructor(private authService: AuthService) {}
diff --git a/src/app/guards/edit-user.can-activate.guard.ts b/src/app/guards/edit-user.can-activate.guard.ts
index 81fc36e..29c927a 100644
--- a/src/app/guards/edit-user.can-activate.guard.ts
+++ b/src/app/guards/edit-user.can-activate.guard.ts
@@ -18,7 +18,7 @@
import { Injectable } from '@angular/core';
-import { ActivatedRouteSnapshot, CanActivate, Router } from '@angular/router';
+import { ActivatedRouteSnapshot, Router } from '@angular/router';
import { Observable, of } from 'rxjs';
import { UsersService } from '../../../openapi/output';
import { catchError, map } from 'rxjs/operators';
@@ -26,7 +26,7 @@ import { TranslateService } from '@ngx-translate/core';
@Injectable({
providedIn: 'root',
})
-export class EditUserCanActivateGuard implements CanActivate {
+export class EditUserCanActivateGuard {
constructor(private usersService: UsersService, private router: Router, private translateService: TranslateService) {}
canActivate(route: ActivatedRouteSnapshot): Observable<boolean> {
const userId = route.paramMap.get('userId');
diff --git a/src/app/guards/has-permissions.guard.ts b/src/app/guards/has-permissions.guard.ts
index cc04673..1731a33 100644
--- a/src/app/guards/has-permissions.guard.ts
+++ b/src/app/guards/has-permissions.guard.ts
@@ -18,7 +18,7 @@
import { Inject, Injectable } from '@angular/core';
-import { ActivatedRouteSnapshot, CanActivate, Router, UrlTree } from '@angular/router';
+import { ActivatedRouteSnapshot, Router, UrlTree } from '@angular/router';
import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { ACL_CONFIG, AclConfig } from '../modules/auth/injection-tokens';
@@ -29,7 +29,7 @@ import { map } from 'rxjs/operators';
@Injectable({
providedIn: 'root',
})
-export class HasPermissionsGuard implements CanActivate {
+export class HasPermissionsGuard {
constructor(
private readonly authService: AuthService,
private readonly httpClient: HttpClient,
diff --git a/src/app/helpers/helpers.ts b/src/app/helpers/helpers.ts
index 7c03dbd..6b0c486 100644
--- a/src/app/helpers/helpers.ts
+++ b/src/app/helpers/helpers.ts
@@ -17,7 +17,7 @@
*/
-import { FormArray, FormGroup } from '@angular/forms';
+import { UntypedFormArray, UntypedFormGroup } from '@angular/forms';
export function isNotUndefined<T>(val: T | undefined): val is T {
return val !== undefined;
@@ -27,7 +27,7 @@ export function isNotNull<T>(val: T | null): val is T {
return val !== null;
}
-export function markAsDirtyAndValidate(formGroup: FormGroup): void {
+export function markAsDirtyAndValidate(formGroup: UntypedFormGroup): void {
Object.values(formGroup.controls).forEach(control => {
control.markAsDirty();
control.updateValueAndValidity();
@@ -54,10 +54,10 @@ export function getRandomNumber(min: number, max: number) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
-export function areFormControlsValid(form: FormGroup): boolean {
+export function areFormControlsValid(form: UntypedFormGroup): boolean {
const formControls = Object.keys(form.controls)
.map(key => form.controls[key])
- .filter(control => !(control instanceof FormArray));
+ .filter(control => !(control instanceof UntypedFormArray));
return formControls.find(control => control.invalid && (control.dirty || control.touched)) === undefined;
}
@@ -68,9 +68,9 @@ export function isString(value: any): boolean {
export function resetSelectDefaultValue(cssSelector: string): void {
setTimeout(() => {
const element = document.querySelector(cssSelector);
- if (element) {
+ if (element && document.querySelector(cssSelector)) {
//@ts-ignore
- document.querySelector(cssSelector)?.selectedIndex = -1;
+ document.querySelector(cssSelector).selectedIndex = -1;
}
}, 0);
}
diff --git a/src/app/modules/dashboard/apps/user-last-action-tile/user-last-action-tile.component.ts b/src/app/modules/dashboard/apps/user-last-action-tile/user-last-action-tile.component.ts
index c03016f..ee477b5 100644
--- a/src/app/modules/dashboard/apps/user-last-action-tile/user-last-action-tile.component.ts
+++ b/src/app/modules/dashboard/apps/user-last-action-tile/user-last-action-tile.component.ts
@@ -61,12 +61,12 @@ export class UserLastActionTileComponent implements OnInit {
.pipe(shareReplay({ refCount: true, bufferSize: 1 }));
public actionFilterType$ = this.userActionsSettings$.pipe(
- selectDistinctState<LastUserActionSettings, ActionFilter>(STATE_KEYS.FILTER_TYPE),
+ selectDistinctState<LastUserActionSettings, ActionFilter>(STATE_KEYS.FILTER_TYPE as keyof LastUserActionSettings),
shareReplay({ refCount: true, bufferSize: 1 }),
);
public actionIntervalType$ = this.userActionsSettings$.pipe(
- selectDistinctState<LastUserActionSettings, ActionInterval>(STATE_KEYS.INTERVAL),
+ selectDistinctState<LastUserActionSettings, ActionInterval>(STATE_KEYS.INTERVAL as keyof LastUserActionSettings),
shareReplay({ refCount: true, bufferSize: 1 }),
);
diff --git a/src/app/modules/i18n/i18n.module.ts b/src/app/modules/i18n/i18n.module.ts
index 52bedbe..a6a1da6 100644
--- a/src/app/modules/i18n/i18n.module.ts
+++ b/src/app/modules/i18n/i18n.module.ts
@@ -41,7 +41,7 @@ import { TranslateHttpLoader } from '@ngx-translate/http-loader';
export class I18nModule {
constructor(translate: TranslateService) {
translate.addLangs(['en', 'de']);
- const browserLang = translate.getBrowserLang();
+ const browserLang = translate.getBrowserLang() ?? 'en';
translate.use(browserLang.match(/en|de/) ? browserLang : 'en');
}
}
diff --git a/src/app/modules/user-administration/user-administration-form/user-administration-form.component.ts b/src/app/modules/user-administration/user-administration-form/user-administration-form.component.ts
index 7df2700..2c93654 100644
--- a/src/app/modules/user-administration/user-administration-form/user-administration-form.component.ts
+++ b/src/app/modules/user-administration/user-administration-form/user-administration-form.component.ts
@@ -18,7 +18,7 @@
import { Component, OnInit } from '@angular/core';
-import { AbstractControl, FormControl, FormGroup, Validators } from '@angular/forms';
+import { AbstractControl, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';
import {
CreateUserRequest,
Role,
@@ -47,7 +47,7 @@ import { HistoryService } from '../../../services/history.service';
})
export class UserAdministrationFormComponent implements OnInit {
public readonly userId: string | null;
- public readonly keycloakUserForm: FormGroup;
+ public readonly keycloakUserForm: UntypedFormGroup;
public user: UserResponse | undefined = undefined;
public checkBoxes: {
@@ -70,17 +70,17 @@ export class UserAdministrationFormComponent implements OnInit {
) {
this.userId = this.route.snapshot.paramMap.get('userId');
- this.keycloakUserForm = new FormGroup({
- id: new FormControl({ value: null, disabled: true }),
- username: new FormControl({ value: null, disabled: this.userId !== null }, [
+ this.keycloakUserForm = new UntypedFormGroup({
+ id: new UntypedFormControl({ value: null, disabled: true }),
+ username: new UntypedFormControl({ value: null, disabled: this.userId !== null }, [
Validators.required,
Validators.maxLength(50),
Validators.pattern(VALIDATION_PATTERN),
Validators.pattern(NON_WHITE_SPACE_PATTERN),
]),
- email: new FormControl(null, [Validators.email, Validators.required, Validators.pattern(VALIDATION_PATTERN)]),
- firstName: new FormControl(null, [Validators.pattern(VALIDATION_PATTERN)]),
- lastName: new FormControl(null, [Validators.pattern(VALIDATION_PATTERN)]),
+ email: new UntypedFormControl(null, [Validators.email, Validators.required, Validators.pattern(VALIDATION_PATTERN)]),
+ firstName: new UntypedFormControl(null, [Validators.pattern(VALIDATION_PATTERN)]),
+ lastName: new UntypedFormControl(null, [Validators.pattern(VALIDATION_PATTERN)]),
});
}
@@ -121,20 +121,20 @@ export class UserAdministrationFormComponent implements OnInit {
}
}
- get userName(): FormControl {
- return this.keycloakUserForm.get('username') as FormControl;
+ get userName(): UntypedFormControl {
+ return this.keycloakUserForm.get('username') as UntypedFormControl;
}
- get email(): FormControl {
- return this.keycloakUserForm.get('email') as FormControl;
+ get email(): UntypedFormControl {
+ return this.keycloakUserForm.get('email') as UntypedFormControl;
}
- get firstName(): FormControl {
- return this.keycloakUserForm.get('firstName') as FormControl;
+ get firstName(): UntypedFormControl {
+ return this.keycloakUserForm.get('firstName') as UntypedFormControl;
}
- get lastName(): FormControl {
- return this.keycloakUserForm.get('lastName') as FormControl;
+ get lastName(): UntypedFormControl {
+ return this.keycloakUserForm.get('lastName') as UntypedFormControl;
}
public onSubmit(): void {
@@ -212,7 +212,7 @@ export class UserAdministrationFormComponent implements OnInit {
private updateUserData(userResponse: Observable<UserResponse>, roleResponse: Observable<RoleListResponse>): void {
forkJoin([userResponse, roleResponse])
.pipe(
- switchMap(([,]) =>
+ switchMap(() =>
this.historyService.createUserHistoryAction({
type: ActionType.EDIT,
entity: EntityType.USERADMINISTRATION,
diff --git a/src/app/services/tileservice/tiles.service.ts b/src/app/services/tileservice/tiles.service.ts
index 167e42a..acdce5b 100644
--- a/src/app/services/tileservice/tiles.service.ts
+++ b/src/app/services/tileservice/tiles.service.ts
@@ -19,7 +19,7 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
-import { Observable } from 'rxjs';
+import { firstValueFrom, Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { Tile, TilesListResponse } from '../../model/tile';
import { map } from 'rxjs/operators';
@@ -50,8 +50,8 @@ export class TilesService {
* GET tile by id
* @param id to get specific tile
*/
- getTileById(id: number): Promise<Tile> {
- return this.httpClient.get<Tile>(urlTileApi + '/' + id).toPromise();
+ getTileById(id: number): Promise<Tile | undefined> {
+ return firstValueFrom(this.httpClient.get<Tile>(urlTileApi + '/' + id));
}
/**
@@ -59,11 +59,11 @@ export class TilesService {
* @param tile
* @returns the new saved tile
*/
- saveTiles(tile: Tile): Promise<Tile> {
+ saveTiles(tile: Tile): Promise<Tile | undefined> {
const options = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
};
- return this.httpClient.post<Tile>(urlTileApi, tile, options).toPromise();
+ return firstValueFrom(this.httpClient.post<Tile>(urlTileApi, tile, options));
}
/**
@@ -71,11 +71,11 @@ export class TilesService {
* @returns the updated hero
* @param tile
*/
- updateTiles(tile: Tile): Promise<Tile> {
+ updateTiles(tile: Tile): Promise<Tile | undefined> {
const options = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
};
- return this.httpClient.put<Tile>(urlTileApi + '/' + tile.id, tile, options).toPromise();
+ return firstValueFrom(this.httpClient.put<Tile>(urlTileApi + '/' + tile.id, tile, options));
}
/**
diff --git a/src/app/services/user-settings.service.ts b/src/app/services/user-settings.service.ts
index cbaa992..2f7e578 100644
--- a/src/app/services/user-settings.service.ts
+++ b/src/app/services/user-settings.service.ts
@@ -49,14 +49,14 @@ export class UserSettingsService {
}
selectDashboard = () =>
- this.getPreferences$().pipe(selectDistinctState<UserPreferencesModel, DashboardModel>(STATE_KEYS.DASHBOARD));
+ this.getPreferences$().pipe(selectDistinctState<UserPreferencesModel, DashboardModel>(STATE_KEYS.DASHBOARD as keyof UserPreferencesModel));
selectDashboardApps = () =>
- this.selectDashboard().pipe(selectDistinctState<DashboardModel, DashboardAppsModel>(STATE_KEYS.APPS));
+ this.selectDashboard().pipe(selectDistinctState<DashboardModel, DashboardAppsModel>(STATE_KEYS.APPS as keyof DashboardModel));
selectDashboardAvailableTiles = () =>
- this.selectDashboardApps().pipe(selectDistinctState<DashboardAppsModel, DashboardTileSettings[]>(STATE_KEYS.TILES));
+ this.selectDashboardApps().pipe(selectDistinctState<DashboardAppsModel, DashboardTileSettings[]>(STATE_KEYS.TILES as keyof DashboardAppsModel));
selectLastUserAction = () =>
this.selectDashboardApps().pipe(
- selectDistinctState<DashboardAppsModel, LastUserActionSettings>(STATE_KEYS.USER_ACTIONS),
+ selectDistinctState<DashboardAppsModel, LastUserActionSettings>(STATE_KEYS.USER_ACTIONS as keyof DashboardAppsModel),
);
getPreferences(): void {
@@ -106,6 +106,8 @@ export class UserSettingsService {
}
}
-export function selectDistinctState<T, I>(key: string): UnaryFunction<Observable<T>, Observable<I>> {
- return pipe(pluck<T, I>(key), distinctUntilChanged<I>());
+export function selectDistinctState<T, I>(key: keyof T): UnaryFunction<Observable<T>, Observable<I>> {
+ // return pipe(map(x => x[key] as I), distinctUntilChanged<I>());
+ return pipe(pluck(key), map(value => value as unknown as I), distinctUntilChanged());
+ // return pipe(pluck<T, I>(key), distinctUntilChanged<I>());
}
diff --git a/src/test.ts b/src/test.ts
index 36b9be6..c64afa3 100644
--- a/src/test.ts
+++ b/src/test.ts
@@ -23,20 +23,5 @@ import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
-declare const require: {
- context(
- path: string,
- deep?: boolean,
- filter?: RegExp,
- ): {
- keys(): string[];
- <T>(id: string): T;
- };
-};
-
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
-// Then we find all the tests.
-const context = require.context('./', true, /\.spec\.ts$/);
-// And load the modules.
-context.keys().forEach(context);