From 67f88342c83167791ed3acb4f1344fcba2e5ef4c Mon Sep 17 00:00:00 2001 From: "surendar.m@watermelon.us" Date: Tue, 14 Mar 2023 12:16:20 +0530 Subject: [PATCH] routing --- ng-seed/src/app/app.module.ts | 4 +- ng-seed/src/app/app.routing.ts | 24 ++++- .../appoinment/appoinment-routing.module.ts | 77 ++++++++-------- .../appoinments/appoinments-routing.module.ts | 13 ++- .../business-list/business-list.component.ts | 6 +- .../business/business-routing.module.ts | 13 ++- .../consultants/consultants-routing.module.ts | 13 ++- .../customers/customers-routing.module.ts | 13 ++- .../service-list-routing.module.ts | 13 ++- .../appoinment/user/user-routing.module.ts | 14 ++- .../app/dashboard/dashboard.component.html | 7 -- .../layouts/admin/admin-layout.component.ts | 6 +- .../app/layouts/role-menu-items.pipe.spec.ts | 8 ++ .../src/app/layouts/role-menu-items.pipe.ts | 52 +++++++++++ .../menu-items/horizontal-menu-items.ts | 84 +++++++++++++---- .../src/app/shared/menu-items/menu-items.ts | 92 +++++++------------ 16 files changed, 303 insertions(+), 136 deletions(-) create mode 100644 ng-seed/src/app/layouts/role-menu-items.pipe.spec.ts create mode 100644 ng-seed/src/app/layouts/role-menu-items.pipe.ts diff --git a/ng-seed/src/app/app.module.ts b/ng-seed/src/app/app.module.ts index 1564658..89a48c0 100644 --- a/ng-seed/src/app/app.module.ts +++ b/ng-seed/src/app/app.module.ts @@ -37,6 +37,7 @@ import { MatFormFieldModule } from '@angular/material/form-field'; import { TokenInterceptor } from './_guard/token.interceptor'; import { SessionService } from './session-services/session.service'; import { AppointmentService } from './appoinment/appointment.service'; +import { RoleMenuItemsPipe } from './layouts/role-menu-items.pipe'; export function HttpLoaderFactory(http: HttpClient) { @@ -56,7 +57,8 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = { AppComponent, AdminLayoutComponent, AuthLayoutComponent, - ProgressSpineerDialogComponent + ProgressSpineerDialogComponent, + RoleMenuItemsPipe ], imports: [ DemoMaterialModule, diff --git a/ng-seed/src/app/app.routing.ts b/ng-seed/src/app/app.routing.ts index d5c57a3..b6579ef 100644 --- a/ng-seed/src/app/app.routing.ts +++ b/ng-seed/src/app/app.routing.ts @@ -15,8 +15,28 @@ export const AppRoutes: Routes = [{ loadChildren: () => import('./dashboard/dashboard.module').then(m => m.DashboardModule) }, { - path: 'appoinment', - loadChildren: () => import('./appoinment/appoinment.module').then(m => m.AppoinmentModule) + path: 'appoinments', + loadChildren: () => import('./appoinment/appoinments/appoinments.module').then(m => m.AppoinmentsModule) + }, + { + path: 'service', + loadChildren: () => import('./appoinment/service-list-details/service-list.module').then(m => m.ServiceListModule) + }, + { + path: 'users', + loadChildren: () => import('./appoinment/user/user.module').then(m => m.UserModule) + }, + { + path: 'consultants', + loadChildren: () => import('./appoinment/consultants/consultants.module').then(m => m.ConsultantsModule) + }, + { + path: 'customers', + loadChildren: () => import('./appoinment/customers/customers.module').then(m => m.CustomersModule) + }, + { + path: 'business', + loadChildren: () => import('./appoinment/business/business.module').then(m => m.BusinessModule) }, ] }, { diff --git a/ng-seed/src/app/appoinment/appoinment-routing.module.ts b/ng-seed/src/app/appoinment/appoinment-routing.module.ts index c9c0c6a..0119427 100644 --- a/ng-seed/src/app/appoinment/appoinment-routing.module.ts +++ b/ng-seed/src/app/appoinment/appoinment-routing.module.ts @@ -12,46 +12,51 @@ import { } from './service-list-details/service-list/service-list.component' import { ConsultantsListComponent } from './consultants/consultants-list/consultants-list.component'; -const routes: Routes = [{ - path: 'add-business-list', - component: AddBusinessListComponent -}, -{ - path: 'business-list', - component: BusinessListComponent -}, -{ - path: 'add-user-list', - component: AddUserListComponent -}, -{ - path: 'user-list', - component: UserListComponent -}, -{ - path: 'appoinments-list', - component: AppoinmentsListComponent -}, -{ - path: 'customers-list', - component: CustomersListComponent -}, +const routes: Routes = [ +// { +// path:'', +// redirectTo:'', +// pathMatch:'full' +// },{ +// path: 'add-business-list', +// component: AddBusinessListComponent +// }, +// { +// path: 'business-list', +// component: BusinessListComponent +// }, +// { +// path: 'add-user-list', +// component: AddUserListComponent +// }, +// { +// path: 'user-list', +// component: UserListComponent +// }, +// { +// path: 'appoinments-list', +// component: AppoinmentsListComponent +// }, +// { +// path: 'customers-list', +// component: CustomersListComponent +// }, +// // { +// // path: 'calendar-list', +// // component: CalendarListComponent +// // }, // { // path: 'calendar-list', // component: CalendarListComponent // }, -{ - path: 'calendar-list', - component: CalendarListComponent -}, -{ - path: 'services-list', - component: ServiceListComponent -}, -{ - path: 'consultants-list', - component: ConsultantsListComponent -} +// { +// path: 'services-list', +// component: ServiceListComponent +// }, +// { +// path: 'consultants-list', +// component: ConsultantsListComponent +// } ]; diff --git a/ng-seed/src/app/appoinment/appoinments/appoinments-routing.module.ts b/ng-seed/src/app/appoinment/appoinments/appoinments-routing.module.ts index 253a6bb..d17286b 100644 --- a/ng-seed/src/app/appoinment/appoinments/appoinments-routing.module.ts +++ b/ng-seed/src/app/appoinment/appoinments/appoinments-routing.module.ts @@ -1,7 +1,18 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; +import { AppoinmentsListComponent } from './appoinments-list/appoinments-list.component'; -const routes: Routes = []; +const routes: Routes = [ + { + path:'', + redirectTo:'appoinment/appoinments', + pathMatch:'full' + }, + { + path:'appoinment/appoinments', + component:AppoinmentsListComponent + }, +]; @NgModule({ imports: [RouterModule.forChild(routes)], diff --git a/ng-seed/src/app/appoinment/business/business-list/business-list.component.ts b/ng-seed/src/app/appoinment/business/business-list/business-list.component.ts index b65913a..4c0bea9 100644 --- a/ng-seed/src/app/appoinment/business/business-list/business-list.component.ts +++ b/ng-seed/src/app/appoinment/business/business-list/business-list.component.ts @@ -67,9 +67,9 @@ export class BusinessListComponent implements OnInit { }) } - ngAfterViewInit() { - this.businessList.paginator = this.paginator; - } + // ngAfterViewInit() { + // this.businessList.paginator = this.paginator; + // } applyFilter(event: Event) { const filterValue = (event.target as HTMLInputElement).value; this.businessList.filter = filterValue.trim().toLowerCase(); diff --git a/ng-seed/src/app/appoinment/business/business-routing.module.ts b/ng-seed/src/app/appoinment/business/business-routing.module.ts index 8aa0991..9d53057 100644 --- a/ng-seed/src/app/appoinment/business/business-routing.module.ts +++ b/ng-seed/src/app/appoinment/business/business-routing.module.ts @@ -1,7 +1,18 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; +import { BusinessListComponent } from './business-list/business-list.component'; -const routes: Routes = []; +const routes: Routes = [ + { + path:'', + redirectTo:'appoinment/business', + pathMatch:'full' + }, + { + path:'appoinment/business', + component:BusinessListComponent + }, +]; @NgModule({ imports: [RouterModule.forChild(routes)], diff --git a/ng-seed/src/app/appoinment/consultants/consultants-routing.module.ts b/ng-seed/src/app/appoinment/consultants/consultants-routing.module.ts index 8217529..d95d432 100644 --- a/ng-seed/src/app/appoinment/consultants/consultants-routing.module.ts +++ b/ng-seed/src/app/appoinment/consultants/consultants-routing.module.ts @@ -1,7 +1,18 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; +import { ConsultantsListComponent } from './consultants-list/consultants-list.component'; -const routes: Routes = []; +const routes: Routes = [ + { + path:'', + redirectTo:'appoinment/consultants', + pathMatch:'full' + }, + { + path:'appoinment/consultants', + component:ConsultantsListComponent + }, +]; @NgModule({ imports: [RouterModule.forChild(routes)], diff --git a/ng-seed/src/app/appoinment/customers/customers-routing.module.ts b/ng-seed/src/app/appoinment/customers/customers-routing.module.ts index 7528a3e..ee6d999 100644 --- a/ng-seed/src/app/appoinment/customers/customers-routing.module.ts +++ b/ng-seed/src/app/appoinment/customers/customers-routing.module.ts @@ -1,7 +1,18 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; +import { CustomersListComponent } from './customers-list/customers-list.component'; -const routes: Routes = []; +const routes: Routes = [ + { + path:'', + redirectTo:'appoinment/customers', + pathMatch:'full' + }, + { + path:'appoinment/customers', + component:CustomersListComponent + }, +]; @NgModule({ imports: [RouterModule.forChild(routes)], diff --git a/ng-seed/src/app/appoinment/service-list-details/service-list-routing.module.ts b/ng-seed/src/app/appoinment/service-list-details/service-list-routing.module.ts index 47a642c..33d2178 100644 --- a/ng-seed/src/app/appoinment/service-list-details/service-list-routing.module.ts +++ b/ng-seed/src/app/appoinment/service-list-details/service-list-routing.module.ts @@ -1,7 +1,18 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; +import { ServiceListComponent } from './service-list/service-list.component'; -const routes: Routes = []; +const routes: Routes = [ + { + path:'', + redirectTo:'appoinment/service', + pathMatch:'full' + }, + { + path:'appoinment/service', + component:ServiceListComponent + }, +]; @NgModule({ imports: [RouterModule.forChild(routes)], diff --git a/ng-seed/src/app/appoinment/user/user-routing.module.ts b/ng-seed/src/app/appoinment/user/user-routing.module.ts index a330604..7077cd2 100644 --- a/ng-seed/src/app/appoinment/user/user-routing.module.ts +++ b/ng-seed/src/app/appoinment/user/user-routing.module.ts @@ -1,7 +1,19 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; +import { UserListComponent } from './user-list/user-list.component'; +import { UserModule } from './user.module'; -const routes: Routes = []; +const routes: Routes = [ + { + path:'', + redirectTo:'appoinment/users', + pathMatch:'full' + }, + { + path:'appoinment/users', + component:UserListComponent + }, +]; @NgModule({ imports: [RouterModule.forChild(routes)], diff --git a/ng-seed/src/app/dashboard/dashboard.component.html b/ng-seed/src/app/dashboard/dashboard.component.html index 672e205..e69de29 100644 --- a/ng-seed/src/app/dashboard/dashboard.component.html +++ b/ng-seed/src/app/dashboard/dashboard.component.html @@ -1,7 +0,0 @@ - - - - - Dr. Saravanan - - \ No newline at end of file diff --git a/ng-seed/src/app/layouts/admin/admin-layout.component.ts b/ng-seed/src/app/layouts/admin/admin-layout.component.ts index 4ad56de..e991f2d 100644 --- a/ng-seed/src/app/layouts/admin/admin-layout.component.ts +++ b/ng-seed/src/app/layouts/admin/admin-layout.component.ts @@ -10,10 +10,12 @@ import {TranslateService} from '@ngx-translate/core'; import PerfectScrollbar from 'perfect-scrollbar'; import { PerfectScrollbarConfigInterface, PerfectScrollbarComponent, PerfectScrollbarDirective } from 'ngx-perfect-scrollbar'; +import { RoleMenuItemsPipe } from '../role-menu-items.pipe'; @Component({ selector: 'app-layout', - templateUrl: './admin-layout.component.html' + templateUrl: './admin-layout.component.html', + providers: [RoleMenuItemsPipe], }) export class AdminLayoutComponent implements OnInit, OnDestroy { @@ -219,7 +221,7 @@ users() { } logout() { localStorage.clear(); - this.router.navigate(['/']); + this.router.navigate(['/authentication/login']); } } diff --git a/ng-seed/src/app/layouts/role-menu-items.pipe.spec.ts b/ng-seed/src/app/layouts/role-menu-items.pipe.spec.ts new file mode 100644 index 0000000..9cd405b --- /dev/null +++ b/ng-seed/src/app/layouts/role-menu-items.pipe.spec.ts @@ -0,0 +1,8 @@ +import { RoleMenuItemsPipe } from './role-menu-items.pipe'; + +describe('RoleMenuItemsPipe', () => { + it('create an instance', () => { + const pipe = new RoleMenuItemsPipe(); + expect(pipe).toBeTruthy(); + }); +}); diff --git a/ng-seed/src/app/layouts/role-menu-items.pipe.ts b/ng-seed/src/app/layouts/role-menu-items.pipe.ts new file mode 100644 index 0000000..0842694 --- /dev/null +++ b/ng-seed/src/app/layouts/role-menu-items.pipe.ts @@ -0,0 +1,52 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'roleMenuItems' +}) +export class RoleMenuItemsPipe implements PipeTransform { + + transform(value: any, type: any): any { + console.log(value,type) + // // this is for horizontal menu filter + // if(type=="1"){ + // switch(localStorage.getItem('user_role')){ + // case '1': return value.filter(val=>val.state!="settings" && val.state!="quality_check_discussion" && val.state!="sales-pd-list"); + // case '2': return value.filter(val=>val.state!="settings" && val.state!="quality_check_discussion" && val.state!="sales-pd-list"); + // case '3': return value.filter(val=>val.state!="settings"); + // case '4': return value.filter(val=>val.state!="settings" && val.state!="quality_check_discussion" && val.state!="reports" && val.state!="sales-pd-list"); + // case '5': return value.filter(val=>val.state!="settings" && val.state!="quality_check_discussion" && val.state!="reports" && val.state!="sales-pd-list"); + // case '6': return value.filter(val=>val.state!="settings" && val.state!="personal_discussion" && val.state!="reports" && val.state!="sales-pd-list"); + // case '7': return value.filter(val=>val.state!="settings" && val.state!="personal_discussion" && val.state!="reports" && val.state!="sales-pd-list"); + // case '8': return value.filter(val=>val.state!="settings" && val.state!="quality_check_discussion" && val.state!="sales-pd-list"); + // case '9': return value.filter(val=>val.state!="settings" && val.state!="quality_check_discussion" && val.state!="sales-pd-list"); + // case '10': return value; + // // case '3': return value.filter(val=>val.state!="settings" && val.state!="quality_check_discussion"); + // // case '4': return value.filter(val=>val.state!="settings" && val.state!="quality_check_discussion" && val.state!="reports"); + // // case '6': return value.filter(val=>val.state!="settings" && val.state!="personal_discussion" && val.state!="reports"); + // // default: return value.filter(val=>val.state!="settings" && val.state!="quality_check_discussion"); + // } + // } + // // this is for vertical menu filter + // else if(type=="2"){ + // switch(localStorage.getItem('user_role')){ + // case '1': return value.filter(val=>val.state!="settings" && val.state!="quality_check_discussion" && val.state!="sales-pd-list"); + // case '2': return value.filter(val=>val.state!="settings" && val.state!="quality_check_discussion" && val.state!="sales-pd-list"); + // case '3': return value.filter(val=>val.state!="settings"); + // case '4': return value.filter(val=>val.state!="settings" && val.state!="quality_check_discussion" && val.state!="reports" && val.state!="sales-pd-list"); + // case '5': return value.filter(val=>val.state!="settings" && val.state!="quality_check_discussion" && val.state!="reports" && val.state!="sales-pd-list"); + // case '6': return value.filter(val=>val.state!="settings" && val.state!="personal_discussion" && val.state!="reports" && val.state!="sales-pd-list"); + // case '7': return value.filter(val=>val.state!="settings" && val.state!="personal_discussion" && val.state!="reports" && val.state!="sales-pd-list"); + // case '8': return value.filter(val=>val.state!="settings" && val.state!="quality_check_discussion" && val.state!="sales-pd-list"); + // case '9': return value.filter(val=>val.state!="settings" && val.state!="quality_check_discussion" && val.state!="sales-pd-list"); + // case '10': return value; + // // default: return value.filter(val=>val.state!="settings" && val.state!="quality_check_discussion"); + // } + // } + // else{ + // return []; + // } + + + } + +} diff --git a/ng-seed/src/app/shared/menu-items/horizontal-menu-items.ts b/ng-seed/src/app/shared/menu-items/horizontal-menu-items.ts index 4616325..9cdf0cf 100644 --- a/ng-seed/src/app/shared/menu-items/horizontal-menu-items.ts +++ b/ng-seed/src/app/shared/menu-items/horizontal-menu-items.ts @@ -26,29 +26,73 @@ const HORIZONTALMENUITEMS = [ state: 'home', name: 'HOME', type: 'link', - icon: 'home' + icon: 'explore' }, { - state: 'authentication', - name: 'AUTHENTICATION', - type: 'sub', + state: 'appoinments', + name: 'Appoinments', + type: 'link', icon: 'security', - children: [ - {state: 'authentication/login', name: 'LOGIN'}, - {state: 'authentication/register', name: 'REGISTER'}, - {state: 'authentication/forgot-password', name: 'FORGOT'}, - {state: 'authentication/lockscreen', name: 'LOCKSCREEN'}, - { - state: 'error', - name: 'ERROR', - type: 'super-sub', - icon: 'error_outline', - subchildren: [ - {state: 'error/404', name: '404'}, - {state: 'error/503', name: '503'} - ] - } - ] + // children: [ + // {state: 'appoinments-list', name: 'Appoinments List'}, + // ] + }, + { + state: 'business', + name: 'Business', + type: 'link', + icon: 'security', + // children: [ + // {state: 'business-list', name: 'Business List'}, + // // {state: 'add-business-list', name: 'Add Business '}, + // ] + }, + // { + // state: 'appoinment', + // name: 'Calendar', + // type: 'sub', + // icon: 'security', + // children: [ + // {state: 'calendar-list', name: 'Calendar List'}, + // ] + // }, + { + state: 'customers', + name: 'Customers', + type: 'link', + icon: 'security', + // children: [ + // {state: 'customers-list', name: 'Customers List'}, + // ] + }, + { + state: 'consultants', + name: 'Consultants', + type: 'link', + icon: 'security', + // children: [ + // {state: 'consultants-list', name: 'Consultants List'}, + // ] + }, + { + state: 'users', + name: 'Users', + type: 'link', + icon: 'security', + // children: [ + // {state: 'user-list', name: 'Users List'}, + // // {state: 'add-user-list', name: 'Add Users '}, + // ] + }, + { + state: 'service', + name: 'Services List', + type: 'link', + icon: 'security', + // children: [ + // {state: 'services-list', name: 'Services List'}, + // // {state: 'add-user-list', name: 'Add Users '}, + // ] } ]; diff --git a/ng-seed/src/app/shared/menu-items/menu-items.ts b/ng-seed/src/app/shared/menu-items/menu-items.ts index 96a0af0..0f3dd9d 100644 --- a/ng-seed/src/app/shared/menu-items/menu-items.ts +++ b/ng-seed/src/app/shared/menu-items/menu-items.ts @@ -28,23 +28,23 @@ const MENUITEMS : Menu[] = [ icon: 'explore' }, { - state: 'appoinment', + state: 'appoinments', name: 'Appoinments', - type: 'sub', + type: 'link', icon: 'security', - children: [ - {state: 'appoinments-list', name: 'Appoinments List'}, - ] + // children: [ + // {state: 'appoinments-list', name: 'Appoinments List'}, + // ] }, { - state: 'appoinment', + state: 'business', name: 'Business', - type: 'sub', + type: 'link', icon: 'security', - children: [ - {state: 'business-list', name: 'Business List'}, - // {state: 'add-business-list', name: 'Add Business '}, - ] + // children: [ + // {state: 'business-list', name: 'Business List'}, + // // {state: 'add-business-list', name: 'Add Business '}, + // ] }, // { // state: 'appoinment', @@ -56,70 +56,44 @@ const MENUITEMS : Menu[] = [ // ] // }, { - state: 'appoinment', + state: 'customers', name: 'Customers', - type: 'sub', + type: 'link', icon: 'security', - children: [ - {state: 'customers-list', name: 'Customers List'}, - ] + // children: [ + // {state: 'customers-list', name: 'Customers List'}, + // ] }, { - state: 'appoinment', + state: 'consultants', name: 'Consultants', - type: 'sub', + type: 'link', icon: 'security', - children: [ - {state: 'consultants-list', name: 'Consultants List'}, - ] + // children: [ + // {state: 'consultants-list', name: 'Consultants List'}, + // ] }, { - state: 'appoinment', + state: 'users', name: 'Users', - type: 'sub', + type: 'link', icon: 'security', - children: [ - {state: 'user-list', name: 'Users List'}, - // {state: 'add-user-list', name: 'Add Users '}, - ] + // children: [ + // {state: 'user-list', name: 'Users List'}, + // // {state: 'add-user-list', name: 'Add Users '}, + // ] }, { - state: 'appoinment', + state: 'service', name: 'Services List', - type: 'sub', + type: 'link', icon: 'security', - children: [ - {state: 'services-list', name: 'Services List'}, - // {state: 'add-user-list', name: 'Add Users '}, - ] + // children: [ + // {state: 'services-list', name: 'Services List'}, + // // {state: 'add-user-list', name: 'Add Users '}, + // ] } - - - - // { - // state: 'authentication', - // name: 'AUTHENTICATIONs', - // type: 'sub', - // icon: 'security', - // children: [ - // {state: 'login', name: 'LOGIN'}, - // {state: 'register', name: 'REGISTER'}, - // {state: 'forgot-password', name: 'FORGOT'}, - // {state: 'lockscreen', name: 'LOCKSCREEN'} - // ] - // }, - // { - // state: 'error', - // name: 'ERROR', - // type: 'sub', - // icon: 'error_outline', - // children: [ - // {state: '404', name: '404'}, - // {state: '503', name: '503'} - // ] - // } - ]; @Injectable()