-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(stark-ui): implementation of a session timeout warning #876
feat(stark-ui): implementation of a session timeout warning #876
Conversation
Hey guys, I still need to look after the translation problem, but I've made the pull request anyway so you can already have a look at the change ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes... one of them might solve the issue with the translations :)
docs/TIMEOUT_WARNING.md
Outdated
@@ -0,0 +1,43 @@ | |||
# Session Timeout Warning configuration | |||
|
|||
If you wish your project to warn the user that its session is about to end, you can use our `SessionTimeoutWarningDialogComponent`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can re-phrase this like:
"Stark provides a nice feature when it comes to session expiration handling: in case the user's session is about to end due to inactivity (the user is idle for some time) and you want to warn him about this. This is what the SessionTimeoutWarningDialogComponent
does and also asks the user whether to keep his session alive."
What do you think?
docs/TIMEOUT_WARNING.md
Outdated
|
||
If you wish your project to warn the user that its session is about to end, you can use our `SessionTimeoutWarningDialogComponent`. | ||
|
||
To do so, you'll have to modifiy the `app.module.ts` file of your application. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"To use this feature, you'll have to modify the app.module.ts
file of your application."
docs/TIMEOUT_WARNING.md
Outdated
``` | ||
import { | ||
StarkSessionUiModule | ||
} from "@nationalbankbelgium/stark-ui"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put this import in one single line to make it more readable?
docs/TIMEOUT_WARNING.md
Outdated
StarkSessionUiModule | ||
} from "@nationalbankbelgium/stark-ui"; | ||
|
||
//the timeoutWarningDialogEffects won't be used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??
docs/TIMEOUT_WARNING.md
Outdated
@NgModule({ | ||
imports: [ | ||
StarkSessionUiModule.forRoot({ | ||
enableTimeoutWarningDialogEffects: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed, can you rename this option to "timeoutWarningDialogDisabled" so we keep consistency with the way the options in stark-app-config
are named?
); | ||
|
||
/** | ||
* Definition of the configuration object for the Stark Session service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Stark Session UI module"
*/ | ||
export class StarkSessionUiConfig { | ||
/** | ||
* Router state for the Login page where the user can choose a profile and use it to impersonate himself as someone else. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??
* Router state for the Login page where the user can choose a profile and use it to impersonate himself as someone else. | ||
* This state is only used in DEVELOPMENT. | ||
*/ | ||
public enableTimeoutWarningDialogEffects?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed, can you rename this option to "timeoutWarningDialogDisabled" so we keep consistency with the way the options in stark-app-config
are named?
const english: StarkLocale = { languageCode: "en", translations: translationsEn }; | ||
const french: StarkLocale = { languageCode: "fr", translations: translationsFr }; | ||
const dutch: StarkLocale = { languageCode: "nl", translations: translationsNl }; | ||
mergeUiTranslations(translateService, english, french, dutch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is why the translations are not working anymore in the Session UI module :p Maybe a rebase problem?
showcase/src/app/app.module.ts
Outdated
@@ -235,7 +235,9 @@ export const metaReducers: MetaReducer<State>[] = ENV !== "production" ? [logger | |||
position: "top right", | |||
actionClasses: [] | |||
}), | |||
StarkSessionUiModule.forRoot(), | |||
StarkSessionUiModule.forRoot({ | |||
enableTimeoutWarningDialogEffects: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can revert this change when you rename this option to "timeoutWarningDialogDisabled" as I mentioned in my comments above ;)
2f03dba
to
7887ba6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small changes to do.
Also be careful with the fit
in the unit tests. You can easily notice this by checking the comments from Coveralls, in this case your PR decreased the coverage in almost 30%! So obviously this indicates there is an fit
somewhere
docs/TIMEOUT_WARNING.md
Outdated
@NgModule({ | ||
imports: [ | ||
StarkSessionUiModule.forRoot({ | ||
timeoutWarningDialogDisabled: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This option should not be defined if they want the dialog to be shown. In fact this should be put in the code example below :p
@NgModule({ | ||
imports: [ | ||
StarkSessionUiModule.forRoot(), | ||
... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The option should be passed here :p
docs/TIMEOUT_WARNING.md
Outdated
}) | ||
``` | ||
|
||
To indicate that you don't wish to use this effect, just set `timeoutWarningDialogDisabled` value to true. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"To indicate that you don't wish to display such warning dialog, "
docs/TIMEOUT_WARNING.md
Outdated
|
||
To indicate that you don't wish to use this effect, just set `timeoutWarningDialogDisabled` value to true. | ||
|
||
If you don't pass this value (or if you set it to false), it will be set to false by default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This text is a bit repetitive... I suggest to add in the line before: "This option is "false" by default.
@@ -20,7 +22,8 @@ import { StarkAppContainerComponent } from "./components"; | |||
StoreModule.forFeature("StarkSession", starkSessionReducers), | |||
UIRouterModule.forChild({ | |||
states: SESSION_STATES | |||
}) | |||
}), | |||
EffectsModule.forFeature([StarkSettingsEffects]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is wrong... I think this file got messed up with a rebase or something. Just revert these changes.
|
||
(<Spy>mockObserver.next).calls.reset(); | ||
|
||
// the effects should keep on running with any action other than the "stopping action" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the other than the "stopping action"
part ;)
|
||
(<Spy>mockObserver.next).calls.reset(); | ||
|
||
// the effects should keep on running with any action other than the "stopping action" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the other than the "stopping action"
part ;)
imports: [ | ||
CommonModule, | ||
UIRouterModule.forChild({ | ||
states: SESSION_UI_STATES | ||
}), | ||
StarkSessionModule, | ||
StarkLoggingModule, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove these two modules otherwise we are creating a hard link between the different modules of Stark.
Our goal is to have soft links, meaning that we just require the services (which the developer can provide by his own) but not the Stark modules themselves.
*/ | ||
export class StarkSessionUiConfig { | ||
/** | ||
* If the warning dialog effect is disabled or not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's expand this description so that it is clear we use an effect for this. What about this?
"Whether the warning dialog should be displayed or not. If true, then the Ngrx Effects in charge of displaying the dialog won't be executed."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
much better
Stark provides a nice feature when it comes to session expiration handling: in case the user's session is about to end due | ||
to inactivity (the user is idle for some time) and you want to warn him about this, a dialog will be displayed. | ||
|
||
This is what the `SessionTimeoutWarningDialogComponent` does and also asks the user if its session should be kept alive. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add this in the same line to explain how we do this ;)
"This warning dialog is displayed by an NGRX Effect that triggers when a StarkSessionActionTypes.SESSION_TIMEOUT_COUNTDOWN_START
action is dispatched (by the Session service when the user becomes idle)."
7887ba6
to
e5e6436
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed some other small changes to be done... sorry
STAY_CONNECTED: "Stay connected", | ||
TITLE: "Session timeout warning", | ||
WILL_EXPIRE_IN: "Your session will expire in ", | ||
WISH_STAY_CONNECTED: "Do you wish to stay connected ?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a whitespace before the question mark ?
:s
STAY_CONNECTED: "Rester connecté", | ||
TITLE: "Avertissement d'expiration de session", | ||
WILL_EXPIRE_IN: "Votre session va expirer dans ", | ||
WISH_STAY_CONNECTED: "Voulez-vous rester connecté ?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a whitespace before the question mark ?
:s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In French, we have a whitespace before the question mark 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WTF!! 😮
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, if I remember well my typing lessons (yep, I've had that, boring as hell), the convention is not to put a white space before, to treat it like a regular point. Word, OpenOffice, etc, always try to put one before, but it is not the official convention ^^ So I do think Christopher is right, I'll remove it, my bad :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I have no idea about this so you can do what think it is best 😉
STAY_CONNECTED: "Verbonden blijven", | ||
TITLE: "Sessietime-out waarschuwing", | ||
WILL_EXPIRE_IN: "Uw sessie zal binnen ", | ||
WISH_STAY_CONNECTED: "Wilt u verbonden blijven ?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a whitespace before the question mark ?
:s
@@ -0,0 +1,18 @@ | |||
<div class="stark-timeout-warning-dialog" role="alertdialog" aria-busy="true" aria-live="assertive"> | |||
<header><i></i></header> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this line is needed, there is nothing related to those elements in the CSS
@@ -0,0 +1,18 @@ | |||
<div class="stark-timeout-warning-dialog" role="alertdialog" aria-busy="true" aria-live="assertive"> | |||
<header><i></i></header> | |||
<h2 translate>STARK.SESSION_TIMEOUT.TITLE</h2> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should follow the API from Angular Material for Dialogs, basically we should add these directives except the MatDialogClose
.
You can see how they are used in the example
2619f3d
to
103b7a3
Compare
103b7a3
to
578b8a2
Compare
ISSUES CLOSED: #719
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Issue Number: #119 #719
What is the new behavior?
A new SessionTimeoutWarning dialog will be displayed when the user is inactive for too long, along with a timer.
Does this PR introduce a breaking change?
Other information