barsa-novin-ray-core 2.3.95 → 2.3.97

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,6 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable, inject, ElementRef, Input, ChangeDetectionStrategy, Component, Pipe, ComponentFactoryResolver, Injector, ApplicationRef, Compiler, DOCUMENT, NgModuleFactory, InjectionToken, NgZone, EventEmitter, ChangeDetectorRef, Renderer2, HostBinding, Output, HostListener, ViewContainerRef, ViewChild, signal, Directive, TemplateRef, input, NgModule, NO_ERRORS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA, provideAppInitializer, ErrorHandler } from '@angular/core';
3
- import { Subject, from, BehaviorSubject, of, exhaustMap, map as map$1, combineLatest, withLatestFrom as withLatestFrom$1, fromEvent, forkJoin, takeUntil as takeUntil$1, filter as filter$1, throwError, merge, interval, concatMap as concatMap$1, catchError as catchError$1, finalize as finalize$1, take, debounceTime as debounceTime$1, skip, Observable, tap as tap$1, timer, mergeWith, Subscription } from 'rxjs';
3
+ import { Subject, from, BehaviorSubject, of, exhaustMap, map as map$1, combineLatest, withLatestFrom as withLatestFrom$1, fromEvent, forkJoin, takeUntil as takeUntil$1, filter as filter$1, throwError, merge, interval, tap as tap$1, concatMap as concatMap$1, catchError as catchError$1, finalize as finalize$1, take, debounceTime as debounceTime$1, skip, Observable, timer, mergeWith, Subscription } from 'rxjs';
4
4
  import * as i1 from '@angular/router';
5
5
  import { Router, NavigationEnd, ActivatedRoute, RouterEvent, NavigationStart, RouterModule } from '@angular/router';
6
6
  import { DomSanitizer, Title } from '@angular/platform-browser';
@@ -7802,16 +7802,35 @@ const NOTIFICATION_WEBWORKER_FACTORY = new InjectionToken('notificaion-worker');
7802
7802
 
7803
7803
  class ServiceWorkerNotificationService {
7804
7804
  constructor() {
7805
+ this.hasRegistration = false;
7805
7806
  this._logService = inject(LogService);
7806
7807
  this._swPush = inject(SwPush);
7807
7808
  this._portalService = inject(PortalService);
7808
- this._notificationPermissionAllowed = false;
7809
- this._hasRegistration = false;
7810
- this.init();
7809
+ this._notificationPermissionAllowed = true;
7810
+ const _logService = this._logService;
7811
+ const _swPush = this._swPush;
7812
+ _logService.info(`swPush enable ${_swPush.isEnabled}`);
7813
+ _swPush.notificationClicks.pipe(tap$1((c) => console.log(c))).subscribe((e) => {
7814
+ if (!e.notification.tag) {
7815
+ return;
7816
+ }
7817
+ this.closeNotifications([e.notification.tag]);
7818
+ let actionTitle = e.action;
7819
+ if (actionTitle === '') {
7820
+ actionTitle = 'show';
7821
+ }
7822
+ if (!BarsaApi?.LoginFormData?.IsUserLoggedIn) {
7823
+ return;
7824
+ }
7825
+ this._portalService.ExecuteNotificationAction(e.notification.tag, actionTitle);
7826
+ // TODO:exeucte action
7827
+ // not handled!!
7828
+ });
7829
+ this.getSw().then((c) => (this.hasRegistration = !!c));
7830
+ this.handlePermission();
7811
7831
  }
7812
- // بررسی وضعیت فعلی
7813
7832
  get isEnabled() {
7814
- return this._swPush.isEnabled && this._hasRegistration && this._notificationPermissionAllowed;
7833
+ return this._swPush.isEnabled && this.hasRegistration && this._notificationPermissionAllowed;
7815
7834
  }
7816
7835
  async closeNotifications(tags) {
7817
7836
  const sw = await this.getSw();
@@ -7825,7 +7844,6 @@ class ServiceWorkerNotificationService {
7825
7844
  }
7826
7845
  });
7827
7846
  }
7828
- // نمایش دستی نوتیفیکیشن (برای تست)
7829
7847
  async showNotification(payload) {
7830
7848
  const sw = await this.getSw();
7831
7849
  if (!sw) {
@@ -7865,40 +7883,43 @@ class ServiceWorkerNotificationService {
7865
7883
  data
7866
7884
  });
7867
7885
  }
7868
- async init() {
7869
- this._logService.info(`SwPush enabled: ${this._swPush.isEnabled}`);
7870
- // مدیریت کلیک روی نوتیفیکیشن‌ها
7871
- this._swPush.notificationClicks.subscribe((e) => {
7872
- if (!e.notification.tag) {
7873
- return;
7874
- }
7875
- const actionTitle = e.action || 'show';
7876
- if (!BarsaApi?.LoginFormData?.IsUserLoggedIn) {
7877
- return;
7878
- }
7879
- this._portalService.ExecuteNotificationAction(e.notification.tag, actionTitle);
7880
- });
7881
- // بررسی مجوز و ثبت سرویس‌ورکر
7882
- await this.registerServiceWorker();
7883
- await this.requestPermission();
7884
- }
7885
- async requestPermission() {
7886
- if (Notification.permission === 'default') {
7887
- await Notification.requestPermission();
7886
+ handlePermission() {
7887
+ if (!navigator?.permissions?.query) {
7888
+ return;
7888
7889
  }
7889
- this._notificationPermissionAllowed = Notification.permission === 'granted';
7890
+ return navigator.permissions
7891
+ .query({ name: 'notifications' })
7892
+ .then(this.permissionQuery.bind(this))
7893
+ .catch(this.permissionError.bind(this));
7890
7894
  }
7891
- async registerServiceWorker() {
7892
- if (!('serviceWorker' in navigator)) {
7893
- return;
7895
+ permissionQuery(result) {
7896
+ let newPrompt;
7897
+ if (result.state === 'granted') {
7898
+ // notifications allowed, go wild
7899
+ }
7900
+ else if (result.state === 'prompt') {
7901
+ // we can ask the user
7902
+ newPrompt = Notification.requestPermission();
7894
7903
  }
7895
- const reg = await navigator.serviceWorker.getRegistration();
7896
- this._hasRegistration = !!reg;
7904
+ else if (result.state === 'denied') {
7905
+ // notifications were disabled
7906
+ this._notificationPermissionAllowed = false;
7907
+ }
7908
+ result.onchange = () => console.log({ updatedPermission: result });
7909
+ return newPrompt || result;
7910
+ }
7911
+ permissionError(error) {
7912
+ this._notificationPermissionAllowed = false;
7913
+ console.error(error);
7897
7914
  }
7898
7915
  async getSw() {
7899
- const reg = await navigator.serviceWorker.getRegistration();
7900
- this._hasRegistration = !!reg;
7901
- return reg;
7916
+ if (!navigator.serviceWorker) {
7917
+ this.hasRegistration = false;
7918
+ return undefined;
7919
+ }
7920
+ const x = await navigator.serviceWorker.getRegistration('custom-ngsw-worker.js');
7921
+ this.hasRegistration = !!x;
7922
+ return x;
7902
7923
  }
7903
7924
  _isSupported() {
7904
7925
  if (!('serviceWorker' in navigator)) {
@@ -11103,40 +11124,40 @@ class FormPageComponent extends FormPageBaseComponent {
11103
11124
  this.absolutePageClass = false;
11104
11125
  }
11105
11126
  ngOnInit() {
11106
- this.containerRef = this.formRef.vcr; // it must be first because we change containerRef
11127
+ this.containerRef.insert(this._placeHolderTemplate.createEmbeddedView(this, this._injector));
11107
11128
  super.ngOnInit();
11108
11129
  }
11109
- ngAfterViewInit() {
11110
- super.ngAfterViewInit();
11111
- if (!this._el.nativeElement.classList.contains('absolute-page-removed')) {
11112
- this.absolutePageClass = true;
11113
- }
11114
- }
11115
11130
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: FormPageComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
11116
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.6", type: FormPageComponent, isStandalone: false, selector: "bnrc-form-page", inputs: { formPanelCtrlr: "formPanelCtrlr" }, host: { properties: { "class.section": "this.sectionClass", "class.absolute-page": "this.absolutePageClass" } }, providers: [FormService, ContainerService], viewQueries: [{ propertyName: "formRef", first: true, predicate: FormComponent, descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: `
11117
- <bnrc-form
11118
- [formPanelCtrl]="formPanelCtrlr"
11119
- [formPanelCtrlId]="formpanelCtrlrId"
11120
- [params]="params"
11121
- (formClose)="onFormClose()"
11122
- ></bnrc-form>
11131
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.6", type: FormPageComponent, isStandalone: false, selector: "bnrc-form-page", inputs: { formPanelCtrlr: "formPanelCtrlr" }, host: { properties: { "class.section": "this.sectionClass", "class.absolute-page": "this.absolutePageClass" } }, providers: [FormService, ContainerService], viewQueries: [{ propertyName: "_placeHolderTemplate", first: true, predicate: ["placeHolderTemplate"], descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: `
11132
+ <ng-template #placeHolderTemplate>
11133
+ <bnrc-form
11134
+ [formPanelCtrl]="formPanelCtrlr"
11135
+ [formPanelCtrlId]="formpanelCtrlrId"
11136
+ [params]="params"
11137
+ (formClose)="onFormClose()"
11138
+ ></bnrc-form>
11139
+ </ng-template>
11140
+ <ng-container #containerRef> </ng-container>
11123
11141
  <router-outlet></router-outlet>
11124
11142
  `, isInline: true, styles: [":host{display:block;background:var(--sapBackgroundColor)}\n"], dependencies: [{ kind: "directive", type: i1.RouterOutlet, selector: "router-outlet", inputs: ["name", "routerOutletData"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }, { kind: "component", type: FormComponent, selector: "bnrc-form", inputs: ["params", "customFormPanelUi", "formPanelCtrl", "UlvMainCtrlr", "formPanelCtrlId", "saveOnChange", "inlineEditInReport"], outputs: ["titleChanged", "moChanged", "formClose", "uiComponent", "formRendered", "bruleAction", "beforeTransition", "afterTransition"] }, { kind: "directive", type: FormCloseDirective, selector: "[formClose]", inputs: ["isMobile"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
11125
11143
  }
11126
11144
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: FormPageComponent, decorators: [{
11127
11145
  type: Component,
11128
11146
  args: [{ selector: 'bnrc-form-page', template: `
11129
- <bnrc-form
11130
- [formPanelCtrl]="formPanelCtrlr"
11131
- [formPanelCtrlId]="formpanelCtrlrId"
11132
- [params]="params"
11133
- (formClose)="onFormClose()"
11134
- ></bnrc-form>
11147
+ <ng-template #placeHolderTemplate>
11148
+ <bnrc-form
11149
+ [formPanelCtrl]="formPanelCtrlr"
11150
+ [formPanelCtrlId]="formpanelCtrlrId"
11151
+ [params]="params"
11152
+ (formClose)="onFormClose()"
11153
+ ></bnrc-form>
11154
+ </ng-template>
11155
+ <ng-container #containerRef> </ng-container>
11135
11156
  <router-outlet></router-outlet>
11136
11157
  `, providers: [FormService, ContainerService], changeDetection: ChangeDetectionStrategy.OnPush, standalone: false, styles: [":host{display:block;background:var(--sapBackgroundColor)}\n"] }]
11137
- }], propDecorators: { formRef: [{
11158
+ }], propDecorators: { _placeHolderTemplate: [{
11138
11159
  type: ViewChild,
11139
- args: [FormComponent, { static: true }]
11160
+ args: ['placeHolderTemplate', { static: true }]
11140
11161
  }], formPanelCtrlr: [{
11141
11162
  type: Input
11142
11163
  }], sectionClass: [{