codefoxcore 0.0.6 → 0.0.8
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/esm2022/lib/interceptors/error.interceptor.mjs +32 -0
- package/esm2022/lib/interceptors/index.mjs +3 -1
- package/esm2022/lib/interceptors/precheck.interceptor.mjs +34 -0
- package/esm2022/lib/providers.mjs +9 -3
- package/esm2022/lib/services/dialog.service.mjs +18 -4
- package/esm2022/lib/services/google.maps.service.mjs +42 -0
- package/esm2022/lib/services/index.mjs +2 -1
- package/esm2022/lib/tokens/dialog.token.mjs +7 -2
- package/esm2022/lib/tokens/google.maps.token.mjs +7 -0
- package/esm2022/lib/tokens/index.mjs +2 -1
- package/fesm2022/codefoxcore.mjs +128 -5
- package/fesm2022/codefoxcore.mjs.map +1 -1
- package/lib/interceptors/error.interceptor.d.ts +10 -0
- package/lib/interceptors/index.d.ts +2 -0
- package/lib/interceptors/precheck.interceptor.d.ts +10 -0
- package/lib/providers.d.ts +1 -0
- package/lib/services/dialog.service.d.ts +3 -0
- package/lib/services/google.maps.service.d.ts +14 -0
- package/lib/services/index.d.ts +1 -0
- package/lib/tokens/dialog.token.d.ts +2 -1
- package/lib/tokens/google.maps.token.d.ts +2 -0
- package/lib/tokens/index.d.ts +1 -0
- package/package.json +1 -1
package/fesm2022/codefoxcore.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Subject, filter, Observable, takeUntil, timer } from 'rxjs';
|
|
1
|
+
import { Subject, filter, Observable, takeUntil, timer, of, tap, throwError } from 'rxjs';
|
|
2
2
|
import { isPlatformBrowser, DOCUMENT } from '@angular/common';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
4
|
import { InjectionToken, inject, Injector, PLATFORM_ID, ApplicationRef, createComponent, Injectable, makeEnvironmentProviders } from '@angular/core';
|
|
5
5
|
import { Title } from '@angular/platform-browser';
|
|
6
6
|
import { HttpClient, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
7
|
+
import { catchError } from 'rxjs/operators';
|
|
7
8
|
|
|
8
9
|
class DialogRef {
|
|
9
10
|
constructor() {
|
|
@@ -131,11 +132,16 @@ const ALERT_CONFIGURATIONS = new InjectionToken('Alert configurations predefined
|
|
|
131
132
|
}
|
|
132
133
|
});
|
|
133
134
|
|
|
134
|
-
const
|
|
135
|
+
const PREDEFINED_DIALOGS = new InjectionToken('Predefined dialogs', {
|
|
135
136
|
factory: () => {
|
|
136
137
|
return {};
|
|
137
138
|
}
|
|
138
139
|
});
|
|
140
|
+
const OPENED_DIALOG_BODY_CLASS = new InjectionToken('Opened dialog body class', {
|
|
141
|
+
factory: () => {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
139
145
|
|
|
140
146
|
const CONFIRM_CONFIGURATIONS = new InjectionToken('Confirm configurations predefined', {
|
|
141
147
|
factory: () => {
|
|
@@ -211,15 +217,23 @@ const LOG_LEVEL = new InjectionToken('Log level', {
|
|
|
211
217
|
}
|
|
212
218
|
});
|
|
213
219
|
|
|
220
|
+
const GOOGLE_MAPS_API_KEY = new InjectionToken('Google Maps Api Key', {
|
|
221
|
+
factory: () => {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
|
|
214
226
|
class DialogService {
|
|
215
227
|
constructor() {
|
|
216
228
|
this.injector = inject(Injector);
|
|
217
229
|
this.predefinedConfirmConfigurations = inject(CONFIRM_CONFIGURATIONS);
|
|
218
230
|
this.predefinedAlertConfigurations = inject(ALERT_CONFIGURATIONS);
|
|
219
|
-
this.predefinedDialogs = inject(
|
|
231
|
+
this.predefinedDialogs = inject(PREDEFINED_DIALOGS);
|
|
232
|
+
this.openedDialogBodyClass = inject(OPENED_DIALOG_BODY_CLASS);
|
|
220
233
|
this.title = inject(Title);
|
|
221
234
|
this.messageService = inject(MessageService);
|
|
222
235
|
this.dialogs = new Map();
|
|
236
|
+
this.dialogCountChanged = new Subject();
|
|
223
237
|
this.openIndex = 1;
|
|
224
238
|
this.platformId = inject(PLATFORM_ID);
|
|
225
239
|
if (isPlatformBrowser(this.platformId)) {
|
|
@@ -242,6 +256,16 @@ class DialogService {
|
|
|
242
256
|
}
|
|
243
257
|
});
|
|
244
258
|
}
|
|
259
|
+
this.dialogCountChanged.subscribe((size) => {
|
|
260
|
+
if (isPlatformBrowser(this.platformId) && this.openedDialogBodyClass !== null) {
|
|
261
|
+
if (size === 0) {
|
|
262
|
+
document.body.classList.remove(this.openedDialogBodyClass);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
document.body.classList.add(this.openedDialogBodyClass);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
});
|
|
245
269
|
}
|
|
246
270
|
async openPredefined(name, dialogConfiguration = {}) {
|
|
247
271
|
if (this.predefinedDialogs[name] === undefined) {
|
|
@@ -388,6 +412,7 @@ class DialogService {
|
|
|
388
412
|
container: dialogContainer,
|
|
389
413
|
openIndex: this.openIndex
|
|
390
414
|
});
|
|
415
|
+
this.dialogCountChanged.next(this.dialogs.size);
|
|
391
416
|
this.openIndex++;
|
|
392
417
|
return dialogRef;
|
|
393
418
|
}
|
|
@@ -406,6 +431,7 @@ class DialogService {
|
|
|
406
431
|
}
|
|
407
432
|
dialogComponentRefContainer.componentRef.destroy();
|
|
408
433
|
this.dialogs.delete(dialogRef);
|
|
434
|
+
this.dialogCountChanged.next(this.dialogs.size);
|
|
409
435
|
if (this.dialogs.size === 0) {
|
|
410
436
|
this.openIndex = 1;
|
|
411
437
|
}
|
|
@@ -1141,6 +1167,41 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
1141
1167
|
}]
|
|
1142
1168
|
}] });
|
|
1143
1169
|
|
|
1170
|
+
class GoogleMapsService {
|
|
1171
|
+
constructor() {
|
|
1172
|
+
this.apiService = inject(ApiService);
|
|
1173
|
+
this.interceptorsService = inject(InterceptorsService);
|
|
1174
|
+
this.googleMapsApiKey = inject(GOOGLE_MAPS_API_KEY);
|
|
1175
|
+
this.mapsJsLoaded = false;
|
|
1176
|
+
}
|
|
1177
|
+
load() {
|
|
1178
|
+
if (this.googleMapsApiKey === null) {
|
|
1179
|
+
throw new Error('Google maps api key is not set!');
|
|
1180
|
+
}
|
|
1181
|
+
if (this.mapsJsLoaded) {
|
|
1182
|
+
return of(true);
|
|
1183
|
+
}
|
|
1184
|
+
this.interceptorsService.skip = [InterceptorType.TOKEN];
|
|
1185
|
+
return this.apiService.httpClient.jsonp(`https://maps.googleapis.com/maps/api/js?key=${this.googleMapsApiKey}`, 'callback').pipe(tap(() => {
|
|
1186
|
+
this.interceptorsService.skip = [];
|
|
1187
|
+
this.mapsJsLoaded = true;
|
|
1188
|
+
}));
|
|
1189
|
+
}
|
|
1190
|
+
createMaps(element = null, config = {}) {
|
|
1191
|
+
return this.load().pipe(tap(() => {
|
|
1192
|
+
new window.google.maps.Map(element, config);
|
|
1193
|
+
}));
|
|
1194
|
+
}
|
|
1195
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GoogleMapsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1196
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GoogleMapsService, providedIn: 'root' }); }
|
|
1197
|
+
}
|
|
1198
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GoogleMapsService, decorators: [{
|
|
1199
|
+
type: Injectable,
|
|
1200
|
+
args: [{
|
|
1201
|
+
providedIn: 'root'
|
|
1202
|
+
}]
|
|
1203
|
+
}] });
|
|
1204
|
+
|
|
1144
1205
|
class BaseInterceptor {
|
|
1145
1206
|
skipInterceptor() {
|
|
1146
1207
|
if (this.type !== null && this.interceptorsService.skip.indexOf(InterceptorType.ALL) !== -1) {
|
|
@@ -1199,6 +1260,62 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
1199
1260
|
}]
|
|
1200
1261
|
}], ctorParameters: function () { return []; } });
|
|
1201
1262
|
|
|
1263
|
+
class PrecheckInterceptor extends BaseInterceptor {
|
|
1264
|
+
intercept(request, next) {
|
|
1265
|
+
if (this.skipInterceptor()) {
|
|
1266
|
+
return next.handle(request);
|
|
1267
|
+
}
|
|
1268
|
+
if (this.interceptorsService.precheck !== null) {
|
|
1269
|
+
request = request.clone({
|
|
1270
|
+
setHeaders: {
|
|
1271
|
+
Precheck: this.interceptorsService.precheck
|
|
1272
|
+
}
|
|
1273
|
+
});
|
|
1274
|
+
if (this.interceptorsService.resetPrecheck) {
|
|
1275
|
+
this.interceptorsService.precheck = null;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
return next.handle(request);
|
|
1279
|
+
}
|
|
1280
|
+
constructor() {
|
|
1281
|
+
super(InterceptorType.PRECHECK);
|
|
1282
|
+
}
|
|
1283
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PrecheckInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1284
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PrecheckInterceptor, providedIn: 'root' }); }
|
|
1285
|
+
}
|
|
1286
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PrecheckInterceptor, decorators: [{
|
|
1287
|
+
type: Injectable,
|
|
1288
|
+
args: [{
|
|
1289
|
+
providedIn: 'root'
|
|
1290
|
+
}]
|
|
1291
|
+
}], ctorParameters: function () { return []; } });
|
|
1292
|
+
|
|
1293
|
+
class ErrorInterceptor extends BaseInterceptor {
|
|
1294
|
+
intercept(request, next) {
|
|
1295
|
+
if (this.skipInterceptor()) {
|
|
1296
|
+
return next.handle(request);
|
|
1297
|
+
}
|
|
1298
|
+
return next.handle(request).pipe(catchError((httpErrorResponse) => {
|
|
1299
|
+
if (this.interceptorsService.errorCallbackfunction !== null && !this.interceptorsService.errorSkipStatusCodes.includes(httpErrorResponse.status)) {
|
|
1300
|
+
this.loggerService.info('Error Interceptor Callback Function Called');
|
|
1301
|
+
this.interceptorsService.errorCallbackfunction(httpErrorResponse);
|
|
1302
|
+
}
|
|
1303
|
+
return throwError(() => httpErrorResponse);
|
|
1304
|
+
}));
|
|
1305
|
+
}
|
|
1306
|
+
constructor() {
|
|
1307
|
+
super(InterceptorType.ERROR);
|
|
1308
|
+
}
|
|
1309
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ErrorInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1310
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ErrorInterceptor, providedIn: 'root' }); }
|
|
1311
|
+
}
|
|
1312
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ErrorInterceptor, decorators: [{
|
|
1313
|
+
type: Injectable,
|
|
1314
|
+
args: [{
|
|
1315
|
+
providedIn: 'root'
|
|
1316
|
+
}]
|
|
1317
|
+
}], ctorParameters: function () { return []; } });
|
|
1318
|
+
|
|
1202
1319
|
function provideTokenInterceptor() {
|
|
1203
1320
|
return makeEnvironmentProviders([{
|
|
1204
1321
|
provide: HTTP_INTERCEPTORS,
|
|
@@ -1208,14 +1325,20 @@ function provideTokenInterceptor() {
|
|
|
1208
1325
|
}
|
|
1209
1326
|
function providePredefinedDialogs(predefinedDialogs) {
|
|
1210
1327
|
return makeEnvironmentProviders([{
|
|
1211
|
-
provide:
|
|
1328
|
+
provide: PREDEFINED_DIALOGS,
|
|
1212
1329
|
useValue: predefinedDialogs
|
|
1213
1330
|
}]);
|
|
1214
1331
|
}
|
|
1332
|
+
function provideOpenedDialogBodyClass(openedDialogBodyClass) {
|
|
1333
|
+
return makeEnvironmentProviders([{
|
|
1334
|
+
provide: OPENED_DIALOG_BODY_CLASS,
|
|
1335
|
+
useValue: openedDialogBodyClass
|
|
1336
|
+
}]);
|
|
1337
|
+
}
|
|
1215
1338
|
|
|
1216
1339
|
/**
|
|
1217
1340
|
* Generated bundle index. Do not edit.
|
|
1218
1341
|
*/
|
|
1219
1342
|
|
|
1220
|
-
export { ALERT_CONFIGURATIONS, ALERT_DEFAULT_BUTTON_CONFIGURATION, AcceptValidationMode, ApiService,
|
|
1343
|
+
export { ALERT_CONFIGURATIONS, ALERT_DEFAULT_BUTTON_CONFIGURATION, AcceptValidationMode, ApiService, CONFIRM_CONFIGURATIONS, CookieService, DialogConfig, DialogInjector, DialogRef, DialogService, ErrorInterceptor, GOOGLE_MAPS_API_KEY, GoogleMapsService, InterceptorType, LOG_LEVEL, LogLevel, LoggerService, MESSAGE_DEFAULT_CONFIGURATION, MessagePosition, MessageService, MessageSeverity, OPENED_DIALOG_BODY_CLASS, PREDEFINED_DIALOGS, Precheck, PrecheckInterceptor, TokenInterceptor, TokenService, TokenServiceMode, isBrowser, localStorage, provideOpenedDialogBodyClass, providePredefinedDialogs, provideTokenInterceptor, sessionStorage };
|
|
1221
1344
|
//# sourceMappingURL=codefoxcore.mjs.map
|