11import { AfterViewInit , Component , OnDestroy , OnInit , ViewChild } from '@angular/core' ;
22import { ActionsSubject , select , Store } from '@ngrx/store' ;
33import { DataTableDirective } from 'angular-datatables' ;
4- import { Observable , Subject , Subscription } from 'rxjs' ;
4+ import { Observable , Subject , Subscription } from 'rxjs' ;
55import { delay , filter , map } from 'rxjs/operators' ;
66import { FeatureManagerService } from 'src/app/modules/shared/feature-toggles/feature-toggle-manager.service' ;
77import { User } from '../../models/users' ;
8- import { GrantRoleUser , LoadUsers , RevokeRoleUser , UserActionTypes , AddUserToGroup , RemoveUserToGroup } from '../../store/user.actions' ;
8+ import {
9+ GrantRoleUser ,
10+ LoadUsers ,
11+ RevokeRoleUser ,
12+ UserActionTypes ,
13+ AddUserToGroup ,
14+ RemoveUserToGroup ,
15+ } from '../../store/user.actions' ;
916import { getIsLoading } from '../../store/user.selectors' ;
1017
1118@Component ( {
@@ -24,13 +31,13 @@ export class UsersListComponent implements OnInit, OnDestroy, AfterViewInit {
2431 dtOptions : any = { } ;
2532 switchGroupsSubscription : Subscription ;
2633 isEnableToggleSubscription : Subscription ;
27- isUserRoleToggleOn ;
28- flakyToggle : true ;
34+ isUserGroupsToggleOn ;
35+ flakyToggle : boolean = false ; // borrar para implementar feature toggle
2936
3037 constructor (
3138 private store : Store < User > ,
3239 private actionsSubject$ : ActionsSubject ,
33- private featureManagerService : FeatureManagerService
40+ // private featureManagerService: FeatureManagerService
3441 ) {
3542 this . isLoading$ = store . pipe ( delay ( 0 ) , select ( getIsLoading ) ) ;
3643 }
@@ -44,10 +51,10 @@ export class UsersListComponent implements OnInit, OnDestroy, AfterViewInit {
4451 this . rerenderDataTable ( ) ;
4552 } ) ;
4653
47- this . isEnableToggleSubscription = this . isFeatureToggleActivated ( ) . subscribe ( ( flag ) => {
48- this . isUserRoleToggleOn = flag ;
49- console . log ( 'in subscription' , this . isUserRoleToggleOn ) ;
50- } ) ;
54+ /* this.isEnableToggleSubscription = this.isFeatureToggleActivated().subscribe((flag) => {
55+ this.isUserGroupsToggleOn = flag;
56+ console.log('in subscription', this.isUserGroupsToggleOn );
57+ });*/
5158
5259 this . switchGroupsSubscription = this . actionsSubject$
5360 . pipe (
@@ -102,17 +109,17 @@ export class UsersListComponent implements OnInit, OnDestroy, AfterViewInit {
102109 : this . store . dispatch ( new GrantRoleUser ( userId , roleId ) ) ;
103110 }
104111
105- isFeatureToggleActivated ( ) {
112+ switchGroup ( userId : string , userGroups : string [ ] , groupName : string ) {
113+ userGroups . includes ( groupName )
114+ ? this . store . dispatch ( new RemoveUserToGroup ( userId , groupName ) )
115+ : this . store . dispatch ( new AddUserToGroup ( userId , groupName ) ) ;
116+ }
117+
118+ /* isFeatureToggleActivated() {
106119 return this.featureManagerService.isToggleEnabledForUser('ui-list-technologies').pipe(
107120 map((enabled) => {
108121 return enabled === true ? true : false;
109122 })
110123 );
111- }
112-
113- switchGroups ( userId : string , userGroups : string [ ] , groupname : string , groupValue : string ) {
114- userGroups . includes ( groupValue )
115- ? this . store . dispatch ( new RemoveUserToGroup ( userId , groupname ) )
116- : this . store . dispatch ( new AddUserToGroup ( userId , groupname ) ) ;
117- }
124+ }*/
118125}
0 commit comments