From f1e0af64fb43492283854376c9d14ff6e8015ca1 Mon Sep 17 00:00:00 2001 From: aziz Date: Tue, 14 Nov 2023 20:23:53 +0100 Subject: [PATCH 1/3] fix(geo): eliminate 300 ppp resolution for mobile devices --- .../lib/print/print-form/print-form.component.html | 6 +++--- .../lib/print/print-form/print-form.component.ts | 14 ++++++++++++-- packages/geo/src/lib/print/shared/print.type.ts | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/geo/src/lib/print/print-form/print-form.component.html b/packages/geo/src/lib/print/print-form/print-form.component.html index 5f0632dc68..ed1c00cf2d 100644 --- a/packages/geo/src/lib/print/print-form/print-form.component.html +++ b/packages/geo/src/lib/print/print-form/print-form.component.html @@ -191,10 +191,10 @@ placeholder="{{ 'igo.geo.printForm.resolution' | translate }}" > - {{ resolution.value }} + {{ resolution }} diff --git a/packages/geo/src/lib/print/print-form/print-form.component.ts b/packages/geo/src/lib/print/print-form/print-form.component.ts index 33bb75594d..21e745210b 100644 --- a/packages/geo/src/lib/print/print-form/print-form.component.ts +++ b/packages/geo/src/lib/print/print-form/print-form.component.ts @@ -6,6 +6,8 @@ import { Validators } from '@angular/forms'; +import { MediaService } from '@igo2/core'; + import { BehaviorSubject } from 'rxjs'; import { PrintOptions } from '../shared/print.interface'; @@ -201,8 +203,11 @@ export class PrintFormComponent implements OnInit { @Output() submit: EventEmitter = new EventEmitter(); maxLength: number = 180; - - constructor(private formBuilder: UntypedFormBuilder) { + targetResolutions: Array = Object.keys(this.resolutions); + constructor( + private formBuilder: UntypedFormBuilder, + private mediaService: MediaService + ) { this.form = this.formBuilder.group({ title: ['', [Validators.minLength(0), Validators.maxLength(130)]], subtitle: ['', [Validators.minLength(0), Validators.maxLength(120)]], @@ -225,6 +230,11 @@ export class PrintFormComponent implements OnInit { ngOnInit() { this.doZipFileField.setValue(false); + if (this.mediaService.isMobile()) { + this.targetResolutions = this.targetResolutions.filter( + (resolution) => resolution !== this.resolutions['300'] + ); + } } handleFormSubmit(data: PrintOptions, isValid: boolean) { diff --git a/packages/geo/src/lib/print/shared/print.type.ts b/packages/geo/src/lib/print/shared/print.type.ts index bed6449870..de2c26088c 100644 --- a/packages/geo/src/lib/print/shared/print.type.ts +++ b/packages/geo/src/lib/print/shared/print.type.ts @@ -19,7 +19,7 @@ export type PrintPaperFormat = keyof typeof PrintPaperFormat; export const PrintOrientation = strEnum(['landscape', 'portrait']); export type PrintOrientation = keyof typeof PrintOrientation; -export const PrintResolution = strEnum(['72', '96', '150']); // For now, we remove the 300 dpi because there is too much instability on iOS and slow device. +export const PrintResolution = strEnum(['72', '96', '150', '300']); export type PrintResolution = keyof typeof PrintResolution; export const PrintSaveImageFormat = strEnum([ From 365f36c1938384d85151047dd2bbcc5219299c14 Mon Sep 17 00:00:00 2001 From: aziz Date: Tue, 14 Nov 2023 20:55:25 +0100 Subject: [PATCH 2/3] code optimization --- .../src/lib/print/print-form/print-form.component.html | 5 +---- .../geo/src/lib/print/print-form/print-form.component.ts | 8 ++++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/geo/src/lib/print/print-form/print-form.component.html b/packages/geo/src/lib/print/print-form/print-form.component.html index ed1c00cf2d..0c648f5c3c 100644 --- a/packages/geo/src/lib/print/print-form/print-form.component.html +++ b/packages/geo/src/lib/print/print-form/print-form.component.html @@ -190,10 +190,7 @@ formControlName="resolution" placeholder="{{ 'igo.geo.printForm.resolution' | translate }}" > - + {{ resolution }} diff --git a/packages/geo/src/lib/print/print-form/print-form.component.ts b/packages/geo/src/lib/print/print-form/print-form.component.ts index 21e745210b..75834cee5a 100644 --- a/packages/geo/src/lib/print/print-form/print-form.component.ts +++ b/packages/geo/src/lib/print/print-form/print-form.component.ts @@ -30,7 +30,7 @@ export class PrintFormComponent implements OnInit { public outputFormats = PrintOutputFormat; public paperFormats = PrintPaperFormat; public orientations = PrintOrientation; - public resolutions = PrintResolution; + public resolutions: Array = Object.keys(PrintResolution); public imageFormats = PrintSaveImageFormat; public legendPositions = PrintLegendPosition; public isPrintService = true; @@ -203,7 +203,7 @@ export class PrintFormComponent implements OnInit { @Output() submit: EventEmitter = new EventEmitter(); maxLength: number = 180; - targetResolutions: Array = Object.keys(this.resolutions); + constructor( private formBuilder: UntypedFormBuilder, private mediaService: MediaService @@ -231,8 +231,8 @@ export class PrintFormComponent implements OnInit { ngOnInit() { this.doZipFileField.setValue(false); if (this.mediaService.isMobile()) { - this.targetResolutions = this.targetResolutions.filter( - (resolution) => resolution !== this.resolutions['300'] + this.resolutions = this.resolutions.filter( + (resolution) => resolution !== PrintResolution['300'] ); } } From 5743c2a44a98c1e989e00448b3aca0552a08bdec Mon Sep 17 00:00:00 2001 From: Alexandre Caron Date: Thu, 16 Nov 2023 15:17:48 -0500 Subject: [PATCH 3/3] fix(geo/print): use array instead of strEnum --- .../geo/src/lib/print/print-form/print-form.component.ts | 6 +++--- packages/geo/src/lib/print/shared/print.type.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/geo/src/lib/print/print-form/print-form.component.ts b/packages/geo/src/lib/print/print-form/print-form.component.ts index 75834cee5a..e37477248d 100644 --- a/packages/geo/src/lib/print/print-form/print-form.component.ts +++ b/packages/geo/src/lib/print/print-form/print-form.component.ts @@ -30,7 +30,7 @@ export class PrintFormComponent implements OnInit { public outputFormats = PrintOutputFormat; public paperFormats = PrintPaperFormat; public orientations = PrintOrientation; - public resolutions: Array = Object.keys(PrintResolution); + public resolutions = [...PrintResolution]; public imageFormats = PrintSaveImageFormat; public legendPositions = PrintLegendPosition; public isPrintService = true; @@ -82,7 +82,7 @@ export class PrintFormComponent implements OnInit { return this.resolutionField.value; } set resolution(value: PrintResolution) { - this.resolutionField.setValue(value || PrintResolution['96'], { + this.resolutionField.setValue(value || ('96' satisfies PrintResolution), { onlySelf: true }); } @@ -232,7 +232,7 @@ export class PrintFormComponent implements OnInit { this.doZipFileField.setValue(false); if (this.mediaService.isMobile()) { this.resolutions = this.resolutions.filter( - (resolution) => resolution !== PrintResolution['300'] + (resolution) => resolution !== '300' ); } } diff --git a/packages/geo/src/lib/print/shared/print.type.ts b/packages/geo/src/lib/print/shared/print.type.ts index de2c26088c..b0c8279928 100644 --- a/packages/geo/src/lib/print/shared/print.type.ts +++ b/packages/geo/src/lib/print/shared/print.type.ts @@ -19,8 +19,8 @@ export type PrintPaperFormat = keyof typeof PrintPaperFormat; export const PrintOrientation = strEnum(['landscape', 'portrait']); export type PrintOrientation = keyof typeof PrintOrientation; -export const PrintResolution = strEnum(['72', '96', '150', '300']); -export type PrintResolution = keyof typeof PrintResolution; +export const PrintResolution = ['72', '96', '150', '300'] as const; +export type PrintResolution = (typeof PrintResolution)[number]; export const PrintSaveImageFormat = strEnum([ 'Bmp',