Skip to content

Commit

Permalink
Merge pull request #349 from rahulramakrishnan3/release-2.6.0
Browse files Browse the repository at this point in the history
Release 2.6.0
  • Loading branch information
kiranharidas187 authored Jan 19, 2024
2 parents 320f268 + 4896131 commit e56f79f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
44 changes: 43 additions & 1 deletion src/app/core/guards/permission/permission.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,60 @@
import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { PermissionService } from '../../services/permission/permission.service';
import { UtilService } from '../../services';
import { TranslateService } from '@ngx-translate/core';
import { AlertController } from '@ionic/angular';
import { Location } from '@angular/common';

@Injectable({
providedIn: 'root',
})
export class PermissionGuard implements CanActivate {
constructor(private permissionService: PermissionService) {}
isMobile: boolean;
constructor(
private permissionService: PermissionService,
private utilService: UtilService,
private translate: TranslateService,
private alert: AlertController,
private _location: Location,
) {
this.isMobile = utilService.isMobile()
}

canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
): boolean {
const permissions = route.data.permissions ? route.data.permissions : {};
(permissions && this.isMobile) ? this.portalOnlyAlert(): '';
return this.permissionService.hasPermission(permissions);
}

async portalOnlyAlert(){
let texts: any;
this.translate
.get(['OK', 'PORTAL_ONLY_TOAST_MESSAGE'])
.subscribe((text) => {
texts = text;
});
const alert = await this.alert.create({
message: texts['PORTAL_ONLY_TOAST_MESSAGE'],
buttons: [
{
text: texts['OK'],
role: 'cancel',
cssClass: 'alert-button-red',
handler: () => {
},
},
],
backdropDismiss: false
});
await alert.present();
let data = await alert.onDidDismiss();
if (data.role == 'cancel') {
this._location.back()
}
return false;
}
}
1 change: 1 addition & 0 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@
"SEARCH_RESULT_NOT_FOUND":"Search result not found",
"THIS_SPACE_LOOKS_EMPTY":"This space looks empty",
"SSESSIONS_MENTOR_SEARCH_PLACEHOLDER":"Search for sessions,mentors",
"PORTAL_ONLY_TOAST_MESSAGE": "Portal is recommended for administrative tasks",
"APPLY":"Apply",
"VIEW":"View"
}

0 comments on commit e56f79f

Please sign in to comment.