dev #42
@@ -1,14 +1,13 @@
|
|||||||
# Stage 1: Build
|
FROM node:22-alpine
|
||||||
FROM node:20 as build
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm install
|
RUN npm ci --legacy-peer-deps
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm run build --configuration=production
|
RUN npm run build -- --configuration=production
|
||||||
|
|
||||||
# Stage 2: Serve
|
ENV NODE_ENV=production
|
||||||
FROM nginx:alpine
|
ENV PORT=80
|
||||||
COPY --from=build /app/dist/frontend/browser /usr/share/nginx/html
|
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
CMD ["node", "dist/frontend/server/server.mjs"]
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
# Stage 1: Build
|
FROM node:22-alpine
|
||||||
FROM node:20 as build
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm install
|
RUN npm ci --legacy-peer-deps
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Use development configuration to pick up environment.ts (localhost)
|
# Use development configuration to pick up environment.ts (localhost)
|
||||||
RUN npm run build -- --configuration=development
|
RUN npm run build -- --configuration=development
|
||||||
|
|
||||||
# Stage 2: Serve
|
ENV NODE_ENV=development
|
||||||
FROM nginx:alpine
|
ENV PORT=80
|
||||||
COPY --from=build /app/dist/frontend/browser /usr/share/nginx/html
|
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
CMD ["node", "dist/frontend/server/server.mjs"]
|
||||||
|
|||||||
@@ -36,7 +36,12 @@
|
|||||||
"@angular/material/prebuilt-themes/azure-blue.css",
|
"@angular/material/prebuilt-themes/azure-blue.css",
|
||||||
"src/styles.scss"
|
"src/styles.scss"
|
||||||
],
|
],
|
||||||
"scripts": []
|
"scripts": [],
|
||||||
|
"server": "src/main.server.ts",
|
||||||
|
"prerender": false,
|
||||||
|
"ssr": {
|
||||||
|
"entry": "src/server.ts"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"production": {
|
"production": {
|
||||||
|
|||||||
901
frontend/package-lock.json
generated
901
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -6,35 +6,41 @@
|
|||||||
"start": "ng serve",
|
"start": "ng serve",
|
||||||
"build": "ng build",
|
"build": "ng build",
|
||||||
"watch": "ng build --watch --configuration development",
|
"watch": "ng build --watch --configuration development",
|
||||||
"test": "ng test"
|
"test": "ng test",
|
||||||
|
"serve:ssr:frontend": "node dist/frontend/server/server.mjs"
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^22.0.0"
|
"node": "^22.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/cdk": "^19.2.19",
|
"@angular/cdk": "19.2.19",
|
||||||
"@angular/common": "^19.2.18",
|
"@angular/common": "19.2.19",
|
||||||
"@angular/compiler": "^19.2.18",
|
"@angular/compiler": "19.2.19",
|
||||||
"@angular/core": "^19.2.18",
|
"@angular/core": "19.2.19",
|
||||||
"@angular/forms": "^19.2.18",
|
"@angular/forms": "19.2.19",
|
||||||
"@angular/material": "^19.2.19",
|
"@angular/material": "19.2.19",
|
||||||
"@angular/platform-browser": "^19.2.18",
|
"@angular/platform-browser": "19.2.19",
|
||||||
"@angular/platform-browser-dynamic": "^19.2.18",
|
"@angular/platform-browser-dynamic": "19.2.19",
|
||||||
"@angular/router": "^19.2.18",
|
"@angular/platform-server": "19.2.19",
|
||||||
|
"@angular/router": "19.2.19",
|
||||||
|
"@angular/ssr": "19.2.19",
|
||||||
"@ngx-translate/core": "^17.0.0",
|
"@ngx-translate/core": "^17.0.0",
|
||||||
"@ngx-translate/http-loader": "^17.0.0",
|
"@ngx-translate/http-loader": "^17.0.0",
|
||||||
"@types/three": "^0.182.0",
|
"@types/three": "^0.182.0",
|
||||||
|
"express": "^4.18.2",
|
||||||
"rxjs": "~7.8.0",
|
"rxjs": "~7.8.0",
|
||||||
"three": "^0.182.0",
|
"three": "^0.182.0",
|
||||||
"tslib": "^2.3.0",
|
"tslib": "^2.3.0",
|
||||||
"zone.js": "~0.15.0"
|
"zone.js": "~0.15.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/build-angular": "^19.2.19",
|
"@angular-devkit/build-angular": "19.2.19",
|
||||||
"@angular/cli": "^19.2.19",
|
"@angular/cli": "19.2.19",
|
||||||
"@angular/compiler-cli": "^19.2.18",
|
"@angular/compiler-cli": "19.2.19",
|
||||||
|
"@types/express": "^4.17.17",
|
||||||
"@types/jasmine": "~5.1.0",
|
"@types/jasmine": "~5.1.0",
|
||||||
|
"@types/node": "^18.18.0",
|
||||||
"jasmine-core": "~5.6.0",
|
"jasmine-core": "~5.6.0",
|
||||||
"karma": "~6.4.0",
|
"karma": "~6.4.0",
|
||||||
"karma-chrome-launcher": "~3.2.0",
|
"karma-chrome-launcher": "~3.2.0",
|
||||||
|
|||||||
9
frontend/src/app/app.config.server.ts
Normal file
9
frontend/src/app/app.config.server.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
|
||||||
|
import { provideServerRendering } from '@angular/platform-server';
|
||||||
|
import { appConfig } from './app.config';
|
||||||
|
|
||||||
|
const serverConfig: ApplicationConfig = {
|
||||||
|
providers: [provideServerRendering()],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const config = mergeApplicationConfig(appConfig, serverConfig);
|
||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
TranslateHttpLoader,
|
TranslateHttpLoader,
|
||||||
} from '@ngx-translate/http-loader';
|
} from '@ngx-translate/http-loader';
|
||||||
import { adminAuthInterceptor } from './core/interceptors/admin-auth.interceptor';
|
import { adminAuthInterceptor } from './core/interceptors/admin-auth.interceptor';
|
||||||
|
import { provideClientHydration, withEventReplay } from '@angular/platform-browser';
|
||||||
|
|
||||||
export const appConfig: ApplicationConfig = {
|
export const appConfig: ApplicationConfig = {
|
||||||
providers: [
|
providers: [
|
||||||
@@ -43,5 +44,6 @@ export const appConfig: ApplicationConfig = {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
provideClientHydration(withEventReplay()),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule, isPlatformBrowser } from '@angular/common';
|
||||||
import { Component, OnInit, inject } from '@angular/core';
|
import { Component, OnInit, PLATFORM_ID, inject } from '@angular/core';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import {
|
import {
|
||||||
AdminCadInvoice,
|
AdminCadInvoice,
|
||||||
@@ -16,6 +16,7 @@ import { CopyOnClickDirective } from '../../../shared/directives/copy-on-click.d
|
|||||||
styleUrl: './admin-cad-invoices.component.scss',
|
styleUrl: './admin-cad-invoices.component.scss',
|
||||||
})
|
})
|
||||||
export class AdminCadInvoicesComponent implements OnInit {
|
export class AdminCadInvoicesComponent implements OnInit {
|
||||||
|
private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
||||||
private readonly adminOperationsService = inject(AdminOperationsService);
|
private readonly adminOperationsService = inject(AdminOperationsService);
|
||||||
private readonly adminOrdersService = inject(AdminOrdersService);
|
private readonly adminOrdersService = inject(AdminOrdersService);
|
||||||
|
|
||||||
@@ -112,11 +113,17 @@ export class AdminCadInvoicesComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
openCheckout(path: string): void {
|
openCheckout(path: string): void {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const url = this.toCheckoutUrl(path);
|
const url = this.toCheckoutUrl(path);
|
||||||
window.open(url, '_blank');
|
window.open(url, '_blank');
|
||||||
}
|
}
|
||||||
|
|
||||||
copyCheckout(path: string): void {
|
copyCheckout(path: string): void {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const url = this.toCheckoutUrl(path);
|
const url = this.toCheckoutUrl(path);
|
||||||
navigator.clipboard?.writeText(url);
|
navigator.clipboard?.writeText(url);
|
||||||
this.successMessage = 'Link checkout CAD copiato negli appunti.';
|
this.successMessage = 'Link checkout CAD copiato negli appunti.';
|
||||||
@@ -126,6 +133,9 @@ export class AdminCadInvoicesComponent implements OnInit {
|
|||||||
if (!orderId) return;
|
if (!orderId) return;
|
||||||
this.adminOrdersService.downloadOrderInvoice(orderId).subscribe({
|
this.adminOrdersService.downloadOrderInvoice(orderId).subscribe({
|
||||||
next: (blob) => {
|
next: (blob) => {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const url = window.URL.createObjectURL(blob);
|
const url = window.URL.createObjectURL(blob);
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.href = url;
|
a.href = url;
|
||||||
@@ -142,10 +152,16 @@ export class AdminCadInvoicesComponent implements OnInit {
|
|||||||
private toCheckoutUrl(path: string): string {
|
private toCheckoutUrl(path: string): string {
|
||||||
const safePath = path.startsWith('/') ? path : `/${path}`;
|
const safePath = path.startsWith('/') ? path : `/${path}`;
|
||||||
const lang = this.resolveLang();
|
const lang = this.resolveLang();
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return `/${lang}${safePath}`;
|
||||||
|
}
|
||||||
return `${window.location.origin}/${lang}${safePath}`;
|
return `${window.location.origin}/${lang}${safePath}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private resolveLang(): string {
|
private resolveLang(): string {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return 'it';
|
||||||
|
}
|
||||||
const firstSegment = window.location.pathname
|
const firstSegment = window.location.pathname
|
||||||
.split('/')
|
.split('/')
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule, isPlatformBrowser } from '@angular/common';
|
||||||
import { Component, inject, OnInit } from '@angular/core';
|
import { Component, PLATFORM_ID, inject, OnInit } from '@angular/core';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import {
|
import {
|
||||||
AdminContactRequest,
|
AdminContactRequest,
|
||||||
@@ -17,6 +17,7 @@ import { CopyOnClickDirective } from '../../../shared/directives/copy-on-click.d
|
|||||||
styleUrl: './admin-contact-requests.component.scss',
|
styleUrl: './admin-contact-requests.component.scss',
|
||||||
})
|
})
|
||||||
export class AdminContactRequestsComponent implements OnInit {
|
export class AdminContactRequestsComponent implements OnInit {
|
||||||
|
private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
||||||
private readonly adminOperationsService = inject(AdminOperationsService);
|
private readonly adminOperationsService = inject(AdminOperationsService);
|
||||||
|
|
||||||
readonly statusOptions = ['NEW', 'PENDING', 'IN_PROGRESS', 'DONE', 'CLOSED'];
|
readonly statusOptions = ['NEW', 'PENDING', 'IN_PROGRESS', 'DONE', 'CLOSED'];
|
||||||
@@ -171,6 +172,9 @@ export class AdminContactRequestsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private downloadBlob(blob: Blob, filename: string): void {
|
private downloadBlob(blob: Blob, filename: string): void {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const url = window.URL.createObjectURL(blob);
|
const url = window.URL.createObjectURL(blob);
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.href = url;
|
a.href = url;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule, isPlatformBrowser } from '@angular/common';
|
||||||
import { Component, inject, OnInit } from '@angular/core';
|
import { Component, PLATFORM_ID, inject, OnInit } from '@angular/core';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import {
|
import {
|
||||||
AdminOrder,
|
AdminOrder,
|
||||||
@@ -16,6 +16,7 @@ import { CopyOnClickDirective } from '../../../shared/directives/copy-on-click.d
|
|||||||
styleUrl: './admin-dashboard.component.scss',
|
styleUrl: './admin-dashboard.component.scss',
|
||||||
})
|
})
|
||||||
export class AdminDashboardComponent implements OnInit {
|
export class AdminDashboardComponent implements OnInit {
|
||||||
|
private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
||||||
private readonly adminOrdersService = inject(AdminOrdersService);
|
private readonly adminOrdersService = inject(AdminOrdersService);
|
||||||
|
|
||||||
orders: AdminOrder[] = [];
|
orders: AdminOrder[] = [];
|
||||||
@@ -498,6 +499,9 @@ export class AdminDashboardComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private downloadBlob(blob: Blob, filename: string): void {
|
private downloadBlob(blob: Blob, filename: string): void {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const url = window.URL.createObjectURL(blob);
|
const url = window.URL.createObjectURL(blob);
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.href = url;
|
a.href = url;
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule, isPlatformBrowser } from '@angular/common';
|
||||||
import { Component, inject, OnDestroy, OnInit } from '@angular/core';
|
import {
|
||||||
|
Component,
|
||||||
|
PLATFORM_ID,
|
||||||
|
inject,
|
||||||
|
OnDestroy,
|
||||||
|
OnInit,
|
||||||
|
} from '@angular/core';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { of, switchMap } from 'rxjs';
|
import { of, switchMap } from 'rxjs';
|
||||||
import {
|
import {
|
||||||
@@ -85,6 +91,7 @@ const MEDIA_LANGUAGE_LABELS: Readonly<Record<AdminMediaLanguage, string>> = {
|
|||||||
styleUrl: './admin-home-media.component.scss',
|
styleUrl: './admin-home-media.component.scss',
|
||||||
})
|
})
|
||||||
export class AdminHomeMediaComponent implements OnInit, OnDestroy {
|
export class AdminHomeMediaComponent implements OnInit, OnDestroy {
|
||||||
|
private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
||||||
private readonly adminMediaService = inject(AdminMediaService);
|
private readonly adminMediaService = inject(AdminMediaService);
|
||||||
readonly mediaLanguages = SUPPORTED_MEDIA_LANGUAGES;
|
readonly mediaLanguages = SUPPORTED_MEDIA_LANGUAGES;
|
||||||
readonly mediaLanguageLabels = MEDIA_LANGUAGE_LABELS;
|
readonly mediaLanguageLabels = MEDIA_LANGUAGE_LABELS;
|
||||||
@@ -243,7 +250,8 @@ export class AdminHomeMediaComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
this.revokePreviewUrl(formState.previewUrl);
|
this.revokePreviewUrl(formState.previewUrl);
|
||||||
formState.file = file;
|
formState.file = file;
|
||||||
formState.previewUrl = file ? URL.createObjectURL(file) : null;
|
formState.previewUrl =
|
||||||
|
file && this.isBrowser ? URL.createObjectURL(file) : null;
|
||||||
|
|
||||||
if (file && this.areAllTitlesBlank(formState.translations)) {
|
if (file && this.areAllTitlesBlank(formState.translations)) {
|
||||||
const nextTitle = this.deriveDefaultTitle(file.name);
|
const nextTitle = this.deriveDefaultTitle(file.name);
|
||||||
@@ -583,6 +591,9 @@ export class AdminHomeMediaComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private revokePreviewUrl(previewUrl: string | null): void {
|
private revokePreviewUrl(previewUrl: string | null): void {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!previewUrl?.startsWith('blob:')) {
|
if (!previewUrl?.startsWith('blob:')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule, isPlatformBrowser } from '@angular/common';
|
||||||
import { Component, inject, OnInit } from '@angular/core';
|
import { Component, PLATFORM_ID, inject, OnInit } from '@angular/core';
|
||||||
import {
|
import {
|
||||||
AdminOperationsService,
|
AdminOperationsService,
|
||||||
AdminQuoteSession,
|
AdminQuoteSession,
|
||||||
@@ -15,6 +15,7 @@ import { CopyOnClickDirective } from '../../../shared/directives/copy-on-click.d
|
|||||||
styleUrl: './admin-sessions.component.scss',
|
styleUrl: './admin-sessions.component.scss',
|
||||||
})
|
})
|
||||||
export class AdminSessionsComponent implements OnInit {
|
export class AdminSessionsComponent implements OnInit {
|
||||||
|
private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
||||||
private readonly adminOperationsService = inject(AdminOperationsService);
|
private readonly adminOperationsService = inject(AdminOperationsService);
|
||||||
|
|
||||||
sessions: AdminQuoteSession[] = [];
|
sessions: AdminQuoteSession[] = [];
|
||||||
@@ -51,7 +52,9 @@ export class AdminSessionsComponent implements OnInit {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmed = window.confirm(
|
const confirmed =
|
||||||
|
this.isBrowser &&
|
||||||
|
window.confirm(
|
||||||
`Vuoi eliminare la sessione ${session.id}? Questa azione non si puo annullare.`,
|
`Vuoi eliminare la sessione ${session.id}? Questa azione non si puo annullare.`,
|
||||||
);
|
);
|
||||||
if (!confirmed) {
|
if (!confirmed) {
|
||||||
|
|||||||
@@ -878,6 +878,7 @@
|
|||||||
class="ui-form-control"
|
class="ui-form-control"
|
||||||
[(ngModel)]="material.materialCode"
|
[(ngModel)]="material.materialCode"
|
||||||
[name]="'material-code-' + index"
|
[name]="'material-code-' + index"
|
||||||
|
(ngModelChange)="onMaterialCodeChange(index, $event)"
|
||||||
>
|
>
|
||||||
<option [ngValue]="''" disabled>Seleziona materiale</option>
|
<option [ngValue]="''" disabled>Seleziona materiale</option>
|
||||||
<option
|
<option
|
||||||
@@ -915,6 +916,28 @@
|
|||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
<label class="ui-form-field" *ngIf="material.isDefault">
|
||||||
|
<span class="ui-form-caption">Colore default</span>
|
||||||
|
<select
|
||||||
|
class="ui-form-control"
|
||||||
|
[(ngModel)]="material.defaultColorKey"
|
||||||
|
[name]="'material-default-color-' + index"
|
||||||
|
[disabled]="materialColorCount(material.materialCode) === 0"
|
||||||
|
>
|
||||||
|
<option [ngValue]="''" disabled>
|
||||||
|
Seleziona colore default
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
*ngFor="
|
||||||
|
let option of materialColorOptions(material.materialCode)
|
||||||
|
"
|
||||||
|
[ngValue]="option.key"
|
||||||
|
>
|
||||||
|
{{ option.label }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
|
||||||
<div class="toggle-row toggle-row--compact">
|
<div class="toggle-row toggle-row--compact">
|
||||||
<label class="ui-checkbox">
|
<label class="ui-checkbox">
|
||||||
<input
|
<input
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule, DOCUMENT, isPlatformBrowser } from '@angular/common';
|
||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
ElementRef,
|
ElementRef,
|
||||||
HostListener,
|
HostListener,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
OnInit,
|
OnInit,
|
||||||
|
PLATFORM_ID,
|
||||||
ViewChild,
|
ViewChild,
|
||||||
inject,
|
inject,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
@@ -53,6 +54,7 @@ interface CategoryFormState {
|
|||||||
|
|
||||||
interface ProductMaterialFormState {
|
interface ProductMaterialFormState {
|
||||||
materialCode: string;
|
materialCode: string;
|
||||||
|
defaultColorKey: string;
|
||||||
priceChf: string;
|
priceChf: string;
|
||||||
isDefault: boolean;
|
isDefault: boolean;
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
@@ -138,6 +140,9 @@ const RICH_TEXT_ALLOWED_TAGS = new Set([
|
|||||||
styleUrl: './admin-shop.component.scss',
|
styleUrl: './admin-shop.component.scss',
|
||||||
})
|
})
|
||||||
export class AdminShopComponent implements OnInit, OnDestroy {
|
export class AdminShopComponent implements OnInit, OnDestroy {
|
||||||
|
private readonly platformId = inject(PLATFORM_ID);
|
||||||
|
private readonly isBrowser = isPlatformBrowser(this.platformId);
|
||||||
|
private readonly documentRef = inject(DOCUMENT);
|
||||||
private readonly adminShopService = inject(AdminShopService);
|
private readonly adminShopService = inject(AdminShopService);
|
||||||
private readonly adminOperationsService = inject(AdminOperationsService);
|
private readonly adminOperationsService = inject(AdminOperationsService);
|
||||||
private descriptionEditorElement: HTMLDivElement | null = null;
|
private descriptionEditorElement: HTMLDivElement | null = null;
|
||||||
@@ -200,12 +205,14 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.revokeImagePreviewUrl(this.imageUploadState.previewUrl);
|
this.revokeImagePreviewUrl(this.imageUploadState.previewUrl);
|
||||||
document.body.style.removeProperty('cursor');
|
if (this.isBrowser) {
|
||||||
|
this.documentRef.body?.style.removeProperty('cursor');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@HostListener('window:pointermove', ['$event'])
|
@HostListener('window:pointermove', ['$event'])
|
||||||
onWindowPointerMove(event: PointerEvent): void {
|
onWindowPointerMove(event: PointerEvent): void {
|
||||||
if (!this.isResizingPanels) {
|
if (!this.isBrowser || !this.isResizingPanels) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.updateListPanelWidthFromPointer(event.clientX);
|
this.updateListPanelWidthFromPointer(event.clientX);
|
||||||
@@ -214,11 +221,13 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
@HostListener('window:pointerup')
|
@HostListener('window:pointerup')
|
||||||
@HostListener('window:pointercancel')
|
@HostListener('window:pointercancel')
|
||||||
onWindowPointerUp(): void {
|
onWindowPointerUp(): void {
|
||||||
if (!this.isResizingPanels) {
|
if (!this.isBrowser || !this.isResizingPanels) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.isResizingPanels = false;
|
this.isResizingPanels = false;
|
||||||
document.body.style.cursor = '';
|
if (this.documentRef.body) {
|
||||||
|
this.documentRef.body.style.cursor = '';
|
||||||
|
}
|
||||||
this.persistListPanelWidth();
|
this.persistListPanelWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,7 +377,7 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!window.confirm(
|
!this.confirmBrowser(
|
||||||
"Eliminare questo prodotto? L'azione non puo essere annullata.",
|
"Eliminare questo prodotto? L'azione non puo essere annullata.",
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
@@ -412,12 +421,14 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
startPanelResize(event: PointerEvent): void {
|
startPanelResize(event: PointerEvent): void {
|
||||||
if (window.innerWidth <= 1060) {
|
if (!this.isBrowser || window.innerWidth <= 1060) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.isResizingPanels = true;
|
this.isResizingPanels = true;
|
||||||
document.body.style.cursor = 'col-resize';
|
if (this.documentRef.body) {
|
||||||
|
this.documentRef.body.style.cursor = 'col-resize';
|
||||||
|
}
|
||||||
this.updateListPanelWidthFromPointer(event.clientX);
|
this.updateListPanelWidthFromPointer(event.clientX);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,7 +518,7 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!window.confirm(
|
!this.confirmBrowser(
|
||||||
'Eliminare questa categoria? Fallira se contiene sottocategorie o prodotti.',
|
'Eliminare questa categoria? Fallira se contiene sottocategorie o prodotti.',
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
@@ -642,7 +653,14 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
(_, currentIndex) => currentIndex !== index,
|
(_, currentIndex) => currentIndex !== index,
|
||||||
);
|
);
|
||||||
if (!nextMaterials.some((material) => material.isDefault)) {
|
if (!nextMaterials.some((material) => material.isDefault)) {
|
||||||
nextMaterials[0].isDefault = true;
|
nextMaterials[0] = {
|
||||||
|
...nextMaterials[0],
|
||||||
|
isDefault: true,
|
||||||
|
defaultColorKey: this.resolveMaterialDefaultColorKey(
|
||||||
|
nextMaterials[0].materialCode,
|
||||||
|
nextMaterials[0].defaultColorKey,
|
||||||
|
),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
this.productForm.materials = nextMaterials;
|
this.productForm.materials = nextMaterials;
|
||||||
}
|
}
|
||||||
@@ -652,10 +670,34 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
(material, currentIndex) => ({
|
(material, currentIndex) => ({
|
||||||
...material,
|
...material,
|
||||||
isDefault: currentIndex === index,
|
isDefault: currentIndex === index,
|
||||||
|
defaultColorKey: this.resolveMaterialDefaultColorKey(
|
||||||
|
material.materialCode,
|
||||||
|
material.defaultColorKey,
|
||||||
|
),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMaterialCodeChange(index: number, nextMaterialCode: string): void {
|
||||||
|
const normalizedMaterialCode = nextMaterialCode.trim().toUpperCase();
|
||||||
|
this.productForm.materials = this.productForm.materials.map(
|
||||||
|
(material, currentIndex) => {
|
||||||
|
if (currentIndex !== index) {
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...material,
|
||||||
|
materialCode: normalizedMaterialCode,
|
||||||
|
defaultColorKey: this.resolveMaterialDefaultColorKey(
|
||||||
|
normalizedMaterialCode,
|
||||||
|
material.defaultColorKey,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
availableMaterialChoices(currentMaterialCode: string): string[] {
|
availableMaterialChoices(currentMaterialCode: string): string[] {
|
||||||
const normalizedCurrentMaterialCode = currentMaterialCode
|
const normalizedCurrentMaterialCode = currentMaterialCode
|
||||||
.trim()
|
.trim()
|
||||||
@@ -693,6 +735,22 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
.slice(0, 6);
|
.slice(0, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
materialColorOptions(
|
||||||
|
materialCode: string,
|
||||||
|
): Array<{ key: string; label: string }> {
|
||||||
|
const normalizedMaterialCode = materialCode.trim().toUpperCase();
|
||||||
|
return this.stockVariantsForMaterial(normalizedMaterialCode).map(
|
||||||
|
(variant) => ({
|
||||||
|
key: this.variantKey(
|
||||||
|
normalizedMaterialCode,
|
||||||
|
variant.colorName,
|
||||||
|
variant.colorHex,
|
||||||
|
),
|
||||||
|
label: this.stockVariantLabel(variant),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
onModelFileSelected(event: Event): void {
|
onModelFileSelected(event: Event): void {
|
||||||
const input = event.target as HTMLInputElement | null;
|
const input = event.target as HTMLInputElement | null;
|
||||||
const file = input?.files?.[0] ?? null;
|
const file = input?.files?.[0] ?? null;
|
||||||
@@ -759,9 +817,7 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (!this.confirmBrowser('Rimuovere il modello 3D associato a questo prodotto?')) {
|
||||||
!window.confirm('Rimuovere il modello 3D associato a questo prodotto?')
|
|
||||||
) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -832,7 +888,7 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
this.imageUploadState = {
|
this.imageUploadState = {
|
||||||
...this.imageUploadState,
|
...this.imageUploadState,
|
||||||
file,
|
file,
|
||||||
previewUrl: URL.createObjectURL(file),
|
previewUrl: this.isBrowser ? URL.createObjectURL(file) : null,
|
||||||
translations: nextTranslations,
|
translations: nextTranslations,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1008,7 +1064,7 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!window.confirm('Rimuovere questa immagine dal prodotto?')) {
|
if (!this.confirmBrowser('Rimuovere questa immagine dal prodotto?')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1120,6 +1176,9 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private restoreListPanelWidth(): void {
|
private restoreListPanelWidth(): void {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const storedValue = window.localStorage.getItem(
|
const storedValue = window.localStorage.getItem(
|
||||||
SHOP_LIST_PANEL_WIDTH_STORAGE_KEY,
|
SHOP_LIST_PANEL_WIDTH_STORAGE_KEY,
|
||||||
);
|
);
|
||||||
@@ -1134,6 +1193,9 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private persistListPanelWidth(): void {
|
private persistListPanelWidth(): void {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
window.localStorage.setItem(
|
window.localStorage.setItem(
|
||||||
SHOP_LIST_PANEL_WIDTH_STORAGE_KEY,
|
SHOP_LIST_PANEL_WIDTH_STORAGE_KEY,
|
||||||
String(this.listPanelWidthPercent),
|
String(this.listPanelWidthPercent),
|
||||||
@@ -1282,6 +1344,7 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
): ProductMaterialFormState {
|
): ProductMaterialFormState {
|
||||||
return {
|
return {
|
||||||
materialCode,
|
materialCode,
|
||||||
|
defaultColorKey: this.resolveMaterialDefaultColorKey(materialCode),
|
||||||
priceChf: '0.00',
|
priceChf: '0.00',
|
||||||
isDefault,
|
isDefault,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
@@ -1361,8 +1424,21 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
(left, right) => (left.sortOrder ?? 0) - (right.sortOrder ?? 0),
|
(left, right) => (left.sortOrder ?? 0) - (right.sortOrder ?? 0),
|
||||||
);
|
);
|
||||||
const firstVariant = sortedVariants[0];
|
const firstVariant = sortedVariants[0];
|
||||||
|
const defaultVariantForMaterial =
|
||||||
|
materialVariants.find((variant) => variant.isDefault) ?? null;
|
||||||
|
const persistedDefaultColorKey = defaultVariantForMaterial
|
||||||
|
? this.variantKey(
|
||||||
|
materialCode,
|
||||||
|
defaultVariantForMaterial.colorName,
|
||||||
|
defaultVariantForMaterial.colorHex,
|
||||||
|
)
|
||||||
|
: null;
|
||||||
return {
|
return {
|
||||||
materialCode,
|
materialCode,
|
||||||
|
defaultColorKey: this.resolveMaterialDefaultColorKey(
|
||||||
|
materialCode,
|
||||||
|
persistedDefaultColorKey,
|
||||||
|
),
|
||||||
priceChf: Number(firstVariant?.priceChf ?? 0).toFixed(2),
|
priceChf: Number(firstVariant?.priceChf ?? 0).toFixed(2),
|
||||||
isDefault: materialVariants.some((variant) => variant.isDefault),
|
isDefault: materialVariants.some((variant) => variant.isDefault),
|
||||||
isActive: materialVariants.some((variant) => variant.isActive),
|
isActive: materialVariants.some((variant) => variant.isActive),
|
||||||
@@ -1494,9 +1570,6 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private buildVariantsFromMaterials(): AdminUpsertShopProductVariantPayload[] {
|
private buildVariantsFromMaterials(): AdminUpsertShopProductVariantPayload[] {
|
||||||
const persistedDefaultVariant = this.selectedProduct?.variants.find(
|
|
||||||
(variant) => variant.isDefault,
|
|
||||||
);
|
|
||||||
const existingVariantsByKey = new Map(
|
const existingVariantsByKey = new Map(
|
||||||
(this.selectedProduct?.variants ?? []).map((variant) => [
|
(this.selectedProduct?.variants ?? []).map((variant) => [
|
||||||
this.variantKey(
|
this.variantKey(
|
||||||
@@ -1507,14 +1580,6 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
variant,
|
variant,
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
const persistedDefaultKey = persistedDefaultVariant
|
|
||||||
? this.variantKey(
|
|
||||||
persistedDefaultVariant.internalMaterialCode,
|
|
||||||
persistedDefaultVariant.colorName,
|
|
||||||
persistedDefaultVariant.colorHex,
|
|
||||||
)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const variants: AdminUpsertShopProductVariantPayload[] = [];
|
const variants: AdminUpsertShopProductVariantPayload[] = [];
|
||||||
let defaultAssigned = false;
|
let defaultAssigned = false;
|
||||||
|
|
||||||
@@ -1525,20 +1590,10 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
for (const material of sortedMaterials) {
|
for (const material of sortedMaterials) {
|
||||||
const materialCode = material.materialCode.trim().toUpperCase();
|
const materialCode = material.materialCode.trim().toUpperCase();
|
||||||
const stockVariants = this.stockVariantsForMaterial(materialCode);
|
const stockVariants = this.stockVariantsForMaterial(materialCode);
|
||||||
let defaultVariantKeyForMaterial: string | null = null;
|
const selectedDefaultColorKey = this.resolveMaterialDefaultColorKey(
|
||||||
|
|
||||||
if (material.isDefault && persistedDefaultKey) {
|
|
||||||
defaultVariantKeyForMaterial =
|
|
||||||
stockVariants
|
|
||||||
.map((variant) =>
|
|
||||||
this.variantKey(
|
|
||||||
materialCode,
|
materialCode,
|
||||||
variant.colorName,
|
material.defaultColorKey,
|
||||||
variant.colorHex,
|
);
|
||||||
),
|
|
||||||
)
|
|
||||||
.find((variantKey) => variantKey === persistedDefaultKey) ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
stockVariants.forEach((stockVariant, colorIndex) => {
|
stockVariants.forEach((stockVariant, colorIndex) => {
|
||||||
const variantKey = this.variantKey(
|
const variantKey = this.variantKey(
|
||||||
@@ -1550,9 +1605,7 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
const isDefault =
|
const isDefault =
|
||||||
material.isDefault &&
|
material.isDefault &&
|
||||||
!defaultAssigned &&
|
!defaultAssigned &&
|
||||||
(defaultVariantKeyForMaterial
|
variantKey === selectedDefaultColorKey;
|
||||||
? variantKey === defaultVariantKeyForMaterial
|
|
||||||
: colorIndex === 0);
|
|
||||||
|
|
||||||
variants.push({
|
variants.push({
|
||||||
id: existingVariant?.id,
|
id: existingVariant?.id,
|
||||||
@@ -1623,6 +1676,51 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private resolveMaterialDefaultColorKey(
|
||||||
|
materialCode: string,
|
||||||
|
preferredKey?: string | null,
|
||||||
|
): string {
|
||||||
|
const normalizedMaterialCode = materialCode.trim().toUpperCase();
|
||||||
|
const stockVariants = this.stockVariantsForMaterial(normalizedMaterialCode);
|
||||||
|
if (stockVariants.length === 0) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const normalizedPreferredKey = (preferredKey ?? '').trim();
|
||||||
|
if (
|
||||||
|
normalizedPreferredKey &&
|
||||||
|
stockVariants.some(
|
||||||
|
(variant) =>
|
||||||
|
this.variantKey(
|
||||||
|
normalizedMaterialCode,
|
||||||
|
variant.colorName,
|
||||||
|
variant.colorHex,
|
||||||
|
) === normalizedPreferredKey,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return normalizedPreferredKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
const firstVariant = stockVariants[0];
|
||||||
|
return this.variantKey(
|
||||||
|
normalizedMaterialCode,
|
||||||
|
firstVariant.colorName,
|
||||||
|
firstVariant.colorHex,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private stockVariantLabel(variant: AdminFilamentVariant): string {
|
||||||
|
const colorName = variant.colorName.trim();
|
||||||
|
const variantDisplayName = variant.variantDisplayName.trim();
|
||||||
|
if (
|
||||||
|
variantDisplayName &&
|
||||||
|
variantDisplayName.toLowerCase() !== colorName.toLowerCase()
|
||||||
|
) {
|
||||||
|
return `${colorName} (${variantDisplayName})`;
|
||||||
|
}
|
||||||
|
return colorName;
|
||||||
|
}
|
||||||
|
|
||||||
private nextAvailableMaterialCode(): string | null {
|
private nextAvailableMaterialCode(): string | null {
|
||||||
const selectedCodes = new Set(
|
const selectedCodes = new Set(
|
||||||
this.productForm.materials
|
this.productForm.materials
|
||||||
@@ -1741,6 +1839,9 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private revokeImagePreviewUrl(previewUrl: string | null): void {
|
private revokeImagePreviewUrl(previewUrl: string | null): void {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (previewUrl?.startsWith('blob:')) {
|
if (previewUrl?.startsWith('blob:')) {
|
||||||
URL.revokeObjectURL(previewUrl);
|
URL.revokeObjectURL(previewUrl);
|
||||||
}
|
}
|
||||||
@@ -1863,12 +1964,15 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private applyDescriptionExecCommand(command: string): void {
|
private applyDescriptionExecCommand(command: string): void {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const editor = this.descriptionEditorElement;
|
const editor = this.descriptionEditorElement;
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
editor.focus();
|
editor.focus();
|
||||||
document.execCommand(command, false);
|
this.documentRef.execCommand(command, false);
|
||||||
this.syncDescriptionFromEditor(editor, false);
|
this.syncDescriptionFromEditor(editor, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1912,6 +2016,10 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private sanitizeRichTextHtml(value: string): string {
|
private sanitizeRichTextHtml(value: string): string {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return this.stripPotentiallyUnsafeHtml(value);
|
||||||
|
}
|
||||||
|
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
const sourceDocument = parser.parseFromString(
|
const sourceDocument = parser.parseFromString(
|
||||||
`<body>${value}</body>`,
|
`<body>${value}</body>`,
|
||||||
@@ -2017,12 +2125,18 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private extractTextFromHtml(value: string): string {
|
private extractTextFromHtml(value: string): string {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return value.replace(/<[^>]+>/g, ' ');
|
||||||
|
}
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
const parsed = parser.parseFromString(`<body>${value}</body>`, 'text/html');
|
const parsed = parser.parseFromString(`<body>${value}</body>`, 'text/html');
|
||||||
return parsed.body.textContent ?? '';
|
return parsed.body.textContent ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
private serializeNodeChildren(node: Node): string {
|
private serializeNodeChildren(node: Node): string {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return node.textContent ?? '';
|
||||||
|
}
|
||||||
const serializer = new XMLSerializer();
|
const serializer = new XMLSerializer();
|
||||||
let html = '';
|
let html = '';
|
||||||
for (const child of Array.from(node.childNodes)) {
|
for (const child of Array.from(node.childNodes)) {
|
||||||
@@ -2035,6 +2149,10 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
element: HTMLElement,
|
element: HTMLElement,
|
||||||
html: string,
|
html: string,
|
||||||
): void {
|
): void {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!html) {
|
if (!html) {
|
||||||
element.replaceChildren();
|
element.replaceChildren();
|
||||||
return;
|
return;
|
||||||
@@ -2043,11 +2161,21 @@ export class AdminShopComponent implements OnInit, OnDestroy {
|
|||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
const parsed = parser.parseFromString(`<body>${html}</body>`, 'text/html');
|
const parsed = parser.parseFromString(`<body>${html}</body>`, 'text/html');
|
||||||
const nodes = Array.from(parsed.body.childNodes).map((child) =>
|
const nodes = Array.from(parsed.body.childNodes).map((child) =>
|
||||||
document.importNode(child, true),
|
this.documentRef.importNode(child, true),
|
||||||
);
|
);
|
||||||
element.replaceChildren(...nodes);
|
element.replaceChildren(...nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private confirmBrowser(message: string): boolean {
|
||||||
|
return this.isBrowser ? window.confirm(message) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private stripPotentiallyUnsafeHtml(value: string): string {
|
||||||
|
return value
|
||||||
|
.replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi, '')
|
||||||
|
.replace(/<style[\s\S]*?>[\s\S]*?<\/style>/gi, '');
|
||||||
|
}
|
||||||
|
|
||||||
private escapeHtml(value: string): string {
|
private escapeHtml(value: string): string {
|
||||||
return value
|
return value
|
||||||
.replace(/&/g, '&')
|
.replace(/&/g, '&')
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ import {
|
|||||||
ViewChild,
|
ViewChild,
|
||||||
ElementRef,
|
ElementRef,
|
||||||
OnInit,
|
OnInit,
|
||||||
|
PLATFORM_ID,
|
||||||
|
inject,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule, isPlatformBrowser } from '@angular/common';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { forkJoin, of } from 'rxjs';
|
import { forkJoin, of } from 'rxjs';
|
||||||
import { catchError, map } from 'rxjs/operators';
|
import { catchError, map } from 'rxjs/operators';
|
||||||
@@ -53,6 +55,7 @@ type TrackedPrintSettings = {
|
|||||||
styleUrl: './calculator-page.component.scss',
|
styleUrl: './calculator-page.component.scss',
|
||||||
})
|
})
|
||||||
export class CalculatorPageComponent implements OnInit {
|
export class CalculatorPageComponent implements OnInit {
|
||||||
|
private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
||||||
mode = signal<'easy' | 'advanced'>('easy');
|
mode = signal<'easy' | 'advanced'>('easy');
|
||||||
step = signal<'upload' | 'quote' | 'details' | 'success'>('upload');
|
step = signal<'upload' | 'quote' | 'details' | 'success'>('upload');
|
||||||
|
|
||||||
@@ -260,7 +263,7 @@ export class CalculatorPageComponent implements OnInit {
|
|||||||
|
|
||||||
// Auto-scroll on mobile to make analysis visible
|
// Auto-scroll on mobile to make analysis visible
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this.resultCol && window.innerWidth < 768) {
|
if (this.isBrowser && this.resultCol && window.innerWidth < 768) {
|
||||||
this.resultCol.nativeElement.scrollIntoView({
|
this.resultCol.nativeElement.scrollIntoView({
|
||||||
behavior: 'smooth',
|
behavior: 'smooth',
|
||||||
block: 'start',
|
block: 'start',
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
import { Component, signal, effect, inject, OnDestroy } from '@angular/core';
|
import {
|
||||||
import { CommonModule } from '@angular/common';
|
Component,
|
||||||
|
signal,
|
||||||
|
effect,
|
||||||
|
inject,
|
||||||
|
OnDestroy,
|
||||||
|
PLATFORM_ID,
|
||||||
|
} from '@angular/core';
|
||||||
|
import { CommonModule, isPlatformBrowser } from '@angular/common';
|
||||||
import {
|
import {
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
FormBuilder,
|
FormBuilder,
|
||||||
@@ -16,6 +23,7 @@ import {
|
|||||||
import { QuoteEstimatorService } from '../../../calculator/services/quote-estimator.service';
|
import { QuoteEstimatorService } from '../../../calculator/services/quote-estimator.service';
|
||||||
import { QuoteRequestService } from '../../../../core/services/quote-request.service';
|
import { QuoteRequestService } from '../../../../core/services/quote-request.service';
|
||||||
import { LanguageService } from '../../../../core/services/language.service';
|
import { LanguageService } from '../../../../core/services/language.service';
|
||||||
|
import { SuccessStateComponent } from '../../../../shared/components/success-state/success-state.component';
|
||||||
|
|
||||||
interface FilePreview {
|
interface FilePreview {
|
||||||
file: File;
|
file: File;
|
||||||
@@ -23,8 +31,6 @@ interface FilePreview {
|
|||||||
type: 'image' | 'video' | 'pdf' | '3d' | 'document' | 'other';
|
type: 'image' | 'video' | 'pdf' | '3d' | 'document' | 'other';
|
||||||
}
|
}
|
||||||
|
|
||||||
import { SuccessStateComponent } from '../../../../shared/components/success-state/success-state.component';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-contact-form',
|
selector: 'app-contact-form',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
@@ -41,6 +47,7 @@ import { SuccessStateComponent } from '../../../../shared/components/success-sta
|
|||||||
styleUrl: './contact-form.component.scss',
|
styleUrl: './contact-form.component.scss',
|
||||||
})
|
})
|
||||||
export class ContactFormComponent implements OnDestroy {
|
export class ContactFormComponent implements OnDestroy {
|
||||||
|
private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
||||||
form: FormGroup;
|
form: FormGroup;
|
||||||
sent = signal(false);
|
sent = signal(false);
|
||||||
files = signal<FilePreview[]>([]);
|
files = signal<FilePreview[]>([]);
|
||||||
@@ -127,7 +134,7 @@ export class ContactFormComponent implements OnDestroy {
|
|||||||
return {
|
return {
|
||||||
file: f,
|
file: f,
|
||||||
type,
|
type,
|
||||||
url: this.shouldCreatePreview(type)
|
url: this.isBrowser && this.shouldCreatePreview(type)
|
||||||
? URL.createObjectURL(f)
|
? URL.createObjectURL(f)
|
||||||
: undefined,
|
: undefined,
|
||||||
};
|
};
|
||||||
@@ -185,7 +192,7 @@ export class ContactFormComponent implements OnDestroy {
|
|||||||
const preview: FilePreview = {
|
const preview: FilePreview = {
|
||||||
file,
|
file,
|
||||||
type,
|
type,
|
||||||
url: this.shouldCreatePreview(type)
|
url: this.isBrowser && this.shouldCreatePreview(type)
|
||||||
? URL.createObjectURL(file)
|
? URL.createObjectURL(file)
|
||||||
: undefined,
|
: undefined,
|
||||||
};
|
};
|
||||||
@@ -354,6 +361,9 @@ export class ContactFormComponent implements OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private revokePreviewUrl(file: FilePreview): void {
|
private revokePreviewUrl(file: FilePreview): void {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (file.url?.startsWith('blob:')) {
|
if (file.url?.startsWith('blob:')) {
|
||||||
URL.revokeObjectURL(file.url);
|
URL.revokeObjectURL(file.url);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Component, OnInit, inject, signal } from '@angular/core';
|
import { Component, OnInit, PLATFORM_ID, inject, signal } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule, isPlatformBrowser } from '@angular/common';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { AppButtonComponent } from '../../shared/components/app-button/app-button.component';
|
import { AppButtonComponent } from '../../shared/components/app-button/app-button.component';
|
||||||
import { AppCardComponent } from '../../shared/components/app-card/app-card.component';
|
import { AppCardComponent } from '../../shared/components/app-card/app-card.component';
|
||||||
@@ -75,6 +75,7 @@ export class OrderComponent implements OnInit {
|
|||||||
private router = inject(Router);
|
private router = inject(Router);
|
||||||
private quoteService = inject(QuoteEstimatorService);
|
private quoteService = inject(QuoteEstimatorService);
|
||||||
private translate = inject(TranslateService);
|
private translate = inject(TranslateService);
|
||||||
|
private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
||||||
|
|
||||||
orderId: string | null = null;
|
orderId: string | null = null;
|
||||||
selectedPaymentMethod: 'twint' | 'bill' | null = 'twint';
|
selectedPaymentMethod: 'twint' | 'bill' | null = 'twint';
|
||||||
@@ -115,6 +116,9 @@ export class OrderComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
downloadQrInvoice() {
|
downloadQrInvoice() {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const orderId = this.orderId;
|
const orderId = this.orderId;
|
||||||
if (!orderId) return;
|
if (!orderId) return;
|
||||||
this.quoteService.getOrderConfirmation(orderId).subscribe({
|
this.quoteService.getOrderConfirmation(orderId).subscribe({
|
||||||
@@ -153,7 +157,7 @@ export class OrderComponent implements OnInit {
|
|||||||
|
|
||||||
openTwintPayment(): void {
|
openTwintPayment(): void {
|
||||||
const openUrl = this.twintOpenUrl();
|
const openUrl = this.twintOpenUrl();
|
||||||
if (typeof window !== 'undefined' && openUrl) {
|
if (this.isBrowser && openUrl) {
|
||||||
window.open(openUrl, '_blank');
|
window.open(openUrl, '_blank');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule, isPlatformBrowser } from '@angular/common';
|
||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
DestroyRef,
|
DestroyRef,
|
||||||
Injector,
|
Injector,
|
||||||
|
PLATFORM_ID,
|
||||||
computed,
|
computed,
|
||||||
inject,
|
inject,
|
||||||
input,
|
input,
|
||||||
@@ -62,6 +63,7 @@ export class ProductDetailComponent {
|
|||||||
private readonly seoService = inject(SeoService);
|
private readonly seoService = inject(SeoService);
|
||||||
private readonly languageService = inject(LanguageService);
|
private readonly languageService = inject(LanguageService);
|
||||||
private readonly shopRouteService = inject(ShopRouteService);
|
private readonly shopRouteService = inject(ShopRouteService);
|
||||||
|
private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
||||||
readonly shopService = inject(ShopService);
|
readonly shopService = inject(ShopService);
|
||||||
|
|
||||||
readonly categorySlug = input<string | undefined>();
|
readonly categorySlug = input<string | undefined>();
|
||||||
@@ -444,7 +446,7 @@ export class ProductDetailComponent {
|
|||||||
|
|
||||||
goBackToShop(): void {
|
goBackToShop(): void {
|
||||||
const returnUrl =
|
const returnUrl =
|
||||||
typeof history.state?.shopReturnUrl === 'string'
|
this.isBrowser && typeof history.state?.shopReturnUrl === 'string'
|
||||||
? history.state.shopReturnUrl
|
? history.state.shopReturnUrl
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
@@ -671,6 +673,15 @@ export class ProductDetailComponent {
|
|||||||
if (!this.containsHtmlMarkup(normalized)) {
|
if (!this.containsHtmlMarkup(normalized)) {
|
||||||
return normalized;
|
return normalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
const text = normalized
|
||||||
|
.replace(/<[^>]+>/g, ' ')
|
||||||
|
.replace(/\s+/g, ' ')
|
||||||
|
.trim();
|
||||||
|
return text || null;
|
||||||
|
}
|
||||||
|
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
const parsed = parser.parseFromString(
|
const parsed = parser.parseFromString(
|
||||||
`<body>${normalized}</body>`,
|
`<body>${normalized}</body>`,
|
||||||
@@ -694,6 +705,10 @@ export class ProductDetailComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private syncPublicUrl(product: ShopProductDetail): void {
|
private syncPublicUrl(product: ShopProductDetail): void {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const currentProductSlug = this.productSlug()?.trim().toLowerCase() ?? '';
|
const currentProductSlug = this.productSlug()?.trim().toLowerCase() ?? '';
|
||||||
const targetProductSlug = this.shopRouteService.productPathSegment(product);
|
const targetProductSlug = this.shopRouteService.productPathSegment(product);
|
||||||
if (currentProductSlug === targetProductSlug) {
|
if (currentProductSlug === targetProductSlug) {
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ import {
|
|||||||
OnChanges,
|
OnChanges,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
OnInit,
|
OnInit,
|
||||||
|
PLATFORM_ID,
|
||||||
ViewChild,
|
ViewChild,
|
||||||
SimpleChanges,
|
SimpleChanges,
|
||||||
|
inject,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule, isPlatformBrowser } from '@angular/common';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import * as THREE from 'three';
|
import * as THREE from 'three';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@@ -24,6 +26,9 @@ import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
|
|||||||
styleUrl: './stl-viewer.component.scss',
|
styleUrl: './stl-viewer.component.scss',
|
||||||
})
|
})
|
||||||
export class StlViewerComponent implements OnInit, OnDestroy, OnChanges {
|
export class StlViewerComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
|
private readonly platformId = inject(PLATFORM_ID);
|
||||||
|
private readonly isBrowser = isPlatformBrowser(this.platformId);
|
||||||
|
|
||||||
@Input() file: File | null = null;
|
@Input() file: File | null = null;
|
||||||
@Input() color: string = '#facf0a'; // Default Brand Color
|
@Input() color: string = '#facf0a'; // Default Brand Color
|
||||||
@Input() height = 300;
|
@Input() height = 300;
|
||||||
@@ -39,14 +44,22 @@ export class StlViewerComponent implements OnInit, OnDestroy, OnChanges {
|
|||||||
private animationId: number | null = null;
|
private animationId: number | null = null;
|
||||||
private currentMesh: THREE.Mesh | null = null;
|
private currentMesh: THREE.Mesh | null = null;
|
||||||
private autoRotate = true;
|
private autoRotate = true;
|
||||||
|
private resizeObserver: ResizeObserver | null = null;
|
||||||
|
|
||||||
loading = false;
|
loading = false;
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.initThree();
|
this.initThree();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (changes['file'] && this.file) {
|
if (changes['file'] && this.file) {
|
||||||
this.loadFile(this.file);
|
this.loadFile(this.file);
|
||||||
}
|
}
|
||||||
@@ -57,6 +70,9 @@ export class StlViewerComponent implements OnInit, OnDestroy, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
this.resizeObserver?.disconnect();
|
||||||
|
this.resizeObserver = null;
|
||||||
|
|
||||||
if (this.animationId) cancelAnimationFrame(this.animationId);
|
if (this.animationId) cancelAnimationFrame(this.animationId);
|
||||||
this.clearCurrentMesh();
|
this.clearCurrentMesh();
|
||||||
if (this.controls) this.controls.dispose();
|
if (this.controls) this.controls.dispose();
|
||||||
@@ -121,7 +137,7 @@ export class StlViewerComponent implements OnInit, OnDestroy, OnChanges {
|
|||||||
this.animate();
|
this.animate();
|
||||||
|
|
||||||
// Handle resize
|
// Handle resize
|
||||||
const resizeObserver = new ResizeObserver(() => {
|
this.resizeObserver = new ResizeObserver(() => {
|
||||||
if (!this.rendererContainer) return;
|
if (!this.rendererContainer) return;
|
||||||
const w = this.rendererContainer.nativeElement.clientWidth;
|
const w = this.rendererContainer.nativeElement.clientWidth;
|
||||||
const h = this.rendererContainer.nativeElement.clientHeight;
|
const h = this.rendererContainer.nativeElement.clientHeight;
|
||||||
@@ -129,7 +145,7 @@ export class StlViewerComponent implements OnInit, OnDestroy, OnChanges {
|
|||||||
this.camera.updateProjectionMatrix();
|
this.camera.updateProjectionMatrix();
|
||||||
this.renderer.setSize(w, h);
|
this.renderer.setSize(w, h);
|
||||||
});
|
});
|
||||||
resizeObserver.observe(this.rendererContainer.nativeElement);
|
this.resizeObserver.observe(this.rendererContainer.nativeElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
dimensions = { x: 0, y: 0, z: 0 };
|
dimensions = { x: 0, y: 0, z: 0 };
|
||||||
|
|||||||
@@ -1,10 +1,20 @@
|
|||||||
import { Directive, HostBinding, HostListener, Input } from '@angular/core';
|
import { isPlatformBrowser } from '@angular/common';
|
||||||
|
import {
|
||||||
|
Directive,
|
||||||
|
HostBinding,
|
||||||
|
HostListener,
|
||||||
|
Input,
|
||||||
|
PLATFORM_ID,
|
||||||
|
inject,
|
||||||
|
} from '@angular/core';
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: '[appCopyOnClick]',
|
selector: '[appCopyOnClick]',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
})
|
})
|
||||||
export class CopyOnClickDirective {
|
export class CopyOnClickDirective {
|
||||||
|
private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
||||||
|
|
||||||
@Input('appCopyOnClick') value: string | null | undefined;
|
@Input('appCopyOnClick') value: string | null | undefined;
|
||||||
|
|
||||||
@HostBinding('style.cursor') readonly cursor = 'pointer';
|
@HostBinding('style.cursor') readonly cursor = 'pointer';
|
||||||
@@ -21,6 +31,10 @@ export class CopyOnClickDirective {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async copy(text: string): Promise<void> {
|
private async copy(text: string): Promise<void> {
|
||||||
|
if (!this.isBrowser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (navigator.clipboard?.writeText) {
|
if (navigator.clipboard?.writeText) {
|
||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(text);
|
await navigator.clipboard.writeText(text);
|
||||||
|
|||||||
8
frontend/src/main.server.ts
Normal file
8
frontend/src/main.server.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { BootstrapContext, bootstrapApplication } from '@angular/platform-browser';
|
||||||
|
import { AppComponent } from './app/app.component';
|
||||||
|
import { config } from './app/app.config.server';
|
||||||
|
|
||||||
|
const bootstrap = (context: BootstrapContext) =>
|
||||||
|
bootstrapApplication(AppComponent, config, context);
|
||||||
|
|
||||||
|
export default bootstrap;
|
||||||
67
frontend/src/server.ts
Normal file
67
frontend/src/server.ts
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
import { APP_BASE_HREF } from '@angular/common';
|
||||||
|
import { CommonEngine, isMainModule } from '@angular/ssr/node';
|
||||||
|
import express from 'express';
|
||||||
|
import { dirname, join, resolve } from 'node:path';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
import bootstrap from './main.server';
|
||||||
|
|
||||||
|
const serverDistFolder = dirname(fileURLToPath(import.meta.url));
|
||||||
|
const browserDistFolder = resolve(serverDistFolder, '../browser');
|
||||||
|
const indexHtml = join(serverDistFolder, 'index.server.html');
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
const commonEngine = new CommonEngine();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example Express Rest API endpoints can be defined here.
|
||||||
|
* Uncomment and define endpoints as necessary.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* ```ts
|
||||||
|
* app.get('/api/**', (req, res) => {
|
||||||
|
* // Handle API request
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serve static files from /browser
|
||||||
|
*/
|
||||||
|
app.get(
|
||||||
|
'**',
|
||||||
|
express.static(browserDistFolder, {
|
||||||
|
maxAge: '1y',
|
||||||
|
index: false,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle all other requests by rendering the Angular application.
|
||||||
|
*/
|
||||||
|
app.get('**', (req, res, next) => {
|
||||||
|
const { protocol, originalUrl, baseUrl, headers } = req;
|
||||||
|
|
||||||
|
commonEngine
|
||||||
|
.render({
|
||||||
|
bootstrap,
|
||||||
|
documentFilePath: indexHtml,
|
||||||
|
url: `${protocol}://${headers.host}${originalUrl}`,
|
||||||
|
publicPath: browserDistFolder,
|
||||||
|
providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }],
|
||||||
|
})
|
||||||
|
.then((html) => res.send(html))
|
||||||
|
.catch((err) => next(err));
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the server if this module is the main entry point.
|
||||||
|
* The server listens on the port defined by the `PORT` environment variable, or defaults to 4000.
|
||||||
|
*/
|
||||||
|
if (isMainModule(import.meta.url)) {
|
||||||
|
const port = process.env['PORT'] || 4000;
|
||||||
|
app.listen(port, () => {
|
||||||
|
console.log(`Node Express server listening on http://localhost:${port}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default app;
|
||||||
@@ -4,10 +4,14 @@
|
|||||||
"extends": "./tsconfig.json",
|
"extends": "./tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./out-tsc/app",
|
"outDir": "./out-tsc/app",
|
||||||
"types": []
|
"types": [
|
||||||
|
"node"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"src/main.ts"
|
"src/main.ts",
|
||||||
|
"src/main.server.ts",
|
||||||
|
"src/server.ts"
|
||||||
],
|
],
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*.d.ts"
|
"src/**/*.d.ts"
|
||||||
|
|||||||
Reference in New Issue
Block a user