@energycap/components 0.27.8 → 0.27.9
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/bundles/energycap-components.umd.js +130 -110
- package/bundles/energycap-components.umd.js.map +1 -1
- package/bundles/energycap-components.umd.min.js +2 -2
- package/bundles/energycap-components.umd.min.js.map +1 -1
- package/energycap-components.metadata.json +1 -1
- package/esm2015/lib/controls/banner/banner.component.js +24 -3
- package/fesm2015/energycap-components.js +125 -105
- package/fesm2015/energycap-components.js.map +1 -1
- package/lib/controls/banner/banner.component.d.ts +9 -0
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Component, Input, Output, EventEmitter, HostBinding } from '@angular/core';
|
|
2
|
+
import { CacheService } from '../../core/cache.service';
|
|
2
3
|
export class BannerComponent {
|
|
3
|
-
constructor() {
|
|
4
|
+
constructor(cacheService) {
|
|
5
|
+
this.cacheService = cacheService;
|
|
4
6
|
/** hidden hides the banner */
|
|
5
7
|
this.hidden = false;
|
|
6
8
|
/**The ID of the component, rendered into the HTML to make it more accessible to automation */
|
|
@@ -12,6 +14,8 @@ export class BannerComponent {
|
|
|
12
14
|
this.showCloseBtn = false;
|
|
13
15
|
/** When true, the banner will hide itself when the close button is clicked */
|
|
14
16
|
this.autoHideOnClose = true;
|
|
17
|
+
/** When true, the banner will automatically hide itself based on the state found in local storage */
|
|
18
|
+
this.rememberClosed = false;
|
|
15
19
|
/**Event to hide the banner */
|
|
16
20
|
this.closed = new EventEmitter();
|
|
17
21
|
/**
|
|
@@ -19,6 +23,7 @@ export class BannerComponent {
|
|
|
19
23
|
* If no value for overrideIcon is provided, will be automatically selected based on the type input.
|
|
20
24
|
*/
|
|
21
25
|
this.icon = '';
|
|
26
|
+
this.cacheKeyPrefix = 'dismissableBanner-';
|
|
22
27
|
}
|
|
23
28
|
ngOnChanges() {
|
|
24
29
|
if (this.customIcon) {
|
|
@@ -27,12 +32,24 @@ export class BannerComponent {
|
|
|
27
32
|
else {
|
|
28
33
|
this.getIconByBannerType();
|
|
29
34
|
}
|
|
35
|
+
if (this.rememberClosed) {
|
|
36
|
+
let cacheValue = this.cacheService.getItem(`${this.cacheKeyPrefix}${this.id}`);
|
|
37
|
+
if (cacheValue) {
|
|
38
|
+
this.hidden = cacheValue.hidden;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
this.hidden = false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
30
44
|
}
|
|
31
45
|
/** On close, explicitly hide the banner one time. If the input changes afterward then it can reappear*/
|
|
32
46
|
close() {
|
|
33
47
|
if (this.autoHideOnClose) {
|
|
34
48
|
this.hidden = true;
|
|
35
49
|
}
|
|
50
|
+
if (this.rememberClosed) {
|
|
51
|
+
this.cacheService.setItem(`${this.cacheKeyPrefix}${this.id}`, { hidden: true });
|
|
52
|
+
}
|
|
36
53
|
this.closed.emit();
|
|
37
54
|
}
|
|
38
55
|
getIconByBannerType() {
|
|
@@ -53,10 +70,13 @@ export class BannerComponent {
|
|
|
53
70
|
BannerComponent.decorators = [
|
|
54
71
|
{ type: Component, args: [{
|
|
55
72
|
selector: 'ec-banner',
|
|
56
|
-
template: "<div class=\"banner {{type}} {{bannerStyle}}\">\r\n <ec-button id=\"banner{{id}}_close\"\r\n *ngIf=\"showCloseBtn\"\r\n type=\"icon\"\r\n icon=\"ec-icon-sm icon-cancel\"\r\n (clicked)=\"close()\">\r\n </ec-button>\r\n <div class=\"banner-content d-flex text-body-1 font-color-secondary\">\r\n <i class=\"ec-icon {{icon}}\"></i>\r\n <div class=\"ml-2\">\r\n <p class=\"title mb-0\" *ngIf=\"title\">\r\n {{title}}\r\n </p>\r\n <p class=\"text mb-0\" *ngIf=\"text\">{{text}}</p>\r\n \r\n <ul class=\"list mb-0\" *ngIf=\"list?.length\">\r\n <li *ngFor=\"let item of list\">{{item}}</li>\r\n </ul>\r\n <ng-content></ng-content>\r\n </div>\r\n </div>\r\n\r\n</div>\r\n",
|
|
73
|
+
template: "<div id=\"banner_{{id}}\" class=\"banner {{type}} {{bannerStyle}}\">\r\n <ec-button id=\"banner{{id}}_close\"\r\n *ngIf=\"showCloseBtn\"\r\n type=\"icon\"\r\n icon=\"ec-icon-sm icon-cancel\"\r\n (clicked)=\"close()\">\r\n </ec-button>\r\n <div class=\"banner-content d-flex text-body-1 font-color-secondary\">\r\n <i class=\"ec-icon {{icon}}\"></i>\r\n <div class=\"ml-2\">\r\n <p class=\"title mb-0\" *ngIf=\"title\">\r\n {{title}}\r\n </p>\r\n <p class=\"text mb-0\" *ngIf=\"text\">{{text}}</p>\r\n \r\n <ul class=\"list mb-0\" *ngIf=\"list?.length\">\r\n <li *ngFor=\"let item of list\">{{item}}</li>\r\n </ul>\r\n <ng-content></ng-content>\r\n </div>\r\n </div>\r\n\r\n</div>\r\n",
|
|
57
74
|
styles: ["@-webkit-keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}:host{display:flex}:host(.border-bottom-0) .banner{border-bottom:0}.banner{display:flex;flex:1 1;flex-direction:column;min-height:2.5rem;overflow-y:auto;position:relative}.banner-content{flex:none;margin:auto 0;padding:.5rem 1rem}.banner-content ::ng-deep p{line-height:inherit}.ec-icon{font-size:1.125rem}ec-button{position:absolute;right:.25rem;top:.25rem}ec-button+.banner-content{padding-right:2.75rem}.title{font-weight:700}.list{margin:0;padding-left:2em}.text+.list{margin-top:1em}.info{background-color:#dae4e9}.info .banner-content>.ec-icon{color:#2d9ab8}.warning{background-color:#fff8cc}.warning .banner-content>.ec-icon{color:#fa7b2e}.success{background-color:#dff0d8}.success .banner-content>.ec-icon{color:#3c763d}.error{background-color:#ecc4c5}.error .banner-content>.ec-icon{color:#cd1d20}.pinned{border-bottom:1px solid rgba(26,26,35,.08)}.toast{border:1px solid rgba(26,26,35,.08);box-shadow:0 .125rem .625rem 0 rgba(26,26,35,.18)}.toast ec-button{right:.1875rem;top:.1875rem}"]
|
|
58
75
|
},] }
|
|
59
76
|
];
|
|
77
|
+
BannerComponent.ctorParameters = () => [
|
|
78
|
+
{ type: CacheService }
|
|
79
|
+
];
|
|
60
80
|
BannerComponent.propDecorators = {
|
|
61
81
|
hidden: [{ type: HostBinding, args: ['hidden',] }, { type: Input }],
|
|
62
82
|
id: [{ type: Input }],
|
|
@@ -68,6 +88,7 @@ BannerComponent.propDecorators = {
|
|
|
68
88
|
showCloseBtn: [{ type: Input }],
|
|
69
89
|
autoHideOnClose: [{ type: Input }],
|
|
70
90
|
customIcon: [{ type: Input }],
|
|
91
|
+
rememberClosed: [{ type: Input }],
|
|
71
92
|
closed: [{ type: Output }]
|
|
72
93
|
};
|
|
73
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
94
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFubmVyLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL2NvbXBvbmVudHMvc3JjL2xpYi9jb250cm9scy9iYW5uZXIvYmFubmVyLmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsU0FBUyxFQUFFLEtBQUssRUFBRSxNQUFNLEVBQUUsWUFBWSxFQUFFLFdBQVcsRUFBYSxNQUFNLGVBQWUsQ0FBQztBQUMvRixPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFXeEQsTUFBTSxPQUFPLGVBQWU7SUErQzFCLFlBQW9CLFlBQTBCO1FBQTFCLGlCQUFZLEdBQVosWUFBWSxDQUFjO1FBOUM5Qyw4QkFBOEI7UUFFZCxXQUFNLEdBQUcsS0FBSyxDQUFDO1FBRS9CLDhGQUE4RjtRQUM5RSxPQUFFLEdBQVcsRUFBRSxDQUFDO1FBRWhDLCtEQUErRDtRQUMvQ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y50eXBlID09PSAnaW5mbycpIHtcclxuICAgICAgdGhpcy5pY29uID0gJ2ljb24taW5mby1jaXJjbGUnO1xyXG4gICAgfSBlbHNlIGlmKHRoaXMudHlwZSA9PT0gJ3dhcm5pbmcnKSB7XHJcbiAgICAgIHRoaXMuaWNvbiA9ICdpY29uLXdhcm5pbmcnO1xyXG4gICAgfSBlbHNlIGlmKHRoaXMudHlwZSA9PT0gJ2Vycm9yJykge1xyXG4gICAgICB0aGlzLmljb24gPSAnaWNvbi1lcnJvcic7XHJcbiAgICB9IGVsc2UgaWYodGhpcy50eXBlID09PSAnc3VjY2VzcycpIHtcclxuICAgICAgdGhpcy5pY29uID0gJ2ljb24tY2hlY2stY2lyY2xlJztcclxuICAgIH1cclxuICB9XHJcbiAgXHJcbn1cclxuIl19
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { A11yModule } from '@angular/cdk/a11y';
|
|
2
2
|
import { OverlayConfig, Overlay as Overlay$1, OverlayModule } from '@angular/cdk/overlay';
|
|
3
3
|
import { DOCUMENT, CommonModule } from '@angular/common';
|
|
4
|
-
import { EventEmitter, Component, HostBinding, Input, Output, ViewChild, Directive,
|
|
4
|
+
import { ɵɵdefineInjectable, Injectable, EventEmitter, Component, HostBinding, Input, Output, ViewChild, Directive, Pipe, ɵɵinject, TemplateRef, ViewContainerRef, Inject, Renderer2, HostListener, ElementRef, ViewEncapsulation, ContentChild, ComponentFactoryResolver, Injector, ContentChildren, NgModule } from '@angular/core';
|
|
5
5
|
import { Validators, FormControl, FormGroup, FormControlDirective, FormArray, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
6
6
|
import { Router, ActivatedRoute, NavigationEnd, RouterModule } from '@angular/router';
|
|
7
7
|
import { TranslateService, TranslateModule } from '@ngx-translate/core';
|
|
@@ -14,8 +14,111 @@ import Popper from 'popper.js';
|
|
|
14
14
|
import { cloneDeep, uniqueId, isEqual, sortBy, orderBy, get, upperFirst } from 'lodash';
|
|
15
15
|
import { TemplatePortal } from '@angular/cdk/portal';
|
|
16
16
|
|
|
17
|
-
class
|
|
17
|
+
class CacheService {
|
|
18
18
|
constructor() {
|
|
19
|
+
this.localStorageAvailable = false;
|
|
20
|
+
this.sessionStorageAvailable = false;
|
|
21
|
+
let cacheError = null;
|
|
22
|
+
try {
|
|
23
|
+
let dateStr = 'roundtrip-test-' + new Date().getTime();
|
|
24
|
+
const value = 'val-' + dateStr;
|
|
25
|
+
localStorage.setItem(dateStr, value);
|
|
26
|
+
sessionStorage.setItem(dateStr, value);
|
|
27
|
+
this.localStorageAvailable = localStorage.getItem(dateStr) == value;
|
|
28
|
+
this.sessionStorageAvailable = sessionStorage.getItem(dateStr) == value;
|
|
29
|
+
localStorage.removeItem(dateStr);
|
|
30
|
+
sessionStorage.removeItem(dateStr);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
cacheError = error;
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
if (!this.localStorageAvailable || !this.sessionStorageAvailable) {
|
|
37
|
+
console.warn('storage unavailable for caching purposes. Some features will not be fully supported. ', {
|
|
38
|
+
local: this.localStorageAvailable,
|
|
39
|
+
session: this.sessionStorageAvailable,
|
|
40
|
+
error: cacheError
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**Return true if the requested cache allows the user to round-trip data in the current environment.
|
|
46
|
+
* Security settings can prevent it and the app may need to know if "not found" means "never set" or "not supported"
|
|
47
|
+
*/
|
|
48
|
+
isCacheAvailable(sessionOnly = false) {
|
|
49
|
+
return sessionOnly ? this.sessionStorageAvailable : this.localStorageAvailable;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Retrieve an item from cache
|
|
53
|
+
*/
|
|
54
|
+
getItem(key, sessionOnly = false) {
|
|
55
|
+
let storage = this.getStorage(sessionOnly);
|
|
56
|
+
if (storage) {
|
|
57
|
+
let result = storage.getItem(key);
|
|
58
|
+
if (result) {
|
|
59
|
+
return JSON.parse(result);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Retrieves all keys from cache
|
|
66
|
+
*/
|
|
67
|
+
keys(sessionOnly = false) {
|
|
68
|
+
let result = new Array();
|
|
69
|
+
let storage = this.getStorage(sessionOnly);
|
|
70
|
+
if (storage) {
|
|
71
|
+
for (var i = 0, len = storage.length; i < len; ++i) {
|
|
72
|
+
result.push(storage.key(i));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Removes an item from the cache
|
|
79
|
+
*/
|
|
80
|
+
removeItem(key, sessionOnly = false) {
|
|
81
|
+
let storage = this.getStorage(sessionOnly);
|
|
82
|
+
if (storage) {
|
|
83
|
+
storage.removeItem(key);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Persists an item to cache
|
|
88
|
+
*/
|
|
89
|
+
setItem(key, value, sessionOnly = false) {
|
|
90
|
+
let storage = this.getStorage(sessionOnly);
|
|
91
|
+
if (storage) {
|
|
92
|
+
storage.setItem(key, JSON.stringify(value));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**Returns the local or session storage to use for backing the given cache request.
|
|
96
|
+
* If the browser does not support the requested storage the result will be null.
|
|
97
|
+
* This can happen if the user is in Firefox for example with the setting dom.storage.enabled = false
|
|
98
|
+
*/
|
|
99
|
+
getStorage(sessionOnly) {
|
|
100
|
+
if (sessionOnly && this.sessionStorageAvailable) {
|
|
101
|
+
return window.sessionStorage;
|
|
102
|
+
}
|
|
103
|
+
else if (this.localStorageAvailable) {
|
|
104
|
+
return window.localStorage;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
CacheService.ɵprov = ɵɵdefineInjectable({ factory: function CacheService_Factory() { return new CacheService(); }, token: CacheService, providedIn: "root" });
|
|
112
|
+
CacheService.decorators = [
|
|
113
|
+
{ type: Injectable, args: [{
|
|
114
|
+
providedIn: 'root'
|
|
115
|
+
},] }
|
|
116
|
+
];
|
|
117
|
+
CacheService.ctorParameters = () => [];
|
|
118
|
+
|
|
119
|
+
class BannerComponent {
|
|
120
|
+
constructor(cacheService) {
|
|
121
|
+
this.cacheService = cacheService;
|
|
19
122
|
/** hidden hides the banner */
|
|
20
123
|
this.hidden = false;
|
|
21
124
|
/**The ID of the component, rendered into the HTML to make it more accessible to automation */
|
|
@@ -27,6 +130,8 @@ class BannerComponent {
|
|
|
27
130
|
this.showCloseBtn = false;
|
|
28
131
|
/** When true, the banner will hide itself when the close button is clicked */
|
|
29
132
|
this.autoHideOnClose = true;
|
|
133
|
+
/** When true, the banner will automatically hide itself based on the state found in local storage */
|
|
134
|
+
this.rememberClosed = false;
|
|
30
135
|
/**Event to hide the banner */
|
|
31
136
|
this.closed = new EventEmitter();
|
|
32
137
|
/**
|
|
@@ -34,6 +139,7 @@ class BannerComponent {
|
|
|
34
139
|
* If no value for overrideIcon is provided, will be automatically selected based on the type input.
|
|
35
140
|
*/
|
|
36
141
|
this.icon = '';
|
|
142
|
+
this.cacheKeyPrefix = 'dismissableBanner-';
|
|
37
143
|
}
|
|
38
144
|
ngOnChanges() {
|
|
39
145
|
if (this.customIcon) {
|
|
@@ -42,12 +148,24 @@ class BannerComponent {
|
|
|
42
148
|
else {
|
|
43
149
|
this.getIconByBannerType();
|
|
44
150
|
}
|
|
151
|
+
if (this.rememberClosed) {
|
|
152
|
+
let cacheValue = this.cacheService.getItem(`${this.cacheKeyPrefix}${this.id}`);
|
|
153
|
+
if (cacheValue) {
|
|
154
|
+
this.hidden = cacheValue.hidden;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
this.hidden = false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
45
160
|
}
|
|
46
161
|
/** On close, explicitly hide the banner one time. If the input changes afterward then it can reappear*/
|
|
47
162
|
close() {
|
|
48
163
|
if (this.autoHideOnClose) {
|
|
49
164
|
this.hidden = true;
|
|
50
165
|
}
|
|
166
|
+
if (this.rememberClosed) {
|
|
167
|
+
this.cacheService.setItem(`${this.cacheKeyPrefix}${this.id}`, { hidden: true });
|
|
168
|
+
}
|
|
51
169
|
this.closed.emit();
|
|
52
170
|
}
|
|
53
171
|
getIconByBannerType() {
|
|
@@ -68,10 +186,13 @@ class BannerComponent {
|
|
|
68
186
|
BannerComponent.decorators = [
|
|
69
187
|
{ type: Component, args: [{
|
|
70
188
|
selector: 'ec-banner',
|
|
71
|
-
template: "<div class=\"banner {{type}} {{bannerStyle}}\">\r\n <ec-button id=\"banner{{id}}_close\"\r\n *ngIf=\"showCloseBtn\"\r\n type=\"icon\"\r\n icon=\"ec-icon-sm icon-cancel\"\r\n (clicked)=\"close()\">\r\n </ec-button>\r\n <div class=\"banner-content d-flex text-body-1 font-color-secondary\">\r\n <i class=\"ec-icon {{icon}}\"></i>\r\n <div class=\"ml-2\">\r\n <p class=\"title mb-0\" *ngIf=\"title\">\r\n {{title}}\r\n </p>\r\n <p class=\"text mb-0\" *ngIf=\"text\">{{text}}</p>\r\n \r\n <ul class=\"list mb-0\" *ngIf=\"list?.length\">\r\n <li *ngFor=\"let item of list\">{{item}}</li>\r\n </ul>\r\n <ng-content></ng-content>\r\n </div>\r\n </div>\r\n\r\n</div>\r\n",
|
|
189
|
+
template: "<div id=\"banner_{{id}}\" class=\"banner {{type}} {{bannerStyle}}\">\r\n <ec-button id=\"banner{{id}}_close\"\r\n *ngIf=\"showCloseBtn\"\r\n type=\"icon\"\r\n icon=\"ec-icon-sm icon-cancel\"\r\n (clicked)=\"close()\">\r\n </ec-button>\r\n <div class=\"banner-content d-flex text-body-1 font-color-secondary\">\r\n <i class=\"ec-icon {{icon}}\"></i>\r\n <div class=\"ml-2\">\r\n <p class=\"title mb-0\" *ngIf=\"title\">\r\n {{title}}\r\n </p>\r\n <p class=\"text mb-0\" *ngIf=\"text\">{{text}}</p>\r\n \r\n <ul class=\"list mb-0\" *ngIf=\"list?.length\">\r\n <li *ngFor=\"let item of list\">{{item}}</li>\r\n </ul>\r\n <ng-content></ng-content>\r\n </div>\r\n </div>\r\n\r\n</div>\r\n",
|
|
72
190
|
styles: ["@-webkit-keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}:host{display:flex}:host(.border-bottom-0) .banner{border-bottom:0}.banner{display:flex;flex:1 1;flex-direction:column;min-height:2.5rem;overflow-y:auto;position:relative}.banner-content{flex:none;margin:auto 0;padding:.5rem 1rem}.banner-content ::ng-deep p{line-height:inherit}.ec-icon{font-size:1.125rem}ec-button{position:absolute;right:.25rem;top:.25rem}ec-button+.banner-content{padding-right:2.75rem}.title{font-weight:700}.list{margin:0;padding-left:2em}.text+.list{margin-top:1em}.info{background-color:#dae4e9}.info .banner-content>.ec-icon{color:#2d9ab8}.warning{background-color:#fff8cc}.warning .banner-content>.ec-icon{color:#fa7b2e}.success{background-color:#dff0d8}.success .banner-content>.ec-icon{color:#3c763d}.error{background-color:#ecc4c5}.error .banner-content>.ec-icon{color:#cd1d20}.pinned{border-bottom:1px solid rgba(26,26,35,.08)}.toast{border:1px solid rgba(26,26,35,.08);box-shadow:0 .125rem .625rem 0 rgba(26,26,35,.18)}.toast ec-button{right:.1875rem;top:.1875rem}"]
|
|
73
191
|
},] }
|
|
74
192
|
];
|
|
193
|
+
BannerComponent.ctorParameters = () => [
|
|
194
|
+
{ type: CacheService }
|
|
195
|
+
];
|
|
75
196
|
BannerComponent.propDecorators = {
|
|
76
197
|
hidden: [{ type: HostBinding, args: ['hidden',] }, { type: Input }],
|
|
77
198
|
id: [{ type: Input }],
|
|
@@ -83,6 +204,7 @@ BannerComponent.propDecorators = {
|
|
|
83
204
|
showCloseBtn: [{ type: Input }],
|
|
84
205
|
autoHideOnClose: [{ type: Input }],
|
|
85
206
|
customIcon: [{ type: Input }],
|
|
207
|
+
rememberClosed: [{ type: Input }],
|
|
86
208
|
closed: [{ type: Output }]
|
|
87
209
|
};
|
|
88
210
|
|
|
@@ -5291,108 +5413,6 @@ JsonDisplayComponent.propDecorators = {
|
|
|
5291
5413
|
maxLength: [{ type: Input }]
|
|
5292
5414
|
};
|
|
5293
5415
|
|
|
5294
|
-
class CacheService {
|
|
5295
|
-
constructor() {
|
|
5296
|
-
this.localStorageAvailable = false;
|
|
5297
|
-
this.sessionStorageAvailable = false;
|
|
5298
|
-
let cacheError = null;
|
|
5299
|
-
try {
|
|
5300
|
-
let dateStr = 'roundtrip-test-' + new Date().getTime();
|
|
5301
|
-
const value = 'val-' + dateStr;
|
|
5302
|
-
localStorage.setItem(dateStr, value);
|
|
5303
|
-
sessionStorage.setItem(dateStr, value);
|
|
5304
|
-
this.localStorageAvailable = localStorage.getItem(dateStr) == value;
|
|
5305
|
-
this.sessionStorageAvailable = sessionStorage.getItem(dateStr) == value;
|
|
5306
|
-
localStorage.removeItem(dateStr);
|
|
5307
|
-
sessionStorage.removeItem(dateStr);
|
|
5308
|
-
}
|
|
5309
|
-
catch (error) {
|
|
5310
|
-
cacheError = error;
|
|
5311
|
-
}
|
|
5312
|
-
finally {
|
|
5313
|
-
if (!this.localStorageAvailable || !this.sessionStorageAvailable) {
|
|
5314
|
-
console.warn('storage unavailable for caching purposes. Some features will not be fully supported. ', {
|
|
5315
|
-
local: this.localStorageAvailable,
|
|
5316
|
-
session: this.sessionStorageAvailable,
|
|
5317
|
-
error: cacheError
|
|
5318
|
-
});
|
|
5319
|
-
}
|
|
5320
|
-
}
|
|
5321
|
-
}
|
|
5322
|
-
/**Return true if the requested cache allows the user to round-trip data in the current environment.
|
|
5323
|
-
* Security settings can prevent it and the app may need to know if "not found" means "never set" or "not supported"
|
|
5324
|
-
*/
|
|
5325
|
-
isCacheAvailable(sessionOnly = false) {
|
|
5326
|
-
return sessionOnly ? this.sessionStorageAvailable : this.localStorageAvailable;
|
|
5327
|
-
}
|
|
5328
|
-
/**
|
|
5329
|
-
* Retrieve an item from cache
|
|
5330
|
-
*/
|
|
5331
|
-
getItem(key, sessionOnly = false) {
|
|
5332
|
-
let storage = this.getStorage(sessionOnly);
|
|
5333
|
-
if (storage) {
|
|
5334
|
-
let result = storage.getItem(key);
|
|
5335
|
-
if (result) {
|
|
5336
|
-
return JSON.parse(result);
|
|
5337
|
-
}
|
|
5338
|
-
}
|
|
5339
|
-
return null;
|
|
5340
|
-
}
|
|
5341
|
-
/**
|
|
5342
|
-
* Retrieves all keys from cache
|
|
5343
|
-
*/
|
|
5344
|
-
keys(sessionOnly = false) {
|
|
5345
|
-
let result = new Array();
|
|
5346
|
-
let storage = this.getStorage(sessionOnly);
|
|
5347
|
-
if (storage) {
|
|
5348
|
-
for (var i = 0, len = storage.length; i < len; ++i) {
|
|
5349
|
-
result.push(storage.key(i));
|
|
5350
|
-
}
|
|
5351
|
-
}
|
|
5352
|
-
return result;
|
|
5353
|
-
}
|
|
5354
|
-
/**
|
|
5355
|
-
* Removes an item from the cache
|
|
5356
|
-
*/
|
|
5357
|
-
removeItem(key, sessionOnly = false) {
|
|
5358
|
-
let storage = this.getStorage(sessionOnly);
|
|
5359
|
-
if (storage) {
|
|
5360
|
-
storage.removeItem(key);
|
|
5361
|
-
}
|
|
5362
|
-
}
|
|
5363
|
-
/**
|
|
5364
|
-
* Persists an item to cache
|
|
5365
|
-
*/
|
|
5366
|
-
setItem(key, value, sessionOnly = false) {
|
|
5367
|
-
let storage = this.getStorage(sessionOnly);
|
|
5368
|
-
if (storage) {
|
|
5369
|
-
storage.setItem(key, JSON.stringify(value));
|
|
5370
|
-
}
|
|
5371
|
-
}
|
|
5372
|
-
/**Returns the local or session storage to use for backing the given cache request.
|
|
5373
|
-
* If the browser does not support the requested storage the result will be null.
|
|
5374
|
-
* This can happen if the user is in Firefox for example with the setting dom.storage.enabled = false
|
|
5375
|
-
*/
|
|
5376
|
-
getStorage(sessionOnly) {
|
|
5377
|
-
if (sessionOnly && this.sessionStorageAvailable) {
|
|
5378
|
-
return window.sessionStorage;
|
|
5379
|
-
}
|
|
5380
|
-
else if (this.localStorageAvailable) {
|
|
5381
|
-
return window.localStorage;
|
|
5382
|
-
}
|
|
5383
|
-
else {
|
|
5384
|
-
return null;
|
|
5385
|
-
}
|
|
5386
|
-
}
|
|
5387
|
-
}
|
|
5388
|
-
CacheService.ɵprov = ɵɵdefineInjectable({ factory: function CacheService_Factory() { return new CacheService(); }, token: CacheService, providedIn: "root" });
|
|
5389
|
-
CacheService.decorators = [
|
|
5390
|
-
{ type: Injectable, args: [{
|
|
5391
|
-
providedIn: 'root'
|
|
5392
|
-
},] }
|
|
5393
|
-
];
|
|
5394
|
-
CacheService.ctorParameters = () => [];
|
|
5395
|
-
|
|
5396
5416
|
/**
|
|
5397
5417
|
* Base class for handling click and drag resizing of elements with a mouse.
|
|
5398
5418
|
* Derived classes must provide the element to be resized and implement the setWidth function.
|