Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(geo): eliminate 300 ppp resolution from mobile devices #1498

Merged
merged 3 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,8 @@
formControlName="resolution"
placeholder="{{ 'igo.geo.printForm.resolution' | translate }}"
>
<mat-option
*ngFor="let resolution of resolutions | keyvalue"
[value]="resolution.key"
>
{{ resolution.value }}
<mat-option *ngFor="let resolution of resolutions" [value]="resolution">
{{ resolution }}
</mat-option>
</mat-select>
</mat-form-field>
Expand Down
16 changes: 13 additions & 3 deletions packages/geo/src/lib/print/print-form/print-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
Validators
} from '@angular/forms';

import { MediaService } from '@igo2/core';

import { BehaviorSubject } from 'rxjs';

import { PrintOptions } from '../shared/print.interface';
Expand All @@ -28,7 +30,7 @@ export class PrintFormComponent implements OnInit {
public outputFormats = PrintOutputFormat;
public paperFormats = PrintPaperFormat;
public orientations = PrintOrientation;
public resolutions = PrintResolution;
public resolutions = [...PrintResolution];
public imageFormats = PrintSaveImageFormat;
public legendPositions = PrintLegendPosition;
public isPrintService = true;
Expand Down Expand Up @@ -80,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
});
}
Expand Down Expand Up @@ -202,7 +204,10 @@ export class PrintFormComponent implements OnInit {

maxLength: number = 180;

constructor(private formBuilder: UntypedFormBuilder) {
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)]],
Expand All @@ -225,6 +230,11 @@ export class PrintFormComponent implements OnInit {

ngOnInit() {
this.doZipFileField.setValue(false);
if (this.mediaService.isMobile()) {
this.resolutions = this.resolutions.filter(
(resolution) => resolution !== '300'
);
}
}

handleFormSubmit(data: PrintOptions, isValid: boolean) {
Expand Down
4 changes: 2 additions & 2 deletions packages/geo/src/lib/print/shared/print.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']); // For now, we remove the 300 dpi because there is too much instability on iOS and slow device.
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',
Expand Down