[Library | Trunk]: 1. FIx menu active items base on routes. 2. Add input to role verification

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59829 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2020-11-12 17:49:20 +00:00
parent bc0628d9f7
commit 57c0da003a
5 changed files with 30 additions and 13 deletions

View File

@ -48,7 +48,7 @@ export interface Option {
</mat-form-field> </mat-form-field>
</div> </div>
</ng-template> </ng-template>
<span *ngIf="formControl.errors && formControl.errors.error" class="uk-text-small uk-text-danger">{{formControl.errors.error}}</span> <span *ngIf="formControl.invalid && formControl.errors.error" class="uk-text-small uk-text-danger">{{formControl.errors.error}}</span>
<span *ngIf="warning" class="uk-text-small uk-text-warning">{{warning}}</span> <span *ngIf="warning" class="uk-text-small uk-text-warning">{{warning}}</span>
</div> </div>
</div> </div>

View File

@ -6,6 +6,9 @@ import {UserRegistryService} from "../../../services/user-registry.service";
import {EnvProperties} from "../../../utils/properties/env-properties"; import {EnvProperties} from "../../../utils/properties/env-properties";
import {properties} from "../../../../../environments/environment"; import {properties} from "../../../../../environments/environment";
import {Session} from "../../../login/utils/helper.class"; import {Session} from "../../../login/utils/helper.class";
import {UserManagementService} from "../../../services/user-management.service";
import {Router} from "@angular/router";
import {LoginErrorCodes} from "../../../login/utils/guardHelper.class";
declare var UIkit; declare var UIkit;
@ -44,11 +47,23 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
@ViewChild('createRoleModal') createRoleModal: AlertModal; @ViewChild('createRoleModal') createRoleModal: AlertModal;
constructor(private userRegistryService: UserRegistryService, constructor(private userRegistryService: UserRegistryService,
private userManagementService: UserManagementService,
private router: Router,
private fb: FormBuilder) { private fb: FormBuilder) {
} }
ngOnInit() { ngOnInit() {
this.updateLists(); this.updateLists();
this.userManagementService.getUserInfo().subscribe(user => {
if(!Session.isPortalAdministrator(user) && !Session.isCurator(this.type, user) && !Session.isManager(this.type, this.id, user)) {
this.router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_AUTHORIZED,
"redirectUrl": this.router.url
}
});
}
});
} }
ngOnChanges(changes: SimpleChanges) { ngOnChanges(changes: SimpleChanges) {
@ -129,6 +144,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
this.loadActive = true; this.loadActive = true;
this.userRegistryService.remove(this.type, this.id, this.selectedUser, this.role).subscribe(() => { this.userRegistryService.remove(this.type, this.id, this.selectedUser, this.role).subscribe(() => {
this.active = this.active.filter(user => user.email != this.selectedUser); this.active = this.active.filter(user => user.email != this.selectedUser);
this.userManagementService.updateUserInfo();
this.loadActive = false; this.loadActive = false;
this.error = null; this.error = null;
}, error => { }, error => {

View File

@ -17,10 +17,10 @@ import {AlertModal} from "../utils/modal/alert";
<span class="portal-color">Fill</span> in the <span class="portal-color">verification code</span>, sent to your <span class="portal-color">Fill</span> in the <span class="portal-color">verification code</span>, sent to your
email, to accept the invitation request. email, to accept the invitation request.
</div> </div>
<div *ngIf="!loading" class="uk-margin-medium-top uk-text-center"> <div *ngIf="!loading" class="uk-margin-medium-top uk-flex uk-flex-center">
<input [formControl]="code" class="uk-input uk-width-medium" placeholder="Write verification code" <div dashboard-input [formInput]="code" [extraLeft]="false" class="uk-width-medium" placeholder="Write verification code">
[class.uk-form-danger]="code.invalid && code.touched"> <div *ngIf="error" class="uk-text-danger uk-margin-remove uk-width-1-1">{{error}}</div>
<div *ngIf="error" class="uk-text-danger uk-margin-top">{{error}}</div> </div>
</div> </div>
<div *ngIf="loading" class="uk-margin-medium-top"> <div *ngIf="loading" class="uk-margin-medium-top">
<loading></loading> <loading></loading>
@ -42,10 +42,10 @@ import {AlertModal} from "../utils/modal/alert";
your your
email, to accept the invitation request. email, to accept the invitation request.
</div> </div>
<div *ngIf="!loading" class="uk-margin-medium-top uk-text-center"> <div *ngIf="!loading" class="uk-margin-medium-top uk-flex uk-flex-wrap uk-flex-center">
<input [formControl]="code" class="uk-input uk-width-medium" placeholder="Write verification code" <div dashboard-input [formInput]="code" [extraLeft]="false" class="uk-width-medium" placeholder="Write verification code">
[class.uk-form-danger]="code.invalid && code.touched"> <div *ngIf="error" class="uk-text-danger uk-margin-remove uk-width-1-1">{{error}}</div>
<div *ngIf="error" class="uk-text-danger uk-margin-top">{{error}}</div> </div>
</div> </div>
<div *ngIf="loading" class="uk-margin-medium-top"> <div *ngIf="loading" class="uk-margin-medium-top">
<loading></loading> <loading></loading>
@ -166,7 +166,7 @@ export class RoleVerificationComponent implements OnInit, OnDestroy {
this.error = null; this.error = null;
this.errorModal.cancelButton = false; this.errorModal.cancelButton = false;
this.errorModal.okButtonText = 'Ok'; this.errorModal.okButtonText = 'Ok';
this.errorModal.alertTitle = 'Cannot Complete Invitation'; this.errorModal.alertTitle = 'Invalid request';
this.errorModal.open(); this.errorModal.open();
} }
@ -193,7 +193,7 @@ export class RoleVerificationComponent implements OnInit, OnDestroy {
this.error = null; this.error = null;
this.subs.push(this.userManagementService.getUserInfo(false).subscribe(user => { this.subs.push(this.userManagementService.getUserInfo(false).subscribe(user => {
this.user = user; this.user = user;
this.memberModal.cancel(); this.isMember = true;
})); }));
}, error => { }, error => {
this.loading = false; this.loading = false;

View File

@ -4,9 +4,10 @@ import {RoleVerificationComponent} from "./role-verification.component";
import {AlertModalModule} from "../utils/modal/alertModal.module"; import {AlertModalModule} from "../utils/modal/alertModal.module";
import {ReactiveFormsModule} from "@angular/forms"; import {ReactiveFormsModule} from "@angular/forms";
import {LoadingModule} from "../utils/loading/loading.module"; import {LoadingModule} from "../utils/loading/loading.module";
import {InputModule} from "../dashboard/sharedComponents/input/input.module";
@NgModule({ @NgModule({
imports: [CommonModule, AlertModalModule, ReactiveFormsModule, LoadingModule], imports: [CommonModule, AlertModalModule, ReactiveFormsModule, LoadingModule, InputModule],
declarations: [RoleVerificationComponent], declarations: [RoleVerificationComponent],
exports: [RoleVerificationComponent] exports: [RoleVerificationComponent]
}) })

View File

@ -38,7 +38,7 @@ export class MenuItem {
if (!menu.markAsActive) { if (!menu.markAsActive) {
return false; return false;
} }
if (menu.route.length > 0 && (currentRoute == menu.route || currentRoute.indexOf(menu.route) != -1)) { if (menu.route.length > 0 && (currentRoute == menu.route)) {
return true; return true;
} else if (menu.items.length > 0) { } else if (menu.items.length > 0) {
for (let menuItem of menu.items) { for (let menuItem of menu.items) {