Commit 8874d017 by Nattana Chaiyamat

กำหนดสิทธิการเข้าใช้งาน

parent 57aa19ab
...@@ -85,6 +85,7 @@ export class SidebarComponent { ...@@ -85,6 +85,7 @@ export class SidebarComponent {
this.getConfigPermissionByUserLevel() this.getConfigPermissionByUserLevel()
this.ParentActive(); this.ParentActive();
this.router.events.subscribe((event) => { this.router.events.subscribe((event) => {
sessionStorage.setItem('currentUrl', this.router.url)
if (event instanceof NavigationEnd) { if (event instanceof NavigationEnd) {
this.ParentActive(); this.ParentActive();
} }
...@@ -115,25 +116,32 @@ export class SidebarComponent { ...@@ -115,25 +116,32 @@ export class SidebarComponent {
this.configPermission.data = new MyConfigPermissionModel(response) this.configPermission.data = new MyConfigPermissionModel(response)
this.menuItems.forEach(x => { this.menuItems.forEach(x => {
// เปิดทุกเมนู // เปิดทุกเมนู
x.show = true // x.show = true
x.children?.forEach(y => {
y.show = true
})
// เปิดตาม config
// const configMenu = this.configPermission.data.menuBody.find(y => y.id == x.id)
// if (configMenu) {
// x.show = configMenu.show
// x.children?.forEach(y => { // x.children?.forEach(y => {
// const configChildren = configMenu.children.find(z => z.id == y.id) // y.show = true
// if (configChildren) {
// y.show = configChildren.show
// }
// }) // })
// }
// เปิดตาม config
const configMenu = this.configPermission.data.menuBody.find(y => y.id == x.id)
if (configMenu) {
x.show = configMenu.show
x.children?.forEach(y => {
const configChildren = configMenu.children.find(z => z.id == y.id)
if (configChildren) {
y.show = configChildren.show
}
})
}
}) })
let path404check = '/404page' let path404check = '/404page'
this.menuItems.forEach(x => { this.menuItems.forEach(x => {
const children = x.children?.find(y => y.path == sessionStorage.getItem('currentUrl'))
if (children?.show && path404check == '/404page') {
path404check = children.path || '/404page'
}
})
if (path404check == '/404page') {
this.menuItems.forEach(x => {
if (x.show && path404check == '/404page') { if (x.show && path404check == '/404page') {
x.children?.forEach(y => { x.children?.forEach(y => {
if (y.show) { if (y.show) {
...@@ -142,6 +150,7 @@ export class SidebarComponent { ...@@ -142,6 +150,7 @@ export class SidebarComponent {
}) })
} }
}) })
}
this.router.navigate([path404check]); this.router.navigate([path404check]);
this.configPermission.loading = false this.configPermission.loading = false
this.cdr.detectChanges() this.cdr.detectChanges()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment