@genesislcap/foundation-header 14.321.1-alpha-3586f61.0 → 14.322.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +322 -0
- package/dist/custom-elements.json +424 -0
- package/dist/dts/main/main.d.ts +44 -0
- package/dist/dts/main/main.d.ts.map +1 -1
- package/dist/esm/main/main.js +82 -0
- package/dist/foundation-header.api.json +122 -1
- package/dist/foundation-header.d.ts +44 -0
- package/docs/api/foundation-header.navigation.disconnectedcallback.md +17 -0
- package/docs/api/foundation-header.navigation.enableinactivitymonitoring.md +18 -0
- package/docs/api/foundation-header.navigation.inactivitytimeoutminutes.md +18 -0
- package/docs/api/foundation-header.navigation.inactivitywarningminutes.md +18 -0
- package/docs/api/foundation-header.navigation.md +71 -0
- package/docs/api-report.md.api.md +4 -0
- package/package.json +22 -22
package/README.md
CHANGED
|
@@ -262,6 +262,321 @@ export class MainRouterConfig extends RouterConfiguration<LoginSettings> {
|
|
|
262
262
|
}
|
|
263
263
|
```
|
|
264
264
|
|
|
265
|
+
## Inactivity Monitoring
|
|
266
|
+
|
|
267
|
+
The `foundation-header` component supports configurable inactivity monitoring through attributes.
|
|
268
|
+
|
|
269
|
+
### Configuration Attributes
|
|
270
|
+
|
|
271
|
+
#### `inactivity-timeout-minutes`
|
|
272
|
+
- **Type**: Number
|
|
273
|
+
- **Default**: 30
|
|
274
|
+
- **Description**: Sets the inactivity timeout in minutes before automatic logout
|
|
275
|
+
|
|
276
|
+
#### `inactivity-warning-minutes`
|
|
277
|
+
- **Type**: Number
|
|
278
|
+
- **Default**: 5
|
|
279
|
+
- **Description**: Sets the inactivity warning time in minutes before timeout
|
|
280
|
+
|
|
281
|
+
#### `enable-inactivity-monitoring`
|
|
282
|
+
- **Type**: Boolean
|
|
283
|
+
- **Default**: `true`
|
|
284
|
+
- **Description**: Controls whether inactivity monitoring is enabled
|
|
285
|
+
|
|
286
|
+
### Usage Examples
|
|
287
|
+
|
|
288
|
+
#### Basic Configuration
|
|
289
|
+
```html
|
|
290
|
+
<foundation-header
|
|
291
|
+
inactivity-timeout-minutes="20"
|
|
292
|
+
inactivity-warning-minutes="3"
|
|
293
|
+
></foundation-header>
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
#### Short Session (15 minutes timeout, 2 minutes warning)
|
|
297
|
+
```html
|
|
298
|
+
<foundation-header
|
|
299
|
+
inactivity-timeout-minutes="15"
|
|
300
|
+
inactivity-warning-minutes="2"
|
|
301
|
+
></foundation-header>
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
#### Long Session (60 minutes timeout, 10 minutes warning)
|
|
305
|
+
```html
|
|
306
|
+
<foundation-header
|
|
307
|
+
inactivity-timeout-minutes="60"
|
|
308
|
+
inactivity-warning-minutes="10"
|
|
309
|
+
></foundation-header>
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
#### Default Configuration (30 minutes timeout, 5 minutes warning)
|
|
313
|
+
```html
|
|
314
|
+
<foundation-header></foundation-header>
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
#### Enable Inactivity Monitoring (Default)
|
|
318
|
+
```html
|
|
319
|
+
<foundation-header></foundation-header>
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
#### Enable Inactivity Monitoring (Explicit)
|
|
323
|
+
```html
|
|
324
|
+
<foundation-header enable-inactivity-monitoring></foundation-header>
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
#### Disable Inactivity Monitoring
|
|
328
|
+
```html
|
|
329
|
+
<foundation-header enable-inactivity-monitoring="false"></foundation-header>
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
#### Complete Configuration with Enable/Disable
|
|
333
|
+
```html
|
|
334
|
+
<!-- Enabled with custom timeout -->
|
|
335
|
+
<foundation-header
|
|
336
|
+
enable-inactivity-monitoring
|
|
337
|
+
inactivity-timeout-minutes="20"
|
|
338
|
+
inactivity-warning-minutes="3"
|
|
339
|
+
></foundation-header>
|
|
340
|
+
|
|
341
|
+
<!-- Disabled (other attributes ignored) -->
|
|
342
|
+
<foundation-header
|
|
343
|
+
enable-inactivity-monitoring="false"
|
|
344
|
+
inactivity-timeout-minutes="30"
|
|
345
|
+
inactivity-warning-minutes="5"
|
|
346
|
+
></foundation-header>
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Behavior
|
|
350
|
+
|
|
351
|
+
#### When Enabled (Default)
|
|
352
|
+
- InactivityManager is created and started
|
|
353
|
+
- User activity is monitored
|
|
354
|
+
- Warning dialog appears before timeout
|
|
355
|
+
- Automatic logout occurs on timeout
|
|
356
|
+
- Debug log: "Inactivity manager initialized and started..."
|
|
357
|
+
|
|
358
|
+
#### When Disabled
|
|
359
|
+
- No InactivityManager is created
|
|
360
|
+
- No activity monitoring occurs
|
|
361
|
+
- No warning dialogs or timeouts
|
|
362
|
+
- Debug log: "Inactivity monitoring is disabled"
|
|
363
|
+
|
|
364
|
+
### Event Handling
|
|
365
|
+
|
|
366
|
+
The component automatically emits events based on the configured timeout and warning settings:
|
|
367
|
+
|
|
368
|
+
```html
|
|
369
|
+
<foundation-header
|
|
370
|
+
id="app-header"
|
|
371
|
+
inactivity-timeout-minutes="20"
|
|
372
|
+
inactivity-warning-minutes="3"
|
|
373
|
+
></foundation-header>
|
|
374
|
+
|
|
375
|
+
<script>
|
|
376
|
+
const header = document.getElementById('app-header');
|
|
377
|
+
|
|
378
|
+
// Warning will be triggered 3 minutes before timeout (at 17 minutes of inactivity)
|
|
379
|
+
header.addEventListener('inactivity-warning', (event) => {
|
|
380
|
+
const remainingSeconds = event.detail.remainingSeconds;
|
|
381
|
+
console.log(`Warning: Session will expire in ${remainingSeconds} seconds`);
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
// Timeout will be triggered after 20 minutes of inactivity
|
|
385
|
+
header.addEventListener('inactivity-timeout', () => {
|
|
386
|
+
console.log('Session expired due to inactivity');
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
// Reset is triggered whenever user activity is detected
|
|
390
|
+
header.addEventListener('inactivity-reset', () => {
|
|
391
|
+
console.log('User activity detected - timer reset');
|
|
392
|
+
});
|
|
393
|
+
</script>
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### Configuration Guidelines
|
|
397
|
+
|
|
398
|
+
#### Recommended Settings
|
|
399
|
+
|
|
400
|
+
| Use Case | Timeout | Warning | Description |
|
|
401
|
+
|----------|---------|---------|-------------|
|
|
402
|
+
| **High Security** | 15-20 min | 2-3 min | Banking, healthcare, sensitive data |
|
|
403
|
+
| **Standard** | 30 min | 5 min | General business applications |
|
|
404
|
+
| **Long Sessions** | 60 min | 10 min | Creative work, analysis tools |
|
|
405
|
+
| **Development** | 120 min | 15 min | Development environments |
|
|
406
|
+
|
|
407
|
+
#### Best Practices
|
|
408
|
+
|
|
409
|
+
1. **Warning Time**: Should be 10-20% of the timeout time
|
|
410
|
+
2. **Minimum Values**: Don't set timeout below 10 minutes or warning below 1 minute
|
|
411
|
+
3. **User Experience**: Consider the user's workflow when setting these values
|
|
412
|
+
4. **Security Requirements**: Align with your organization's security policies
|
|
413
|
+
|
|
414
|
+
### Use Cases
|
|
415
|
+
|
|
416
|
+
#### Development/Testing
|
|
417
|
+
```html
|
|
418
|
+
<!-- Disable during development -->
|
|
419
|
+
<foundation-header enable-inactivity-monitoring="false"></foundation-header>
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
#### Production with Monitoring
|
|
423
|
+
```html
|
|
424
|
+
<!-- Enable with appropriate timeout for production -->
|
|
425
|
+
<foundation-header
|
|
426
|
+
enable-inactivity-monitoring
|
|
427
|
+
inactivity-timeout-minutes="30"
|
|
428
|
+
inactivity-warning-minutes="5"
|
|
429
|
+
></foundation-header>
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
#### Conditional Monitoring
|
|
433
|
+
```javascript
|
|
434
|
+
const header = document.querySelector('foundation-header');
|
|
435
|
+
|
|
436
|
+
// Enable monitoring for admin users
|
|
437
|
+
if (userRole === 'admin') {
|
|
438
|
+
header.setAttribute('enable-inactivity-monitoring', 'true');
|
|
439
|
+
} else {
|
|
440
|
+
header.setAttribute('enable-inactivity-monitoring', 'false');
|
|
441
|
+
}
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
### Dynamic Configuration
|
|
445
|
+
|
|
446
|
+
You can also set these attributes programmatically:
|
|
447
|
+
|
|
448
|
+
```javascript
|
|
449
|
+
const header = document.querySelector('foundation-header');
|
|
450
|
+
|
|
451
|
+
// Set timeout to 45 minutes
|
|
452
|
+
header.setAttribute('inactivity-timeout-minutes', '45');
|
|
453
|
+
|
|
454
|
+
// Set warning to 5 minutes
|
|
455
|
+
header.setAttribute('inactivity-warning-minutes', '5');
|
|
456
|
+
|
|
457
|
+
// Disable monitoring
|
|
458
|
+
header.setAttribute('enable-inactivity-monitoring', 'false');
|
|
459
|
+
|
|
460
|
+
// Enable monitoring
|
|
461
|
+
header.setAttribute('enable-inactivity-monitoring', 'true');
|
|
462
|
+
|
|
463
|
+
// Check current state
|
|
464
|
+
const isEnabled = header.hasAttribute('enable-inactivity-monitoring') &&
|
|
465
|
+
header.getAttribute('enable-inactivity-monitoring') !== 'false';
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### Integration with Authentication
|
|
469
|
+
|
|
470
|
+
The inactivity monitoring integrates seamlessly with the existing authentication system:
|
|
471
|
+
|
|
472
|
+
```html
|
|
473
|
+
<foundation-header
|
|
474
|
+
inactivity-timeout-minutes="30"
|
|
475
|
+
inactivity-warning-minutes="5"
|
|
476
|
+
></foundation-header>
|
|
477
|
+
|
|
478
|
+
<script>
|
|
479
|
+
const header = document.querySelector('foundation-header');
|
|
480
|
+
|
|
481
|
+
// Handle logout when timeout occurs
|
|
482
|
+
header.addEventListener('logout-clicked', () => {
|
|
483
|
+
// Clear session data
|
|
484
|
+
sessionStorage.clear();
|
|
485
|
+
localStorage.removeItem('auth-token');
|
|
486
|
+
|
|
487
|
+
// Redirect to login page
|
|
488
|
+
window.location.href = '/login';
|
|
489
|
+
});
|
|
490
|
+
</script>
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
### Complete Example
|
|
494
|
+
|
|
495
|
+
```html
|
|
496
|
+
<!DOCTYPE html>
|
|
497
|
+
<html>
|
|
498
|
+
<head>
|
|
499
|
+
<title>Foundation Header with Inactivity Monitoring</title>
|
|
500
|
+
</head>
|
|
501
|
+
<body>
|
|
502
|
+
<foundation-header
|
|
503
|
+
id="app-header"
|
|
504
|
+
enable-inactivity-monitoring
|
|
505
|
+
inactivity-timeout-minutes="25"
|
|
506
|
+
inactivity-warning-minutes="4"
|
|
507
|
+
show-connection-indicator
|
|
508
|
+
show-language-selector
|
|
509
|
+
></foundation-header>
|
|
510
|
+
|
|
511
|
+
<div id="inactivity-notification" style="display: none; position: fixed; top: 20px; right: 20px; background: #ff9800; color: white; padding: 16px; border-radius: 4px; z-index: 1000;">
|
|
512
|
+
<div id="notification-text"></div>
|
|
513
|
+
<button onclick="extendSession()" style="margin-top: 8px; padding: 4px 8px;">Continue Session</button>
|
|
514
|
+
</div>
|
|
515
|
+
|
|
516
|
+
<!-- Control buttons -->
|
|
517
|
+
<div style="margin: 20px;">
|
|
518
|
+
<button onclick="enableMonitoring()">Enable Monitoring</button>
|
|
519
|
+
<button onclick="disableMonitoring()">Disable Monitoring</button>
|
|
520
|
+
<button onclick="checkStatus()">Check Status</button>
|
|
521
|
+
</div>
|
|
522
|
+
|
|
523
|
+
<script type="module">
|
|
524
|
+
import { foundationHeader } from '@genesislcap/foundation-header';
|
|
525
|
+
|
|
526
|
+
const header = document.getElementById('app-header');
|
|
527
|
+
const notification = document.getElementById('inactivity-notification');
|
|
528
|
+
const notificationText = document.getElementById('notification-text');
|
|
529
|
+
|
|
530
|
+
header.addEventListener('inactivity-warning', (event) => {
|
|
531
|
+
const remainingSeconds = event.detail.remainingSeconds;
|
|
532
|
+
notificationText.textContent = `Your session will expire in ${remainingSeconds} seconds.`;
|
|
533
|
+
notification.style.display = 'block';
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
header.addEventListener('inactivity-reset', () => {
|
|
537
|
+
notification.style.display = 'none';
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
header.addEventListener('logout-clicked', () => {
|
|
541
|
+
alert('Session expired. You will be redirected to the login page.');
|
|
542
|
+
window.location.href = '/login';
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
function extendSession() {
|
|
546
|
+
// Trigger user activity to reset the timer
|
|
547
|
+
document.body.click();
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
function enableMonitoring() {
|
|
551
|
+
header.setAttribute('enable-inactivity-monitoring', 'true');
|
|
552
|
+
console.log('Inactivity monitoring enabled');
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
function disableMonitoring() {
|
|
556
|
+
header.setAttribute('enable-inactivity-monitoring', 'false');
|
|
557
|
+
console.log('Inactivity monitoring disabled');
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
function checkStatus() {
|
|
561
|
+
const isEnabled = header.hasAttribute('enable-inactivity-monitoring') &&
|
|
562
|
+
header.getAttribute('enable-inactivity-monitoring') !== 'false';
|
|
563
|
+
console.log('Inactivity monitoring is:', isEnabled ? 'enabled' : 'disabled');
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
// Check initial status
|
|
567
|
+
checkStatus();
|
|
568
|
+
</script>
|
|
569
|
+
</body>
|
|
570
|
+
</html>
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
### Notes
|
|
574
|
+
|
|
575
|
+
- When disabled, the InactivityManager is not created, saving memory and CPU
|
|
576
|
+
- The enable/disable state is checked only during initialization
|
|
577
|
+
- Changing the attribute after the component is created requires reconnecting the component to take effect
|
|
578
|
+
- All other inactivity-related attributes are ignored when monitoring is disabled
|
|
579
|
+
|
|
265
580
|
## DOM API
|
|
266
581
|
|
|
267
582
|
Property and attribute binding examples for foundation-header micro-frontend.
|
|
@@ -278,6 +593,9 @@ Property and attribute binding examples for foundation-header micro-frontend.
|
|
|
278
593
|
| show-connection-indicator | `boolean` | Boolean attribute which controls whether the navigation bar will display the connection indicator. | `<foundation-header show-connection-indicator>` |
|
|
279
594
|
| show-language-selector | `boolean` | Boolean attribute which controls whether the navigation bar will display the language selector. | `<foundation-header show-language-selector>` |
|
|
280
595
|
| hide-side-bar | `boolean` | Boolean attribute which controls whether the navigation bar will display the side bar. | `<foundation-header hide-side-bar>` |
|
|
596
|
+
| inactivity-timeout-minutes | `number` | Number attribute which sets the inactivity timeout in minutes (default: 30). | `<foundation-header inactivity-timeout-minutes="20">` |
|
|
597
|
+
| inactivity-warning-minutes | `number` | Number attribute which sets the inactivity warning time in minutes (default: 5). | `<foundation-header inactivity-warning-minutes="3">` |
|
|
598
|
+
| enable-inactivity-monitoring | `boolean` | Boolean attribute which controls whether inactivity monitoring is enabled (default: true). | `<foundation-header enable-inactivity-monitoring="false">` |
|
|
281
599
|
|
|
282
600
|
### Properties
|
|
283
601
|
|
|
@@ -317,6 +635,10 @@ Property and attribute binding examples for foundation-header micro-frontend.
|
|
|
317
635
|
| misc-icon-clicked | `void` | Dispatched when the user clicks on the miscellaneous behaviour icon in the navigation bar. | `<foundation-header @misc-icon-clicked="${(x) => x.handleMiscIconClick}">` |
|
|
318
636
|
| notification-icon-clicked | `void` | Dispatched when the user clicks on the notification icon in the navigation bar. | `<foundation-header @notification-icon-clicked="${(x) => x.handleNotificationIconClick}">` |
|
|
319
637
|
| language-changed | `void` | Dispatched when the user changes the language in the language selector. | `<foundation-header @language-changed="${(x) => x.handleLanguageChange}">` |
|
|
638
|
+
| inactivity-warning | `InactivityWarningEvent` | Dispatched when the inactivity warning is triggered. | `<foundation-header @inactivity-warning="${(x) => x.handleInactivityWarning}">` |
|
|
639
|
+
| inactivity-timeout | `void` | Dispatched when the inactivity timeout is reached. | `<foundation-header @inactivity-timeout="${(x) => x.handleInactivityTimeout}">` |
|
|
640
|
+
| inactivity-reset | `void` | Dispatched when user activity is detected and the timer is reset. | `<foundation-header @inactivity-reset="${(x) => x.handleInactivityReset}">` |
|
|
641
|
+
| logout-clicked | `void` | Dispatched when logout is triggered due to inactivity timeout. | `<foundation-header @logout-clicked="${(x) => x.handleLogout}">` |
|
|
320
642
|
|
|
321
643
|
## Listened Events
|
|
322
644
|
|