This commit is contained in:
2026-05-11 18:42:05 +03:30
parent 88adb566eb
commit 9bcb917d3b
17 changed files with 185 additions and 17 deletions
@@ -1,4 +1,18 @@
<div class="h-svh w-svw flex flex-col items-center justify-center">
{{ requireInstall }}
{{ pwaInstalled() }}
<img [src]="logo" class="w-32 animate-pulse" />
<span class="text-xl font-medium text-center text-muted-color mt-4"> در حال بارگذاری ... </span>
@if (requireInstall && !pwaInstalled()) {
<div class="mt-6 flex flex-col items-center gap-3">
<span class="text-base font-medium text-center text-muted-color">برای ادامه، نصب برنامه الزامی است.</span>
@if (canInstall()) {
<button pButton type="button" size="small" (click)="installPwa()">نصب برنامه</button>
} @else {
<span class="text-sm text-center text-muted-color">منتظر فعال شدن امکان نصب در مرورگر...</span>
}
<button pButton type="button" outlined size="small" (click)="continueAfterInstall()">ادامه</button>
</div>
} @else {
<span class="text-xl font-medium text-center text-muted-color mt-4"> در حال بارگذاری ... </span>
}
</div>
@@ -1,4 +1,6 @@
import { PwaInstallService } from '@/core/services';
import { Component, EventEmitter, inject, Output } from '@angular/core';
import { ButtonDirective } from 'primeng/button';
import { finalize, forkJoin } from 'rxjs';
import images from 'src/assets/images';
import { PosInfoStore, PosProfileStore } from '../store';
@@ -7,6 +9,7 @@ import { DeviceInfoStore } from '../store/device.store';
@Component({
selector: 'pos-splash',
templateUrl: 'splash.component.html',
imports: [ButtonDirective],
})
export class PosSplashComponent {
@Output() onComplete = new EventEmitter<void>();
@@ -14,8 +17,27 @@ export class PosSplashComponent {
private readonly posProfileStore = inject(PosProfileStore);
private readonly posInfoStore = inject(PosInfoStore);
private readonly deviceInfoStore = inject(DeviceInfoStore);
private readonly pwaInstallService = inject(PwaInstallService);
logo = images.logo;
requireInstall = false;
// requireInstall = brandingConfig.enableInstallPrompt;
pwaInstalled = this.pwaInstallService.isInstalled;
canInstall = this.pwaInstallService.canInstall;
private installPromptShown = false;
// constructor() {
// effect(() => {
// if (!this.requireInstall || this.pwaInstalled() || this.installPromptShown) {
// return;
// }
// if (this.canInstall()) {
// this.installPromptShown = true;
// this.pwaInstallService.openInstallConfirm();
// }
// });
// }
async ngOnInit() {
const data = await this.deviceInfoStore.getData();
@@ -25,9 +47,27 @@ export class PosSplashComponent {
forkJoin([profileObs, infoObs])
.pipe(
finalize(() => {
this.onComplete.emit();
if (!this.requireInstall || this.pwaInstalled()) {
this.onComplete.emit();
return;
}
if (this.canInstall()) {
this.pwaInstallService.openInstallConfirm();
this.installPromptShown = true;
}
}),
)
.subscribe(([profileResult, infoResult]) => {});
}
installPwa() {
this.pwaInstallService.openInstallConfirm();
}
continueAfterInstall() {
if (this.pwaInstalled()) {
this.onComplete.emit();
}
}
}
@@ -19,18 +19,18 @@
<li>
<a
pRipple
routerLink="/pos/sale_invoices"
routerLink="/sale_invoices"
(click)="drawerRef.close($event)"
class="flex items-center cursor-pointer p-4 rounded-border text-surface-700 dark:text-surface-100 hover:bg-surface-100 dark:hover:bg-surface-700 duration-150 transition-colors p-ripple"
>
<i class="pi pi-home me-2"></i>
<span class="font-medium">مشاهده‌ی فاکتورها</span>
<span class="font-medium">فاکتورها</span>
</a>
</li>
<li>
<a
pRipple
routerLink="/pos"
routerLink="/"
(click)="drawerRef.close($event)"
class="flex items-center cursor-pointer p-4 rounded-border text-surface-700 dark:text-surface-100 hover:bg-surface-100 dark:hover:bg-surface-700 duration-150 transition-colors p-ripple"
>
@@ -41,7 +41,7 @@
<li>
<a
pRipple
routerLink="/pos/about"
routerLink="/about"
(click)="drawerRef.close($event)"
class="flex items-center cursor-pointer p-4 rounded-border text-surface-700 dark:text-surface-100 hover:bg-surface-100 dark:hover:bg-surface-700 duration-150 transition-colors p-ripple"
>
@@ -52,7 +52,7 @@
<li>
<a
pRipple
routerLink="/pos/support"
routerLink="/support"
(click)="drawerRef.close($event)"
class="flex items-center cursor-pointer p-4 rounded-border text-surface-700 dark:text-surface-100 hover:bg-surface-100 dark:hover:bg-surface-700 duration-150 transition-colors p-ripple"
>
@@ -1,3 +1,4 @@
import { ToastService } from '@/core/services/toast.service';
import { AbstractDialog } from '@/shared/abstractClasses/abstract-dialog';
import { Component, computed, inject } from '@angular/core';
import { RouterLink } from '@angular/router';
@@ -16,6 +17,7 @@ import { PosInfoStore } from '../../store';
export class PosMainMenuSidebarComponent extends AbstractDialog {
private readonly posInfoStore = inject(PosInfoStore);
private readonly swUpdate = inject(SwUpdate);
private readonly toastService = inject(ToastService);
readonly posInfo = computed(() => this.posInfoStore.entity());
appVersion = '0.0.0';
@@ -31,12 +33,15 @@ export class PosMainMenuSidebarComponent extends AbstractDialog {
ngOnInit() {
this.isPwaBuild = this.swUpdate.isEnabled;
console.log(this.swUpdate);
if (!this.isPwaBuild) return;
fetch('/ngsw.json')
.then((res) => res.json())
.then((data: { appData?: { appVersion?: string } }) => {
this.appVersion = data?.appData?.appVersion || this.appVersion;
this.toastService.info({ text: this.appVersion });
console.log('appVersion:', data?.appData);
})
.catch((err) => {
@@ -1,3 +1,4 @@
import { POS_ROUTES } from '@/domains/pos/routes';
import { InnerPagesHeaderComponent } from '@/shared/components/innerPagesHeader/inner-pages-header.component';
import { Component, computed, inject, signal } from '@angular/core';
import { Router } from '@angular/router';
@@ -70,7 +71,7 @@ export class PosSaleInvoiceListComponent {
});
});
activeFilterCount = computed(() => this.activeFilters().length);
backRoute = '/pos';
backRoute = POS_ROUTES.path || '/';
ngOnInit() {
this.getData();