feat: tour integration

Tour Integration
This commit is contained in:
Ramveer
2022-09-02 17:03:13 +05:30
committed by GitHub
parent 52b7a3274e
commit f1be9ab5b1
119 changed files with 6360 additions and 456 deletions
@@ -1,13 +1,17 @@
/** Angular Imports */
import { Component, OnInit, ViewChild } from '@angular/core';
import { Component, OnInit, TemplateRef, ElementRef, ViewChild, AfterViewInit } from '@angular/core';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
/** rxjs Imports */
import { of } from 'rxjs';
/** Custom Services */
import { PopoverService } from '../../configuration-wizard/popover/popover.service';
import { ConfigurationWizardService } from '../../configuration-wizard/configuration-wizard.service';
/**
* Roles and Permissions component.
*/
@@ -16,7 +20,7 @@ import { of } from 'rxjs';
templateUrl: './roles-and-permissions.component.html',
styleUrls: ['./roles-and-permissions.component.scss']
})
export class RolesAndPermissionsComponent implements OnInit {
export class RolesAndPermissionsComponent implements OnInit, AfterViewInit {
/** Role data. */
roleData: any;
@@ -30,11 +34,25 @@ export class RolesAndPermissionsComponent implements OnInit {
/** Sorter for roles and permissions table. */
@ViewChild(MatSort, { static: true }) sort: MatSort;
/* Reference of add role button */
@ViewChild('buttonAddRole') buttonAddRole: ElementRef<any>;
/* Template for popovver on add role button */
@ViewChild('templateButtonAddRole') templateButtonAddRole: TemplateRef<any>;
/* Reference of roles and permission table */
@ViewChild('tableRolesandPermissions') tableRolesandPermissions: ElementRef<any>;
/* Template for roles and permission table */
@ViewChild('templateTableRolesandPermissions') templateTableRolesandPermissions: TemplateRef<any>;
/**
* Retrieves the roles data from `resolve`.
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService.
*/
constructor(private route: ActivatedRoute) {
constructor(private route: ActivatedRoute,
private router: Router,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService) {
this.route.data.subscribe(( data: { roles: any }) => {
this.roleData = data.roles;
});
@@ -72,4 +90,51 @@ export class RolesAndPermissionsComponent implements OnInit {
this.dataSource.sort = this.sort;
}
/**
* Popover function
* @param template TemplateRef<any>.
* @param target HTMLElement | ElementRef<any>.
* @param position String.
* @param backdrop Boolean.
*/
showPopover(template: TemplateRef<any>, target: HTMLElement | ElementRef<any>, position: string, backdrop: boolean): void {
setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200);
}
/**
* To show popover.
*/
ngAfterViewInit() {
if (this.configurationWizardService.showRolesandPermissionPage === true) {
setTimeout(() => {
this.showPopover(this.templateButtonAddRole, this.buttonAddRole.nativeElement, 'bottom', true);
});
}
if (this.configurationWizardService.showRolesandPermissionList === true) {
setTimeout(() => {
this.showPopover(this.templateTableRolesandPermissions, this.tableRolesandPermissions.nativeElement, 'top', true);
});
}
}
/**
* Next Step (Users) Configuration Wizard.
*/
nextStep() {
this.configurationWizardService.showRolesandPermissionPage = false;
this.configurationWizardService.showRolesandPermissionList = false;
this.configurationWizardService.showUsers = true;
this.router.navigate(['/users']);
}
/**
* Previous Step (Roles and Permission System Page) Configuration Wizard.
*/
previousStep() {
this.configurationWizardService.showRolesandPermissionPage = false;
this.configurationWizardService.showRolesandPermissionList = false;
this.configurationWizardService.showRolesandPermission = true;
this.router.navigate(['/system']);
}
}