akveo / ngx-admin

Customizable admin dashboard template based on Angular 10+
https://akveo.github.io/ngx-admin/
MIT License
25.19k stars 7.94k forks source link

use ng2-smart-table with security in ngx-admin #2050

Closed hoangph91 closed 4 years ago

hoangph91 commented 5 years ago

Now, I using ngx-admin for my project , I have to ng2-smart-table with security in ngx-admin, But I dont know how to hidden buttons in actions , as button delete, edit ...

Can I help you ?.

thanks you so much!

lautaro-osacar commented 5 years ago

You can hide action buttons on ng2-smart-table on settings object. Like this actions: { add: false, edit: false, delete: false, } Check ng2-smart-table documentation

hoangph91 commented 5 years ago

@lautaro-osacar : Thanks you, but I implement role and permission on ngx-admin , I want to hide action buttons by permission before the user authen .

Can you help me ?

lautaro-osacar commented 5 years ago

Maybe you can implement it on ngOnInit() of table's component. Something like this:

ngOnInit() {
 const newSettings = {...this.settings};
 this.userService.getUser().subscribe(user => {
    if (!user.permissions.includes(delete_posts)){
      newSettings.delete = false;
    }
    this.settings = Object.assign({}, newSettings);
  )}
}

Something like https://github.com/AlexKhymenko/ngx-permissions may help

ArtemRomanovsky commented 4 years ago

Thank you @lautaro-osacar ! Closed as answered