@igo2/core 1.15.5 → 1.15.6
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/esm2020/igo2-core.mjs +4 -4
- package/esm2020/lib/activity/activity.interceptor.mjs +29 -29
- package/esm2020/lib/activity/activity.module.mjs +29 -29
- package/esm2020/lib/activity/activity.service.mjs +32 -32
- package/esm2020/lib/activity/index.mjs +2 -2
- package/esm2020/lib/analytics/index.mjs +1 -1
- package/esm2020/lib/analytics/shared/analytics.interface.mjs +1 -1
- package/esm2020/lib/analytics/shared/analytics.service.mjs +80 -80
- package/esm2020/lib/analytics/shared/index.mjs +2 -2
- package/esm2020/lib/compression/compressedData.interface.mjs +1 -1
- package/esm2020/lib/compression/compression.service.mjs +139 -139
- package/esm2020/lib/compression/index.mjs +2 -2
- package/esm2020/lib/config/config.interface.mjs +1 -1
- package/esm2020/lib/config/config.module.mjs +22 -22
- package/esm2020/lib/config/config.provider.mjs +20 -20
- package/esm2020/lib/config/config.service.mjs +51 -51
- package/esm2020/lib/config/index.mjs +3 -3
- package/esm2020/lib/config/version.mjs +5 -5
- package/esm2020/lib/core.module.mjs +91 -91
- package/esm2020/lib/gesture/gesture.module.mjs +29 -29
- package/esm2020/lib/gesture/gesture.provider.mjs +15 -15
- package/esm2020/lib/language/index.mjs +1 -1
- package/esm2020/lib/language/language.module.mjs +38 -38
- package/esm2020/lib/language/shared/index.mjs +4 -4
- package/esm2020/lib/language/shared/language.interface.mjs +1 -1
- package/esm2020/lib/language/shared/language.loader.mjs +25 -25
- package/esm2020/lib/language/shared/language.provider.mjs +21 -21
- package/esm2020/lib/language/shared/language.service.mjs +31 -31
- package/esm2020/lib/language/shared/missing-translation.guard.mjs +14 -14
- package/esm2020/lib/media/index.mjs +2 -2
- package/esm2020/lib/media/media.enum.mjs +11 -11
- package/esm2020/lib/media/media.service.mjs +75 -75
- package/esm2020/lib/message/index.mjs +1 -1
- package/esm2020/lib/message/message.module.mjs +55 -55
- package/esm2020/lib/message/shared/index.mjs +3 -3
- package/esm2020/lib/message/shared/message.enum.mjs +9 -9
- package/esm2020/lib/message/shared/message.interface.mjs +1 -1
- package/esm2020/lib/message/shared/message.service.mjs +200 -200
- package/esm2020/lib/network/index.mjs +2 -2
- package/esm2020/lib/network/network.interfaces.mjs +1 -1
- package/esm2020/lib/network/network.service.mjs +59 -59
- package/esm2020/lib/regex/index.mjs +2 -2
- package/esm2020/lib/regex/regex.interface.mjs +1 -1
- package/esm2020/lib/regex/regex.service.mjs +26 -26
- package/esm2020/lib/request/error.interceptor.mjs +65 -65
- package/esm2020/lib/request/error.module.mjs +38 -38
- package/esm2020/lib/request/index.mjs +2 -2
- package/esm2020/lib/request/logging.interceptor.mjs +27 -27
- package/esm2020/lib/request/logging.module.mjs +29 -29
- package/esm2020/lib/route/route.interface.mjs +1 -1
- package/esm2020/lib/route/route.service.mjs +70 -70
- package/esm2020/lib/storage/index.mjs +2 -2
- package/esm2020/lib/storage/storage.interface.mjs +12 -12
- package/esm2020/lib/storage/storage.service.mjs +78 -78
- package/esm2020/public_api.mjs +27 -27
- package/fesm2015/igo2-core.mjs +1328 -1328
- package/fesm2015/igo2-core.mjs.map +1 -1
- package/fesm2020/igo2-core.mjs +1273 -1273
- package/fesm2020/igo2-core.mjs.map +1 -1
- package/index.d.ts +5 -5
- package/lib/activity/activity.interceptor.d.ts +11 -11
- package/lib/activity/activity.module.d.ts +8 -8
- package/lib/activity/activity.service.d.ts +11 -11
- package/lib/activity/index.d.ts +2 -2
- package/lib/analytics/index.d.ts +1 -1
- package/lib/analytics/shared/analytics.interface.d.ts +6 -6
- package/lib/analytics/shared/analytics.service.d.ts +23 -23
- package/lib/analytics/shared/index.d.ts +2 -2
- package/lib/compression/compressedData.interface.d.ts +5 -5
- package/lib/compression/compression.service.d.ts +15 -15
- package/lib/compression/index.d.ts +2 -2
- package/lib/config/config.interface.d.ts +6 -6
- package/lib/config/config.module.d.ts +8 -8
- package/lib/config/config.provider.d.ts +15 -15
- package/lib/config/config.service.d.ts +18 -18
- package/lib/config/index.d.ts +3 -3
- package/lib/config/version.d.ts +5 -5
- package/lib/core.module.d.ts +19 -19
- package/lib/gesture/gesture.module.d.ts +9 -9
- package/lib/gesture/gesture.provider.d.ts +7 -7
- package/lib/language/index.d.ts +1 -1
- package/lib/language/language.module.d.ts +9 -9
- package/lib/language/shared/index.d.ts +4 -4
- package/lib/language/shared/language.interface.d.ts +3 -3
- package/lib/language/shared/language.loader.d.ts +11 -11
- package/lib/language/shared/language.provider.d.ts +15 -15
- package/lib/language/shared/language.service.d.ts +13 -13
- package/lib/language/shared/missing-translation.guard.d.ts +4 -4
- package/lib/media/index.d.ts +2 -2
- package/lib/media/media.enum.d.ts +9 -9
- package/lib/media/media.service.d.ts +16 -16
- package/lib/message/index.d.ts +1 -1
- package/lib/message/message.module.d.ts +10 -10
- package/lib/message/shared/index.d.ts +4 -4
- package/lib/message/shared/message.enum.d.ts +8 -8
- package/lib/message/shared/message.interface.d.ts +21 -21
- package/lib/message/shared/message.service.d.ts +31 -31
- package/lib/network/index.d.ts +2 -2
- package/lib/network/network.interfaces.d.ts +3 -3
- package/lib/network/network.service.d.ts +21 -21
- package/lib/regex/index.d.ts +2 -2
- package/lib/regex/regex.interface.d.ts +3 -3
- package/lib/regex/regex.service.d.ts +12 -12
- package/lib/request/error.interceptor.d.ts +14 -14
- package/lib/request/error.module.d.ts +9 -9
- package/lib/request/index.d.ts +2 -2
- package/lib/request/logging.interceptor.d.ts +8 -8
- package/lib/request/logging.module.d.ts +8 -8
- package/lib/route/route.interface.d.ts +23 -23
- package/lib/route/route.service.d.ts +19 -19
- package/lib/storage/index.d.ts +2 -2
- package/lib/storage/storage.interface.d.ts +20 -20
- package/lib/storage/storage.service.d.ts +19 -19
- package/package.json +2 -2
- package/public_api.d.ts +24 -24
- package/style/partial/media.scss +80 -80
package/fesm2020/igo2-core.mjs
CHANGED
|
@@ -18,1345 +18,1345 @@ import * as i1$3 from '@angular/router';
|
|
|
18
18
|
import * as i1$4 from '@angular/cdk/layout';
|
|
19
19
|
import { Breakpoints } from '@angular/cdk/layout';
|
|
20
20
|
|
|
21
|
-
class ActivityService {
|
|
22
|
-
constructor() {
|
|
23
|
-
this.counter$ = new BehaviorSubject(0);
|
|
24
|
-
this.ids = [];
|
|
25
|
-
}
|
|
26
|
-
register() {
|
|
27
|
-
const id = uuid();
|
|
28
|
-
this.ids.push(id);
|
|
29
|
-
this.counter$.next(this.ids.length);
|
|
30
|
-
return id;
|
|
31
|
-
}
|
|
32
|
-
unregister(id) {
|
|
33
|
-
const index = this.ids.indexOf(id);
|
|
34
|
-
if (index === -1) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
this.ids.splice(index, 1);
|
|
38
|
-
this.counter$.next(this.ids.length);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
ActivityService.ɵfac = function ActivityService_Factory(t) { return new (t || ActivityService)(); };
|
|
42
|
-
ActivityService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ActivityService, factory: ActivityService.ɵfac, providedIn: 'root' });
|
|
43
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ActivityService, [{
|
|
44
|
-
type: Injectable,
|
|
45
|
-
args: [{
|
|
46
|
-
providedIn: 'root'
|
|
47
|
-
}]
|
|
21
|
+
class ActivityService {
|
|
22
|
+
constructor() {
|
|
23
|
+
this.counter$ = new BehaviorSubject(0);
|
|
24
|
+
this.ids = [];
|
|
25
|
+
}
|
|
26
|
+
register() {
|
|
27
|
+
const id = uuid();
|
|
28
|
+
this.ids.push(id);
|
|
29
|
+
this.counter$.next(this.ids.length);
|
|
30
|
+
return id;
|
|
31
|
+
}
|
|
32
|
+
unregister(id) {
|
|
33
|
+
const index = this.ids.indexOf(id);
|
|
34
|
+
if (index === -1) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this.ids.splice(index, 1);
|
|
38
|
+
this.counter$.next(this.ids.length);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
ActivityService.ɵfac = function ActivityService_Factory(t) { return new (t || ActivityService)(); };
|
|
42
|
+
ActivityService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ActivityService, factory: ActivityService.ɵfac, providedIn: 'root' });
|
|
43
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ActivityService, [{
|
|
44
|
+
type: Injectable,
|
|
45
|
+
args: [{
|
|
46
|
+
providedIn: 'root'
|
|
47
|
+
}]
|
|
48
48
|
}], function () { return []; }, null); })();
|
|
49
49
|
|
|
50
|
-
class ActivityInterceptor {
|
|
51
|
-
constructor(activityService) {
|
|
52
|
-
this.activityService = activityService;
|
|
53
|
-
}
|
|
54
|
-
intercept(req, next) {
|
|
55
|
-
const activity = req.headers.get('activityInterceptor');
|
|
56
|
-
if (activity) {
|
|
57
|
-
const actReq = req.clone({
|
|
58
|
-
headers: req.headers.delete('activityInterceptor')
|
|
59
|
-
});
|
|
60
|
-
if (activity === 'false') {
|
|
61
|
-
return next.handle(actReq);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
const id = this.activityService.register();
|
|
65
|
-
return next.handle(req).pipe(finalize(() => {
|
|
66
|
-
this.activityService.unregister(id);
|
|
67
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
ActivityInterceptor.ɵfac = function ActivityInterceptor_Factory(t) { return new (t || ActivityInterceptor)(i0.ɵɵinject(ActivityService)); };
|
|
71
|
-
ActivityInterceptor.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ActivityInterceptor, factory: ActivityInterceptor.ɵfac });
|
|
72
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ActivityInterceptor, [{
|
|
73
|
-
type: Injectable
|
|
50
|
+
class ActivityInterceptor {
|
|
51
|
+
constructor(activityService) {
|
|
52
|
+
this.activityService = activityService;
|
|
53
|
+
}
|
|
54
|
+
intercept(req, next) {
|
|
55
|
+
const activity = req.headers.get('activityInterceptor');
|
|
56
|
+
if (activity) {
|
|
57
|
+
const actReq = req.clone({
|
|
58
|
+
headers: req.headers.delete('activityInterceptor')
|
|
59
|
+
});
|
|
60
|
+
if (activity === 'false') {
|
|
61
|
+
return next.handle(actReq);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const id = this.activityService.register();
|
|
65
|
+
return next.handle(req).pipe(finalize(() => {
|
|
66
|
+
this.activityService.unregister(id);
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
ActivityInterceptor.ɵfac = function ActivityInterceptor_Factory(t) { return new (t || ActivityInterceptor)(i0.ɵɵinject(ActivityService)); };
|
|
71
|
+
ActivityInterceptor.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ActivityInterceptor, factory: ActivityInterceptor.ɵfac });
|
|
72
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ActivityInterceptor, [{
|
|
73
|
+
type: Injectable
|
|
74
74
|
}], function () { return [{ type: ActivityService }]; }, null); })();
|
|
75
75
|
|
|
76
|
-
class IgoActivityModule {
|
|
77
|
-
static forRoot() {
|
|
78
|
-
return {
|
|
79
|
-
ngModule: IgoActivityModule,
|
|
80
|
-
providers: [
|
|
81
|
-
{
|
|
82
|
-
provide: HTTP_INTERCEPTORS,
|
|
83
|
-
useClass: ActivityInterceptor,
|
|
84
|
-
multi: true
|
|
85
|
-
}
|
|
86
|
-
]
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
IgoActivityModule.ɵfac = function IgoActivityModule_Factory(t) { return new (t || IgoActivityModule)(); };
|
|
91
|
-
IgoActivityModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoActivityModule });
|
|
92
|
-
IgoActivityModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({});
|
|
93
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoActivityModule, [{
|
|
94
|
-
type: NgModule,
|
|
95
|
-
args: [{
|
|
96
|
-
imports: [],
|
|
97
|
-
declarations: [],
|
|
98
|
-
exports: []
|
|
99
|
-
}]
|
|
76
|
+
class IgoActivityModule {
|
|
77
|
+
static forRoot() {
|
|
78
|
+
return {
|
|
79
|
+
ngModule: IgoActivityModule,
|
|
80
|
+
providers: [
|
|
81
|
+
{
|
|
82
|
+
provide: HTTP_INTERCEPTORS,
|
|
83
|
+
useClass: ActivityInterceptor,
|
|
84
|
+
multi: true
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
IgoActivityModule.ɵfac = function IgoActivityModule_Factory(t) { return new (t || IgoActivityModule)(); };
|
|
91
|
+
IgoActivityModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoActivityModule });
|
|
92
|
+
IgoActivityModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({});
|
|
93
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoActivityModule, [{
|
|
94
|
+
type: NgModule,
|
|
95
|
+
args: [{
|
|
96
|
+
imports: [],
|
|
97
|
+
declarations: [],
|
|
98
|
+
exports: []
|
|
99
|
+
}]
|
|
100
100
|
}], null, null); })();
|
|
101
101
|
|
|
102
|
-
const version = {
|
|
103
|
-
lib: '1.15.
|
|
104
|
-
releaseDate:
|
|
102
|
+
const version = {
|
|
103
|
+
lib: '1.15.6',
|
|
104
|
+
releaseDate: 1713187580855
|
|
105
105
|
};
|
|
106
106
|
|
|
107
|
-
class ConfigService {
|
|
108
|
-
constructor(injector) {
|
|
109
|
-
this.injector = injector;
|
|
110
|
-
this.config = {};
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Use to get the data found in config file
|
|
114
|
-
*/
|
|
115
|
-
getConfig(key) {
|
|
116
|
-
return ObjectUtils.resolve(this.config, key);
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* This method loads "[path]" to get all config's variables
|
|
120
|
-
*/
|
|
121
|
-
load(options) {
|
|
122
|
-
const baseConfig = options.default || {};
|
|
123
|
-
if (!options.path) {
|
|
124
|
-
this.config = baseConfig;
|
|
125
|
-
return true;
|
|
126
|
-
}
|
|
127
|
-
const http = this.injector.get(HttpClient);
|
|
128
|
-
return new Promise((resolve, _reject) => {
|
|
129
|
-
http
|
|
130
|
-
.get(options.path)
|
|
131
|
-
.pipe(catchError((error) => {
|
|
132
|
-
console.log(`Configuration file ${options.path} could not be read`);
|
|
133
|
-
resolve(true);
|
|
134
|
-
return throwError(error.error || 'Server error');
|
|
135
|
-
}))
|
|
136
|
-
.subscribe((configResponse) => {
|
|
137
|
-
this.config = ObjectUtils.mergeDeep(ObjectUtils.mergeDeep({ version }, baseConfig), configResponse);
|
|
138
|
-
resolve(true);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
ConfigService.ɵfac = function ConfigService_Factory(t) { return new (t || ConfigService)(i0.ɵɵinject(i0.Injector)); };
|
|
144
|
-
ConfigService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ConfigService, factory: ConfigService.ɵfac, providedIn: 'root' });
|
|
145
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ConfigService, [{
|
|
146
|
-
type: Injectable,
|
|
147
|
-
args: [{
|
|
148
|
-
providedIn: 'root'
|
|
149
|
-
}]
|
|
107
|
+
class ConfigService {
|
|
108
|
+
constructor(injector) {
|
|
109
|
+
this.injector = injector;
|
|
110
|
+
this.config = {};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Use to get the data found in config file
|
|
114
|
+
*/
|
|
115
|
+
getConfig(key) {
|
|
116
|
+
return ObjectUtils.resolve(this.config, key);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* This method loads "[path]" to get all config's variables
|
|
120
|
+
*/
|
|
121
|
+
load(options) {
|
|
122
|
+
const baseConfig = options.default || {};
|
|
123
|
+
if (!options.path) {
|
|
124
|
+
this.config = baseConfig;
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
const http = this.injector.get(HttpClient);
|
|
128
|
+
return new Promise((resolve, _reject) => {
|
|
129
|
+
http
|
|
130
|
+
.get(options.path)
|
|
131
|
+
.pipe(catchError((error) => {
|
|
132
|
+
console.log(`Configuration file ${options.path} could not be read`);
|
|
133
|
+
resolve(true);
|
|
134
|
+
return throwError(error.error || 'Server error');
|
|
135
|
+
}))
|
|
136
|
+
.subscribe((configResponse) => {
|
|
137
|
+
this.config = ObjectUtils.mergeDeep(ObjectUtils.mergeDeep({ version }, baseConfig), configResponse);
|
|
138
|
+
resolve(true);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
ConfigService.ɵfac = function ConfigService_Factory(t) { return new (t || ConfigService)(i0.ɵɵinject(i0.Injector)); };
|
|
144
|
+
ConfigService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ConfigService, factory: ConfigService.ɵfac, providedIn: 'root' });
|
|
145
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ConfigService, [{
|
|
146
|
+
type: Injectable,
|
|
147
|
+
args: [{
|
|
148
|
+
providedIn: 'root'
|
|
149
|
+
}]
|
|
150
150
|
}], function () { return [{ type: i0.Injector }]; }, null); })();
|
|
151
151
|
|
|
152
|
-
let CONFIG_OPTIONS = new InjectionToken('configOptions');
|
|
153
|
-
function provideConfigOptions(options) {
|
|
154
|
-
return {
|
|
155
|
-
provide: CONFIG_OPTIONS,
|
|
156
|
-
useValue: options
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
function configFactory(configService, options) {
|
|
160
|
-
return () => configService.load(options);
|
|
161
|
-
}
|
|
162
|
-
function provideConfigLoader() {
|
|
163
|
-
return {
|
|
164
|
-
provide: APP_INITIALIZER,
|
|
165
|
-
useFactory: configFactory,
|
|
166
|
-
multi: true,
|
|
167
|
-
deps: [ConfigService, CONFIG_OPTIONS]
|
|
168
|
-
};
|
|
152
|
+
let CONFIG_OPTIONS = new InjectionToken('configOptions');
|
|
153
|
+
function provideConfigOptions(options) {
|
|
154
|
+
return {
|
|
155
|
+
provide: CONFIG_OPTIONS,
|
|
156
|
+
useValue: options
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function configFactory(configService, options) {
|
|
160
|
+
return () => configService.load(options);
|
|
161
|
+
}
|
|
162
|
+
function provideConfigLoader() {
|
|
163
|
+
return {
|
|
164
|
+
provide: APP_INITIALIZER,
|
|
165
|
+
useFactory: configFactory,
|
|
166
|
+
multi: true,
|
|
167
|
+
deps: [ConfigService, CONFIG_OPTIONS]
|
|
168
|
+
};
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
class IgoConfigModule {
|
|
172
|
-
static forRoot() {
|
|
173
|
-
return {
|
|
174
|
-
ngModule: IgoConfigModule,
|
|
175
|
-
providers: [provideConfigOptions({}), provideConfigLoader()]
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
IgoConfigModule.ɵfac = function IgoConfigModule_Factory(t) { return new (t || IgoConfigModule)(); };
|
|
180
|
-
IgoConfigModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoConfigModule });
|
|
181
|
-
IgoConfigModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({});
|
|
182
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoConfigModule, [{
|
|
183
|
-
type: NgModule,
|
|
184
|
-
args: [{
|
|
185
|
-
imports: [],
|
|
186
|
-
declarations: [],
|
|
187
|
-
exports: []
|
|
188
|
-
}]
|
|
171
|
+
class IgoConfigModule {
|
|
172
|
+
static forRoot() {
|
|
173
|
+
return {
|
|
174
|
+
ngModule: IgoConfigModule,
|
|
175
|
+
providers: [provideConfigOptions({}), provideConfigLoader()]
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
IgoConfigModule.ɵfac = function IgoConfigModule_Factory(t) { return new (t || IgoConfigModule)(); };
|
|
180
|
+
IgoConfigModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoConfigModule });
|
|
181
|
+
IgoConfigModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({});
|
|
182
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoConfigModule, [{
|
|
183
|
+
type: NgModule,
|
|
184
|
+
args: [{
|
|
185
|
+
imports: [],
|
|
186
|
+
declarations: [],
|
|
187
|
+
exports: []
|
|
188
|
+
}]
|
|
189
189
|
}], null, null); })();
|
|
190
190
|
|
|
191
|
-
class LanguageLoader {
|
|
192
|
-
constructor(http, prefix, suffix = '.json', config) {
|
|
193
|
-
this.http = http;
|
|
194
|
-
this.prefix = prefix;
|
|
195
|
-
this.suffix = suffix;
|
|
196
|
-
this.config = config;
|
|
197
|
-
}
|
|
198
|
-
getTranslation(lang) {
|
|
199
|
-
const igoLocale$ = this.http.get(`locale/libs_locale/${lang}.json`);
|
|
200
|
-
if (this.config && !this.prefix) {
|
|
201
|
-
const prefix = this.config.getConfig('language.prefix');
|
|
202
|
-
this.prefix = !prefix || Array.isArray(prefix) ? prefix : [prefix];
|
|
203
|
-
}
|
|
204
|
-
if (!this.prefix || this.prefix.length === 0) {
|
|
205
|
-
return igoLocale$;
|
|
206
|
-
}
|
|
207
|
-
const appLocale$ = this.prefix.map((prefix) => this.http.get(`${prefix}${lang}${this.suffix}`));
|
|
208
|
-
const locale$ = forkJoin([igoLocale$, ...appLocale$]);
|
|
209
|
-
return locale$.pipe(map((translations) => {
|
|
210
|
-
return translations.reduce((acc, current) => ObjectUtils.mergeDeep(acc, current), {});
|
|
211
|
-
}));
|
|
212
|
-
}
|
|
191
|
+
class LanguageLoader {
|
|
192
|
+
constructor(http, prefix, suffix = '.json', config) {
|
|
193
|
+
this.http = http;
|
|
194
|
+
this.prefix = prefix;
|
|
195
|
+
this.suffix = suffix;
|
|
196
|
+
this.config = config;
|
|
197
|
+
}
|
|
198
|
+
getTranslation(lang) {
|
|
199
|
+
const igoLocale$ = this.http.get(`locale/libs_locale/${lang}.json`);
|
|
200
|
+
if (this.config && !this.prefix) {
|
|
201
|
+
const prefix = this.config.getConfig('language.prefix');
|
|
202
|
+
this.prefix = !prefix || Array.isArray(prefix) ? prefix : [prefix];
|
|
203
|
+
}
|
|
204
|
+
if (!this.prefix || this.prefix.length === 0) {
|
|
205
|
+
return igoLocale$;
|
|
206
|
+
}
|
|
207
|
+
const appLocale$ = this.prefix.map((prefix) => this.http.get(`${prefix}${lang}${this.suffix}`));
|
|
208
|
+
const locale$ = forkJoin([igoLocale$, ...appLocale$]);
|
|
209
|
+
return locale$.pipe(map((translations) => {
|
|
210
|
+
return translations.reduce((acc, current) => ObjectUtils.mergeDeep(acc, current), {});
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
function defaultLanguageLoader(http, config) {
|
|
216
|
-
return new LanguageLoader(http, undefined, undefined, config);
|
|
217
|
-
}
|
|
218
|
-
function provideLanguageLoader(loader) {
|
|
219
|
-
return {
|
|
220
|
-
provide: TranslateLoader,
|
|
221
|
-
useFactory: loader || defaultLanguageLoader,
|
|
222
|
-
deps: [HttpClient]
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
function provideDefaultLanguageLoader(loader) {
|
|
226
|
-
return {
|
|
227
|
-
provide: TranslateLoader,
|
|
228
|
-
useFactory: loader || defaultLanguageLoader,
|
|
229
|
-
deps: [HttpClient, ConfigService]
|
|
230
|
-
};
|
|
215
|
+
function defaultLanguageLoader(http, config) {
|
|
216
|
+
return new LanguageLoader(http, undefined, undefined, config);
|
|
217
|
+
}
|
|
218
|
+
function provideLanguageLoader(loader) {
|
|
219
|
+
return {
|
|
220
|
+
provide: TranslateLoader,
|
|
221
|
+
useFactory: loader || defaultLanguageLoader,
|
|
222
|
+
deps: [HttpClient]
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
function provideDefaultLanguageLoader(loader) {
|
|
226
|
+
return {
|
|
227
|
+
provide: TranslateLoader,
|
|
228
|
+
useFactory: loader || defaultLanguageLoader,
|
|
229
|
+
deps: [HttpClient, ConfigService]
|
|
230
|
+
};
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
class IgoMissingTranslationHandler {
|
|
234
|
-
handle(params) {
|
|
235
|
-
if (!params.translateService.langs.length) {
|
|
233
|
+
class IgoMissingTranslationHandler {
|
|
234
|
+
handle(params) {
|
|
235
|
+
if (!params.translateService.langs.length) {
|
|
236
236
|
const error = 'Translations are not yet loaded. \
|
|
237
|
-
Check that the LanguageService is injected.';
|
|
238
|
-
throw new Error(error);
|
|
239
|
-
}
|
|
240
|
-
if (params.key.substr(0, 4) === 'igo.') {
|
|
241
|
-
throw new Error(`The Key "${params.key}" is missing in locale file.`);
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
return params.key;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
237
|
+
Check that the LanguageService is injected.';
|
|
238
|
+
throw new Error(error);
|
|
239
|
+
}
|
|
240
|
+
if (params.key.substr(0, 4) === 'igo.') {
|
|
241
|
+
throw new Error(`The Key "${params.key}" is missing in locale file.`);
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
return params.key;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
class IgoLanguageModule {
|
|
250
|
-
static forRoot() {
|
|
251
|
-
return {
|
|
252
|
-
ngModule: IgoLanguageModule,
|
|
253
|
-
providers: [provideDefaultLanguageLoader()]
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
IgoLanguageModule.ɵfac = function IgoLanguageModule_Factory(t) { return new (t || IgoLanguageModule)(); };
|
|
258
|
-
IgoLanguageModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoLanguageModule });
|
|
259
|
-
IgoLanguageModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [TranslateModule.forRoot({
|
|
260
|
-
missingTranslationHandler: {
|
|
261
|
-
provide: MissingTranslationHandler,
|
|
262
|
-
useClass: IgoMissingTranslationHandler
|
|
263
|
-
}
|
|
264
|
-
}), TranslateModule] });
|
|
265
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoLanguageModule, [{
|
|
266
|
-
type: NgModule,
|
|
267
|
-
args: [{
|
|
268
|
-
imports: [
|
|
269
|
-
TranslateModule.forRoot({
|
|
270
|
-
missingTranslationHandler: {
|
|
271
|
-
provide: MissingTranslationHandler,
|
|
272
|
-
useClass: IgoMissingTranslationHandler
|
|
273
|
-
}
|
|
274
|
-
})
|
|
275
|
-
],
|
|
276
|
-
declarations: [],
|
|
277
|
-
exports: [TranslateModule]
|
|
278
|
-
}]
|
|
279
|
-
}], null, null); })();
|
|
249
|
+
class IgoLanguageModule {
|
|
250
|
+
static forRoot() {
|
|
251
|
+
return {
|
|
252
|
+
ngModule: IgoLanguageModule,
|
|
253
|
+
providers: [provideDefaultLanguageLoader()]
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
IgoLanguageModule.ɵfac = function IgoLanguageModule_Factory(t) { return new (t || IgoLanguageModule)(); };
|
|
258
|
+
IgoLanguageModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoLanguageModule });
|
|
259
|
+
IgoLanguageModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [TranslateModule.forRoot({
|
|
260
|
+
missingTranslationHandler: {
|
|
261
|
+
provide: MissingTranslationHandler,
|
|
262
|
+
useClass: IgoMissingTranslationHandler
|
|
263
|
+
}
|
|
264
|
+
}), TranslateModule] });
|
|
265
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoLanguageModule, [{
|
|
266
|
+
type: NgModule,
|
|
267
|
+
args: [{
|
|
268
|
+
imports: [
|
|
269
|
+
TranslateModule.forRoot({
|
|
270
|
+
missingTranslationHandler: {
|
|
271
|
+
provide: MissingTranslationHandler,
|
|
272
|
+
useClass: IgoMissingTranslationHandler
|
|
273
|
+
}
|
|
274
|
+
})
|
|
275
|
+
],
|
|
276
|
+
declarations: [],
|
|
277
|
+
exports: [TranslateModule]
|
|
278
|
+
}]
|
|
279
|
+
}], null, null); })();
|
|
280
280
|
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(IgoLanguageModule, { imports: [i1.TranslateModule], exports: [TranslateModule] }); })();
|
|
281
281
|
|
|
282
|
-
class IgoMessageModule {
|
|
283
|
-
static forRoot() {
|
|
284
|
-
return {
|
|
285
|
-
ngModule: IgoMessageModule,
|
|
286
|
-
providers: []
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
IgoMessageModule.ɵfac = function IgoMessageModule_Factory(t) { return new (t || IgoMessageModule)(); };
|
|
291
|
-
IgoMessageModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoMessageModule });
|
|
292
|
-
IgoMessageModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
|
|
293
|
-
ToastrModule.forRoot({
|
|
294
|
-
positionClass: 'toast-bottom-right',
|
|
295
|
-
timeOut: 10000,
|
|
296
|
-
extendedTimeOut: 10000,
|
|
297
|
-
messageClass: 'toast-message mat-typography',
|
|
298
|
-
closeButton: true,
|
|
299
|
-
progressBar: true,
|
|
300
|
-
enableHtml: true,
|
|
301
|
-
tapToDismiss: true,
|
|
302
|
-
maxOpened: 4,
|
|
303
|
-
preventDuplicates: true,
|
|
304
|
-
resetTimeoutOnDuplicate: true,
|
|
305
|
-
countDuplicates: false,
|
|
306
|
-
includeTitleDuplicates: true
|
|
307
|
-
})] });
|
|
308
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoMessageModule, [{
|
|
309
|
-
type: NgModule,
|
|
310
|
-
args: [{
|
|
311
|
-
imports: [CommonModule,
|
|
312
|
-
ToastrModule.forRoot({
|
|
313
|
-
positionClass: 'toast-bottom-right',
|
|
314
|
-
timeOut: 10000,
|
|
315
|
-
extendedTimeOut: 10000,
|
|
316
|
-
messageClass: 'toast-message mat-typography',
|
|
317
|
-
closeButton: true,
|
|
318
|
-
progressBar: true,
|
|
319
|
-
enableHtml: true,
|
|
320
|
-
tapToDismiss: true,
|
|
321
|
-
maxOpened: 4,
|
|
322
|
-
preventDuplicates: true,
|
|
323
|
-
resetTimeoutOnDuplicate: true,
|
|
324
|
-
countDuplicates: false,
|
|
325
|
-
includeTitleDuplicates: true
|
|
326
|
-
})],
|
|
327
|
-
declarations: [],
|
|
328
|
-
exports: []
|
|
329
|
-
}]
|
|
330
|
-
}], null, null); })();
|
|
282
|
+
class IgoMessageModule {
|
|
283
|
+
static forRoot() {
|
|
284
|
+
return {
|
|
285
|
+
ngModule: IgoMessageModule,
|
|
286
|
+
providers: []
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
IgoMessageModule.ɵfac = function IgoMessageModule_Factory(t) { return new (t || IgoMessageModule)(); };
|
|
291
|
+
IgoMessageModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoMessageModule });
|
|
292
|
+
IgoMessageModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
|
|
293
|
+
ToastrModule.forRoot({
|
|
294
|
+
positionClass: 'toast-bottom-right',
|
|
295
|
+
timeOut: 10000,
|
|
296
|
+
extendedTimeOut: 10000,
|
|
297
|
+
messageClass: 'toast-message mat-typography',
|
|
298
|
+
closeButton: true,
|
|
299
|
+
progressBar: true,
|
|
300
|
+
enableHtml: true,
|
|
301
|
+
tapToDismiss: true,
|
|
302
|
+
maxOpened: 4,
|
|
303
|
+
preventDuplicates: true,
|
|
304
|
+
resetTimeoutOnDuplicate: true,
|
|
305
|
+
countDuplicates: false,
|
|
306
|
+
includeTitleDuplicates: true
|
|
307
|
+
})] });
|
|
308
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoMessageModule, [{
|
|
309
|
+
type: NgModule,
|
|
310
|
+
args: [{
|
|
311
|
+
imports: [CommonModule,
|
|
312
|
+
ToastrModule.forRoot({
|
|
313
|
+
positionClass: 'toast-bottom-right',
|
|
314
|
+
timeOut: 10000,
|
|
315
|
+
extendedTimeOut: 10000,
|
|
316
|
+
messageClass: 'toast-message mat-typography',
|
|
317
|
+
closeButton: true,
|
|
318
|
+
progressBar: true,
|
|
319
|
+
enableHtml: true,
|
|
320
|
+
tapToDismiss: true,
|
|
321
|
+
maxOpened: 4,
|
|
322
|
+
preventDuplicates: true,
|
|
323
|
+
resetTimeoutOnDuplicate: true,
|
|
324
|
+
countDuplicates: false,
|
|
325
|
+
includeTitleDuplicates: true
|
|
326
|
+
})],
|
|
327
|
+
declarations: [],
|
|
328
|
+
exports: []
|
|
329
|
+
}]
|
|
330
|
+
}], null, null); })();
|
|
331
331
|
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(IgoMessageModule, { imports: [CommonModule, i1$1.ToastrModule] }); })();
|
|
332
332
|
|
|
333
|
-
var MessageType;
|
|
334
|
-
(function (MessageType) {
|
|
335
|
-
MessageType["ERROR"] = "error";
|
|
336
|
-
MessageType["ALERT"] = "warning";
|
|
337
|
-
MessageType["WARNING"] = "warning";
|
|
338
|
-
MessageType["INFO"] = "info";
|
|
339
|
-
MessageType["SUCCESS"] = "success";
|
|
340
|
-
MessageType["SHOW"] = "show";
|
|
333
|
+
var MessageType;
|
|
334
|
+
(function (MessageType) {
|
|
335
|
+
MessageType["ERROR"] = "error";
|
|
336
|
+
MessageType["ALERT"] = "warning";
|
|
337
|
+
MessageType["WARNING"] = "warning";
|
|
338
|
+
MessageType["INFO"] = "info";
|
|
339
|
+
MessageType["SUCCESS"] = "success";
|
|
340
|
+
MessageType["SHOW"] = "show";
|
|
341
341
|
})(MessageType || (MessageType = {}));
|
|
342
342
|
|
|
343
|
-
class LanguageService {
|
|
344
|
-
constructor(translate) {
|
|
345
|
-
this.translate = translate;
|
|
346
|
-
this.language = this.translate.getBrowserLang();
|
|
347
|
-
this.language$ = new BehaviorSubject(undefined);
|
|
348
|
-
const lang = this.getLanguage();
|
|
349
|
-
this.translate.setDefaultLang(lang);
|
|
350
|
-
this.language$.next(lang);
|
|
351
|
-
}
|
|
352
|
-
getLanguage() {
|
|
353
|
-
return this.language.match(/en|fr/) ? this.language : 'en';
|
|
354
|
-
}
|
|
355
|
-
setLanguage(language) {
|
|
356
|
-
this.language = language.match(/en|fr/) ? language : 'en';
|
|
357
|
-
combineLatest([this.translate.use(this.language), this.translate.reloadLang(this.language)]).subscribe(() => {
|
|
358
|
-
this.language$.next(this.language);
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
LanguageService.ɵfac = function LanguageService_Factory(t) { return new (t || LanguageService)(i0.ɵɵinject(i1.TranslateService)); };
|
|
363
|
-
LanguageService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LanguageService, factory: LanguageService.ɵfac, providedIn: 'root' });
|
|
364
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LanguageService, [{
|
|
365
|
-
type: Injectable,
|
|
366
|
-
args: [{
|
|
367
|
-
providedIn: 'root'
|
|
368
|
-
}]
|
|
343
|
+
class LanguageService {
|
|
344
|
+
constructor(translate) {
|
|
345
|
+
this.translate = translate;
|
|
346
|
+
this.language = this.translate.getBrowserLang();
|
|
347
|
+
this.language$ = new BehaviorSubject(undefined);
|
|
348
|
+
const lang = this.getLanguage();
|
|
349
|
+
this.translate.setDefaultLang(lang);
|
|
350
|
+
this.language$.next(lang);
|
|
351
|
+
}
|
|
352
|
+
getLanguage() {
|
|
353
|
+
return this.language.match(/en|fr/) ? this.language : 'en';
|
|
354
|
+
}
|
|
355
|
+
setLanguage(language) {
|
|
356
|
+
this.language = language.match(/en|fr/) ? language : 'en';
|
|
357
|
+
combineLatest([this.translate.use(this.language), this.translate.reloadLang(this.language)]).subscribe(() => {
|
|
358
|
+
this.language$.next(this.language);
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
LanguageService.ɵfac = function LanguageService_Factory(t) { return new (t || LanguageService)(i0.ɵɵinject(i1.TranslateService)); };
|
|
363
|
+
LanguageService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LanguageService, factory: LanguageService.ɵfac, providedIn: 'root' });
|
|
364
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LanguageService, [{
|
|
365
|
+
type: Injectable,
|
|
366
|
+
args: [{
|
|
367
|
+
providedIn: 'root'
|
|
368
|
+
}]
|
|
369
369
|
}], function () { return [{ type: i1.TranslateService }]; }, null); })();
|
|
370
370
|
|
|
371
|
-
class MessageService {
|
|
372
|
-
constructor(injector, configService, languageService) {
|
|
373
|
-
this.injector = injector;
|
|
374
|
-
this.configService = configService;
|
|
375
|
-
this.languageService = languageService;
|
|
376
|
-
this.messages$ = new BehaviorSubject([]);
|
|
377
|
-
this.activeMessageTranslations = [];
|
|
378
|
-
this.options = this.configService.getConfig('message') || {};
|
|
379
|
-
this.languageService.language$.pipe(debounceTime(500)).subscribe(r => {
|
|
380
|
-
if (this.toastr.toasts.length === 0) {
|
|
381
|
-
this.activeMessageTranslations = [];
|
|
382
|
-
}
|
|
383
|
-
this.toastr.toasts.map(toast => {
|
|
384
|
-
const activeMessageTranslation = this.activeMessageTranslations.find(amt => amt.id === toast.toastId);
|
|
385
|
-
if (activeMessageTranslation) {
|
|
386
|
-
const translatedTextInterpolateParams = { ...activeMessageTranslation.textInterpolateParams };
|
|
387
|
-
const translatedTitleInterpolateParams = { ...activeMessageTranslation.titleInterpolateParams };
|
|
388
|
-
if (activeMessageTranslation.textInterpolateParams) {
|
|
389
|
-
Object.keys(activeMessageTranslation.textInterpolateParams).map(k => {
|
|
390
|
-
if (k) {
|
|
391
|
-
translatedTextInterpolateParams[k] =
|
|
392
|
-
this.languageService.translate.instant(activeMessageTranslation.textInterpolateParams[k]);
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
if (activeMessageTranslation.titleInterpolateParams) {
|
|
397
|
-
Object.keys(activeMessageTranslation.titleInterpolateParams).map(k => {
|
|
398
|
-
if (k) {
|
|
399
|
-
translatedTitleInterpolateParams[k] =
|
|
400
|
-
this.languageService.translate.instant(activeMessageTranslation.titleInterpolateParams[k]);
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
forkJoin([
|
|
405
|
-
this.languageService.translate.get(activeMessageTranslation.textKey, translatedTextInterpolateParams),
|
|
406
|
-
this.languageService.translate.get(activeMessageTranslation.titleKey, translatedTitleInterpolateParams)
|
|
407
|
-
]).pipe(first()).subscribe((res) => {
|
|
408
|
-
toast.toastRef.componentInstance.message = res[0];
|
|
409
|
-
toast.toastRef.componentInstance.title = res[1];
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
});
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
get toastr() {
|
|
416
|
-
return this.injector.get(ToastrService);
|
|
417
|
-
}
|
|
418
|
-
showError(httpError) {
|
|
419
|
-
httpError.error.caught = true;
|
|
420
|
-
return this.error(httpError.error.message, httpError.error.title);
|
|
421
|
-
}
|
|
422
|
-
message(message) {
|
|
423
|
-
const messageType = message.type;
|
|
424
|
-
this.toastr.toastrConfig.iconClasses[messageType] = `toast-${messageType}`;
|
|
425
|
-
this.messages$.next(this.messages$.value.concat([message]));
|
|
426
|
-
message.options = message.options || {};
|
|
427
|
-
const currentDate = new Date();
|
|
428
|
-
message.options.from = message.options.from ? message.options.from : new Date('1 jan 1900');
|
|
429
|
-
message.options.to = message.options.to ? message.options.to : new Date('1 jan 3000');
|
|
430
|
-
if (typeof message.options.from === 'string') {
|
|
431
|
-
message.options.from = new Date(Date.parse(message.options.from.replace(/-/g, ' ')));
|
|
432
|
-
}
|
|
433
|
-
if (typeof message.options.to === 'string') {
|
|
434
|
-
message.options.to = new Date(Date.parse(message.options.to.replace(/-/g, ' ')));
|
|
435
|
-
}
|
|
436
|
-
if (currentDate > message.options.from && currentDate < message.options.to) {
|
|
437
|
-
if (message.showIcon === false) {
|
|
438
|
-
this.toastr.toastrConfig.iconClasses[messageType] = `toast-${messageType} toast-no-icon`;
|
|
439
|
-
}
|
|
440
|
-
message = this.handleTemplate(message);
|
|
441
|
-
if (message.text) {
|
|
442
|
-
let messageShown;
|
|
443
|
-
switch (message.type) {
|
|
444
|
-
case MessageType.SUCCESS:
|
|
445
|
-
messageShown = this.success(message.text, message.title, message.options, message.textInterpolateParams, message.titleInterpolateParams);
|
|
446
|
-
break;
|
|
447
|
-
case MessageType.ERROR:
|
|
448
|
-
messageShown = this.error(message.text, message.title, message.options, message.textInterpolateParams, message.titleInterpolateParams);
|
|
449
|
-
break;
|
|
450
|
-
case MessageType.INFO:
|
|
451
|
-
messageShown = this.info(message.text, message.title, message.options, message.textInterpolateParams, message.titleInterpolateParams);
|
|
452
|
-
break;
|
|
453
|
-
case MessageType.SHOW:
|
|
454
|
-
messageShown = this.show(message.text, message.title, message.options, message.textInterpolateParams, message.titleInterpolateParams);
|
|
455
|
-
break;
|
|
456
|
-
case MessageType.ALERT:
|
|
457
|
-
case MessageType.WARNING:
|
|
458
|
-
messageShown = this.alert(message.text, message.title, message.options, message.textInterpolateParams, message.titleInterpolateParams);
|
|
459
|
-
break;
|
|
460
|
-
default:
|
|
461
|
-
messageShown = this.info(message.text, message.title, message.options, message.textInterpolateParams, message.titleInterpolateParams);
|
|
462
|
-
break;
|
|
463
|
-
}
|
|
464
|
-
message.options.id = messageShown.toastId;
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
success(text, title = 'igo.core.message.success', options = {}, textInterpolateParams, titleInterpolateParams) {
|
|
469
|
-
return this.handleNgxToastr('success', text, title, options, textInterpolateParams, titleInterpolateParams);
|
|
470
|
-
}
|
|
471
|
-
error(text, title = 'igo.core.message.error', options = {}, textInterpolateParams, titleInterpolateParams) {
|
|
472
|
-
return this.handleNgxToastr('error', text, title, options, textInterpolateParams, titleInterpolateParams);
|
|
473
|
-
}
|
|
474
|
-
info(text, title = 'igo.core.message.info', options = {}, textInterpolateParams, titleInterpolateParams) {
|
|
475
|
-
return this.handleNgxToastr('info', text, title, options, textInterpolateParams, titleInterpolateParams);
|
|
476
|
-
}
|
|
477
|
-
alert(text, title = 'igo.core.message.alert', options = {}, textInterpolateParams, titleInterpolateParams) {
|
|
478
|
-
return this.handleNgxToastr('alert', text, title, options, textInterpolateParams, titleInterpolateParams);
|
|
479
|
-
}
|
|
480
|
-
show(text, title = 'igo.core.message.info', options = {}, textInterpolateParams, titleInterpolateParams) {
|
|
481
|
-
return this.handleNgxToastr('show', text, title, options, textInterpolateParams, titleInterpolateParams);
|
|
482
|
-
}
|
|
483
|
-
handleNgxToastr(type, text, title, options = {}, textInterpolateParams, titleInterpolateParams) {
|
|
484
|
-
const translatedTextInterpolateParams = { ...textInterpolateParams };
|
|
485
|
-
const translatedTitlenterpolateParams = { ...titleInterpolateParams };
|
|
486
|
-
if (textInterpolateParams) {
|
|
487
|
-
Object.keys(textInterpolateParams).map(k => {
|
|
488
|
-
if (textInterpolateParams[k]) {
|
|
489
|
-
translatedTextInterpolateParams[k] =
|
|
490
|
-
this.languageService.translate.instant(textInterpolateParams[k]);
|
|
491
|
-
}
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
if (titleInterpolateParams) {
|
|
495
|
-
Object.keys(titleInterpolateParams).map(k => {
|
|
496
|
-
if (k) {
|
|
497
|
-
translatedTitlenterpolateParams[k] =
|
|
498
|
-
this.languageService.translate.instant(titleInterpolateParams[k]);
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
const message = this.languageService.translate.instant(text, translatedTextInterpolateParams);
|
|
503
|
-
const translatedTitle = this.languageService.translate.instant(title, translatedTitlenterpolateParams);
|
|
504
|
-
let activeToast;
|
|
505
|
-
switch (type) {
|
|
506
|
-
case 'success':
|
|
507
|
-
activeToast = this.toastr.success(message, translatedTitle, options);
|
|
508
|
-
break;
|
|
509
|
-
case 'error':
|
|
510
|
-
activeToast = this.toastr.error(message, translatedTitle, options);
|
|
511
|
-
break;
|
|
512
|
-
case 'show':
|
|
513
|
-
case 'info':
|
|
514
|
-
activeToast = this.toastr.info(message, translatedTitle, options);
|
|
515
|
-
break;
|
|
516
|
-
case 'alert':
|
|
517
|
-
activeToast = this.toastr.warning(message, translatedTitle, options);
|
|
518
|
-
break;
|
|
519
|
-
}
|
|
520
|
-
this.activeMessageTranslations.push({
|
|
521
|
-
id: activeToast.toastId,
|
|
522
|
-
titleKey: title,
|
|
523
|
-
textKey: text,
|
|
524
|
-
textInterpolateParams,
|
|
525
|
-
titleInterpolateParams
|
|
526
|
-
});
|
|
527
|
-
return activeToast;
|
|
528
|
-
}
|
|
529
|
-
remove(id) {
|
|
530
|
-
this.toastr.remove(id);
|
|
531
|
-
}
|
|
532
|
-
removeAllAreNotError() {
|
|
533
|
-
for (const mess of this.messages$.value) {
|
|
534
|
-
if (mess.type !== MessageType.ERROR) {
|
|
535
|
-
this.remove(mess.options.id);
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
handleTemplate(message) {
|
|
540
|
-
if (!this.options.template || message.html) {
|
|
541
|
-
return message;
|
|
542
|
-
}
|
|
543
|
-
let html = this.options.template;
|
|
544
|
-
html = html.replace('${text}', message.text);
|
|
545
|
-
html = html.replace('${title}', message.title);
|
|
546
|
-
message.html = undefined;
|
|
547
|
-
message.text = html;
|
|
548
|
-
message.title = undefined;
|
|
549
|
-
return message;
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
MessageService.ɵfac = function MessageService_Factory(t) { return new (t || MessageService)(i0.ɵɵinject(Injector), i0.ɵɵinject(ConfigService), i0.ɵɵinject(LanguageService)); };
|
|
553
|
-
MessageService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MessageService, factory: MessageService.ɵfac, providedIn: 'root' });
|
|
554
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MessageService, [{
|
|
555
|
-
type: Injectable,
|
|
556
|
-
args: [{
|
|
557
|
-
providedIn: 'root'
|
|
558
|
-
}]
|
|
559
|
-
}], function () { return [{ type: i0.Injector, decorators: [{
|
|
560
|
-
type: Inject,
|
|
561
|
-
args: [Injector]
|
|
371
|
+
class MessageService {
|
|
372
|
+
constructor(injector, configService, languageService) {
|
|
373
|
+
this.injector = injector;
|
|
374
|
+
this.configService = configService;
|
|
375
|
+
this.languageService = languageService;
|
|
376
|
+
this.messages$ = new BehaviorSubject([]);
|
|
377
|
+
this.activeMessageTranslations = [];
|
|
378
|
+
this.options = this.configService.getConfig('message') || {};
|
|
379
|
+
this.languageService.language$.pipe(debounceTime(500)).subscribe(r => {
|
|
380
|
+
if (this.toastr.toasts.length === 0) {
|
|
381
|
+
this.activeMessageTranslations = [];
|
|
382
|
+
}
|
|
383
|
+
this.toastr.toasts.map(toast => {
|
|
384
|
+
const activeMessageTranslation = this.activeMessageTranslations.find(amt => amt.id === toast.toastId);
|
|
385
|
+
if (activeMessageTranslation) {
|
|
386
|
+
const translatedTextInterpolateParams = { ...activeMessageTranslation.textInterpolateParams };
|
|
387
|
+
const translatedTitleInterpolateParams = { ...activeMessageTranslation.titleInterpolateParams };
|
|
388
|
+
if (activeMessageTranslation.textInterpolateParams) {
|
|
389
|
+
Object.keys(activeMessageTranslation.textInterpolateParams).map(k => {
|
|
390
|
+
if (k) {
|
|
391
|
+
translatedTextInterpolateParams[k] =
|
|
392
|
+
this.languageService.translate.instant(activeMessageTranslation.textInterpolateParams[k]);
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
if (activeMessageTranslation.titleInterpolateParams) {
|
|
397
|
+
Object.keys(activeMessageTranslation.titleInterpolateParams).map(k => {
|
|
398
|
+
if (k) {
|
|
399
|
+
translatedTitleInterpolateParams[k] =
|
|
400
|
+
this.languageService.translate.instant(activeMessageTranslation.titleInterpolateParams[k]);
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
forkJoin([
|
|
405
|
+
this.languageService.translate.get(activeMessageTranslation.textKey, translatedTextInterpolateParams),
|
|
406
|
+
this.languageService.translate.get(activeMessageTranslation.titleKey, translatedTitleInterpolateParams)
|
|
407
|
+
]).pipe(first()).subscribe((res) => {
|
|
408
|
+
toast.toastRef.componentInstance.message = res[0];
|
|
409
|
+
toast.toastRef.componentInstance.title = res[1];
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
get toastr() {
|
|
416
|
+
return this.injector.get(ToastrService);
|
|
417
|
+
}
|
|
418
|
+
showError(httpError) {
|
|
419
|
+
httpError.error.caught = true;
|
|
420
|
+
return this.error(httpError.error.message, httpError.error.title);
|
|
421
|
+
}
|
|
422
|
+
message(message) {
|
|
423
|
+
const messageType = message.type;
|
|
424
|
+
this.toastr.toastrConfig.iconClasses[messageType] = `toast-${messageType}`;
|
|
425
|
+
this.messages$.next(this.messages$.value.concat([message]));
|
|
426
|
+
message.options = message.options || {};
|
|
427
|
+
const currentDate = new Date();
|
|
428
|
+
message.options.from = message.options.from ? message.options.from : new Date('1 jan 1900');
|
|
429
|
+
message.options.to = message.options.to ? message.options.to : new Date('1 jan 3000');
|
|
430
|
+
if (typeof message.options.from === 'string') {
|
|
431
|
+
message.options.from = new Date(Date.parse(message.options.from.replace(/-/g, ' ')));
|
|
432
|
+
}
|
|
433
|
+
if (typeof message.options.to === 'string') {
|
|
434
|
+
message.options.to = new Date(Date.parse(message.options.to.replace(/-/g, ' ')));
|
|
435
|
+
}
|
|
436
|
+
if (currentDate > message.options.from && currentDate < message.options.to) {
|
|
437
|
+
if (message.showIcon === false) {
|
|
438
|
+
this.toastr.toastrConfig.iconClasses[messageType] = `toast-${messageType} toast-no-icon`;
|
|
439
|
+
}
|
|
440
|
+
message = this.handleTemplate(message);
|
|
441
|
+
if (message.text) {
|
|
442
|
+
let messageShown;
|
|
443
|
+
switch (message.type) {
|
|
444
|
+
case MessageType.SUCCESS:
|
|
445
|
+
messageShown = this.success(message.text, message.title, message.options, message.textInterpolateParams, message.titleInterpolateParams);
|
|
446
|
+
break;
|
|
447
|
+
case MessageType.ERROR:
|
|
448
|
+
messageShown = this.error(message.text, message.title, message.options, message.textInterpolateParams, message.titleInterpolateParams);
|
|
449
|
+
break;
|
|
450
|
+
case MessageType.INFO:
|
|
451
|
+
messageShown = this.info(message.text, message.title, message.options, message.textInterpolateParams, message.titleInterpolateParams);
|
|
452
|
+
break;
|
|
453
|
+
case MessageType.SHOW:
|
|
454
|
+
messageShown = this.show(message.text, message.title, message.options, message.textInterpolateParams, message.titleInterpolateParams);
|
|
455
|
+
break;
|
|
456
|
+
case MessageType.ALERT:
|
|
457
|
+
case MessageType.WARNING:
|
|
458
|
+
messageShown = this.alert(message.text, message.title, message.options, message.textInterpolateParams, message.titleInterpolateParams);
|
|
459
|
+
break;
|
|
460
|
+
default:
|
|
461
|
+
messageShown = this.info(message.text, message.title, message.options, message.textInterpolateParams, message.titleInterpolateParams);
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
message.options.id = messageShown.toastId;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
success(text, title = 'igo.core.message.success', options = {}, textInterpolateParams, titleInterpolateParams) {
|
|
469
|
+
return this.handleNgxToastr('success', text, title, options, textInterpolateParams, titleInterpolateParams);
|
|
470
|
+
}
|
|
471
|
+
error(text, title = 'igo.core.message.error', options = {}, textInterpolateParams, titleInterpolateParams) {
|
|
472
|
+
return this.handleNgxToastr('error', text, title, options, textInterpolateParams, titleInterpolateParams);
|
|
473
|
+
}
|
|
474
|
+
info(text, title = 'igo.core.message.info', options = {}, textInterpolateParams, titleInterpolateParams) {
|
|
475
|
+
return this.handleNgxToastr('info', text, title, options, textInterpolateParams, titleInterpolateParams);
|
|
476
|
+
}
|
|
477
|
+
alert(text, title = 'igo.core.message.alert', options = {}, textInterpolateParams, titleInterpolateParams) {
|
|
478
|
+
return this.handleNgxToastr('alert', text, title, options, textInterpolateParams, titleInterpolateParams);
|
|
479
|
+
}
|
|
480
|
+
show(text, title = 'igo.core.message.info', options = {}, textInterpolateParams, titleInterpolateParams) {
|
|
481
|
+
return this.handleNgxToastr('show', text, title, options, textInterpolateParams, titleInterpolateParams);
|
|
482
|
+
}
|
|
483
|
+
handleNgxToastr(type, text, title, options = {}, textInterpolateParams, titleInterpolateParams) {
|
|
484
|
+
const translatedTextInterpolateParams = { ...textInterpolateParams };
|
|
485
|
+
const translatedTitlenterpolateParams = { ...titleInterpolateParams };
|
|
486
|
+
if (textInterpolateParams) {
|
|
487
|
+
Object.keys(textInterpolateParams).map(k => {
|
|
488
|
+
if (textInterpolateParams[k]) {
|
|
489
|
+
translatedTextInterpolateParams[k] =
|
|
490
|
+
this.languageService.translate.instant(textInterpolateParams[k]);
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
if (titleInterpolateParams) {
|
|
495
|
+
Object.keys(titleInterpolateParams).map(k => {
|
|
496
|
+
if (k) {
|
|
497
|
+
translatedTitlenterpolateParams[k] =
|
|
498
|
+
this.languageService.translate.instant(titleInterpolateParams[k]);
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
const message = this.languageService.translate.instant(text, translatedTextInterpolateParams);
|
|
503
|
+
const translatedTitle = this.languageService.translate.instant(title, translatedTitlenterpolateParams);
|
|
504
|
+
let activeToast;
|
|
505
|
+
switch (type) {
|
|
506
|
+
case 'success':
|
|
507
|
+
activeToast = this.toastr.success(message, translatedTitle, options);
|
|
508
|
+
break;
|
|
509
|
+
case 'error':
|
|
510
|
+
activeToast = this.toastr.error(message, translatedTitle, options);
|
|
511
|
+
break;
|
|
512
|
+
case 'show':
|
|
513
|
+
case 'info':
|
|
514
|
+
activeToast = this.toastr.info(message, translatedTitle, options);
|
|
515
|
+
break;
|
|
516
|
+
case 'alert':
|
|
517
|
+
activeToast = this.toastr.warning(message, translatedTitle, options);
|
|
518
|
+
break;
|
|
519
|
+
}
|
|
520
|
+
this.activeMessageTranslations.push({
|
|
521
|
+
id: activeToast.toastId,
|
|
522
|
+
titleKey: title,
|
|
523
|
+
textKey: text,
|
|
524
|
+
textInterpolateParams,
|
|
525
|
+
titleInterpolateParams
|
|
526
|
+
});
|
|
527
|
+
return activeToast;
|
|
528
|
+
}
|
|
529
|
+
remove(id) {
|
|
530
|
+
this.toastr.remove(id);
|
|
531
|
+
}
|
|
532
|
+
removeAllAreNotError() {
|
|
533
|
+
for (const mess of this.messages$.value) {
|
|
534
|
+
if (mess.type !== MessageType.ERROR) {
|
|
535
|
+
this.remove(mess.options.id);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
handleTemplate(message) {
|
|
540
|
+
if (!this.options.template || message.html) {
|
|
541
|
+
return message;
|
|
542
|
+
}
|
|
543
|
+
let html = this.options.template;
|
|
544
|
+
html = html.replace('${text}', message.text);
|
|
545
|
+
html = html.replace('${title}', message.title);
|
|
546
|
+
message.html = undefined;
|
|
547
|
+
message.text = html;
|
|
548
|
+
message.title = undefined;
|
|
549
|
+
return message;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
MessageService.ɵfac = function MessageService_Factory(t) { return new (t || MessageService)(i0.ɵɵinject(Injector), i0.ɵɵinject(ConfigService), i0.ɵɵinject(LanguageService)); };
|
|
553
|
+
MessageService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MessageService, factory: MessageService.ɵfac, providedIn: 'root' });
|
|
554
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MessageService, [{
|
|
555
|
+
type: Injectable,
|
|
556
|
+
args: [{
|
|
557
|
+
providedIn: 'root'
|
|
558
|
+
}]
|
|
559
|
+
}], function () { return [{ type: i0.Injector, decorators: [{
|
|
560
|
+
type: Inject,
|
|
561
|
+
args: [Injector]
|
|
562
562
|
}] }, { type: ConfigService }, { type: LanguageService }]; }, null); })();
|
|
563
563
|
|
|
564
|
-
class ErrorInterceptor {
|
|
565
|
-
constructor(injector) {
|
|
566
|
-
this.injector = injector;
|
|
567
|
-
}
|
|
568
|
-
intercept(originalReq, next) {
|
|
569
|
-
const interceptError = originalReq.headers.get('interceptError');
|
|
570
|
-
const req = originalReq.clone({
|
|
571
|
-
headers: originalReq.headers.delete('interceptError')
|
|
572
|
-
});
|
|
573
|
-
if (interceptError === 'false') {
|
|
574
|
-
return next.handle(req);
|
|
575
|
-
}
|
|
576
|
-
const errorContainer = { httpError: undefined };
|
|
577
|
-
return next.handle(req).pipe(catchError(error => this.handleError(error, errorContainer)), finalize(() => {
|
|
578
|
-
this.handleCaughtError(errorContainer);
|
|
579
|
-
this.handleUncaughtError(errorContainer);
|
|
580
|
-
}));
|
|
581
|
-
}
|
|
582
|
-
handleError(httpError, errorContainer) {
|
|
583
|
-
if (httpError instanceof HttpErrorResponse) {
|
|
584
|
-
const errorObj = httpError.error === 'object' ? httpError.error : {};
|
|
585
|
-
errorObj.message = httpError.error?.message || httpError.statusText;
|
|
586
|
-
errorObj.caught = false;
|
|
587
|
-
httpError = new HttpErrorResponse({
|
|
588
|
-
error: errorObj,
|
|
589
|
-
headers: httpError.headers,
|
|
590
|
-
status: httpError.status,
|
|
591
|
-
statusText: httpError.statusText,
|
|
592
|
-
url: httpError.url
|
|
593
|
-
});
|
|
594
|
-
}
|
|
595
|
-
errorContainer.httpError = httpError;
|
|
596
|
-
return throwError(httpError);
|
|
597
|
-
}
|
|
598
|
-
handleCaughtError(errorContainer) {
|
|
599
|
-
const httpError = errorContainer.httpError;
|
|
600
|
-
if (httpError && httpError.error.toDisplay) {
|
|
601
|
-
httpError.error.caught = true;
|
|
602
|
-
const messageService = this.injector.get(MessageService);
|
|
603
|
-
messageService.error(httpError.error.message, httpError.error.title);
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
handleUncaughtError(errorContainer) {
|
|
607
|
-
const httpError = errorContainer.httpError;
|
|
608
|
-
if (httpError && !httpError.error.caught) {
|
|
609
|
-
const messageService = this.injector.get(MessageService);
|
|
610
|
-
httpError.error.caught = true;
|
|
611
|
-
messageService.error('igo.core.errors.uncaught.message', 'igo.core.errors.uncaught.title');
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
ErrorInterceptor.ɵfac = function ErrorInterceptor_Factory(t) { return new (t || ErrorInterceptor)(i0.ɵɵinject(i0.Injector)); };
|
|
616
|
-
ErrorInterceptor.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ErrorInterceptor, factory: ErrorInterceptor.ɵfac, providedIn: 'root' });
|
|
617
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ErrorInterceptor, [{
|
|
618
|
-
type: Injectable,
|
|
619
|
-
args: [{
|
|
620
|
-
providedIn: 'root'
|
|
621
|
-
}]
|
|
564
|
+
class ErrorInterceptor {
|
|
565
|
+
constructor(injector) {
|
|
566
|
+
this.injector = injector;
|
|
567
|
+
}
|
|
568
|
+
intercept(originalReq, next) {
|
|
569
|
+
const interceptError = originalReq.headers.get('interceptError');
|
|
570
|
+
const req = originalReq.clone({
|
|
571
|
+
headers: originalReq.headers.delete('interceptError')
|
|
572
|
+
});
|
|
573
|
+
if (interceptError === 'false') {
|
|
574
|
+
return next.handle(req);
|
|
575
|
+
}
|
|
576
|
+
const errorContainer = { httpError: undefined };
|
|
577
|
+
return next.handle(req).pipe(catchError(error => this.handleError(error, errorContainer)), finalize(() => {
|
|
578
|
+
this.handleCaughtError(errorContainer);
|
|
579
|
+
this.handleUncaughtError(errorContainer);
|
|
580
|
+
}));
|
|
581
|
+
}
|
|
582
|
+
handleError(httpError, errorContainer) {
|
|
583
|
+
if (httpError instanceof HttpErrorResponse) {
|
|
584
|
+
const errorObj = httpError.error === 'object' ? httpError.error : {};
|
|
585
|
+
errorObj.message = httpError.error?.message || httpError.statusText;
|
|
586
|
+
errorObj.caught = false;
|
|
587
|
+
httpError = new HttpErrorResponse({
|
|
588
|
+
error: errorObj,
|
|
589
|
+
headers: httpError.headers,
|
|
590
|
+
status: httpError.status,
|
|
591
|
+
statusText: httpError.statusText,
|
|
592
|
+
url: httpError.url
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
errorContainer.httpError = httpError;
|
|
596
|
+
return throwError(httpError);
|
|
597
|
+
}
|
|
598
|
+
handleCaughtError(errorContainer) {
|
|
599
|
+
const httpError = errorContainer.httpError;
|
|
600
|
+
if (httpError && httpError.error.toDisplay) {
|
|
601
|
+
httpError.error.caught = true;
|
|
602
|
+
const messageService = this.injector.get(MessageService);
|
|
603
|
+
messageService.error(httpError.error.message, httpError.error.title);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
handleUncaughtError(errorContainer) {
|
|
607
|
+
const httpError = errorContainer.httpError;
|
|
608
|
+
if (httpError && !httpError.error.caught) {
|
|
609
|
+
const messageService = this.injector.get(MessageService);
|
|
610
|
+
httpError.error.caught = true;
|
|
611
|
+
messageService.error('igo.core.errors.uncaught.message', 'igo.core.errors.uncaught.title');
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
ErrorInterceptor.ɵfac = function ErrorInterceptor_Factory(t) { return new (t || ErrorInterceptor)(i0.ɵɵinject(i0.Injector)); };
|
|
616
|
+
ErrorInterceptor.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ErrorInterceptor, factory: ErrorInterceptor.ɵfac, providedIn: 'root' });
|
|
617
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ErrorInterceptor, [{
|
|
618
|
+
type: Injectable,
|
|
619
|
+
args: [{
|
|
620
|
+
providedIn: 'root'
|
|
621
|
+
}]
|
|
622
622
|
}], function () { return [{ type: i0.Injector }]; }, null); })();
|
|
623
623
|
|
|
624
|
-
class IgoErrorModule {
|
|
625
|
-
constructor(parentModule) {
|
|
626
|
-
if (parentModule) {
|
|
627
|
-
throw new Error('IgoErrorModule is already loaded. Import it in the AppModule only');
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
static forRoot() {
|
|
631
|
-
return {
|
|
632
|
-
ngModule: IgoErrorModule,
|
|
633
|
-
providers: [
|
|
634
|
-
{
|
|
635
|
-
provide: HTTP_INTERCEPTORS,
|
|
636
|
-
useClass: ErrorInterceptor,
|
|
637
|
-
multi: true
|
|
638
|
-
}
|
|
639
|
-
]
|
|
640
|
-
};
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
IgoErrorModule.ɵfac = function IgoErrorModule_Factory(t) { return new (t || IgoErrorModule)(i0.ɵɵinject(IgoErrorModule, 12)); };
|
|
644
|
-
IgoErrorModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoErrorModule });
|
|
645
|
-
IgoErrorModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({});
|
|
646
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoErrorModule, [{
|
|
647
|
-
type: NgModule,
|
|
648
|
-
args: [{
|
|
649
|
-
imports: [],
|
|
650
|
-
declarations: [],
|
|
651
|
-
exports: []
|
|
652
|
-
}]
|
|
653
|
-
}], function () { return [{ type: IgoErrorModule, decorators: [{
|
|
654
|
-
type: Optional
|
|
655
|
-
}, {
|
|
656
|
-
type: SkipSelf
|
|
624
|
+
class IgoErrorModule {
|
|
625
|
+
constructor(parentModule) {
|
|
626
|
+
if (parentModule) {
|
|
627
|
+
throw new Error('IgoErrorModule is already loaded. Import it in the AppModule only');
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
static forRoot() {
|
|
631
|
+
return {
|
|
632
|
+
ngModule: IgoErrorModule,
|
|
633
|
+
providers: [
|
|
634
|
+
{
|
|
635
|
+
provide: HTTP_INTERCEPTORS,
|
|
636
|
+
useClass: ErrorInterceptor,
|
|
637
|
+
multi: true
|
|
638
|
+
}
|
|
639
|
+
]
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
IgoErrorModule.ɵfac = function IgoErrorModule_Factory(t) { return new (t || IgoErrorModule)(i0.ɵɵinject(IgoErrorModule, 12)); };
|
|
644
|
+
IgoErrorModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoErrorModule });
|
|
645
|
+
IgoErrorModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({});
|
|
646
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoErrorModule, [{
|
|
647
|
+
type: NgModule,
|
|
648
|
+
args: [{
|
|
649
|
+
imports: [],
|
|
650
|
+
declarations: [],
|
|
651
|
+
exports: []
|
|
652
|
+
}]
|
|
653
|
+
}], function () { return [{ type: IgoErrorModule, decorators: [{
|
|
654
|
+
type: Optional
|
|
655
|
+
}, {
|
|
656
|
+
type: SkipSelf
|
|
657
657
|
}] }]; }, null); })();
|
|
658
658
|
|
|
659
|
-
const dbConfig = {
|
|
660
|
-
name: 'igo2DB',
|
|
661
|
-
version: 2,
|
|
662
|
-
objectStoresMeta: [{
|
|
663
|
-
store: 'geoData',
|
|
664
|
-
storeConfig: { keyPath: 'url', autoIncrement: false },
|
|
665
|
-
storeSchema: [
|
|
666
|
-
{ name: 'regionID', keypath: 'regionID', options: { unique: false } }
|
|
667
|
-
]
|
|
668
|
-
},
|
|
669
|
-
{
|
|
670
|
-
store: 'layerData',
|
|
671
|
-
storeConfig: { keyPath: 'layerId', autoIncrement: false },
|
|
672
|
-
storeSchema: [
|
|
673
|
-
{ name: 'layerOptions', keypath: 'layerOptions', options: { unique: false } },
|
|
674
|
-
{ name: 'sourceOptions', keypath: 'sourceOptions', options: { unique: false } }
|
|
675
|
-
]
|
|
676
|
-
}]
|
|
677
|
-
};
|
|
678
|
-
class IgoCoreModule {
|
|
679
|
-
constructor(matIconRegistry, domSanitizer) {
|
|
680
|
-
matIconRegistry.addSvgIconSet(domSanitizer.bypassSecurityTrustResourceUrl('./assets/igo2/core/icons/mdi.svg'));
|
|
681
|
-
}
|
|
682
|
-
static forRoot() {
|
|
683
|
-
return {
|
|
684
|
-
ngModule: IgoCoreModule,
|
|
685
|
-
providers: []
|
|
686
|
-
};
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
IgoCoreModule.ɵfac = function IgoCoreModule_Factory(t) { return new (t || IgoCoreModule)(i0.ɵɵinject(i1$2.MatIconRegistry), i0.ɵɵinject(i2.DomSanitizer)); };
|
|
690
|
-
IgoCoreModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoCoreModule });
|
|
691
|
-
IgoCoreModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
|
|
692
|
-
HttpClientModule,
|
|
693
|
-
IgoActivityModule.forRoot(),
|
|
694
|
-
IgoConfigModule.forRoot(),
|
|
695
|
-
IgoErrorModule.forRoot(),
|
|
696
|
-
IgoLanguageModule.forRoot(),
|
|
697
|
-
IgoMessageModule.forRoot(),
|
|
698
|
-
NgxIndexedDBModule.forRoot(dbConfig), IgoActivityModule,
|
|
699
|
-
IgoConfigModule,
|
|
700
|
-
IgoErrorModule,
|
|
701
|
-
IgoLanguageModule,
|
|
702
|
-
IgoMessageModule] });
|
|
703
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoCoreModule, [{
|
|
704
|
-
type: NgModule,
|
|
705
|
-
args: [{
|
|
706
|
-
imports: [
|
|
707
|
-
CommonModule,
|
|
708
|
-
HttpClientModule,
|
|
709
|
-
IgoActivityModule.forRoot(),
|
|
710
|
-
IgoConfigModule.forRoot(),
|
|
711
|
-
IgoErrorModule.forRoot(),
|
|
712
|
-
IgoLanguageModule.forRoot(),
|
|
713
|
-
IgoMessageModule.forRoot(),
|
|
714
|
-
NgxIndexedDBModule.forRoot(dbConfig)
|
|
715
|
-
],
|
|
716
|
-
declarations: [],
|
|
717
|
-
exports: [
|
|
718
|
-
IgoActivityModule,
|
|
719
|
-
IgoConfigModule,
|
|
720
|
-
IgoErrorModule,
|
|
721
|
-
IgoLanguageModule,
|
|
722
|
-
IgoMessageModule
|
|
723
|
-
]
|
|
724
|
-
}]
|
|
725
|
-
}], function () { return [{ type: i1$2.MatIconRegistry }, { type: i2.DomSanitizer }]; }, null); })();
|
|
726
|
-
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(IgoCoreModule, { imports: [CommonModule,
|
|
727
|
-
HttpClientModule, IgoActivityModule, IgoConfigModule, IgoErrorModule, IgoLanguageModule, IgoMessageModule, i8.NgxIndexedDBModule], exports: [IgoActivityModule,
|
|
728
|
-
IgoConfigModule,
|
|
729
|
-
IgoErrorModule,
|
|
730
|
-
IgoLanguageModule,
|
|
659
|
+
const dbConfig = {
|
|
660
|
+
name: 'igo2DB',
|
|
661
|
+
version: 2,
|
|
662
|
+
objectStoresMeta: [{
|
|
663
|
+
store: 'geoData',
|
|
664
|
+
storeConfig: { keyPath: 'url', autoIncrement: false },
|
|
665
|
+
storeSchema: [
|
|
666
|
+
{ name: 'regionID', keypath: 'regionID', options: { unique: false } }
|
|
667
|
+
]
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
store: 'layerData',
|
|
671
|
+
storeConfig: { keyPath: 'layerId', autoIncrement: false },
|
|
672
|
+
storeSchema: [
|
|
673
|
+
{ name: 'layerOptions', keypath: 'layerOptions', options: { unique: false } },
|
|
674
|
+
{ name: 'sourceOptions', keypath: 'sourceOptions', options: { unique: false } }
|
|
675
|
+
]
|
|
676
|
+
}]
|
|
677
|
+
};
|
|
678
|
+
class IgoCoreModule {
|
|
679
|
+
constructor(matIconRegistry, domSanitizer) {
|
|
680
|
+
matIconRegistry.addSvgIconSet(domSanitizer.bypassSecurityTrustResourceUrl('./assets/igo2/core/icons/mdi.svg'));
|
|
681
|
+
}
|
|
682
|
+
static forRoot() {
|
|
683
|
+
return {
|
|
684
|
+
ngModule: IgoCoreModule,
|
|
685
|
+
providers: []
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
IgoCoreModule.ɵfac = function IgoCoreModule_Factory(t) { return new (t || IgoCoreModule)(i0.ɵɵinject(i1$2.MatIconRegistry), i0.ɵɵinject(i2.DomSanitizer)); };
|
|
690
|
+
IgoCoreModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoCoreModule });
|
|
691
|
+
IgoCoreModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
|
|
692
|
+
HttpClientModule,
|
|
693
|
+
IgoActivityModule.forRoot(),
|
|
694
|
+
IgoConfigModule.forRoot(),
|
|
695
|
+
IgoErrorModule.forRoot(),
|
|
696
|
+
IgoLanguageModule.forRoot(),
|
|
697
|
+
IgoMessageModule.forRoot(),
|
|
698
|
+
NgxIndexedDBModule.forRoot(dbConfig), IgoActivityModule,
|
|
699
|
+
IgoConfigModule,
|
|
700
|
+
IgoErrorModule,
|
|
701
|
+
IgoLanguageModule,
|
|
702
|
+
IgoMessageModule] });
|
|
703
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoCoreModule, [{
|
|
704
|
+
type: NgModule,
|
|
705
|
+
args: [{
|
|
706
|
+
imports: [
|
|
707
|
+
CommonModule,
|
|
708
|
+
HttpClientModule,
|
|
709
|
+
IgoActivityModule.forRoot(),
|
|
710
|
+
IgoConfigModule.forRoot(),
|
|
711
|
+
IgoErrorModule.forRoot(),
|
|
712
|
+
IgoLanguageModule.forRoot(),
|
|
713
|
+
IgoMessageModule.forRoot(),
|
|
714
|
+
NgxIndexedDBModule.forRoot(dbConfig)
|
|
715
|
+
],
|
|
716
|
+
declarations: [],
|
|
717
|
+
exports: [
|
|
718
|
+
IgoActivityModule,
|
|
719
|
+
IgoConfigModule,
|
|
720
|
+
IgoErrorModule,
|
|
721
|
+
IgoLanguageModule,
|
|
722
|
+
IgoMessageModule
|
|
723
|
+
]
|
|
724
|
+
}]
|
|
725
|
+
}], function () { return [{ type: i1$2.MatIconRegistry }, { type: i2.DomSanitizer }]; }, null); })();
|
|
726
|
+
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(IgoCoreModule, { imports: [CommonModule,
|
|
727
|
+
HttpClientModule, IgoActivityModule, IgoConfigModule, IgoErrorModule, IgoLanguageModule, IgoMessageModule, i8.NgxIndexedDBModule], exports: [IgoActivityModule,
|
|
728
|
+
IgoConfigModule,
|
|
729
|
+
IgoErrorModule,
|
|
730
|
+
IgoLanguageModule,
|
|
731
731
|
IgoMessageModule] }); })();
|
|
732
732
|
|
|
733
|
-
class IgoGestureConfig extends HammerGestureConfig {
|
|
734
|
-
buildHammer(element) {
|
|
735
|
-
const mc = super.buildHammer(element);
|
|
736
|
-
mc.set({ touchAction: 'pan-y' });
|
|
737
|
-
return mc;
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
IgoGestureConfig.ɵfac = /*@__PURE__*/ function () { let ɵIgoGestureConfig_BaseFactory; return function IgoGestureConfig_Factory(t) { return (ɵIgoGestureConfig_BaseFactory || (ɵIgoGestureConfig_BaseFactory = i0.ɵɵgetInheritedFactory(IgoGestureConfig)))(t || IgoGestureConfig); }; }();
|
|
741
|
-
IgoGestureConfig.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: IgoGestureConfig, factory: IgoGestureConfig.ɵfac });
|
|
742
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoGestureConfig, [{
|
|
743
|
-
type: Injectable
|
|
733
|
+
class IgoGestureConfig extends HammerGestureConfig {
|
|
734
|
+
buildHammer(element) {
|
|
735
|
+
const mc = super.buildHammer(element);
|
|
736
|
+
mc.set({ touchAction: 'pan-y' });
|
|
737
|
+
return mc;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
IgoGestureConfig.ɵfac = /*@__PURE__*/ function () { let ɵIgoGestureConfig_BaseFactory; return function IgoGestureConfig_Factory(t) { return (ɵIgoGestureConfig_BaseFactory || (ɵIgoGestureConfig_BaseFactory = i0.ɵɵgetInheritedFactory(IgoGestureConfig)))(t || IgoGestureConfig); }; }();
|
|
741
|
+
IgoGestureConfig.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: IgoGestureConfig, factory: IgoGestureConfig.ɵfac });
|
|
742
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoGestureConfig, [{
|
|
743
|
+
type: Injectable
|
|
744
744
|
}], null, null); })();
|
|
745
745
|
|
|
746
|
-
class IgoGestureModule {
|
|
747
|
-
static forRoot() {
|
|
748
|
-
return {
|
|
749
|
-
ngModule: IgoGestureModule,
|
|
750
|
-
providers: [
|
|
751
|
-
{
|
|
752
|
-
provide: HAMMER_GESTURE_CONFIG,
|
|
753
|
-
useClass: IgoGestureConfig
|
|
754
|
-
}
|
|
755
|
-
]
|
|
756
|
-
};
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
IgoGestureModule.ɵfac = function IgoGestureModule_Factory(t) { return new (t || IgoGestureModule)(); };
|
|
760
|
-
IgoGestureModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoGestureModule });
|
|
761
|
-
IgoGestureModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [HammerModule] });
|
|
762
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoGestureModule, [{
|
|
763
|
-
type: NgModule,
|
|
764
|
-
args: [{
|
|
765
|
-
imports: [HammerModule],
|
|
766
|
-
declarations: [],
|
|
767
|
-
exports: []
|
|
768
|
-
}]
|
|
769
|
-
}], null, null); })();
|
|
746
|
+
class IgoGestureModule {
|
|
747
|
+
static forRoot() {
|
|
748
|
+
return {
|
|
749
|
+
ngModule: IgoGestureModule,
|
|
750
|
+
providers: [
|
|
751
|
+
{
|
|
752
|
+
provide: HAMMER_GESTURE_CONFIG,
|
|
753
|
+
useClass: IgoGestureConfig
|
|
754
|
+
}
|
|
755
|
+
]
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
IgoGestureModule.ɵfac = function IgoGestureModule_Factory(t) { return new (t || IgoGestureModule)(); };
|
|
760
|
+
IgoGestureModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoGestureModule });
|
|
761
|
+
IgoGestureModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [HammerModule] });
|
|
762
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoGestureModule, [{
|
|
763
|
+
type: NgModule,
|
|
764
|
+
args: [{
|
|
765
|
+
imports: [HammerModule],
|
|
766
|
+
declarations: [],
|
|
767
|
+
exports: []
|
|
768
|
+
}]
|
|
769
|
+
}], null, null); })();
|
|
770
770
|
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(IgoGestureModule, { imports: [HammerModule] }); })();
|
|
771
771
|
|
|
772
|
-
class LoggingInterceptor {
|
|
773
|
-
intercept(req, next) {
|
|
774
|
-
const started = Date.now();
|
|
775
|
-
let ok;
|
|
776
|
-
// extend server response observable with logging
|
|
777
|
-
return next.handle(req).pipe(tap(
|
|
778
|
-
// Succeeds when there is a response; ignore other events
|
|
779
|
-
event => (ok = event instanceof HttpResponse ? 'succeeded' : ''),
|
|
780
|
-
// Operation failed; error is an HttpErrorResponse
|
|
781
|
-
error => (ok = 'failed')),
|
|
782
|
-
// Log when response observable either completes or errors
|
|
783
|
-
finalize(() => {
|
|
784
|
-
const elapsed = Date.now() - started;
|
|
772
|
+
class LoggingInterceptor {
|
|
773
|
+
intercept(req, next) {
|
|
774
|
+
const started = Date.now();
|
|
775
|
+
let ok;
|
|
776
|
+
// extend server response observable with logging
|
|
777
|
+
return next.handle(req).pipe(tap(
|
|
778
|
+
// Succeeds when there is a response; ignore other events
|
|
779
|
+
event => (ok = event instanceof HttpResponse ? 'succeeded' : ''),
|
|
780
|
+
// Operation failed; error is an HttpErrorResponse
|
|
781
|
+
error => (ok = 'failed')),
|
|
782
|
+
// Log when response observable either completes or errors
|
|
783
|
+
finalize(() => {
|
|
784
|
+
const elapsed = Date.now() - started;
|
|
785
785
|
const msg = `${req.method} "${req.urlWithParams}"
|
|
786
|
-
${ok} in ${elapsed} ms.`;
|
|
787
|
-
console.log(msg);
|
|
788
|
-
}));
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
LoggingInterceptor.ɵfac = function LoggingInterceptor_Factory(t) { return new (t || LoggingInterceptor)(); };
|
|
792
|
-
LoggingInterceptor.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LoggingInterceptor, factory: LoggingInterceptor.ɵfac });
|
|
793
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LoggingInterceptor, [{
|
|
794
|
-
type: Injectable
|
|
786
|
+
${ok} in ${elapsed} ms.`;
|
|
787
|
+
console.log(msg);
|
|
788
|
+
}));
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
LoggingInterceptor.ɵfac = function LoggingInterceptor_Factory(t) { return new (t || LoggingInterceptor)(); };
|
|
792
|
+
LoggingInterceptor.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LoggingInterceptor, factory: LoggingInterceptor.ɵfac });
|
|
793
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LoggingInterceptor, [{
|
|
794
|
+
type: Injectable
|
|
795
795
|
}], null, null); })();
|
|
796
796
|
|
|
797
|
-
class IgoLoggingModule {
|
|
798
|
-
static forRoot() {
|
|
799
|
-
return {
|
|
800
|
-
ngModule: IgoLoggingModule,
|
|
801
|
-
providers: [
|
|
802
|
-
{
|
|
803
|
-
provide: HTTP_INTERCEPTORS,
|
|
804
|
-
useClass: LoggingInterceptor,
|
|
805
|
-
multi: true
|
|
806
|
-
}
|
|
807
|
-
]
|
|
808
|
-
};
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
IgoLoggingModule.ɵfac = function IgoLoggingModule_Factory(t) { return new (t || IgoLoggingModule)(); };
|
|
812
|
-
IgoLoggingModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoLoggingModule });
|
|
813
|
-
IgoLoggingModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({});
|
|
814
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoLoggingModule, [{
|
|
815
|
-
type: NgModule,
|
|
816
|
-
args: [{
|
|
817
|
-
imports: [],
|
|
818
|
-
declarations: [],
|
|
819
|
-
exports: []
|
|
820
|
-
}]
|
|
797
|
+
class IgoLoggingModule {
|
|
798
|
+
static forRoot() {
|
|
799
|
+
return {
|
|
800
|
+
ngModule: IgoLoggingModule,
|
|
801
|
+
providers: [
|
|
802
|
+
{
|
|
803
|
+
provide: HTTP_INTERCEPTORS,
|
|
804
|
+
useClass: LoggingInterceptor,
|
|
805
|
+
multi: true
|
|
806
|
+
}
|
|
807
|
+
]
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
IgoLoggingModule.ɵfac = function IgoLoggingModule_Factory(t) { return new (t || IgoLoggingModule)(); };
|
|
812
|
+
IgoLoggingModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IgoLoggingModule });
|
|
813
|
+
IgoLoggingModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({});
|
|
814
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IgoLoggingModule, [{
|
|
815
|
+
type: NgModule,
|
|
816
|
+
args: [{
|
|
817
|
+
imports: [],
|
|
818
|
+
declarations: [],
|
|
819
|
+
exports: []
|
|
820
|
+
}]
|
|
821
821
|
}], null, null); })();
|
|
822
822
|
|
|
823
|
-
let ROUTE_SERVICE_OPTIONS = new InjectionToken('routeServiceOptions');
|
|
824
|
-
function provideRouteServiceOptions(options) {
|
|
825
|
-
return {
|
|
826
|
-
provide: ROUTE_SERVICE_OPTIONS,
|
|
827
|
-
useValue: options
|
|
828
|
-
};
|
|
829
|
-
}
|
|
830
|
-
class RouteService {
|
|
831
|
-
constructor(router, route, options) {
|
|
832
|
-
this.router = router;
|
|
833
|
-
this.route = route;
|
|
834
|
-
const defaultOptions = {
|
|
835
|
-
centerKey: 'center',
|
|
836
|
-
zoomKey: 'zoom',
|
|
837
|
-
projectionKey: 'projection',
|
|
838
|
-
contextKey: 'context',
|
|
839
|
-
searchKey: 'search',
|
|
840
|
-
visibleOnLayersKey: 'visiblelayers',
|
|
841
|
-
visibleOffLayersKey: 'invisiblelayers',
|
|
842
|
-
directionsCoordKey: 'routing',
|
|
843
|
-
directionsOptionsKey: 'routingOptions',
|
|
844
|
-
toolKey: 'tool',
|
|
845
|
-
wmsUrlKey: 'wmsUrl',
|
|
846
|
-
wmsLayersKey: 'wmsLayers',
|
|
847
|
-
wmtsUrlKey: 'wmtsUrl',
|
|
848
|
-
wmtsLayersKey: 'wmtsLayers',
|
|
849
|
-
arcgisUrlKey: 'arcgisUrl',
|
|
850
|
-
arcgisLayersKey: 'arcgisLayers',
|
|
851
|
-
iarcgisUrlKey: 'iarcgisUrl',
|
|
852
|
-
iarcgisLayersKey: 'iarcgisLayers',
|
|
853
|
-
tarcgisUrlKey: 'tarcgisUrl',
|
|
854
|
-
tarcgisLayersKey: 'tarcgisLayers',
|
|
855
|
-
vectorKey: 'vector'
|
|
856
|
-
};
|
|
857
|
-
this.options = Object.assign({}, defaultOptions, options);
|
|
858
|
-
}
|
|
859
|
-
get queryParams() {
|
|
860
|
-
let url = decodeURIComponent(location.search);
|
|
861
|
-
if (url.includes('¢er=')) {
|
|
862
|
-
url = url.replace('¢er', '¢er');
|
|
863
|
-
const queryParams = url
|
|
864
|
-
.slice(1)
|
|
865
|
-
.split('&')
|
|
866
|
-
.map(p => p.split('='))
|
|
867
|
-
.reduce((obj, pair) => {
|
|
868
|
-
const [key, value] = pair.map(decodeURIComponent);
|
|
869
|
-
obj[key] = value;
|
|
870
|
-
return obj;
|
|
871
|
-
}, {});
|
|
872
|
-
this.router.navigate([], { queryParams });
|
|
873
|
-
}
|
|
874
|
-
return this.route.queryParams;
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
RouteService.ɵfac = function RouteService_Factory(t) { return new (t || RouteService)(i0.ɵɵinject(i1$3.Router), i0.ɵɵinject(i1$3.ActivatedRoute), i0.ɵɵinject(ROUTE_SERVICE_OPTIONS, 8)); };
|
|
878
|
-
RouteService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RouteService, factory: RouteService.ɵfac, providedIn: 'root' });
|
|
879
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RouteService, [{
|
|
880
|
-
type: Injectable,
|
|
881
|
-
args: [{
|
|
882
|
-
providedIn: 'root'
|
|
883
|
-
}]
|
|
884
|
-
}], function () { return [{ type: i1$3.Router }, { type: i1$3.ActivatedRoute }, { type: undefined, decorators: [{
|
|
885
|
-
type: Inject,
|
|
886
|
-
args: [ROUTE_SERVICE_OPTIONS]
|
|
887
|
-
}, {
|
|
888
|
-
type: Optional
|
|
823
|
+
let ROUTE_SERVICE_OPTIONS = new InjectionToken('routeServiceOptions');
|
|
824
|
+
function provideRouteServiceOptions(options) {
|
|
825
|
+
return {
|
|
826
|
+
provide: ROUTE_SERVICE_OPTIONS,
|
|
827
|
+
useValue: options
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
class RouteService {
|
|
831
|
+
constructor(router, route, options) {
|
|
832
|
+
this.router = router;
|
|
833
|
+
this.route = route;
|
|
834
|
+
const defaultOptions = {
|
|
835
|
+
centerKey: 'center',
|
|
836
|
+
zoomKey: 'zoom',
|
|
837
|
+
projectionKey: 'projection',
|
|
838
|
+
contextKey: 'context',
|
|
839
|
+
searchKey: 'search',
|
|
840
|
+
visibleOnLayersKey: 'visiblelayers',
|
|
841
|
+
visibleOffLayersKey: 'invisiblelayers',
|
|
842
|
+
directionsCoordKey: 'routing',
|
|
843
|
+
directionsOptionsKey: 'routingOptions',
|
|
844
|
+
toolKey: 'tool',
|
|
845
|
+
wmsUrlKey: 'wmsUrl',
|
|
846
|
+
wmsLayersKey: 'wmsLayers',
|
|
847
|
+
wmtsUrlKey: 'wmtsUrl',
|
|
848
|
+
wmtsLayersKey: 'wmtsLayers',
|
|
849
|
+
arcgisUrlKey: 'arcgisUrl',
|
|
850
|
+
arcgisLayersKey: 'arcgisLayers',
|
|
851
|
+
iarcgisUrlKey: 'iarcgisUrl',
|
|
852
|
+
iarcgisLayersKey: 'iarcgisLayers',
|
|
853
|
+
tarcgisUrlKey: 'tarcgisUrl',
|
|
854
|
+
tarcgisLayersKey: 'tarcgisLayers',
|
|
855
|
+
vectorKey: 'vector'
|
|
856
|
+
};
|
|
857
|
+
this.options = Object.assign({}, defaultOptions, options);
|
|
858
|
+
}
|
|
859
|
+
get queryParams() {
|
|
860
|
+
let url = decodeURIComponent(location.search);
|
|
861
|
+
if (url.includes('¢er=')) {
|
|
862
|
+
url = url.replace('¢er', '¢er');
|
|
863
|
+
const queryParams = url
|
|
864
|
+
.slice(1)
|
|
865
|
+
.split('&')
|
|
866
|
+
.map(p => p.split('='))
|
|
867
|
+
.reduce((obj, pair) => {
|
|
868
|
+
const [key, value] = pair.map(decodeURIComponent);
|
|
869
|
+
obj[key] = value;
|
|
870
|
+
return obj;
|
|
871
|
+
}, {});
|
|
872
|
+
this.router.navigate([], { queryParams });
|
|
873
|
+
}
|
|
874
|
+
return this.route.queryParams;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
RouteService.ɵfac = function RouteService_Factory(t) { return new (t || RouteService)(i0.ɵɵinject(i1$3.Router), i0.ɵɵinject(i1$3.ActivatedRoute), i0.ɵɵinject(ROUTE_SERVICE_OPTIONS, 8)); };
|
|
878
|
+
RouteService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RouteService, factory: RouteService.ɵfac, providedIn: 'root' });
|
|
879
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RouteService, [{
|
|
880
|
+
type: Injectable,
|
|
881
|
+
args: [{
|
|
882
|
+
providedIn: 'root'
|
|
883
|
+
}]
|
|
884
|
+
}], function () { return [{ type: i1$3.Router }, { type: i1$3.ActivatedRoute }, { type: undefined, decorators: [{
|
|
885
|
+
type: Inject,
|
|
886
|
+
args: [ROUTE_SERVICE_OPTIONS]
|
|
887
|
+
}, {
|
|
888
|
+
type: Optional
|
|
889
889
|
}] }]; }, null); })();
|
|
890
890
|
|
|
891
|
-
class AnalyticsService {
|
|
892
|
-
constructor(config) {
|
|
893
|
-
this.config = config;
|
|
894
|
-
this.options = this.config.getConfig('analytics') || {};
|
|
895
|
-
if (this.options.provider === 'matomo') {
|
|
896
|
-
this.initMatomo();
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
get paq() {
|
|
900
|
-
return (window._paq = window._paq || []);
|
|
901
|
-
}
|
|
902
|
-
initMatomo() {
|
|
903
|
-
if (!this.options.url || !this.options.id) {
|
|
904
|
-
return;
|
|
905
|
-
}
|
|
906
|
-
const url = this.options.url.substr(-1) === '/'
|
|
907
|
-
? this.options.url + 'matomo'
|
|
908
|
-
: this.options.url;
|
|
909
|
-
// this.paq.push(['trackPageView']);
|
|
910
|
-
// this.paq.push(['enableLinkTracking']);
|
|
911
|
-
(() => {
|
|
912
|
-
this.paq.push(['setTrackerUrl', url + '.php']);
|
|
913
|
-
this.paq.push(['setSiteId', this.options.id]);
|
|
914
|
-
const g = document.createElement('script');
|
|
915
|
-
const s = document.getElementsByTagName('script')[0];
|
|
916
|
-
g.type = 'text/javascript';
|
|
917
|
-
g.async = true;
|
|
918
|
-
g.defer = true;
|
|
919
|
-
g.src = url + '.js';
|
|
920
|
-
s.parentNode.insertBefore(g, s);
|
|
921
|
-
})();
|
|
922
|
-
}
|
|
923
|
-
setUser(user, profils) {
|
|
924
|
-
if (this.options.provider === 'matomo') {
|
|
925
|
-
if (!user) {
|
|
926
|
-
this.paq.push(['resetUserId']);
|
|
927
|
-
this.paq.push(['deleteCustomVariable', 1, 'user']);
|
|
928
|
-
this.paq.push(['deleteCustomVariable', 2, 'name']);
|
|
929
|
-
this.paq.push(['deleteCustomVariable', 3, 'profils']);
|
|
930
|
-
}
|
|
931
|
-
else {
|
|
932
|
-
this.paq.push(['setUserId', user.id]);
|
|
933
|
-
const name = `${user.firstName} ${user.lastName}`;
|
|
934
|
-
this.paq.push(['setCustomVariable', 1, 'user', user.sourceId, 'visit']);
|
|
935
|
-
this.paq.push(['setCustomVariable', 2, 'name', name, 'visit']);
|
|
936
|
-
this.paq.push(['setCustomVariable', 3, 'profils', profils, 'visit']);
|
|
937
|
-
}
|
|
938
|
-
this.paq.push(['trackPageView']);
|
|
939
|
-
this.paq.push(['enableLinkTracking']);
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
trackSearch(term, nbResults) {
|
|
943
|
-
if (this.options.provider === 'matomo') {
|
|
944
|
-
this.paq.push(['trackSiteSearch', term, false, nbResults]);
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
trackEvent(category, action, name) {
|
|
948
|
-
if (this.options.provider === 'matomo') {
|
|
949
|
-
this.paq.push(['trackEvent', category, action, name]);
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
/**
|
|
953
|
-
* Function that tracks layers added to the map
|
|
954
|
-
*/
|
|
955
|
-
trackLayer(category, action, parameters) {
|
|
956
|
-
if (this.options.provider === 'matomo')
|
|
957
|
-
this.paq.push(['trackEvent', category, action, parameters]);
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
AnalyticsService.ɵfac = function AnalyticsService_Factory(t) { return new (t || AnalyticsService)(i0.ɵɵinject(ConfigService)); };
|
|
961
|
-
AnalyticsService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AnalyticsService, factory: AnalyticsService.ɵfac, providedIn: 'root' });
|
|
962
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AnalyticsService, [{
|
|
963
|
-
type: Injectable,
|
|
964
|
-
args: [{
|
|
965
|
-
providedIn: 'root'
|
|
966
|
-
}]
|
|
891
|
+
class AnalyticsService {
|
|
892
|
+
constructor(config) {
|
|
893
|
+
this.config = config;
|
|
894
|
+
this.options = this.config.getConfig('analytics') || {};
|
|
895
|
+
if (this.options.provider === 'matomo') {
|
|
896
|
+
this.initMatomo();
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
get paq() {
|
|
900
|
+
return (window._paq = window._paq || []);
|
|
901
|
+
}
|
|
902
|
+
initMatomo() {
|
|
903
|
+
if (!this.options.url || !this.options.id) {
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
const url = this.options.url.substr(-1) === '/'
|
|
907
|
+
? this.options.url + 'matomo'
|
|
908
|
+
: this.options.url;
|
|
909
|
+
// this.paq.push(['trackPageView']);
|
|
910
|
+
// this.paq.push(['enableLinkTracking']);
|
|
911
|
+
(() => {
|
|
912
|
+
this.paq.push(['setTrackerUrl', url + '.php']);
|
|
913
|
+
this.paq.push(['setSiteId', this.options.id]);
|
|
914
|
+
const g = document.createElement('script');
|
|
915
|
+
const s = document.getElementsByTagName('script')[0];
|
|
916
|
+
g.type = 'text/javascript';
|
|
917
|
+
g.async = true;
|
|
918
|
+
g.defer = true;
|
|
919
|
+
g.src = url + '.js';
|
|
920
|
+
s.parentNode.insertBefore(g, s);
|
|
921
|
+
})();
|
|
922
|
+
}
|
|
923
|
+
setUser(user, profils) {
|
|
924
|
+
if (this.options.provider === 'matomo') {
|
|
925
|
+
if (!user) {
|
|
926
|
+
this.paq.push(['resetUserId']);
|
|
927
|
+
this.paq.push(['deleteCustomVariable', 1, 'user']);
|
|
928
|
+
this.paq.push(['deleteCustomVariable', 2, 'name']);
|
|
929
|
+
this.paq.push(['deleteCustomVariable', 3, 'profils']);
|
|
930
|
+
}
|
|
931
|
+
else {
|
|
932
|
+
this.paq.push(['setUserId', user.id]);
|
|
933
|
+
const name = `${user.firstName} ${user.lastName}`;
|
|
934
|
+
this.paq.push(['setCustomVariable', 1, 'user', user.sourceId, 'visit']);
|
|
935
|
+
this.paq.push(['setCustomVariable', 2, 'name', name, 'visit']);
|
|
936
|
+
this.paq.push(['setCustomVariable', 3, 'profils', profils, 'visit']);
|
|
937
|
+
}
|
|
938
|
+
this.paq.push(['trackPageView']);
|
|
939
|
+
this.paq.push(['enableLinkTracking']);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
trackSearch(term, nbResults) {
|
|
943
|
+
if (this.options.provider === 'matomo') {
|
|
944
|
+
this.paq.push(['trackSiteSearch', term, false, nbResults]);
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
trackEvent(category, action, name) {
|
|
948
|
+
if (this.options.provider === 'matomo') {
|
|
949
|
+
this.paq.push(['trackEvent', category, action, name]);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* Function that tracks layers added to the map
|
|
954
|
+
*/
|
|
955
|
+
trackLayer(category, action, parameters) {
|
|
956
|
+
if (this.options.provider === 'matomo')
|
|
957
|
+
this.paq.push(['trackEvent', category, action, parameters]);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
AnalyticsService.ɵfac = function AnalyticsService_Factory(t) { return new (t || AnalyticsService)(i0.ɵɵinject(ConfigService)); };
|
|
961
|
+
AnalyticsService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AnalyticsService, factory: AnalyticsService.ɵfac, providedIn: 'root' });
|
|
962
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AnalyticsService, [{
|
|
963
|
+
type: Injectable,
|
|
964
|
+
args: [{
|
|
965
|
+
providedIn: 'root'
|
|
966
|
+
}]
|
|
967
967
|
}], function () { return [{ type: ConfigService }]; }, null); })();
|
|
968
968
|
|
|
969
|
-
var Media;
|
|
970
|
-
(function (Media) {
|
|
971
|
-
Media["Mobile"] = "mobile";
|
|
972
|
-
Media["Tablet"] = "tablet";
|
|
973
|
-
Media["Desktop"] = "desktop";
|
|
974
|
-
})(Media || (Media = {}));
|
|
975
|
-
var MediaOrientation;
|
|
976
|
-
(function (MediaOrientation) {
|
|
977
|
-
MediaOrientation["Portrait"] = "portrait";
|
|
978
|
-
MediaOrientation["Landscape"] = "landscape";
|
|
969
|
+
var Media;
|
|
970
|
+
(function (Media) {
|
|
971
|
+
Media["Mobile"] = "mobile";
|
|
972
|
+
Media["Tablet"] = "tablet";
|
|
973
|
+
Media["Desktop"] = "desktop";
|
|
974
|
+
})(Media || (Media = {}));
|
|
975
|
+
var MediaOrientation;
|
|
976
|
+
(function (MediaOrientation) {
|
|
977
|
+
MediaOrientation["Portrait"] = "portrait";
|
|
978
|
+
MediaOrientation["Landscape"] = "landscape";
|
|
979
979
|
})(MediaOrientation || (MediaOrientation = {}));
|
|
980
980
|
|
|
981
|
-
class MediaService {
|
|
982
|
-
constructor(breakpointObserver) {
|
|
983
|
-
this.media$ = new BehaviorSubject(undefined);
|
|
984
|
-
this.orientation$ = new BehaviorSubject(undefined);
|
|
985
|
-
breakpointObserver
|
|
986
|
-
.observe([Breakpoints.HandsetLandscape])
|
|
987
|
-
.subscribe(res => {
|
|
988
|
-
if (res.matches) {
|
|
989
|
-
this.media$.next(Media.Mobile);
|
|
990
|
-
this.orientation$.next(MediaOrientation.Landscape);
|
|
991
|
-
}
|
|
992
|
-
});
|
|
993
|
-
breakpointObserver.observe([Breakpoints.HandsetPortrait]).subscribe(res => {
|
|
994
|
-
if (res.matches) {
|
|
995
|
-
this.media$.next(Media.Mobile);
|
|
996
|
-
this.orientation$.next(MediaOrientation.Portrait);
|
|
997
|
-
}
|
|
998
|
-
});
|
|
999
|
-
breakpointObserver.observe([Breakpoints.TabletLandscape]).subscribe(res => {
|
|
1000
|
-
if (res.matches) {
|
|
1001
|
-
this.media$.next(Media.Tablet);
|
|
1002
|
-
this.orientation$.next(MediaOrientation.Landscape);
|
|
1003
|
-
}
|
|
1004
|
-
});
|
|
1005
|
-
breakpointObserver.observe([Breakpoints.TabletPortrait]).subscribe(res => {
|
|
1006
|
-
if (res.matches) {
|
|
1007
|
-
this.media$.next(Media.Tablet);
|
|
1008
|
-
this.orientation$.next(MediaOrientation.Portrait);
|
|
1009
|
-
}
|
|
1010
|
-
});
|
|
1011
|
-
breakpointObserver.observe([Breakpoints.WebLandscape]).subscribe(res => {
|
|
1012
|
-
if (res.matches) {
|
|
1013
|
-
this.media$.next(Media.Desktop);
|
|
1014
|
-
this.orientation$.next(MediaOrientation.Landscape);
|
|
1015
|
-
}
|
|
1016
|
-
});
|
|
1017
|
-
breakpointObserver.observe([Breakpoints.WebPortrait]).subscribe(res => {
|
|
1018
|
-
if (res.matches) {
|
|
1019
|
-
this.media$.next(Media.Desktop);
|
|
1020
|
-
this.orientation$.next(MediaOrientation.Portrait);
|
|
1021
|
-
}
|
|
1022
|
-
});
|
|
1023
|
-
}
|
|
1024
|
-
getMedia() {
|
|
1025
|
-
return this.media$.value;
|
|
1026
|
-
}
|
|
1027
|
-
getOrientation() {
|
|
1028
|
-
return this.orientation$.value;
|
|
1029
|
-
}
|
|
1030
|
-
isTouchScreen() {
|
|
1031
|
-
return 'ontouchstart' in document.documentElement ? true : false;
|
|
1032
|
-
}
|
|
1033
|
-
isMobile() {
|
|
1034
|
-
const media = this.getMedia();
|
|
1035
|
-
return media === 'mobile';
|
|
1036
|
-
}
|
|
1037
|
-
isDesktop() {
|
|
1038
|
-
const media = this.getMedia();
|
|
1039
|
-
return media === 'desktop';
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
MediaService.ɵfac = function MediaService_Factory(t) { return new (t || MediaService)(i0.ɵɵinject(i1$4.BreakpointObserver)); };
|
|
1043
|
-
MediaService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MediaService, factory: MediaService.ɵfac, providedIn: 'root' });
|
|
1044
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MediaService, [{
|
|
1045
|
-
type: Injectable,
|
|
1046
|
-
args: [{
|
|
1047
|
-
providedIn: 'root'
|
|
1048
|
-
}]
|
|
981
|
+
class MediaService {
|
|
982
|
+
constructor(breakpointObserver) {
|
|
983
|
+
this.media$ = new BehaviorSubject(undefined);
|
|
984
|
+
this.orientation$ = new BehaviorSubject(undefined);
|
|
985
|
+
breakpointObserver
|
|
986
|
+
.observe([Breakpoints.HandsetLandscape])
|
|
987
|
+
.subscribe(res => {
|
|
988
|
+
if (res.matches) {
|
|
989
|
+
this.media$.next(Media.Mobile);
|
|
990
|
+
this.orientation$.next(MediaOrientation.Landscape);
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
breakpointObserver.observe([Breakpoints.HandsetPortrait]).subscribe(res => {
|
|
994
|
+
if (res.matches) {
|
|
995
|
+
this.media$.next(Media.Mobile);
|
|
996
|
+
this.orientation$.next(MediaOrientation.Portrait);
|
|
997
|
+
}
|
|
998
|
+
});
|
|
999
|
+
breakpointObserver.observe([Breakpoints.TabletLandscape]).subscribe(res => {
|
|
1000
|
+
if (res.matches) {
|
|
1001
|
+
this.media$.next(Media.Tablet);
|
|
1002
|
+
this.orientation$.next(MediaOrientation.Landscape);
|
|
1003
|
+
}
|
|
1004
|
+
});
|
|
1005
|
+
breakpointObserver.observe([Breakpoints.TabletPortrait]).subscribe(res => {
|
|
1006
|
+
if (res.matches) {
|
|
1007
|
+
this.media$.next(Media.Tablet);
|
|
1008
|
+
this.orientation$.next(MediaOrientation.Portrait);
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
1011
|
+
breakpointObserver.observe([Breakpoints.WebLandscape]).subscribe(res => {
|
|
1012
|
+
if (res.matches) {
|
|
1013
|
+
this.media$.next(Media.Desktop);
|
|
1014
|
+
this.orientation$.next(MediaOrientation.Landscape);
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
1017
|
+
breakpointObserver.observe([Breakpoints.WebPortrait]).subscribe(res => {
|
|
1018
|
+
if (res.matches) {
|
|
1019
|
+
this.media$.next(Media.Desktop);
|
|
1020
|
+
this.orientation$.next(MediaOrientation.Portrait);
|
|
1021
|
+
}
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
getMedia() {
|
|
1025
|
+
return this.media$.value;
|
|
1026
|
+
}
|
|
1027
|
+
getOrientation() {
|
|
1028
|
+
return this.orientation$.value;
|
|
1029
|
+
}
|
|
1030
|
+
isTouchScreen() {
|
|
1031
|
+
return 'ontouchstart' in document.documentElement ? true : false;
|
|
1032
|
+
}
|
|
1033
|
+
isMobile() {
|
|
1034
|
+
const media = this.getMedia();
|
|
1035
|
+
return media === 'mobile';
|
|
1036
|
+
}
|
|
1037
|
+
isDesktop() {
|
|
1038
|
+
const media = this.getMedia();
|
|
1039
|
+
return media === 'desktop';
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
MediaService.ɵfac = function MediaService_Factory(t) { return new (t || MediaService)(i0.ɵɵinject(i1$4.BreakpointObserver)); };
|
|
1043
|
+
MediaService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MediaService, factory: MediaService.ɵfac, providedIn: 'root' });
|
|
1044
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MediaService, [{
|
|
1045
|
+
type: Injectable,
|
|
1046
|
+
args: [{
|
|
1047
|
+
providedIn: 'root'
|
|
1048
|
+
}]
|
|
1049
1049
|
}], function () { return [{ type: i1$4.BreakpointObserver }]; }, null); })();
|
|
1050
1050
|
|
|
1051
|
-
var StorageScope;
|
|
1052
|
-
(function (StorageScope) {
|
|
1053
|
-
StorageScope["SESSION"] = "Session";
|
|
1054
|
-
StorageScope["LOCAL"] = "Local";
|
|
1055
|
-
})(StorageScope || (StorageScope = {}));
|
|
1056
|
-
var StorageServiceEventEnum;
|
|
1057
|
-
(function (StorageServiceEventEnum) {
|
|
1058
|
-
StorageServiceEventEnum["ADDED"] = "Added";
|
|
1059
|
-
StorageServiceEventEnum["MODIFIED"] = "Modified";
|
|
1060
|
-
StorageServiceEventEnum["REMOVED"] = "Removed";
|
|
1061
|
-
StorageServiceEventEnum["CLEARED"] = "Cleared";
|
|
1051
|
+
var StorageScope;
|
|
1052
|
+
(function (StorageScope) {
|
|
1053
|
+
StorageScope["SESSION"] = "Session";
|
|
1054
|
+
StorageScope["LOCAL"] = "Local";
|
|
1055
|
+
})(StorageScope || (StorageScope = {}));
|
|
1056
|
+
var StorageServiceEventEnum;
|
|
1057
|
+
(function (StorageServiceEventEnum) {
|
|
1058
|
+
StorageServiceEventEnum["ADDED"] = "Added";
|
|
1059
|
+
StorageServiceEventEnum["MODIFIED"] = "Modified";
|
|
1060
|
+
StorageServiceEventEnum["REMOVED"] = "Removed";
|
|
1061
|
+
StorageServiceEventEnum["CLEARED"] = "Cleared";
|
|
1062
1062
|
})(StorageServiceEventEnum || (StorageServiceEventEnum = {}));
|
|
1063
1063
|
|
|
1064
|
-
class StorageService {
|
|
1065
|
-
constructor(config) {
|
|
1066
|
-
this.config = config;
|
|
1067
|
-
this.storageChange$ = new BehaviorSubject(undefined);
|
|
1068
|
-
this.options = this.config.getConfig('storage') || { key: 'igo' };
|
|
1069
|
-
}
|
|
1070
|
-
/**
|
|
1071
|
-
* Use to get the data found in storage file
|
|
1072
|
-
*/
|
|
1073
|
-
get(key, scope) {
|
|
1074
|
-
let value;
|
|
1075
|
-
if (!scope || scope === StorageScope.SESSION) {
|
|
1076
|
-
value = sessionStorage.getItem(`${this.options.key}.${key}`);
|
|
1077
|
-
}
|
|
1078
|
-
if (scope === StorageScope.LOCAL || (!value && !scope)) {
|
|
1079
|
-
value = localStorage.getItem(`${this.options.key}.${key}`);
|
|
1080
|
-
}
|
|
1081
|
-
if (value) {
|
|
1082
|
-
try {
|
|
1083
|
-
value = JSON.parse(value);
|
|
1084
|
-
}
|
|
1085
|
-
catch {
|
|
1086
|
-
value = value;
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
return value;
|
|
1090
|
-
}
|
|
1091
|
-
set(key, value, scope = StorageScope.LOCAL) {
|
|
1092
|
-
const previousValue = this.get(key, scope);
|
|
1093
|
-
if (scope === StorageScope.SESSION) {
|
|
1094
|
-
sessionStorage.setItem(`${this.options.key}.${key}`, JSON.stringify(value));
|
|
1095
|
-
}
|
|
1096
|
-
else {
|
|
1097
|
-
localStorage.setItem(`${this.options.key}.${key}`, JSON.stringify(value));
|
|
1098
|
-
}
|
|
1099
|
-
const currentValue = this.get(key, scope);
|
|
1100
|
-
if (currentValue !== previousValue) {
|
|
1101
|
-
this.storageChange$.next({
|
|
1102
|
-
key, scope,
|
|
1103
|
-
event: previousValue !== undefined ? StorageServiceEventEnum.MODIFIED : StorageServiceEventEnum.ADDED,
|
|
1104
|
-
previousValue,
|
|
1105
|
-
currentValue
|
|
1106
|
-
});
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
remove(key, scope = StorageScope.LOCAL) {
|
|
1110
|
-
const previousValue = this.get(key, scope);
|
|
1111
|
-
if (scope === StorageScope.SESSION) {
|
|
1112
|
-
sessionStorage.removeItem(`${this.options.key}.${key}`);
|
|
1113
|
-
}
|
|
1114
|
-
else {
|
|
1115
|
-
localStorage.removeItem(`${this.options.key}.${key}`);
|
|
1116
|
-
}
|
|
1117
|
-
this.storageChange$.next({ key, scope, event: StorageServiceEventEnum.REMOVED, previousValue });
|
|
1118
|
-
}
|
|
1119
|
-
clear(scope = StorageScope.LOCAL) {
|
|
1120
|
-
if (scope === StorageScope.SESSION) {
|
|
1121
|
-
sessionStorage.clear();
|
|
1122
|
-
}
|
|
1123
|
-
else {
|
|
1124
|
-
localStorage.clear();
|
|
1125
|
-
}
|
|
1126
|
-
this.storageChange$.next({ scope, event: StorageServiceEventEnum.CLEARED });
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
StorageService.ɵfac = function StorageService_Factory(t) { return new (t || StorageService)(i0.ɵɵinject(ConfigService)); };
|
|
1130
|
-
StorageService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: StorageService, factory: StorageService.ɵfac, providedIn: 'root' });
|
|
1131
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StorageService, [{
|
|
1132
|
-
type: Injectable,
|
|
1133
|
-
args: [{
|
|
1134
|
-
providedIn: 'root'
|
|
1135
|
-
}]
|
|
1064
|
+
class StorageService {
|
|
1065
|
+
constructor(config) {
|
|
1066
|
+
this.config = config;
|
|
1067
|
+
this.storageChange$ = new BehaviorSubject(undefined);
|
|
1068
|
+
this.options = this.config.getConfig('storage') || { key: 'igo' };
|
|
1069
|
+
}
|
|
1070
|
+
/**
|
|
1071
|
+
* Use to get the data found in storage file
|
|
1072
|
+
*/
|
|
1073
|
+
get(key, scope) {
|
|
1074
|
+
let value;
|
|
1075
|
+
if (!scope || scope === StorageScope.SESSION) {
|
|
1076
|
+
value = sessionStorage.getItem(`${this.options.key}.${key}`);
|
|
1077
|
+
}
|
|
1078
|
+
if (scope === StorageScope.LOCAL || (!value && !scope)) {
|
|
1079
|
+
value = localStorage.getItem(`${this.options.key}.${key}`);
|
|
1080
|
+
}
|
|
1081
|
+
if (value) {
|
|
1082
|
+
try {
|
|
1083
|
+
value = JSON.parse(value);
|
|
1084
|
+
}
|
|
1085
|
+
catch {
|
|
1086
|
+
value = value;
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
return value;
|
|
1090
|
+
}
|
|
1091
|
+
set(key, value, scope = StorageScope.LOCAL) {
|
|
1092
|
+
const previousValue = this.get(key, scope);
|
|
1093
|
+
if (scope === StorageScope.SESSION) {
|
|
1094
|
+
sessionStorage.setItem(`${this.options.key}.${key}`, JSON.stringify(value));
|
|
1095
|
+
}
|
|
1096
|
+
else {
|
|
1097
|
+
localStorage.setItem(`${this.options.key}.${key}`, JSON.stringify(value));
|
|
1098
|
+
}
|
|
1099
|
+
const currentValue = this.get(key, scope);
|
|
1100
|
+
if (currentValue !== previousValue) {
|
|
1101
|
+
this.storageChange$.next({
|
|
1102
|
+
key, scope,
|
|
1103
|
+
event: previousValue !== undefined ? StorageServiceEventEnum.MODIFIED : StorageServiceEventEnum.ADDED,
|
|
1104
|
+
previousValue,
|
|
1105
|
+
currentValue
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
remove(key, scope = StorageScope.LOCAL) {
|
|
1110
|
+
const previousValue = this.get(key, scope);
|
|
1111
|
+
if (scope === StorageScope.SESSION) {
|
|
1112
|
+
sessionStorage.removeItem(`${this.options.key}.${key}`);
|
|
1113
|
+
}
|
|
1114
|
+
else {
|
|
1115
|
+
localStorage.removeItem(`${this.options.key}.${key}`);
|
|
1116
|
+
}
|
|
1117
|
+
this.storageChange$.next({ key, scope, event: StorageServiceEventEnum.REMOVED, previousValue });
|
|
1118
|
+
}
|
|
1119
|
+
clear(scope = StorageScope.LOCAL) {
|
|
1120
|
+
if (scope === StorageScope.SESSION) {
|
|
1121
|
+
sessionStorage.clear();
|
|
1122
|
+
}
|
|
1123
|
+
else {
|
|
1124
|
+
localStorage.clear();
|
|
1125
|
+
}
|
|
1126
|
+
this.storageChange$.next({ scope, event: StorageServiceEventEnum.CLEARED });
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
StorageService.ɵfac = function StorageService_Factory(t) { return new (t || StorageService)(i0.ɵɵinject(ConfigService)); };
|
|
1130
|
+
StorageService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: StorageService, factory: StorageService.ɵfac, providedIn: 'root' });
|
|
1131
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StorageService, [{
|
|
1132
|
+
type: Injectable,
|
|
1133
|
+
args: [{
|
|
1134
|
+
providedIn: 'root'
|
|
1135
|
+
}]
|
|
1136
1136
|
}], function () { return [{ type: ConfigService }]; }, null); })();
|
|
1137
1137
|
|
|
1138
|
-
function getNumber(v, endposition, length) {
|
|
1139
|
-
/* tslint:disable:no-bitwise*/
|
|
1140
|
-
const mask = ((1 << length) - 1);
|
|
1141
|
-
return (v >> endposition) & mask;
|
|
1142
|
-
/* tslint:enable:no-bitwise*/
|
|
1143
|
-
}
|
|
1144
|
-
class CompressionService {
|
|
1145
|
-
constructor() {
|
|
1146
|
-
this.base64Index = new Map();
|
|
1147
|
-
this.indexBase64 = new Map();
|
|
1148
|
-
this.generateBase64Index();
|
|
1149
|
-
}
|
|
1150
|
-
generateBase64Index() {
|
|
1151
|
-
// https://fr.wikipedia.org/wiki/Base64
|
|
1152
|
-
// A-Z => [0, 25]
|
|
1153
|
-
for (let i = 0; i < 26; i++) {
|
|
1154
|
-
this.base64Index.set(String.fromCharCode('A'.charCodeAt(0) + i), i);
|
|
1155
|
-
this.indexBase64.set(i, String.fromCharCode('A'.charCodeAt(0) + i));
|
|
1156
|
-
}
|
|
1157
|
-
// a-z => [26, 51]
|
|
1158
|
-
for (let i = 0; i < 26; i++) {
|
|
1159
|
-
this.base64Index.set(String.fromCharCode('a'.charCodeAt(0) + i), i + 26);
|
|
1160
|
-
this.indexBase64.set(i + 26, String.fromCharCode('a'.charCodeAt(0) + i));
|
|
1161
|
-
}
|
|
1162
|
-
// 0-9 => [52, 61]
|
|
1163
|
-
for (let i = 0; i < 10; i++) {
|
|
1164
|
-
this.base64Index.set(String.fromCharCode('0'.charCodeAt(0) + i), i + 52);
|
|
1165
|
-
this.indexBase64.set(i + 52, String.fromCharCode('0'.charCodeAt(0) + i));
|
|
1166
|
-
}
|
|
1167
|
-
// + / => [62, 63]
|
|
1168
|
-
this.base64Index.set('+', 62);
|
|
1169
|
-
this.base64Index.set('/', 63);
|
|
1170
|
-
this.indexBase64.set(62, '+');
|
|
1171
|
-
this.indexBase64.set(63, '/');
|
|
1172
|
-
}
|
|
1173
|
-
compressBlob(blob) {
|
|
1174
|
-
if (!blob) {
|
|
1175
|
-
return;
|
|
1176
|
-
}
|
|
1177
|
-
const observable = new Observable((observer) => {
|
|
1178
|
-
const reader = new FileReader();
|
|
1179
|
-
reader.readAsDataURL(blob);
|
|
1180
|
-
reader.onload = () => {
|
|
1181
|
-
const base64 = reader.result.valueOf();
|
|
1182
|
-
const text64 = base64.substr(base64.indexOf(',') + 1);
|
|
1183
|
-
const compressed = this.compressStringBase64(text64);
|
|
1184
|
-
const compressedData = { length: text64.length,
|
|
1185
|
-
type: blob.type,
|
|
1186
|
-
object: compressed };
|
|
1187
|
-
observer.next(compressedData);
|
|
1188
|
-
};
|
|
1189
|
-
});
|
|
1190
|
-
return observable;
|
|
1191
|
-
}
|
|
1192
|
-
decompressBlob(compressedData) {
|
|
1193
|
-
/* tslint:disable:no-bitwise*/
|
|
1194
|
-
const object = compressedData.object;
|
|
1195
|
-
const length = compressedData.length;
|
|
1196
|
-
const decompressed = this.decompressStringBase64(object, length);
|
|
1197
|
-
const byteCharacters = atob(decompressed);
|
|
1198
|
-
const byteNumbers = new Array(byteCharacters.length);
|
|
1199
|
-
for (let i = 0; i < byteCharacters.length; i++) {
|
|
1200
|
-
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
|
1201
|
-
}
|
|
1202
|
-
const byteArray = new Uint8Array(byteNumbers);
|
|
1203
|
-
const blob = new Blob([byteArray], { type: compressedData.type });
|
|
1204
|
-
/* tslint:enable:no-bitwise*/
|
|
1205
|
-
return blob;
|
|
1206
|
-
}
|
|
1207
|
-
compressStringBase64(s) {
|
|
1208
|
-
/* tslint:disable:no-bitwise*/
|
|
1209
|
-
let out = '';
|
|
1210
|
-
let bits = 16;
|
|
1211
|
-
let chr = 0;
|
|
1212
|
-
let rem = 0;
|
|
1213
|
-
for (const c of s) {
|
|
1214
|
-
const value = this.base64Index.get(c);
|
|
1215
|
-
if (bits > 6) {
|
|
1216
|
-
bits -= 6;
|
|
1217
|
-
chr += value << bits;
|
|
1218
|
-
}
|
|
1219
|
-
else {
|
|
1220
|
-
rem = 6 - bits;
|
|
1221
|
-
chr += value >> rem;
|
|
1222
|
-
out += String.fromCharCode(chr);
|
|
1223
|
-
chr = (value) << (16 - rem);
|
|
1224
|
-
bits = 16 - rem;
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
if (s.length % 8 !== 0) {
|
|
1228
|
-
out += String.fromCharCode(chr);
|
|
1229
|
-
}
|
|
1230
|
-
/* tslint:enable:no-bitwise*/
|
|
1231
|
-
return String.fromCharCode(9731) + out;
|
|
1232
|
-
}
|
|
1233
|
-
decompressStringBase64(c, length) {
|
|
1234
|
-
/* tslint:disable:no-bitwise*/
|
|
1235
|
-
if (!c) {
|
|
1236
|
-
return;
|
|
1237
|
-
}
|
|
1238
|
-
if (c.charCodeAt(0) !== 9731) {
|
|
1239
|
-
return c;
|
|
1240
|
-
}
|
|
1241
|
-
let chr = 0;
|
|
1242
|
-
let rem = 0;
|
|
1243
|
-
let bits = 16;
|
|
1244
|
-
let out = '';
|
|
1245
|
-
let j = 1;
|
|
1246
|
-
let value = c.charCodeAt(j);
|
|
1247
|
-
for (let i = 0; i < length; i++) {
|
|
1248
|
-
if (bits > 6) {
|
|
1249
|
-
bits -= 6;
|
|
1250
|
-
chr = getNumber(value, bits, 6);
|
|
1251
|
-
out += this.indexBase64.get(chr);
|
|
1252
|
-
}
|
|
1253
|
-
else {
|
|
1254
|
-
rem = 6 - bits;
|
|
1255
|
-
chr = getNumber(value, 0, bits) << rem;
|
|
1256
|
-
value = c.charCodeAt(++j);
|
|
1257
|
-
chr += getNumber(value, 16 - rem, rem);
|
|
1258
|
-
out += this.indexBase64.get(chr);
|
|
1259
|
-
bits = 16 - rem;
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
return out;
|
|
1263
|
-
/* tslint:enable:no-bitwise*/
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
CompressionService.ɵfac = function CompressionService_Factory(t) { return new (t || CompressionService)(); };
|
|
1267
|
-
CompressionService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: CompressionService, factory: CompressionService.ɵfac, providedIn: 'root' });
|
|
1268
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CompressionService, [{
|
|
1269
|
-
type: Injectable,
|
|
1270
|
-
args: [{
|
|
1271
|
-
providedIn: 'root'
|
|
1272
|
-
}]
|
|
1138
|
+
function getNumber(v, endposition, length) {
|
|
1139
|
+
/* tslint:disable:no-bitwise*/
|
|
1140
|
+
const mask = ((1 << length) - 1);
|
|
1141
|
+
return (v >> endposition) & mask;
|
|
1142
|
+
/* tslint:enable:no-bitwise*/
|
|
1143
|
+
}
|
|
1144
|
+
class CompressionService {
|
|
1145
|
+
constructor() {
|
|
1146
|
+
this.base64Index = new Map();
|
|
1147
|
+
this.indexBase64 = new Map();
|
|
1148
|
+
this.generateBase64Index();
|
|
1149
|
+
}
|
|
1150
|
+
generateBase64Index() {
|
|
1151
|
+
// https://fr.wikipedia.org/wiki/Base64
|
|
1152
|
+
// A-Z => [0, 25]
|
|
1153
|
+
for (let i = 0; i < 26; i++) {
|
|
1154
|
+
this.base64Index.set(String.fromCharCode('A'.charCodeAt(0) + i), i);
|
|
1155
|
+
this.indexBase64.set(i, String.fromCharCode('A'.charCodeAt(0) + i));
|
|
1156
|
+
}
|
|
1157
|
+
// a-z => [26, 51]
|
|
1158
|
+
for (let i = 0; i < 26; i++) {
|
|
1159
|
+
this.base64Index.set(String.fromCharCode('a'.charCodeAt(0) + i), i + 26);
|
|
1160
|
+
this.indexBase64.set(i + 26, String.fromCharCode('a'.charCodeAt(0) + i));
|
|
1161
|
+
}
|
|
1162
|
+
// 0-9 => [52, 61]
|
|
1163
|
+
for (let i = 0; i < 10; i++) {
|
|
1164
|
+
this.base64Index.set(String.fromCharCode('0'.charCodeAt(0) + i), i + 52);
|
|
1165
|
+
this.indexBase64.set(i + 52, String.fromCharCode('0'.charCodeAt(0) + i));
|
|
1166
|
+
}
|
|
1167
|
+
// + / => [62, 63]
|
|
1168
|
+
this.base64Index.set('+', 62);
|
|
1169
|
+
this.base64Index.set('/', 63);
|
|
1170
|
+
this.indexBase64.set(62, '+');
|
|
1171
|
+
this.indexBase64.set(63, '/');
|
|
1172
|
+
}
|
|
1173
|
+
compressBlob(blob) {
|
|
1174
|
+
if (!blob) {
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
const observable = new Observable((observer) => {
|
|
1178
|
+
const reader = new FileReader();
|
|
1179
|
+
reader.readAsDataURL(blob);
|
|
1180
|
+
reader.onload = () => {
|
|
1181
|
+
const base64 = reader.result.valueOf();
|
|
1182
|
+
const text64 = base64.substr(base64.indexOf(',') + 1);
|
|
1183
|
+
const compressed = this.compressStringBase64(text64);
|
|
1184
|
+
const compressedData = { length: text64.length,
|
|
1185
|
+
type: blob.type,
|
|
1186
|
+
object: compressed };
|
|
1187
|
+
observer.next(compressedData);
|
|
1188
|
+
};
|
|
1189
|
+
});
|
|
1190
|
+
return observable;
|
|
1191
|
+
}
|
|
1192
|
+
decompressBlob(compressedData) {
|
|
1193
|
+
/* tslint:disable:no-bitwise*/
|
|
1194
|
+
const object = compressedData.object;
|
|
1195
|
+
const length = compressedData.length;
|
|
1196
|
+
const decompressed = this.decompressStringBase64(object, length);
|
|
1197
|
+
const byteCharacters = atob(decompressed);
|
|
1198
|
+
const byteNumbers = new Array(byteCharacters.length);
|
|
1199
|
+
for (let i = 0; i < byteCharacters.length; i++) {
|
|
1200
|
+
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
|
1201
|
+
}
|
|
1202
|
+
const byteArray = new Uint8Array(byteNumbers);
|
|
1203
|
+
const blob = new Blob([byteArray], { type: compressedData.type });
|
|
1204
|
+
/* tslint:enable:no-bitwise*/
|
|
1205
|
+
return blob;
|
|
1206
|
+
}
|
|
1207
|
+
compressStringBase64(s) {
|
|
1208
|
+
/* tslint:disable:no-bitwise*/
|
|
1209
|
+
let out = '';
|
|
1210
|
+
let bits = 16;
|
|
1211
|
+
let chr = 0;
|
|
1212
|
+
let rem = 0;
|
|
1213
|
+
for (const c of s) {
|
|
1214
|
+
const value = this.base64Index.get(c);
|
|
1215
|
+
if (bits > 6) {
|
|
1216
|
+
bits -= 6;
|
|
1217
|
+
chr += value << bits;
|
|
1218
|
+
}
|
|
1219
|
+
else {
|
|
1220
|
+
rem = 6 - bits;
|
|
1221
|
+
chr += value >> rem;
|
|
1222
|
+
out += String.fromCharCode(chr);
|
|
1223
|
+
chr = (value) << (16 - rem);
|
|
1224
|
+
bits = 16 - rem;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
if (s.length % 8 !== 0) {
|
|
1228
|
+
out += String.fromCharCode(chr);
|
|
1229
|
+
}
|
|
1230
|
+
/* tslint:enable:no-bitwise*/
|
|
1231
|
+
return String.fromCharCode(9731) + out;
|
|
1232
|
+
}
|
|
1233
|
+
decompressStringBase64(c, length) {
|
|
1234
|
+
/* tslint:disable:no-bitwise*/
|
|
1235
|
+
if (!c) {
|
|
1236
|
+
return;
|
|
1237
|
+
}
|
|
1238
|
+
if (c.charCodeAt(0) !== 9731) {
|
|
1239
|
+
return c;
|
|
1240
|
+
}
|
|
1241
|
+
let chr = 0;
|
|
1242
|
+
let rem = 0;
|
|
1243
|
+
let bits = 16;
|
|
1244
|
+
let out = '';
|
|
1245
|
+
let j = 1;
|
|
1246
|
+
let value = c.charCodeAt(j);
|
|
1247
|
+
for (let i = 0; i < length; i++) {
|
|
1248
|
+
if (bits > 6) {
|
|
1249
|
+
bits -= 6;
|
|
1250
|
+
chr = getNumber(value, bits, 6);
|
|
1251
|
+
out += this.indexBase64.get(chr);
|
|
1252
|
+
}
|
|
1253
|
+
else {
|
|
1254
|
+
rem = 6 - bits;
|
|
1255
|
+
chr = getNumber(value, 0, bits) << rem;
|
|
1256
|
+
value = c.charCodeAt(++j);
|
|
1257
|
+
chr += getNumber(value, 16 - rem, rem);
|
|
1258
|
+
out += this.indexBase64.get(chr);
|
|
1259
|
+
bits = 16 - rem;
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
return out;
|
|
1263
|
+
/* tslint:enable:no-bitwise*/
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
CompressionService.ɵfac = function CompressionService_Factory(t) { return new (t || CompressionService)(); };
|
|
1267
|
+
CompressionService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: CompressionService, factory: CompressionService.ɵfac, providedIn: 'root' });
|
|
1268
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CompressionService, [{
|
|
1269
|
+
type: Injectable,
|
|
1270
|
+
args: [{
|
|
1271
|
+
providedIn: 'root'
|
|
1272
|
+
}]
|
|
1273
1273
|
}], function () { return []; }, null); })();
|
|
1274
1274
|
|
|
1275
|
-
class NetworkService {
|
|
1276
|
-
constructor(messageService, injector) {
|
|
1277
|
-
this.messageService = messageService;
|
|
1278
|
-
this.injector = injector;
|
|
1279
|
-
this.stateChangeEventEmitter = new EventEmitter();
|
|
1280
|
-
this.state = {
|
|
1281
|
-
connection: window.navigator.onLine
|
|
1282
|
-
};
|
|
1283
|
-
this.checkNetworkState();
|
|
1284
|
-
}
|
|
1285
|
-
checkNetworkState() {
|
|
1286
|
-
this.onlineSubscription = fromEvent(window, 'online').subscribe(() => {
|
|
1287
|
-
if (this.previousMessageId) {
|
|
1288
|
-
this.messageService.remove(this.previousMessageId);
|
|
1289
|
-
}
|
|
1290
|
-
const messageObj = this.messageService.info('igo.core.network.online.message', 'igo.core.network.online.title');
|
|
1291
|
-
this.previousMessageId = messageObj.toastId;
|
|
1292
|
-
this.state.connection = true;
|
|
1293
|
-
this.emitEvent();
|
|
1294
|
-
});
|
|
1295
|
-
this.offlineSubscription = fromEvent(window, 'offline').subscribe(() => {
|
|
1296
|
-
if (this.previousMessageId) {
|
|
1297
|
-
this.messageService.remove(this.previousMessageId);
|
|
1298
|
-
}
|
|
1299
|
-
const messageObj = this.messageService.info('igo.core.network.offline.message', 'igo.core.network.offline.title');
|
|
1300
|
-
this.previousMessageId = messageObj.toastId;
|
|
1301
|
-
this.state.connection = false;
|
|
1302
|
-
this.emitEvent();
|
|
1303
|
-
});
|
|
1304
|
-
}
|
|
1305
|
-
emitEvent() {
|
|
1306
|
-
this.stateChangeEventEmitter.emit(this.state);
|
|
1307
|
-
}
|
|
1308
|
-
ngOnDestroy() {
|
|
1309
|
-
try {
|
|
1310
|
-
this.offlineSubscription.unsubscribe();
|
|
1311
|
-
this.onlineSubscription.unsubscribe();
|
|
1312
|
-
}
|
|
1313
|
-
catch (e) { }
|
|
1314
|
-
}
|
|
1315
|
-
currentState(reportState = true) {
|
|
1316
|
-
return reportState
|
|
1317
|
-
? this.stateChangeEventEmitter.pipe(debounceTime(300), startWith(this.state))
|
|
1318
|
-
: this.stateChangeEventEmitter.pipe(debounceTime(300));
|
|
1319
|
-
}
|
|
1320
|
-
}
|
|
1321
|
-
NetworkService.ɵfac = function NetworkService_Factory(t) { return new (t || NetworkService)(i0.ɵɵinject(MessageService), i0.ɵɵinject(i0.Injector)); };
|
|
1322
|
-
NetworkService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: NetworkService, factory: NetworkService.ɵfac, providedIn: 'root' });
|
|
1323
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NetworkService, [{
|
|
1324
|
-
type: Injectable,
|
|
1325
|
-
args: [{
|
|
1326
|
-
providedIn: 'root'
|
|
1327
|
-
}]
|
|
1275
|
+
class NetworkService {
|
|
1276
|
+
constructor(messageService, injector) {
|
|
1277
|
+
this.messageService = messageService;
|
|
1278
|
+
this.injector = injector;
|
|
1279
|
+
this.stateChangeEventEmitter = new EventEmitter();
|
|
1280
|
+
this.state = {
|
|
1281
|
+
connection: window.navigator.onLine
|
|
1282
|
+
};
|
|
1283
|
+
this.checkNetworkState();
|
|
1284
|
+
}
|
|
1285
|
+
checkNetworkState() {
|
|
1286
|
+
this.onlineSubscription = fromEvent(window, 'online').subscribe(() => {
|
|
1287
|
+
if (this.previousMessageId) {
|
|
1288
|
+
this.messageService.remove(this.previousMessageId);
|
|
1289
|
+
}
|
|
1290
|
+
const messageObj = this.messageService.info('igo.core.network.online.message', 'igo.core.network.online.title');
|
|
1291
|
+
this.previousMessageId = messageObj.toastId;
|
|
1292
|
+
this.state.connection = true;
|
|
1293
|
+
this.emitEvent();
|
|
1294
|
+
});
|
|
1295
|
+
this.offlineSubscription = fromEvent(window, 'offline').subscribe(() => {
|
|
1296
|
+
if (this.previousMessageId) {
|
|
1297
|
+
this.messageService.remove(this.previousMessageId);
|
|
1298
|
+
}
|
|
1299
|
+
const messageObj = this.messageService.info('igo.core.network.offline.message', 'igo.core.network.offline.title');
|
|
1300
|
+
this.previousMessageId = messageObj.toastId;
|
|
1301
|
+
this.state.connection = false;
|
|
1302
|
+
this.emitEvent();
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1305
|
+
emitEvent() {
|
|
1306
|
+
this.stateChangeEventEmitter.emit(this.state);
|
|
1307
|
+
}
|
|
1308
|
+
ngOnDestroy() {
|
|
1309
|
+
try {
|
|
1310
|
+
this.offlineSubscription.unsubscribe();
|
|
1311
|
+
this.onlineSubscription.unsubscribe();
|
|
1312
|
+
}
|
|
1313
|
+
catch (e) { }
|
|
1314
|
+
}
|
|
1315
|
+
currentState(reportState = true) {
|
|
1316
|
+
return reportState
|
|
1317
|
+
? this.stateChangeEventEmitter.pipe(debounceTime(300), startWith(this.state))
|
|
1318
|
+
: this.stateChangeEventEmitter.pipe(debounceTime(300));
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
NetworkService.ɵfac = function NetworkService_Factory(t) { return new (t || NetworkService)(i0.ɵɵinject(MessageService), i0.ɵɵinject(i0.Injector)); };
|
|
1322
|
+
NetworkService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: NetworkService, factory: NetworkService.ɵfac, providedIn: 'root' });
|
|
1323
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NetworkService, [{
|
|
1324
|
+
type: Injectable,
|
|
1325
|
+
args: [{
|
|
1326
|
+
providedIn: 'root'
|
|
1327
|
+
}]
|
|
1328
1328
|
}], function () { return [{ type: MessageService }, { type: i0.Injector }]; }, null); })();
|
|
1329
1329
|
|
|
1330
|
-
class RegexService {
|
|
1331
|
-
constructor(config) {
|
|
1332
|
-
this.config = config;
|
|
1333
|
-
this.options = this.config.getConfig('regex');
|
|
1334
|
-
}
|
|
1335
|
-
getAll() {
|
|
1336
|
-
return this.options;
|
|
1337
|
-
}
|
|
1338
|
-
get(key) {
|
|
1339
|
-
if (this.options) {
|
|
1340
|
-
return this.options[key];
|
|
1341
|
-
}
|
|
1342
|
-
return;
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1345
|
-
RegexService.ɵfac = function RegexService_Factory(t) { return new (t || RegexService)(i0.ɵɵinject(ConfigService)); };
|
|
1346
|
-
RegexService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RegexService, factory: RegexService.ɵfac, providedIn: 'root' });
|
|
1347
|
-
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RegexService, [{
|
|
1348
|
-
type: Injectable,
|
|
1349
|
-
args: [{
|
|
1350
|
-
providedIn: 'root'
|
|
1351
|
-
}]
|
|
1330
|
+
class RegexService {
|
|
1331
|
+
constructor(config) {
|
|
1332
|
+
this.config = config;
|
|
1333
|
+
this.options = this.config.getConfig('regex');
|
|
1334
|
+
}
|
|
1335
|
+
getAll() {
|
|
1336
|
+
return this.options;
|
|
1337
|
+
}
|
|
1338
|
+
get(key) {
|
|
1339
|
+
if (this.options) {
|
|
1340
|
+
return this.options[key];
|
|
1341
|
+
}
|
|
1342
|
+
return;
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
RegexService.ɵfac = function RegexService_Factory(t) { return new (t || RegexService)(i0.ɵɵinject(ConfigService)); };
|
|
1346
|
+
RegexService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RegexService, factory: RegexService.ɵfac, providedIn: 'root' });
|
|
1347
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RegexService, [{
|
|
1348
|
+
type: Injectable,
|
|
1349
|
+
args: [{
|
|
1350
|
+
providedIn: 'root'
|
|
1351
|
+
}]
|
|
1352
1352
|
}], function () { return [{ type: ConfigService }]; }, null); })();
|
|
1353
1353
|
|
|
1354
|
-
/*
|
|
1355
|
-
* Public API Surface of core
|
|
1354
|
+
/*
|
|
1355
|
+
* Public API Surface of core
|
|
1356
1356
|
*/
|
|
1357
1357
|
|
|
1358
|
-
/**
|
|
1359
|
-
* Generated bundle index. Do not edit.
|
|
1358
|
+
/**
|
|
1359
|
+
* Generated bundle index. Do not edit.
|
|
1360
1360
|
*/
|
|
1361
1361
|
|
|
1362
1362
|
export { ActivityInterceptor, ActivityService, AnalyticsService, CONFIG_OPTIONS, CompressionService, ConfigService, ErrorInterceptor, IgoActivityModule, IgoConfigModule, IgoCoreModule, IgoErrorModule, IgoGestureConfig, IgoGestureModule, IgoLanguageModule, IgoLoggingModule, IgoMessageModule, IgoMissingTranslationHandler, LanguageLoader, LanguageService, LoggingInterceptor, Media, MediaOrientation, MediaService, MessageService, MessageType, NetworkService, ROUTE_SERVICE_OPTIONS, RegexService, RouteService, StorageScope, StorageService, StorageServiceEventEnum, configFactory, defaultLanguageLoader, provideConfigLoader, provideConfigOptions, provideDefaultLanguageLoader, provideLanguageLoader, provideRouteServiceOptions, version };
|