Skip to content

Commit 6deb06c

Browse files
committed
Small e2eid fixes and sign-out component
1 parent cc4c7c8 commit 6deb06c

File tree

6 files changed

+63
-16
lines changed

6 files changed

+63
-16
lines changed

eform-client/src/app/app.module.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import {DndModule} from 'ng2-dnd';
1010

1111
import {AccountManagementModule, SimpleSitesModule, SettingsModule, AdvancedModule, HelpersModule} from 'app/modules';
1212
import {PluginsModule} from 'app/plugins/plugins.module';
13-
import {AppComponent, AuthComponent, RestorePasswordComponent, HeaderComponent,
14-
NavigationComponent, FooterComponent} from 'app/components';
13+
import {
14+
AppComponent, AuthComponent, RestorePasswordComponent, HeaderComponent,
15+
NavigationComponent, FooterComponent, SignOutComponent
16+
} from 'app/components';
1517
import {FullLayoutComponent, SimpleLayoutComponent} from 'app/layouts';
1618
import {
1719
AdminService, EntitySearchService, EntitySelectService, SettingsService,
@@ -42,6 +44,7 @@ import {EqualValidatorDirective} from 'app/components/directives/equal-validator
4244
AppComponent,
4345
AuthComponent,
4446
RestorePasswordComponent,
47+
SignOutComponent,
4548
HeaderComponent,
4649
FooterComponent,
4750
NavigationComponent,

eform-client/src/app/app.routing.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {RouterModule, Routes} from '@angular/router';
33

44
import {PreloadResolverConfig} from 'app/configs';
55
import {FullLayoutComponent, SimpleLayoutComponent} from 'app/layouts';
6-
import {RestorePasswordComponent, AuthComponent} from 'app/components';
6+
import {RestorePasswordComponent, AuthComponent, SignOutComponent} from 'app/components';
77
import {AuthGuard} from 'app/guards';
88

99
export const routes: Routes = [
@@ -65,6 +65,10 @@ export const routes: Routes = [
6565
{
6666
path: 'restore-password',
6767
component: RestorePasswordComponent
68+
},
69+
{
70+
path: 'sign-out',
71+
component: SignOutComponent
6872
}
6973
]
7074
},
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {AfterViewChecked, AfterViewInit, Component, OnInit} from '@angular/core';
2+
import {Router} from '@angular/router';
3+
import {AuthService} from 'app/services';
4+
5+
6+
@Component({
7+
selector: 'sign-out',
8+
template: ''
9+
})
10+
export class SignOutComponent implements OnInit, AfterViewChecked {
11+
12+
constructor(private authService: AuthService, private router: Router) { }
13+
14+
ngOnInit() {
15+
16+
}
17+
18+
19+
signOut() {
20+
this.authService.logout().subscribe(() => {
21+
localStorage.clear();
22+
this.router.navigate(['/login']).then();
23+
});
24+
}
25+
26+
ngAfterViewChecked(): void {
27+
this.signOut();
28+
}
29+
}

eform-client/src/app/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export * from './auth/auth.component';
22
export * from './auth/restore-password.component';
3+
export * from './auth/sign-out.component';
34
export * from './footer/footer.component';
45
export * from './header/header.component';
56
export * from './navigation/navigation.component';

eform-client/src/app/components/navigation/navigation.component.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
*ngIf="menu.appendLeftStyles && (userInfo.role == menu.guard
88
|| userInfo.role == 'admin'
99
|| menu.guard == '')">
10-
<a class="dropdown-toggle" *ngIf="menu.submenus.length > 0"
10+
<a class="dropdown-toggle" *ngIf="menu.submenus.length > 0" id="{{menu.e2eId || 'm1'}}"
1111
data-toggle="dropdown" href="javascript:void(0);">
1212
{{menu.name}}
1313
</a>
14-
<a *ngIf="menu.submenus.length == 0" routerLink="{{menu.link}}">
14+
<a *ngIf="menu.submenus.length == 0" routerLink="{{menu.link}}" id="{{menu.e2eId || 'm2'}}">
1515
{{menu.name}}
1616
</a>
1717
<ul class="dropdown-menu dropdown-menu-right" *ngIf="menu.submenus.length > 0">
18-
<li *ngFor="let submenu of menu.submenus">
18+
<li *ngFor="let submenu of menu.submenus" id="{{submenu.e2eId || 'm3'}}">
1919
<a routerLink="{{submenu.link}}" routerLinkActive="active"
2020
*ngIf="userInfo.role == submenu.guard || userInfo.role == 'admin' || submenu.guard == ''">
2121
{{submenu.name}}
@@ -43,14 +43,16 @@
4343
<li [ngClass]="{'dropdown': menu.submenus.length > 0}"
4444
*ngIf="!menu.appendLeftStyles && (userInfo.role == menu.guard || userInfo.role == 'admin' || menu.guard == '')">
4545
<a class="dropdown-toggle" *ngIf="menu.submenus.length > 0"
46+
id="{{menu.e2eId || 'm4'}}"
4647
data-toggle="dropdown" href="javascript:void(0);">
4748
{{menu.name}}
4849
</a>
49-
<a class="dropdown-toggle" *ngIf="menu.submenus.length == 0" routerLink="{{menu.link}}" routerLinkActive="active">
50+
<a class="dropdown-toggle" *ngIf="menu.submenus.length == 0" routerLink="{{menu.link}}" id="{{menu.e2eId || 'm5'}}"
51+
routerLinkActive="active">
5052
{{menu.name}}
5153
</a>
5254
<ul class="dropdown-menu dropdown-menu-right" *ngIf="menu.submenus.length > 0">
53-
<li *ngFor="let submenu of menu.submenus">
55+
<li *ngFor="let submenu of menu.submenus" id="{{submenu.e2eId || 'm6'}}">
5456
<a routerLink="{{submenu.link}}" routerLinkActive="active"
5557
*ngIf="userInfo.role == submenu.guard || userInfo.role == 'admin' || submenu.guard == ''">
5658
{{submenu.name}}

eform-client/src/app/components/navigation/navigation.component.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,69 +25,84 @@ export class NavigationComponent implements OnInit {
2525
this.navigationMenu = [
2626
{
2727
name: this.userInfo.firstName + ' ' + this.userInfo.lastName || 'name',
28+
e2eId: 'sign-out-dropdown',
2829
appendLeftStyles: true,
2930
submenus: [
3031
{
3132
name: 'User Management',
33+
e2eId: 'user-management-menu',
3234
link: '/account-management/users',
3335
guard: 'admin'
3436
},
3537
{
3638
name: 'Google Authenticator',
39+
e2eId: '',
3740
link: '/account-management/google-authenticator'
3841
},
3942
{
4043
name: 'Change password',
44+
e2eId: '',
4145
link: '/account-management/change-password'
4246
},
4347
{
4448
name: 'Sign out',
45-
link: ''
49+
e2eId: 'sign-out',
50+
link: '/login/sign-out'
4651
}
4752
]
4853
},
4954
{
5055
name: 'My eForms',
56+
e2eId: '',
5157
link: '/',
5258
submenus: []
5359
},
5460
{
5561
name: 'Device users',
62+
e2eId: '',
5663
link: '/simplesites',
5764
submenus: []
5865
},
5966
{
6067
name: 'Advanced',
68+
e2eId: '',
6169
submenus: [
6270
{
6371
name: 'Sites',
72+
e2eId: '',
6473
link: '/advanced/sites',
6574
},
6675
{
6776
name: 'Workers',
77+
e2eId: '',
6878
link: '/advanced/workers',
6979
},
7080
{
7181
name: 'Units',
82+
e2eId: '',
7283
link: '/advanced/units',
7384
},
7485
{
7586
name: 'Searchable list',
87+
e2eId: '',
7688
link: '/advanced/entity-search',
7789
},
7890
{
7991
name: 'Selectable list',
92+
e2eId: '',
8093
link: '/advanced/entity-select'
8194
},
8295
{
8396
name: 'Settings',
97+
e2eId: '',
8498
link: '/settings',
8599
guard: 'admin'
86100
}
87101
]
88102
},
89103
{
90104
name: 'Example plugin',
105+
e2eId: '',
91106
link: '/plugins/example-pn',
92107
submenus: []
93108
},
@@ -97,11 +112,4 @@ export class NavigationComponent implements OnInit {
97112

98113

99114
}
100-
101-
signOut() {
102-
this.authService.logout().subscribe(() => {
103-
localStorage.clear();
104-
this.router.navigate(['/login']).then();
105-
});
106-
}
107115
}

0 commit comments

Comments
 (0)