diff --git a/connect/communityGuard/connectAdminLoginGuard.guard.ts b/connect/communityGuard/connectAdminLoginGuard.guard.ts index 9fc8d071..790f6f4a 100644 --- a/connect/communityGuard/connectAdminLoginGuard.guard.ts +++ b/connect/communityGuard/connectAdminLoginGuard.guard.ts @@ -5,7 +5,7 @@ import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, - CanLoad, Route, UrlSegment + CanLoad, Route, UrlSegment, CanActivateChild, UrlTree } from '@angular/router'; import {Observable, of, Subscription} from 'rxjs'; import {Session} from '../../login/utils/helper.class'; @@ -18,7 +18,7 @@ import {UserManagementService} from "../../services/user-management.service"; import {properties} from "../../../../environments/environment"; @Injectable() -export class ConnectAdminLoginGuard implements CanActivate { +export class ConnectAdminLoginGuard implements CanActivate, CanActivateChild { constructor(private router: Router, private propertiesService: EnvironmentSpecificService, @@ -49,6 +49,10 @@ export class ConnectAdminLoginGuard implements CanActivate { } canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | boolean { - return this.check(route.queryParams['communityId'], state.url); + return this.check(route.params['community'], state.url); + } + + canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree { + return this.check(childRoute.params['community'], state.url); } } diff --git a/connect/communityGuard/connectRIGuard.guard.ts b/connect/communityGuard/connectRIGuard.guard.ts index afede15e..7918cbde 100644 --- a/connect/communityGuard/connectRIGuard.guard.ts +++ b/connect/communityGuard/connectRIGuard.guard.ts @@ -6,7 +6,7 @@ import { ActivatedRouteSnapshot, RouterStateSnapshot, CanLoad, - Route, UrlSegment + Route, UrlSegment, CanActivateChild, UrlTree } from '@angular/router'; import {Observable, Subscription} from 'rxjs'; import {CommunityService} from '../community/community.service'; @@ -15,7 +15,7 @@ import {ConnectHelper} from '../connectHelper'; import {properties} from "../../../../environments/environment"; @Injectable() -export class ConnectRIGuard implements CanActivate, CanLoad { +export class ConnectRIGuard implements CanActivate, CanLoad, CanActivateChild { sub: Subscription = null; constructor(private router: Router, @@ -32,10 +32,15 @@ export class ConnectRIGuard implements CanActivate, CanLoad { } canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | boolean { - let community = route.params['community']?route.params['community']:route.queryParams['communityId']; + let community = route.params['community']; return community && this.check(community); } - + + canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree { + let community = childRoute.params['community']; + return community && this.check(community); + } + canLoad(route: Route, segments: UrlSegment[]): Observable | Promise | boolean { const path = '/' + route.path + document.location.search; return this.check(ConnectHelper.getCommunityFromPath(path)); diff --git a/dashboard/users/role-users/role-users.component.ts b/dashboard/users/role-users/role-users.component.ts index c8629224..be23e8c9 100644 --- a/dashboard/users/role-users/role-users.component.ts +++ b/dashboard/users/role-users/role-users.component.ts @@ -9,7 +9,6 @@ import {Role, Session, User} from "../../../login/utils/helper.class"; import {UserManagementService} from "../../../services/user-management.service"; import {Router} from "@angular/router"; import {StringUtils} from "../../../utils/string-utils.class"; -import {NotificationService} from "../../../notifications/notification.service"; declare var UIkit; @@ -54,7 +53,6 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges { constructor(private userRegistryService: UserRegistryService, private userManagementService: UserManagementService, - private notificationService: NotificationService, private router: Router, private fb: FormBuilder) { } @@ -196,21 +194,6 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges { if (!this.pending.includes(this.invited.value)) { this.pending.push(this.invited.value); } - if(this.notificationFn) { - this.subs.push(this.notificationService.sendNotification(this.notificationFn(this.name, this.invited.value, this.role, invitation)).subscribe(notification => { - UIkit.notification('A notification has been sent successfully', { - status: 'success', - timeout: 6000, - pos: 'bottom-right' - }); - }, error => { - UIkit.notification('An error has occurred. Please try again later', { - status: 'danger', - timeout: 6000, - pos: 'bottom-right' - }); - })); - } UIkit.notification(StringUtils.capitalize(this.role) + ' invitation to ' + this.selectedUser + ' has been sent', { status: 'success', timeout: 6000, diff --git a/dashboard/users/role-users/role-users.module.ts b/dashboard/users/role-users/role-users.module.ts index af01d69a..2fcc8ff6 100644 --- a/dashboard/users/role-users/role-users.module.ts +++ b/dashboard/users/role-users/role-users.module.ts @@ -10,10 +10,9 @@ import {IconsModule} from "../../../utils/icons/icons.module"; import {InputModule} from "../../../sharedComponents/input/input.module"; import {PageContentModule} from "../../sharedComponents/page-content/page-content.module"; import {SafeHtmlPipeModule} from "../../../utils/pipes/safeHTMLPipe.module"; -import {NotifyFormModule} from "../../../notifications/notify-form/notify-form.module"; @NgModule({ - imports: [CommonModule, AlertModalModule, ReactiveFormsModule, LoadingModule, IconsModule, InputModule, PageContentModule, SafeHtmlPipeModule, NotifyFormModule], + imports: [CommonModule, AlertModalModule, ReactiveFormsModule, LoadingModule, IconsModule, InputModule, PageContentModule, SafeHtmlPipeModule], declarations: [RoleUsersComponent], exports: [RoleUsersComponent] })