Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nmaas Portal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nmaas
nmaas Portal
Commits
3ecd8338
Commit
3ecd8338
authored
2 years ago
by
kbeyro
Browse files
Options
Downloads
Patches
Plain Diff
Fix problem with timer after logout
parent
627aae7f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/app/app.component.ts
+8
-8
8 additions, 8 deletions
src/app/app.component.ts
src/app/auth/idle-timer.ts
+0
-1
0 additions, 1 deletion
src/app/auth/idle-timer.ts
src/app/shared/navbar/navbar.component.ts
+14
-20
14 additions, 20 deletions
src/app/shared/navbar/navbar.component.ts
with
22 additions
and
29 deletions
src/app/app.component.ts
+
8
−
8
View file @
3ecd8338
import
{
Component
,
ViewEncapsulation
}
from
'
@angular/core
'
;
import
{
AppConfigService
,
ConfigurationService
}
from
'
./service
'
;
import
{
Component
,
ViewEncapsulation
}
from
'
@angular/core
'
;
import
{
AppConfigService
,
ConfigurationService
}
from
'
./service
'
;
import
{
TranslateService
}
from
'
@ngx-translate/core
'
;
import
{
AuthService
}
from
'
./auth/auth.service
'
;
import
{
Router
}
from
'
@angular/router
'
;
...
...
@@ -7,10 +7,10 @@ import {ServiceUnavailableService} from './service-unavailable/service-unavailab
import
{
IdleTimer
}
from
'
./auth/idle-timer
'
;
@
Component
({
selector
:
'
nmaas-root
'
,
templateUrl
:
'
./app.component.html
'
,
styleUrls
:
[
'
./app.component.css
'
],
encapsulation
:
ViewEncapsulation
.
None
selector
:
'
nmaas-root
'
,
templateUrl
:
'
./app.component.html
'
,
styleUrls
:
[
'
./app.component.css
'
],
encapsulation
:
ViewEncapsulation
.
None
})
export
class
AppComponent
{
...
...
@@ -33,8 +33,8 @@ export class AppComponent {
this
.
authService
.
isLoggedIn$
.
subscribe
(
isLoggedIn
=>
{
if
(
isLoggedIn
)
{
this
.
timer
=
new
IdleTimer
(
{
timeout
:
900
,
// 15 min
this
.
timer
=
new
IdleTimer
({
timeout
:
900
,
// 15 min
onTimeout
:
()
=>
{
this
.
authService
.
logout
();
this
.
router
.
navigate
([
'
/welcome
'
])
...
...
This diff is collapsed.
Click to expand it.
src/app/auth/idle-timer.ts
+
0
−
1
View file @
3ecd8338
...
...
@@ -44,7 +44,6 @@ export class IdleTimer {
}
private
cleanUp
()
{
console
.
log
(
'
cleanup
'
)
clearInterval
(
this
.
interval
);
window
.
removeEventListener
(
'
mousemove
'
,
this
.
eventHandler
);
window
.
removeEventListener
(
'
scroll
'
,
this
.
eventHandler
);
...
...
This diff is collapsed.
Click to expand it.
src/app/shared/navbar/navbar.component.ts
+
14
−
20
View file @
3ecd8338
import
{
Component
,
On
Changes
,
OnInit
,
SimpleChanges
,
ViewChild
}
from
'
@angular/core
'
;
import
{
Router
}
from
'
@angular/router
'
;
import
{
Component
,
On
Init
,
ViewChild
}
from
'
@angular/core
'
;
import
{
Router
}
from
'
@angular/router
'
;
import
{
TranslateService
}
from
'
@ngx-translate/core
'
;
import
{
interval
,
Subscription
}
from
'
rxjs
'
;
import
{
AuthService
}
from
'
../../auth/auth.service
'
;
...
...
@@ -13,9 +13,9 @@ import {DatePipe} from '@angular/common';
templateUrl
:
'
./navbar.component.html
'
,
styleUrls
:
[
'
./navbar.component.css
'
]
})
export
class
NavbarComponent
implements
OnInit
,
OnChanges
{
export
class
NavbarComponent
implements
OnInit
{
@
ViewChild
(
ModalNotificationSendComponent
,
{
static
:
true
})
@
ViewChild
(
ModalNotificationSendComponent
,
{
static
:
true
})
public
notificationModal
;
public
languages
:
string
[];
...
...
@@ -59,23 +59,17 @@ export class NavbarComponent implements OnInit, OnChanges {
}
}
this
.
intervalId
=
setInterval
(()
=>
{
const
expiredTimeText
:
string
=
localStorage
.
getItem
(
'
_expiredTime
'
)
if
(
parseInt
(
expiredTimeText
,
10
)
>
Date
.
now
())
{
this
.
time
=
this
.
datePipe
.
transform
(
new
Date
(
parseInt
(
expiredTimeText
,
10
)
-
Date
.
now
()),
'
mm:ss
'
)
console
.
debug
(
'
Autologout in
'
,
this
.
time
);
if
(
this
.
authService
.
isLogged
())
{
const
expiredTimeText
:
string
=
localStorage
.
getItem
(
'
_expiredTime
'
)
if
(
parseInt
(
expiredTimeText
,
10
)
>
Date
.
now
())
{
this
.
time
=
this
.
datePipe
.
transform
(
new
Date
(
parseInt
(
expiredTimeText
,
10
)
-
Date
.
now
()),
'
mm:ss
'
)
console
.
debug
(
'
Autologout in
'
,
this
.
time
);
}
this
.
showClock
=
parseInt
(
expiredTimeText
,
10
)
-
Date
.
now
()
<
180000
&&
parseInt
(
expiredTimeText
,
10
)
-
Date
.
now
()
>=
0
;
}
this
.
showClock
=
parseInt
(
expiredTimeText
,
10
)
-
Date
.
now
()
<
180000
&&
parseInt
(
expiredTimeText
,
10
)
-
Date
.
now
()
>=
0
;
},
1000
);
// this.authService.isLoggedIn$.subscribe( data => {
// if (!data) {
// console.warn("state", data);
// clearInterval(this.intervalId);
// }
// })
}
ngOnChanges
(
changes
:
SimpleChanges
):
void
{
}
public
getSupportedLanguages
()
{
...
...
@@ -87,9 +81,9 @@ export class NavbarComponent implements OnInit, OnChanges {
public
checkUserRole
():
boolean
{
return
this
.
authService
.
getDomains
().
filter
(
value
=>
value
!=
this
.
domainService
.
getGlobalDomainId
()).
length
>
0
||
this
.
authService
.
getRoles
().
filter
(
value
=>
value
!=
'
ROLE_INCOMPLETE
'
)
.
filter
(
value
=>
value
!=
'
ROLE_GUEST
'
)
.
length
>
0
;
||
this
.
authService
.
getRoles
().
filter
(
value
=>
value
!=
'
ROLE_INCOMPLETE
'
)
.
filter
(
value
=>
value
!=
'
ROLE_GUEST
'
)
.
length
>
0
;
}
public
showNotificationModal
():
void
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment