-
Notifications
You must be signed in to change notification settings - Fork 16
PB-2064: Fix import tool file #1516
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
base: feat-PB-1383-pinia-store
Are you sure you want to change the base?
Changes from all commits
b7f37da
6f9882d
80d976e
2afa88d
6153495
c6d9cd5
f41a558
7ebfd7c
6198136
d707314
a6dd8a7
3e8c56a
42428ef
d389aa8
4d2df2a
2b9bc21
fac4d34
0f446a6
8e0b2e3
c0b7032
e4565db
f9cd5c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,9 +7,10 @@ import type { ParseOptions } from '@/modules/menu/components/advancedTools/Impor | |
|
|
||
| import { getFileContentThroughServiceProxy } from '@/api/file-proxy.api' | ||
| import { checkOnlineFileCompliance, getFileContentFromUrl } from '@/api/files.api' | ||
| import { | ||
| CloudOptimizedGeoTIFFParser | ||
| } from '@/modules/menu/components/advancedTools/ImportFile/parser/CloudOptimizedGeoTIFFParser.class' | ||
| import { CloudOptimizedGeoTIFFParser } from '@/modules/menu/components/advancedTools/ImportFile/parser/CloudOptimizedGeoTIFFParser.class' | ||
| import EmptyFileContentError from '@/modules/menu/components/advancedTools/ImportFile/parser/errors/EmptyFileContentError.error' | ||
| import OutOfBoundsError from '@/modules/menu/components/advancedTools/ImportFile/parser/errors/OutOfBoundsError.error' | ||
| import UnknownProjectionError from '@/modules/menu/components/advancedTools/ImportFile/parser/errors/UnknownProjectionError.error' | ||
| import GPXParser from '@/modules/menu/components/advancedTools/ImportFile/parser/GPXParser.class' | ||
| import { KMLParser } from '@/modules/menu/components/advancedTools/ImportFile/parser/KMLParser.class' | ||
| import KMZParser from '@/modules/menu/components/advancedTools/ImportFile/parser/KMZParser.class' | ||
|
|
@@ -36,12 +37,42 @@ async function parseAll(config: ParseAllConfig, options?: ParseOptions): Promise | |
| if (firstFulfilled) { | ||
| return (firstFulfilled as PromiseFulfilledResult<FileLayer>).value | ||
| } | ||
| const anyErrorRaised = allSettled.find( | ||
|
|
||
| // Prioritize specific errors over generic InvalidFileContentError | ||
| // This ensures that if a parser successfully identifies the file format | ||
| // but encounters a specific issue (e.g., out of bounds), that error is shown | ||
| const rejectedResponses = allSettled.filter( | ||
| (response) => response.status === 'rejected' && response.reason | ||
| ) as PromiseRejectedResult[] | ||
|
|
||
| // Priority order: OutOfBounds > Empty > UnknownProjection > Invalid > Other | ||
| const outOfBoundsError = rejectedResponses.find( | ||
| (response) => response.reason instanceof OutOfBoundsError | ||
| ) | ||
| if (outOfBoundsError) { | ||
| throw outOfBoundsError.reason | ||
| } | ||
|
|
||
| const emptyFileError = rejectedResponses.find( | ||
| (response) => response.reason instanceof EmptyFileContentError | ||
| ) | ||
| if (anyErrorRaised) { | ||
| throw (anyErrorRaised as PromiseRejectedResult).reason | ||
| if (emptyFileError) { | ||
| throw emptyFileError.reason | ||
| } | ||
|
|
||
| const unknownProjectionError = rejectedResponses.find( | ||
| (response) => response.reason instanceof UnknownProjectionError | ||
| ) | ||
| if (unknownProjectionError) { | ||
| throw unknownProjectionError.reason | ||
| } | ||
|
Comment on lines
+48
to
+68
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Couldn't you bunch all these instance checking in one if block, if the goal is to prioritize anything else than InvalidFileContentError? I don't really see the benefit of treating them one by one, with the goal you stated |
||
|
|
||
| // Fall back to any error (including InvalidFileContentError) | ||
| const firstError = rejectedResponses[0] | ||
| if (firstError) { | ||
| throw firstError.reason | ||
| } | ||
|
|
||
| throw new Error('Could not parse file') | ||
| } | ||
|
|
||
|
|
@@ -66,7 +97,7 @@ export async function parseLayerFromFile( | |
| const fileComplianceCheck = await checkOnlineFileCompliance(fileSource) | ||
| log.debug({ | ||
| title: '[FileParser][parseLayerFromFile]', | ||
| messages: ['file', fileSource, 'has compliance', fileComplianceCheck] | ||
| messages: ['file', fileSource, 'has compliance', fileComplianceCheck], | ||
| }) | ||
| const { mimeType, supportsCORS, supportsHTTPS } = fileComplianceCheck | ||
|
|
||
|
|
@@ -79,7 +110,7 @@ export async function parseLayerFromFile( | |
| if (parserMatchingMIME) { | ||
| log.debug({ | ||
| title: '[FileParser][parseLayerFromFile]', | ||
| messages: ['parser found for MIME type', mimeType, parserMatchingMIME] | ||
| messages: ['parser found for MIME type', mimeType, parserMatchingMIME], | ||
| }) | ||
| return parserMatchingMIME.parseUrl(fileSource, currentProjection, { | ||
| fileCompliance: fileComplianceCheck, | ||
|
|
@@ -91,7 +122,7 @@ export async function parseLayerFromFile( | |
| try { | ||
| log.debug({ | ||
| title: '[FileParser][parseLayerFromFile]', | ||
| messages: ['no MIME type match, loading file content for', fileSource] | ||
| messages: ['no MIME type match, loading file content for', fileSource], | ||
| }) | ||
| let loadedContent: ArrayBuffer | undefined | ||
| if (supportsCORS && supportsHTTPS) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| <script setup lang="ts"> | ||
| import { useTemplateRef } from 'vue' | ||
| import { computed, useTemplateRef } from 'vue' | ||
| import { useI18n } from 'vue-i18n' | ||
|
|
||
| import { useComponentUniqueId } from '@/utils/composables/useComponentUniqueId' | ||
|
|
@@ -89,15 +89,15 @@ const model = defineModel<string>({ default: '' }) | |
| const emits = defineEmits(['change', 'validate', 'focusin', 'focusout', 'keydown.enter']) | ||
| const { t } = useI18n() | ||
|
|
||
| const validationProps = { | ||
| const validationProps = computed(() => ({ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why use a computed here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, because when we use the prop deconstruction with a default value, we lose the reactivity if we pass it to the composable. So, I need to change |
||
| required, | ||
| validMarker, | ||
| validMessage, | ||
| invalidMarker, | ||
| invalidMessage, | ||
| activateValidation, | ||
| validate, | ||
| } | ||
| })) | ||
|
|
||
| const { | ||
| value, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.