@@ -65,139 +65,7 @@ export class AppComponent {
65
65
async changeOfRoutes ( ) {
66
66
this . issueEmailBody = encodeURIComponent ( `Reported from page: ${ window . location . href } ` ) ;
67
67
await this . getInfo ( ) ;
68
- this . navigations = [
69
- {
70
- name : 'Projects' ,
71
- link : '/project' ,
72
- show : this . isLogged && ! this . projectId ,
73
- routerOptions : { exact : false }
74
- } , {
75
- name : 'Audits' ,
76
- link : '/audit' ,
77
- show : this . globaldata . auditModule
78
- && ! this . projectId
79
- && ( await this . permissionsService . hasPermissions (
80
- [ EGlobalPermissions . manager , EGlobalPermissions . audit_admin , EGlobalPermissions . auditor ] ) ) ,
81
- routerOptions : { exact : false }
82
- } , {
83
- name : this . currentProject ? this . currentProject . name : '' ,
84
- link : `/project/${ this . projectId } ` ,
85
- show : this . isLogged
86
- && this . projectId !== undefined ,
87
- routerOptions : { exact : true }
88
- } , {
89
- name : 'Test Runs' ,
90
- link : `/project/${ this . projectId } /testrun` ,
91
- params : { 'f_debug_st' : false } ,
92
- show : this . isLogged
93
- && this . projectId !== undefined ,
94
- routerOptions : { exact : false }
95
- } , {
96
- name : 'Milestones' ,
97
- link : `/project/${ this . projectId } /milestone` ,
98
- show : this . isLogged
99
- && this . projectId !== undefined ,
100
- routerOptions : { exact : false }
101
- } , {
102
- name : 'Tests' ,
103
- children : [ {
104
- name : 'All' ,
105
- link : `/project/${ this . projectId } /tests` ,
106
- show : true
107
- } , {
108
- name : 'Suites' ,
109
- link : `/project/${ this . projectId } /testsuite` ,
110
- show : true
111
- } , {
112
- name : 'Steps' ,
113
- link : `/project/${ this . projectId } /steps` ,
114
- show : this . currentProject && ! ! this . currentProject . steps
115
- } , {
116
- name : 'Dashboard' ,
117
- link : `/project/${ this . projectId } /testsuite/dashboard` ,
118
- show : true
119
- } ] ,
120
- show : this . isLogged && this . projectId !== undefined ,
121
- routerOptions : { exact : true }
122
- } , {
123
- name : 'Create' ,
124
- show : this . projectId
125
- && ( await this . permissionsService . hasPermissions (
126
- [ EGlobalPermissions . manager ] ,
127
- [ ELocalPermissions . admin , ELocalPermissions . engineer , ELocalPermissions . manager ] ) ) ,
128
- children : [ {
129
- name : 'Milestone' ,
130
- link : `/project/${ this . projectId } /create/milestone` ,
131
- show : true
132
- } , {
133
- name : 'Suite' ,
134
- link : `/project/${ this . projectId } /create/testsuite` ,
135
- show : true
136
- } , {
137
- name : 'Test Run' ,
138
- link : `/project/${ this . projectId } /create/testrun` ,
139
- show : true
140
- } , {
141
- name : 'Test' ,
142
- link : `/project/${ this . projectId } /create/test` ,
143
- show : true
144
- } ]
145
- } , {
146
- name : 'Import' ,
147
- link : `/project/${ this . projectId } /import` ,
148
- show : this . projectId && ( await this . permissionsService . hasPermissions (
149
- [ EGlobalPermissions . manager ] ,
150
- [ ELocalPermissions . admin , ELocalPermissions . engineer , ELocalPermissions . manager ] ) ) ,
151
- routerOptions : { exact : false }
152
- } , {
153
- name : 'Audits' ,
154
- link : `/audit/${ this . projectId } ` ,
155
- show : ( await this . permissionsService . hasPermissions ( undefined ,
156
- [ ELocalPermissions . admin , ELocalPermissions . engineer , ELocalPermissions . manager , ELocalPermissions . viewer ] ) )
157
- && this . projectId && this . globaldata . auditModule ,
158
- routerOptions : { exact : true }
159
- } , {
160
- name : 'Audits' ,
161
- show : ( await this . permissionsService . hasPermissions ( [ EGlobalPermissions . manager , EGlobalPermissions . auditor ,
162
- EGlobalPermissions . audit_admin ] ) ) && this . projectId && this . globaldata . auditModule ,
163
- children : [ {
164
- name : 'Dashboard' ,
165
- link : `/audit` ,
166
- show : true
167
- } , {
168
- name : 'Project' ,
169
- link : `/audit/${ this . projectId } ` ,
170
- show : true
171
- } ]
172
- } , {
173
- name : 'Customers' ,
174
- link : '/customer' ,
175
- show : await this . permissionsService . hasPermissions ( [ EGlobalPermissions . head , EGlobalPermissions . unit_coordinator ,
176
- EGlobalPermissions . account_manager ] ) ,
177
- routerOptions : { exact : false }
178
- }
179
- ] ;
180
- if ( this . isLogged ) {
181
- this . rightNavigations = [ {
182
- name : this . userService . getUserFullName ( this . globaldata . currentUser ) ,
183
- id : 'user-mb' ,
184
- show : true ,
185
- children : [ {
186
- name : 'Edit My Account' ,
187
- link : `/settings` ,
188
- show : true
189
- } , {
190
- name : 'Administration' ,
191
- link : `/administration` ,
192
- show : await this . permissionsService . hasPermissions ( [ EGlobalPermissions . admin , EGlobalPermissions . manager ] ,
193
- [ ELocalPermissions . admin , ELocalPermissions . manager , ELocalPermissions . engineer ] )
194
- } , {
195
- name : 'Report an Issue' ,
196
- href : `https://github.com/aquality-automation/aquality-tracking/issues` ,
197
- show : true
198
- } ]
199
- } ] ;
200
- }
68
+ await this . updateNavigation ( ) ;
201
69
}
202
70
203
71
async getInfo ( ) {
@@ -220,20 +88,155 @@ export class AppComponent {
220
88
this . currentProject = await this . projectService . getProject ( this . projectId ) ;
221
89
}
222
90
223
- this . globaldata . anyLocalPermissions = await this . userService . getAnyLocalPermissions ( ) . toPromise ( ) ;
224
- this . globaldata . localPermissions = this . globaldata . anyLocalPermissions . find ( x => x . project_id === this . projectId ) ;
225
91
} else {
226
92
this . currentProject = undefined ;
227
- this . globaldata . localPermissions = undefined ;
228
93
}
229
94
230
95
this . globaldata . announceCurrentProject ( this . currentProject ) ;
231
96
}
232
97
233
98
async Logout ( ) {
234
- this . cookieService . remove ( 'iio78' ) ;
235
- this . isLogged = false ;
236
- this . globaldata . Clear ( ) ;
99
+ this . userService . logOut ( ) ;
237
100
await this . userService . redirectToLogin ( ) ;
101
+ await this . updateNavigation ( ) ;
102
+ }
103
+
104
+ async updateNavigation ( ) {
105
+ if ( this . isLogged ) {
106
+ this . navigations = [
107
+ {
108
+ name : 'Projects' ,
109
+ link : '/project' ,
110
+ show : this . isLogged && ! this . projectId ,
111
+ routerOptions : { exact : false }
112
+ } , {
113
+ name : 'Audits' ,
114
+ link : '/audit' ,
115
+ show : this . globaldata . auditModule
116
+ && ! this . projectId
117
+ && ( await this . permissionsService . hasPermissions (
118
+ [ EGlobalPermissions . manager , EGlobalPermissions . audit_admin , EGlobalPermissions . auditor ] ) ) ,
119
+ routerOptions : { exact : false }
120
+ } , {
121
+ name : this . currentProject ? this . currentProject . name : '' ,
122
+ link : `/project/${ this . projectId } ` ,
123
+ show : this . isLogged
124
+ && this . projectId !== undefined ,
125
+ routerOptions : { exact : true }
126
+ } , {
127
+ name : 'Test Runs' ,
128
+ link : `/project/${ this . projectId } /testrun` ,
129
+ params : { 'f_debug_st' : false } ,
130
+ show : this . isLogged
131
+ && this . projectId !== undefined ,
132
+ routerOptions : { exact : false }
133
+ } , {
134
+ name : 'Milestones' ,
135
+ link : `/project/${ this . projectId } /milestone` ,
136
+ show : this . isLogged
137
+ && this . projectId !== undefined ,
138
+ routerOptions : { exact : false }
139
+ } , {
140
+ name : 'Tests' ,
141
+ children : [ {
142
+ name : 'All' ,
143
+ link : `/project/${ this . projectId } /tests` ,
144
+ show : true
145
+ } , {
146
+ name : 'Suites' ,
147
+ link : `/project/${ this . projectId } /testsuite` ,
148
+ show : true
149
+ } , {
150
+ name : 'Steps' ,
151
+ link : `/project/${ this . projectId } /steps` ,
152
+ show : this . currentProject && ! ! this . currentProject . steps
153
+ } , {
154
+ name : 'Dashboard' ,
155
+ link : `/project/${ this . projectId } /testsuite/dashboard` ,
156
+ show : true
157
+ } ] ,
158
+ show : this . isLogged && this . projectId !== undefined ,
159
+ routerOptions : { exact : true }
160
+ } , {
161
+ name : 'Create' ,
162
+ show : this . projectId
163
+ && ( await this . permissionsService . hasPermissions (
164
+ [ EGlobalPermissions . manager ] ,
165
+ [ ELocalPermissions . admin , ELocalPermissions . engineer , ELocalPermissions . manager ] ) ) ,
166
+ children : [ {
167
+ name : 'Milestone' ,
168
+ link : `/project/${ this . projectId } /create/milestone` ,
169
+ show : true
170
+ } , {
171
+ name : 'Suite' ,
172
+ link : `/project/${ this . projectId } /create/testsuite` ,
173
+ show : true
174
+ } , {
175
+ name : 'Test Run' ,
176
+ link : `/project/${ this . projectId } /create/testrun` ,
177
+ show : true
178
+ } , {
179
+ name : 'Test' ,
180
+ link : `/project/${ this . projectId } /create/test` ,
181
+ show : true
182
+ } ]
183
+ } , {
184
+ name : 'Import' ,
185
+ link : `/project/${ this . projectId } /import` ,
186
+ show : this . projectId && ( await this . permissionsService . hasPermissions (
187
+ [ EGlobalPermissions . manager ] ,
188
+ [ ELocalPermissions . admin , ELocalPermissions . engineer , ELocalPermissions . manager ] ) ) ,
189
+ routerOptions : { exact : false }
190
+ } , {
191
+ name : 'Audits' ,
192
+ link : `/audit/${ this . projectId } ` ,
193
+ show : ( await this . permissionsService . hasPermissions ( undefined ,
194
+ [ ELocalPermissions . admin , ELocalPermissions . engineer , ELocalPermissions . manager , ELocalPermissions . viewer ] ) )
195
+ && this . projectId && this . globaldata . auditModule ,
196
+ routerOptions : { exact : true }
197
+ } , {
198
+ name : 'Audits' ,
199
+ show : ( await this . permissionsService . hasPermissions ( [ EGlobalPermissions . manager , EGlobalPermissions . auditor ,
200
+ EGlobalPermissions . audit_admin ] ) ) && this . projectId && this . globaldata . auditModule ,
201
+ children : [ {
202
+ name : 'Dashboard' ,
203
+ link : `/audit` ,
204
+ show : true
205
+ } , {
206
+ name : 'Project' ,
207
+ link : `/audit/${ this . projectId } ` ,
208
+ show : true
209
+ } ]
210
+ } , {
211
+ name : 'Customers' ,
212
+ link : '/customer' ,
213
+ show : await this . permissionsService . hasPermissions ( [ EGlobalPermissions . head , EGlobalPermissions . unit_coordinator ,
214
+ EGlobalPermissions . account_manager ] ) ,
215
+ routerOptions : { exact : false }
216
+ }
217
+ ] ;
218
+ this . rightNavigations = [ {
219
+ name : this . userService . getUserFullName ( this . globaldata . currentUser ) ,
220
+ id : 'user-mb' ,
221
+ show : true ,
222
+ children : [ {
223
+ name : 'Edit My Account' ,
224
+ link : `/settings` ,
225
+ show : true
226
+ } , {
227
+ name : 'Administration' ,
228
+ link : `/administration` ,
229
+ show : await this . permissionsService . hasPermissions ( [ EGlobalPermissions . admin , EGlobalPermissions . manager ] ,
230
+ [ ELocalPermissions . admin , ELocalPermissions . manager , ELocalPermissions . engineer ] )
231
+ } , {
232
+ name : 'Report an Issue' ,
233
+ href : `https://github.com/aquality-automation/aquality-tracking/issues` ,
234
+ show : true
235
+ } ]
236
+ } ] ;
237
+ } else {
238
+ this . navigations = [ ] ;
239
+ this . rightNavigations = [ ] ;
240
+ }
238
241
}
239
242
}
0 commit comments