@dbg-riskit/angular-error 12.3.0 → 9999.9999.9999-rc.12148

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.
Files changed (31) hide show
  1. package/dbg-riskit-angular-error.d.ts +1 -2
  2. package/docs/README.md +1 -11
  3. package/esm2020/dbg-riskit-angular-error.mjs +5 -0
  4. package/esm2020/lib/error.collector.mjs +65 -0
  5. package/esm2020/lib/error.menu.component.mjs +205 -0
  6. package/esm2020/lib/error.message.component.mjs +119 -0
  7. package/{esm2015/lib/error.message.wrapper.js → esm2020/lib/error.message.wrapper.mjs} +1 -1
  8. package/esm2020/lib/error.module.mjs +47 -0
  9. package/{esm2015/lib/rxjs.utils.js → esm2020/lib/rxjs.utils.mjs} +0 -0
  10. package/esm2020/public_api.mjs +5 -0
  11. package/fesm2015/dbg-riskit-angular-error.mjs +468 -0
  12. package/fesm2015/dbg-riskit-angular-error.mjs.map +1 -0
  13. package/fesm2020/dbg-riskit-angular-error.mjs +462 -0
  14. package/fesm2020/dbg-riskit-angular-error.mjs.map +1 -0
  15. package/lib/error.collector.d.ts +3 -0
  16. package/lib/error.menu.component.d.ts +3 -0
  17. package/lib/error.message.component.d.ts +3 -0
  18. package/lib/error.module.d.ts +8 -0
  19. package/package.json +26 -14
  20. package/public_api.d.ts +1 -0
  21. package/bundles/dbg-riskit-angular-error.umd.js +0 -767
  22. package/bundles/dbg-riskit-angular-error.umd.js.map +0 -1
  23. package/dbg-riskit-angular-error.metadata.json +0 -1
  24. package/esm2015/dbg-riskit-angular-error.js +0 -7
  25. package/esm2015/lib/error.collector.js +0 -60
  26. package/esm2015/lib/error.menu.component.js +0 -185
  27. package/esm2015/lib/error.message.component.js +0 -84
  28. package/esm2015/lib/error.module.js +0 -31
  29. package/esm2015/public_api.js +0 -4
  30. package/fesm2015/dbg-riskit-angular-error.js +0 -393
  31. package/fesm2015/dbg-riskit-angular-error.js.map +0 -1
@@ -1,767 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@dbg-riskit/angular-common'), require('@dbg-riskit/common'), require('rxjs'), require('@angular/common'), require('@dbg-riskit/angular-view'), require('@angular/animations'), require('rxjs/operators')) :
3
- typeof define === 'function' && define.amd ? define('@dbg-riskit/angular-error', ['exports', '@angular/core', '@dbg-riskit/angular-common', '@dbg-riskit/common', 'rxjs', '@angular/common', '@dbg-riskit/angular-view', '@angular/animations', 'rxjs/operators'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["dbg-riskit"] = global["dbg-riskit"] || {}, global["dbg-riskit"]["angular-error"] = {}), global.ng.core, global["dbg-riskit"]["angular-common"], global["dbg-riskit"].common, global.rxjs, global.ng.common, global["dbg-riskit"]["angular-view"], global.ng.animations, global.rxjs.operators));
5
- })(this, (function (exports, core, angularCommon, common, rxjs, common$1, angularView, animations, operators) { 'use strict';
6
-
7
- /*! *****************************************************************************
8
- Copyright (c) Microsoft Corporation.
9
-
10
- Permission to use, copy, modify, and/or distribute this software for any
11
- purpose with or without fee is hereby granted.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
- PERFORMANCE OF THIS SOFTWARE.
20
- ***************************************************************************** */
21
- /* global Reflect, Promise */
22
- var extendStatics = function (d, b) {
23
- extendStatics = Object.setPrototypeOf ||
24
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25
- function (d, b) { for (var p in b)
26
- if (Object.prototype.hasOwnProperty.call(b, p))
27
- d[p] = b[p]; };
28
- return extendStatics(d, b);
29
- };
30
- function __extends(d, b) {
31
- if (typeof b !== "function" && b !== null)
32
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
33
- extendStatics(d, b);
34
- function __() { this.constructor = d; }
35
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36
- }
37
- var __assign = function () {
38
- __assign = Object.assign || function __assign(t) {
39
- for (var s, i = 1, n = arguments.length; i < n; i++) {
40
- s = arguments[i];
41
- for (var p in s)
42
- if (Object.prototype.hasOwnProperty.call(s, p))
43
- t[p] = s[p];
44
- }
45
- return t;
46
- };
47
- return __assign.apply(this, arguments);
48
- };
49
- function __rest(s, e) {
50
- var t = {};
51
- for (var p in s)
52
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
53
- t[p] = s[p];
54
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
55
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
56
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
57
- t[p[i]] = s[p[i]];
58
- }
59
- return t;
60
- }
61
- function __decorate(decorators, target, key, desc) {
62
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
63
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
64
- r = Reflect.decorate(decorators, target, key, desc);
65
- else
66
- for (var i = decorators.length - 1; i >= 0; i--)
67
- if (d = decorators[i])
68
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
69
- return c > 3 && r && Object.defineProperty(target, key, r), r;
70
- }
71
- function __param(paramIndex, decorator) {
72
- return function (target, key) { decorator(target, key, paramIndex); };
73
- }
74
- function __metadata(metadataKey, metadataValue) {
75
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
76
- return Reflect.metadata(metadataKey, metadataValue);
77
- }
78
- function __awaiter(thisArg, _arguments, P, generator) {
79
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
80
- return new (P || (P = Promise))(function (resolve, reject) {
81
- function fulfilled(value) { try {
82
- step(generator.next(value));
83
- }
84
- catch (e) {
85
- reject(e);
86
- } }
87
- function rejected(value) { try {
88
- step(generator["throw"](value));
89
- }
90
- catch (e) {
91
- reject(e);
92
- } }
93
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
94
- step((generator = generator.apply(thisArg, _arguments || [])).next());
95
- });
96
- }
97
- function __generator(thisArg, body) {
98
- var _ = { label: 0, sent: function () { if (t[0] & 1)
99
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
100
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
101
- function verb(n) { return function (v) { return step([n, v]); }; }
102
- function step(op) {
103
- if (f)
104
- throw new TypeError("Generator is already executing.");
105
- while (_)
106
- try {
107
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
108
- return t;
109
- if (y = 0, t)
110
- op = [op[0] & 2, t.value];
111
- switch (op[0]) {
112
- case 0:
113
- case 1:
114
- t = op;
115
- break;
116
- case 4:
117
- _.label++;
118
- return { value: op[1], done: false };
119
- case 5:
120
- _.label++;
121
- y = op[1];
122
- op = [0];
123
- continue;
124
- case 7:
125
- op = _.ops.pop();
126
- _.trys.pop();
127
- continue;
128
- default:
129
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
130
- _ = 0;
131
- continue;
132
- }
133
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
134
- _.label = op[1];
135
- break;
136
- }
137
- if (op[0] === 6 && _.label < t[1]) {
138
- _.label = t[1];
139
- t = op;
140
- break;
141
- }
142
- if (t && _.label < t[2]) {
143
- _.label = t[2];
144
- _.ops.push(op);
145
- break;
146
- }
147
- if (t[2])
148
- _.ops.pop();
149
- _.trys.pop();
150
- continue;
151
- }
152
- op = body.call(thisArg, _);
153
- }
154
- catch (e) {
155
- op = [6, e];
156
- y = 0;
157
- }
158
- finally {
159
- f = t = 0;
160
- }
161
- if (op[0] & 5)
162
- throw op[1];
163
- return { value: op[0] ? op[1] : void 0, done: true };
164
- }
165
- }
166
- var __createBinding = Object.create ? (function (o, m, k, k2) {
167
- if (k2 === undefined)
168
- k2 = k;
169
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
170
- }) : (function (o, m, k, k2) {
171
- if (k2 === undefined)
172
- k2 = k;
173
- o[k2] = m[k];
174
- });
175
- function __exportStar(m, o) {
176
- for (var p in m)
177
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
178
- __createBinding(o, m, p);
179
- }
180
- function __values(o) {
181
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
182
- if (m)
183
- return m.call(o);
184
- if (o && typeof o.length === "number")
185
- return {
186
- next: function () {
187
- if (o && i >= o.length)
188
- o = void 0;
189
- return { value: o && o[i++], done: !o };
190
- }
191
- };
192
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
193
- }
194
- function __read(o, n) {
195
- var m = typeof Symbol === "function" && o[Symbol.iterator];
196
- if (!m)
197
- return o;
198
- var i = m.call(o), r, ar = [], e;
199
- try {
200
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
201
- ar.push(r.value);
202
- }
203
- catch (error) {
204
- e = { error: error };
205
- }
206
- finally {
207
- try {
208
- if (r && !r.done && (m = i["return"]))
209
- m.call(i);
210
- }
211
- finally {
212
- if (e)
213
- throw e.error;
214
- }
215
- }
216
- return ar;
217
- }
218
- /** @deprecated */
219
- function __spread() {
220
- for (var ar = [], i = 0; i < arguments.length; i++)
221
- ar = ar.concat(__read(arguments[i]));
222
- return ar;
223
- }
224
- /** @deprecated */
225
- function __spreadArrays() {
226
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
227
- s += arguments[i].length;
228
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
229
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
230
- r[k] = a[j];
231
- return r;
232
- }
233
- function __spreadArray(to, from, pack) {
234
- if (pack || arguments.length === 2)
235
- for (var i = 0, l = from.length, ar; i < l; i++) {
236
- if (ar || !(i in from)) {
237
- if (!ar)
238
- ar = Array.prototype.slice.call(from, 0, i);
239
- ar[i] = from[i];
240
- }
241
- }
242
- return to.concat(ar || Array.prototype.slice.call(from));
243
- }
244
- function __await(v) {
245
- return this instanceof __await ? (this.v = v, this) : new __await(v);
246
- }
247
- function __asyncGenerator(thisArg, _arguments, generator) {
248
- if (!Symbol.asyncIterator)
249
- throw new TypeError("Symbol.asyncIterator is not defined.");
250
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
251
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
252
- function verb(n) { if (g[n])
253
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
254
- function resume(n, v) { try {
255
- step(g[n](v));
256
- }
257
- catch (e) {
258
- settle(q[0][3], e);
259
- } }
260
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
261
- function fulfill(value) { resume("next", value); }
262
- function reject(value) { resume("throw", value); }
263
- function settle(f, v) { if (f(v), q.shift(), q.length)
264
- resume(q[0][0], q[0][1]); }
265
- }
266
- function __asyncDelegator(o) {
267
- var i, p;
268
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
269
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
270
- }
271
- function __asyncValues(o) {
272
- if (!Symbol.asyncIterator)
273
- throw new TypeError("Symbol.asyncIterator is not defined.");
274
- var m = o[Symbol.asyncIterator], i;
275
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
276
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
277
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
278
- }
279
- function __makeTemplateObject(cooked, raw) {
280
- if (Object.defineProperty) {
281
- Object.defineProperty(cooked, "raw", { value: raw });
282
- }
283
- else {
284
- cooked.raw = raw;
285
- }
286
- return cooked;
287
- }
288
- ;
289
- var __setModuleDefault = Object.create ? (function (o, v) {
290
- Object.defineProperty(o, "default", { enumerable: true, value: v });
291
- }) : function (o, v) {
292
- o["default"] = v;
293
- };
294
- function __importStar(mod) {
295
- if (mod && mod.__esModule)
296
- return mod;
297
- var result = {};
298
- if (mod != null)
299
- for (var k in mod)
300
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
301
- __createBinding(result, mod, k);
302
- __setModuleDefault(result, mod);
303
- return result;
304
- }
305
- function __importDefault(mod) {
306
- return (mod && mod.__esModule) ? mod : { default: mod };
307
- }
308
- function __classPrivateFieldGet(receiver, state, kind, f) {
309
- if (kind === "a" && !f)
310
- throw new TypeError("Private accessor was defined without a getter");
311
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
312
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
313
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
314
- }
315
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
316
- if (kind === "m")
317
- throw new TypeError("Private method is not writable");
318
- if (kind === "a" && !f)
319
- throw new TypeError("Private accessor was defined without a setter");
320
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
321
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
322
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
323
- }
324
-
325
- function toErrorMessage(err) {
326
- var errorMessage;
327
- if ('errorType' in err) {
328
- errorMessage = err;
329
- }
330
- else {
331
- if ('message' in err) {
332
- err = err.message || common.toString(err);
333
- }
334
- else {
335
- err = common.toString(err);
336
- }
337
- errorMessage = {
338
- message: err,
339
- status: 0,
340
- errorType: common.ErrorType.ERROR
341
- };
342
- }
343
- return errorMessage;
344
- }
345
- var ErrorCollectorService = /** @class */ (function (_super) {
346
- __extends(ErrorCollectorService, _super);
347
- function ErrorCollectorService(authProvider) {
348
- var _this = _super.call(this) || this;
349
- _this._errorObservable = new rxjs.ReplaySubject(10);
350
- if (authProvider) {
351
- authProvider.loggedInStream.subscribe(function (auth) {
352
- _this._errorObservable = new rxjs.ReplaySubject(10);
353
- });
354
- }
355
- return _this;
356
- }
357
- ErrorCollectorService.prototype.error = function (err) {
358
- this._errorObservable.next(err);
359
- };
360
- Object.defineProperty(ErrorCollectorService.prototype, "errorStream", {
361
- get: function () {
362
- return this._errorObservable.asObservable();
363
- },
364
- enumerable: false,
365
- configurable: true
366
- });
367
- ErrorCollectorService.prototype.handleError = function (err) {
368
- try {
369
- _super.prototype.handleError.call(this, err);
370
- }
371
- finally {
372
- this.error(toErrorMessage(err));
373
- }
374
- };
375
- ErrorCollectorService.prototype.handleStreamError = function (err) {
376
- this.handleError(err);
377
- return rxjs.EMPTY;
378
- };
379
- return ErrorCollectorService;
380
- }(core.ErrorHandler));
381
- ErrorCollectorService.decorators = [
382
- { type: core.Injectable }
383
- ];
384
- ErrorCollectorService.ctorParameters = function () { return [
385
- { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [angularCommon.AUTH_PROVIDER,] }] }
386
- ]; };
387
-
388
- var ErrorMessageComponent = /** @class */ (function () {
389
- function ErrorMessageComponent(dateFormat, changeDetectorRef) {
390
- this.dateFormat = dateFormat;
391
- this.changeDetectorRef = changeDetectorRef;
392
- this.readState = null;
393
- this.isLast = false;
394
- }
395
- ErrorMessageComponent.prototype.animate = function () {
396
- var _this = this;
397
- if (this.error != null && !this.error.read && this.readState !== 'read') {
398
- setTimeout(function () {
399
- _this.readState = 'read';
400
- _this.changeDetectorRef.markForCheck();
401
- });
402
- }
403
- };
404
- ErrorMessageComponent.prototype.markRead = function (event) {
405
- if (this.error != null && event.toState === 'read') {
406
- this.error.markRead();
407
- this.changeDetectorRef.markForCheck();
408
- }
409
- };
410
- return ErrorMessageComponent;
411
- }());
412
- ErrorMessageComponent.decorators = [
413
- { type: core.Component, args: [{
414
- selector: 'risk-error-message',
415
- template: "<mat-card [class.risk-error-message-last]=\"isLast\" [@readState]=\"readState\" (@readState.done)=\"markRead($event)\">\n <mat-card-header>\n <mat-icon color=\"warn\" mat-card-avatar>error_outline</mat-icon>\n <mat-card-title *ngIf=\"error?.type.isNetworkError()\">Network error</mat-card-title>\n <mat-card-title *ngIf=\"error?.type.isRequestError()\">API error</mat-card-title>\n <mat-card-title *ngIf=\"error?.type.isAuthError()\">Authorization error</mat-card-title>\n <mat-card-title\n *ngIf=\"!error?.type.isNetworkError() && !error?.type.isRequestError() && !error?.type.isAuthError()\">\n General error\n </mat-card-title>\n <mat-card-subtitle>{{error?.date | date:dateFormat}}</mat-card-subtitle>\n </mat-card-header>\n <mat-card-content>\n <p *ngIf=\"error?.statusCode\" class=\"risk-error-message-code\">Error code: {{error?.statusCode}}</p>\n <p>\n {{error?.message}}\n </p>\n </mat-card-content>\n</mat-card>\n",
416
- animations: [
417
- animations.trigger('readState', [
418
- animations.state('read', animations.style({ background: 'transparent' })),
419
- animations.transition(':enter', [
420
- animations.style({
421
- height: 0,
422
- transform: 'scale(0)'
423
- }),
424
- animations.animate('200ms ease-in', animations.style({
425
- height: '*',
426
- transform: 'scale(1)'
427
- }))
428
- ]),
429
- animations.transition('* => read', [
430
- animations.style({
431
- background: 'transparent'
432
- }),
433
- animations.animate('1500ms', animations.keyframes([
434
- animations.style({
435
- background: 'rgba(204, 51, 51, .5)',
436
- offset: 0.25
437
- }),
438
- animations.style({
439
- background: 'transparent',
440
- offset: 0.5
441
- }),
442
- animations.style({
443
- background: 'rgba(204, 51, 51, .5)',
444
- offset: 0.75
445
- }),
446
- animations.style({
447
- background: 'transparent',
448
- offset: 1
449
- })
450
- ]))
451
- ])
452
- ])
453
- ],
454
- host: {
455
- '[class.risk-error-message]': 'true'
456
- },
457
- changeDetection: core.ChangeDetectionStrategy.OnPush,
458
- preserveWhitespaces: false,
459
- styles: [":host{display:block;padding:0;margin:0}:host>*{vertical-align:bottom}\n", ":host .mat-card{margin:0 10px 7px}:host .mat-card.risk-error-message-last{margin-bottom:0}:host .mat-card .mat-card-subtitle{margin-bottom:5px}:host .mat-card p{margin:0}:host .mat-card p.risk-error-message-code{position:absolute;bottom:10px;right:10px}:host .mat-card p.risk-error-message-code+p:last-child{margin-bottom:3px}\n"]
460
- },] }
461
- ];
462
- ErrorMessageComponent.ctorParameters = function () { return [
463
- { type: String, decorators: [{ type: core.Inject, args: [angularCommon.DATE_FORMAT,] }] },
464
- { type: core.ChangeDetectorRef }
465
- ]; };
466
- ErrorMessageComponent.propDecorators = {
467
- error: [{ type: core.Input }],
468
- isLast: [{ type: core.Input }]
469
- };
470
-
471
- var ErrorMessageWrapper = /** @class */ (function () {
472
- function ErrorMessageWrapper(error) {
473
- this._date = new Date();
474
- this._read = false;
475
- this.readStateChanged = new core.EventEmitter();
476
- this._error = error;
477
- }
478
- Object.defineProperty(ErrorMessageWrapper.prototype, "message", {
479
- get: function () {
480
- return this._error.message;
481
- },
482
- enumerable: false,
483
- configurable: true
484
- });
485
- Object.defineProperty(ErrorMessageWrapper.prototype, "type", {
486
- get: function () {
487
- return this._error.errorType;
488
- },
489
- enumerable: false,
490
- configurable: true
491
- });
492
- Object.defineProperty(ErrorMessageWrapper.prototype, "statusCode", {
493
- get: function () {
494
- return this._error.status;
495
- },
496
- enumerable: false,
497
- configurable: true
498
- });
499
- Object.defineProperty(ErrorMessageWrapper.prototype, "date", {
500
- get: function () {
501
- return this._date;
502
- },
503
- enumerable: false,
504
- configurable: true
505
- });
506
- Object.defineProperty(ErrorMessageWrapper.prototype, "read", {
507
- get: function () {
508
- return this._read;
509
- },
510
- enumerable: false,
511
- configurable: true
512
- });
513
- ErrorMessageWrapper.prototype.markRead = function () {
514
- if (!this._read) {
515
- this._read = true;
516
- this.readStateChanged.emit(this._read);
517
- this.readStateChanged.complete();
518
- }
519
- };
520
- return ErrorMessageWrapper;
521
- }());
522
-
523
- var JIGGLE_ANIMATION = animations.animate('1s ease-in', animations.keyframes([
524
- animations.style({
525
- transform: 'scale(0.8) translateX(-1px) rotate(0)',
526
- offset: 0.1
527
- }),
528
- animations.style({
529
- transform: 'scale(1) translateX(2px) rotate(4deg)',
530
- offset: 0.2
531
- }),
532
- animations.style({
533
- transform: 'scale(1.2) translateX(-4px) rotate(0)',
534
- offset: 0.3
535
- }),
536
- animations.style({
537
- transform: 'scale(1.5) translateX(4px) rotate(0)',
538
- offset: 0.4
539
- }),
540
- animations.style({
541
- transform: 'scale(1.5) translateX(-4px) rotate(-8deg)',
542
- offset: 0.5
543
- }),
544
- animations.style({
545
- transform: 'scale(1.5) translateX(4px) rotate(0)',
546
- offset: 0.6
547
- }),
548
- animations.style({
549
- transform: 'scale(1.2) translateX(-4px) rotate(0)',
550
- offset: 0.7
551
- }),
552
- animations.style({
553
- transform: 'scale(1) translateX(2px) rotate(4deg)',
554
- offset: 0.8
555
- }),
556
- animations.style({
557
- transform: 'scale(1) translateX(-1px) rotate(0)',
558
- offset: 0.9
559
- })
560
- ]));
561
- var ErrorComponent = /** @class */ (function (_super) {
562
- __extends(ErrorComponent, _super);
563
- function ErrorComponent(errorCollector, authProvider, changeDetectorRef) {
564
- var _this = _super.call(this) || this;
565
- _this.errorCollector = errorCollector;
566
- _this.authProvider = authProvider;
567
- _this.changeDetectorRef = changeDetectorRef;
568
- _this.state = null;
569
- _this._errors = [];
570
- _this._menuState = new rxjs.Subject();
571
- return _this;
572
- }
573
- ErrorComponent.prototype.ngOnInit = function () {
574
- var _this = this;
575
- // Init Jiggle animation loop
576
- this.initAnimation();
577
- // Subscribe to error stream
578
- this.subscribeToErrors();
579
- // Once opened animate messages and set as read after animation
580
- this._menuState.pipe(operators.filter(function (opened) { return opened; }), operators.takeUntil(this.destroyed)).subscribe(function () { return _this.animateOnMenuOpened(); });
581
- // Refresh on "logged-in" state changes
582
- if (this.authProvider) {
583
- this.authProvider.loggedInStream.pipe(operators.takeUntil(this.destroyed)).subscribe(function (auth) { return _this.loggedInChanged(auth); });
584
- }
585
- };
586
- ErrorComponent.prototype.animateOnMenuOpened = function () {
587
- var _this = this;
588
- var animateMessages = function () { return _this.errorMessages.forEach(function (message) { return message.animate(); }); };
589
- animateMessages();
590
- this.errorMessages.changes.pipe(operators.takeUntil(rxjs.merge(this.destroyed, this._menuState))).subscribe(function () { return animateMessages(); });
591
- };
592
- ErrorComponent.prototype.loggedInChanged = function (auth) {
593
- // Subscribe to errors once logged in again
594
- if (auth) {
595
- this.subscribeToErrors();
596
- }
597
- else {
598
- while (this._errors.length > 0) {
599
- this._errors.pop();
600
- }
601
- }
602
- this.changeDetectorRef.markForCheck();
603
- };
604
- ErrorComponent.prototype.subscribeToErrors = function () {
605
- var _this = this;
606
- var until = this.destroyed;
607
- // Stop receiving errors once user was logged out
608
- if (this.authProvider) {
609
- until = rxjs.merge(until, this.authProvider.loggedInStream.pipe(operators.filter(function (auth) { return !auth; }), operators.map(function () { return undefined; })));
610
- }
611
- this.errorCollector.errorStream.pipe(operators.takeUntil(until)).subscribe(function (error) { return _this.errorReceived(error, until); });
612
- };
613
- ErrorComponent.prototype.errorReceived = function (error, until) {
614
- var _this = this;
615
- var errorMessageWrapper = new ErrorMessageWrapper(error);
616
- // Subscribe for state changes
617
- errorMessageWrapper.readStateChanged.pipe(operators.takeUntil(until)).subscribe(function () { return _this.changeDetectorRef.detectChanges(); });
618
- this._errors.unshift(errorMessageWrapper);
619
- while (this._errors.length > 10) {
620
- this._errors.pop();
621
- }
622
- this.changeDetectorRef.markForCheck();
623
- };
624
- Object.defineProperty(ErrorComponent.prototype, "color", {
625
- get: function () {
626
- if (this.errors.some(function (error) { return !error.read; })) {
627
- return 'warn';
628
- }
629
- return null;
630
- },
631
- enumerable: false,
632
- configurable: true
633
- });
634
- ErrorComponent.prototype.menuOpened = function () {
635
- this._menuState.next(true);
636
- };
637
- ErrorComponent.prototype.menuClosed = function () {
638
- this._menuState.next(false);
639
- };
640
- Object.defineProperty(ErrorComponent.prototype, "errors", {
641
- get: function () {
642
- return this._errors;
643
- },
644
- enumerable: false,
645
- configurable: true
646
- });
647
- // <editor-fold desc="Animation control" defaultstate="collapsed">
648
- ErrorComponent.prototype.animationDone = function (event) {
649
- if (event.toState === 'newError') {
650
- // Reset after annimation
651
- this.state = 'active';
652
- // Called from animation controller we need to re-check
653
- this.changeDetectorRef.markForCheck();
654
- }
655
- };
656
- ErrorComponent.prototype.initAnimation = function () {
657
- var _this = this;
658
- rxjs.timer(100, 2000).pipe(
659
- // Run animation everytime we have non-read errors
660
- operators.filter(function () { return _this.errors.some(function (error) { return !error.read; }); }), operators.takeUntil(this.destroyed)).subscribe(function () {
661
- switch (_this.state) {
662
- case null:
663
- _this.state = 'active';
664
- break;
665
- case 'active':
666
- _this.state = 'newError';
667
- break;
668
- }
669
- _this.changeDetectorRef.markForCheck();
670
- });
671
- };
672
- return ErrorComponent;
673
- }(angularView.BaseComponent));
674
- ErrorComponent.decorators = [
675
- { type: core.Component, args: [{
676
- selector: 'risk-error-menu',
677
- template: "<button *ngIf=\"state != null\"\n mat-icon-button\n [color]=\"color\"\n type=\"button\"\n [@buttonState]=\"state\"\n (@buttonState.done)=\"animationDone($event)\"\n [matMenuTriggerFor]=\"errorMenu\"\n #errorMenuTrigger=\"matMenuTrigger\"\n (menuOpened)=\"menuOpened()\"\n (menuClosed)=\"menuClosed()\"\n [class.risk-menu-open]=\"errorMenuTrigger.menuOpen\">\n <mat-icon>error_outline</mat-icon>\n</button>\n\n<mat-menu #errorMenu=\"matMenu\"\n class=\"risk-error-menu-mat-menu\"\n [overlapTrigger]=\"false\">\n <risk-error-message *ngFor=\"let error of errors; last as isLast\"\n [error]=\"error\"\n (click)=\"keepVisibleOnClick ? $event.stopPropagation() : null\"\n [isLast]=\"isLast\"></risk-error-message>\n</mat-menu>\n",
678
- animations: [
679
- animations.trigger('buttonState', [
680
- animations.state('inactive', animations.style({ transform: 'translateX(0) scale(0)' })),
681
- animations.state('active', animations.style({ transform: 'translateX(0) scale(1)' })),
682
- animations.state('newError', animations.style({ transform: 'translateX(0) scale(1)' })),
683
- animations.transition('void => active', [
684
- animations.style({ transform: 'scale(0) translateX(0) rotate(0)' }),
685
- JIGGLE_ANIMATION
686
- ]),
687
- animations.transition('void => newError', [
688
- animations.style({ transform: 'scale(0) translateX(0) rotate(0)' }),
689
- JIGGLE_ANIMATION
690
- ]),
691
- animations.transition('active => newError', [
692
- animations.style({ transform: 'scale(1) translateX(0) rotate(0)' }),
693
- JIGGLE_ANIMATION
694
- ])
695
- ])
696
- ],
697
- host: {
698
- '[class.risk-error-menu]': 'true'
699
- },
700
- changeDetection: core.ChangeDetectionStrategy.OnPush,
701
- preserveWhitespaces: false,
702
- styles: [":host{display:block;padding:0;margin:0}:host>*{vertical-align:bottom}\n", "::ng-deep .risk-error-menu-mat-menu{max-width:600px!important}\n"]
703
- },] }
704
- ];
705
- ErrorComponent.ctorParameters = function () { return [
706
- { type: ErrorCollectorService },
707
- { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [angularCommon.AUTH_PROVIDER,] }] },
708
- { type: core.ChangeDetectorRef }
709
- ]; };
710
- ErrorComponent.propDecorators = {
711
- keepVisibleOnClick: [{ type: core.Input }],
712
- errorMessages: [{ type: core.ViewChildren, args: [ErrorMessageComponent,] }]
713
- };
714
-
715
- var ErrorModule = /** @class */ (function () {
716
- function ErrorModule() {
717
- }
718
- return ErrorModule;
719
- }());
720
- ErrorModule.decorators = [
721
- { type: core.NgModule, args: [{
722
- imports: [
723
- common$1.CommonModule,
724
- angularView.CommonViewModule
725
- ],
726
- exports: [
727
- ErrorComponent
728
- ],
729
- declarations: [
730
- ErrorComponent,
731
- ErrorMessageComponent
732
- ],
733
- providers: [
734
- ErrorCollectorService,
735
- {
736
- provide: core.ErrorHandler,
737
- useExisting: ErrorCollectorService
738
- }
739
- ]
740
- },] }
741
- ];
742
-
743
- /**
744
- * Collects all error using error collector and returns the "otherwise" error instead.
745
- * @param errorCollector Error collector service.
746
- * @param otherwise Value to be returned in case of error.
747
- */
748
- function collectErrors(errorCollector, otherwise) {
749
- return function (source) { return source.pipe(operators.catchError(function (err) { return errorCollector.handleStreamError(err); }), operators.defaultIfEmpty(otherwise)); };
750
- }
751
-
752
- /**
753
- * Generated bundle index. Do not edit.
754
- */
755
-
756
- exports.ErrorCollectorService = ErrorCollectorService;
757
- exports.ErrorModule = ErrorModule;
758
- exports.collectErrors = collectErrors;
759
- exports.toErrorMessage = toErrorMessage;
760
- exports["ɵa"] = JIGGLE_ANIMATION;
761
- exports["ɵb"] = ErrorComponent;
762
- exports["ɵc"] = ErrorMessageComponent;
763
-
764
- Object.defineProperty(exports, '__esModule', { value: true });
765
-
766
- }));
767
- //# sourceMappingURL=dbg-riskit-angular-error.umd.js.map