[Library | Trunk]: Revert role-users. Add canActivateChild on connect guards
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60540 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
24f3f8fe82
commit
03780a4112
|
@ -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> | boolean {
|
||||
return this.check(route.queryParams['communityId'], state.url);
|
||||
return this.check(route.params['community'], state.url);
|
||||
}
|
||||
|
||||
canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
||||
return this.check(childRoute.params['community'], state.url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,7 +32,12 @@ export class ConnectRIGuard implements CanActivate, CanLoad {
|
|||
}
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | 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<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
||||
let community = childRoute.params['community'];
|
||||
return community && this.check(community);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <b>sent</b> 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 <b>sent</b>', {
|
||||
status: 'success',
|
||||
timeout: 6000,
|
||||
|
|
|
@ -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]
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue