TwanoO67 / ngx-admin-lte

Admin LTE for Angular 2/4/6/8 as a NPM package
MIT License
109 stars 47 forks source link

Some feature added #29

Closed chinkan closed 6 years ago

chinkan commented 6 years ago

Hi @TwanoO67 ,

I have updated some features:

custom user body in user box: simply create a component and add this code below to app.routes.ts

const userBody: UserBody = new UserBody(UserBodyBoxComponent, {});

const routes: Routes = [
  // logged routes
  {
    canActivate: [CanActivateGuard],
    children: [
      {
        component: HomeComponent,
        path: 'home'
      }
    ],
    component: LayoutAuthComponent,
    data: [{
      'skin': 'skin-black',
      'display_tasks': false,
      'display_control': false,
      'display_messages' : false,
      'display_notifications': false,
      'display_menu_search': false,
      'display_profile': false,
      'user_body': userBody
    }],
    path: '',
  },
  // not logged routes
  {
    children: [
      {
        component: LoginComponent,
        path: ''
      }
    ],
    component: LayoutLoginComponent,
    path: 'login',
  },
];

custom logout action: just add this code to app.component.ts could override the logout process

this.userServ.logoutAction = ()=>{
      //override here
};

menu support multiple section: menu can be multiple section with this links json

private mylinks: any = [
  {
    header: 'Navigator',
    children: [
      {
        'title': 'Home',
        'icon': 'dashboard',
        'link': ['/']
      },
      {
        'title': 'Sub menu',
        'icon': 'link',
        'sublinks': [
          {
            'title': 'Page 2',
            'link': ['/page/2'],
          },
          {
            'title': 'Page 3',
            'link': ['/page/3'],
          }
        ]
      }
    ]
  },
  {
    header: 'Navigator 2',
    children: [
      {
        'title': 'Sub menu 4',
        'icon': 'link',
        'link': ['/page/4'],
      }
    ]
  }
];

and you can hide or show the profile button with adding 'display_profile': false, to component data in app.routes.ts, and the profile link is now default "/profile"

Is it suitable for this project? Thanks and sorry for my English :)

TwanoO67 commented 6 years ago

Hello @chinkan

Thanks for your submit. Unfortunately I can't merge everything in your Pull Request because there's some breaking change and some of the function already exist.

1) For the UserBox component, you can already provide your own userbox, by using the new "header components" from the v1, and as it allow more possibilities I won't replace that.

2) For the logoutAction in the UserService, that's a nice feature, I will definitivly add that to next version (maybe you could submit a separate PR for that ? so your name could be in kept in the commits :) )

3) For the menu, your proposition of data structure will cause breaking change (and so, forcing everyone to change their projects) so I can't merge it that way. But the possibility to have intermediate "header title" is good, so I'm adding just that part. (if you want, you can also do a separate PR for that to mark your contribution :) )

4) For the display_profile property, it's a feature too 'specific' to be in the main configuration of the layout. And as you can override that component by using the "Header Components" I don't see the need of that. But it gave me an idea of a "DisplayService" where we could set our own rules to define if a part of the app should be displayed or not (in a more fine way, for example: ok for that user, but not for the other one...). So I will give you are more personnalisable way to that.

Anyway, feel free to argument if I'm not explaining correctly, and many thanks for your work it will give very good ideas for the project :)

chinkan commented 6 years ago

Thanks @TwanoO67

Let me close this request.