codefoxcore 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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() {
@@ -141,6 +142,16 @@ const OPENED_DIALOG_BODY_CLASS = new InjectionToken('Opened dialog body class',
141
142
  return null;
142
143
  }
143
144
  });
145
+ const DIALOG_CONFIRM_COMPONENT = new InjectionToken('Dialog confirm component', {
146
+ factory: () => {
147
+ return null;
148
+ }
149
+ });
150
+ const DIALOG_ALERT_COMPONENT = new InjectionToken('Dialog alert component', {
151
+ factory: () => {
152
+ return null;
153
+ }
154
+ });
144
155
 
145
156
  const CONFIRM_CONFIGURATIONS = new InjectionToken('Confirm configurations predefined', {
146
157
  factory: () => {
@@ -216,6 +227,12 @@ const LOG_LEVEL = new InjectionToken('Log level', {
216
227
  }
217
228
  });
218
229
 
230
+ const GOOGLE_MAPS_API_KEY = new InjectionToken('Google Maps Api Key', {
231
+ factory: () => {
232
+ return null;
233
+ }
234
+ });
235
+
219
236
  class DialogService {
220
237
  constructor() {
221
238
  this.injector = inject(Injector);
@@ -223,6 +240,8 @@ class DialogService {
223
240
  this.predefinedAlertConfigurations = inject(ALERT_CONFIGURATIONS);
224
241
  this.predefinedDialogs = inject(PREDEFINED_DIALOGS);
225
242
  this.openedDialogBodyClass = inject(OPENED_DIALOG_BODY_CLASS);
243
+ this.dialogConfirmComponent = inject(DIALOG_CONFIRM_COMPONENT);
244
+ this.dialogAlertComponent = inject(DIALOG_ALERT_COMPONENT);
226
245
  this.title = inject(Title);
227
246
  this.messageService = inject(MessageService);
228
247
  this.dialogs = new Map();
@@ -478,7 +497,10 @@ class DialogService {
478
497
  });
479
498
  });
480
499
  }
481
- async confirmAsync(configuration, dialogConfiguration = {}, component) {
500
+ async confirmAsync(configuration, dialogConfiguration = {}, component = this.dialogConfirmComponent) {
501
+ if (component === null) {
502
+ throw new Error('No component provided for confirm dialog!');
503
+ }
482
504
  return await new Promise((resolve) => {
483
505
  this.confirm(configuration, dialogConfiguration, component).then(() => {
484
506
  resolve(true);
@@ -487,12 +509,18 @@ class DialogService {
487
509
  });
488
510
  });
489
511
  }
490
- confirmAccept(configuration, dialogConfiguration = {}, component) {
512
+ confirmAccept(configuration, dialogConfiguration = {}, component = this.dialogConfirmComponent) {
513
+ if (component === null) {
514
+ throw new Error('No component provided for confirm dialog!');
515
+ }
491
516
  return new Promise((resolve) => {
492
517
  this.confirm(configuration, dialogConfiguration, component).then(() => resolve(true)).catch(() => { });
493
518
  });
494
519
  }
495
- confirmDecline(configuration, dialogConfiguration = {}, component) {
520
+ confirmDecline(configuration, dialogConfiguration = {}, component = this.dialogConfirmComponent) {
521
+ if (component === null) {
522
+ throw new Error('No component provided for confirm dialog!');
523
+ }
496
524
  return new Promise((resolve) => {
497
525
  this.confirm(configuration, dialogConfiguration, component).then(() => { }).catch(() => resolve(true));
498
526
  });
@@ -507,7 +535,10 @@ class DialogService {
507
535
  }
508
536
  });
509
537
  }
510
- showAlert(configuration, dialogConfiguration = {}, component) {
538
+ showAlert(configuration, dialogConfiguration = {}, component = this.dialogAlertComponent) {
539
+ if (component === null) {
540
+ throw new Error('No component provided for alert dialog!');
541
+ }
511
542
  if (typeof configuration === 'string') {
512
543
  const predefinedAlertConfiguration = this.predefinedAlertConfigurations[configuration];
513
544
  if (predefinedAlertConfiguration === undefined) {
@@ -1160,6 +1191,41 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1160
1191
  }]
1161
1192
  }] });
1162
1193
 
1194
+ class GoogleMapsService {
1195
+ constructor() {
1196
+ this.apiService = inject(ApiService);
1197
+ this.interceptorsService = inject(InterceptorsService);
1198
+ this.googleMapsApiKey = inject(GOOGLE_MAPS_API_KEY);
1199
+ this.mapsJsLoaded = false;
1200
+ }
1201
+ load() {
1202
+ if (this.googleMapsApiKey === null) {
1203
+ throw new Error('Google maps api key is not set!');
1204
+ }
1205
+ if (this.mapsJsLoaded) {
1206
+ return of(true);
1207
+ }
1208
+ this.interceptorsService.skip = [InterceptorType.TOKEN];
1209
+ return this.apiService.httpClient.jsonp(`https://maps.googleapis.com/maps/api/js?key=${this.googleMapsApiKey}`, 'callback').pipe(tap(() => {
1210
+ this.interceptorsService.skip = [];
1211
+ this.mapsJsLoaded = true;
1212
+ }));
1213
+ }
1214
+ createMaps(element = null, config = {}) {
1215
+ return this.load().pipe(tap(() => {
1216
+ new window.google.maps.Map(element, config);
1217
+ }));
1218
+ }
1219
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GoogleMapsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1220
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GoogleMapsService, providedIn: 'root' }); }
1221
+ }
1222
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GoogleMapsService, decorators: [{
1223
+ type: Injectable,
1224
+ args: [{
1225
+ providedIn: 'root'
1226
+ }]
1227
+ }] });
1228
+
1163
1229
  class BaseInterceptor {
1164
1230
  skipInterceptor() {
1165
1231
  if (this.type !== null && this.interceptorsService.skip.indexOf(InterceptorType.ALL) !== -1) {
@@ -1218,6 +1284,62 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1218
1284
  }]
1219
1285
  }], ctorParameters: function () { return []; } });
1220
1286
 
1287
+ class PrecheckInterceptor extends BaseInterceptor {
1288
+ intercept(request, next) {
1289
+ if (this.skipInterceptor()) {
1290
+ return next.handle(request);
1291
+ }
1292
+ if (this.interceptorsService.precheck !== null) {
1293
+ request = request.clone({
1294
+ setHeaders: {
1295
+ Precheck: this.interceptorsService.precheck
1296
+ }
1297
+ });
1298
+ if (this.interceptorsService.resetPrecheck) {
1299
+ this.interceptorsService.precheck = null;
1300
+ }
1301
+ }
1302
+ return next.handle(request);
1303
+ }
1304
+ constructor() {
1305
+ super(InterceptorType.PRECHECK);
1306
+ }
1307
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PrecheckInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1308
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PrecheckInterceptor, providedIn: 'root' }); }
1309
+ }
1310
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PrecheckInterceptor, decorators: [{
1311
+ type: Injectable,
1312
+ args: [{
1313
+ providedIn: 'root'
1314
+ }]
1315
+ }], ctorParameters: function () { return []; } });
1316
+
1317
+ class ErrorInterceptor extends BaseInterceptor {
1318
+ intercept(request, next) {
1319
+ if (this.skipInterceptor()) {
1320
+ return next.handle(request);
1321
+ }
1322
+ return next.handle(request).pipe(catchError((httpErrorResponse) => {
1323
+ if (this.interceptorsService.errorCallbackfunction !== null && !this.interceptorsService.errorSkipStatusCodes.includes(httpErrorResponse.status)) {
1324
+ this.loggerService.info('Error Interceptor Callback Function Called');
1325
+ this.interceptorsService.errorCallbackfunction(httpErrorResponse);
1326
+ }
1327
+ return throwError(() => httpErrorResponse);
1328
+ }));
1329
+ }
1330
+ constructor() {
1331
+ super(InterceptorType.ERROR);
1332
+ }
1333
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ErrorInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1334
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ErrorInterceptor, providedIn: 'root' }); }
1335
+ }
1336
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ErrorInterceptor, decorators: [{
1337
+ type: Injectable,
1338
+ args: [{
1339
+ providedIn: 'root'
1340
+ }]
1341
+ }], ctorParameters: function () { return []; } });
1342
+
1221
1343
  function provideTokenInterceptor() {
1222
1344
  return makeEnvironmentProviders([{
1223
1345
  provide: HTTP_INTERCEPTORS,
@@ -1237,10 +1359,28 @@ function provideOpenedDialogBodyClass(openedDialogBodyClass) {
1237
1359
  useValue: openedDialogBodyClass
1238
1360
  }]);
1239
1361
  }
1362
+ function provideGoogleMapsApiKey(googleMapsApiKey) {
1363
+ return makeEnvironmentProviders([{
1364
+ provide: GOOGLE_MAPS_API_KEY,
1365
+ useValue: googleMapsApiKey
1366
+ }]);
1367
+ }
1368
+ function provideDialogConfirmComponent(component) {
1369
+ return makeEnvironmentProviders([{
1370
+ provide: DIALOG_CONFIRM_COMPONENT,
1371
+ useValue: component
1372
+ }]);
1373
+ }
1374
+ function provideDialogAlertComponent(component) {
1375
+ return makeEnvironmentProviders([{
1376
+ provide: DIALOG_ALERT_COMPONENT,
1377
+ useValue: component
1378
+ }]);
1379
+ }
1240
1380
 
1241
1381
  /**
1242
1382
  * Generated bundle index. Do not edit.
1243
1383
  */
1244
1384
 
1245
- export { ALERT_CONFIGURATIONS, ALERT_DEFAULT_BUTTON_CONFIGURATION, AcceptValidationMode, ApiService, CONFIRM_CONFIGURATIONS, CookieService, DialogConfig, DialogInjector, DialogRef, DialogService, InterceptorType, LOG_LEVEL, LogLevel, LoggerService, MESSAGE_DEFAULT_CONFIGURATION, MessagePosition, MessageService, MessageSeverity, OPENED_DIALOG_BODY_CLASS, PREDEFINED_DIALOGS, Precheck, TokenInterceptor, TokenService, TokenServiceMode, isBrowser, localStorage, provideOpenedDialogBodyClass, providePredefinedDialogs, provideTokenInterceptor, sessionStorage };
1385
+ export { ALERT_CONFIGURATIONS, ALERT_DEFAULT_BUTTON_CONFIGURATION, AcceptValidationMode, ApiService, CONFIRM_CONFIGURATIONS, CookieService, DIALOG_ALERT_COMPONENT, DIALOG_CONFIRM_COMPONENT, 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, provideDialogAlertComponent, provideDialogConfirmComponent, provideGoogleMapsApiKey, provideOpenedDialogBodyClass, providePredefinedDialogs, provideTokenInterceptor, sessionStorage };
1246
1386
  //# sourceMappingURL=codefoxcore.mjs.map