-
Notifications
You must be signed in to change notification settings - Fork 3
refactor manage columns to use vault #450
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
Changes from all commits
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 | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,7 @@ import CheckPermissions from "../../components/check-permissions/checkPermission | |||||||||||||||
| import { renderPermissionError } from "../../utilities/renderPermissionError.js" | ||||||||||||||||
| import { onProjectReady } from "../../utilities/projectReady.js" | ||||||||||||||||
| import { CleanupRegistry } from '../../utilities/CleanupRegistry.js' | ||||||||||||||||
| import vault from '../../js/vault.js' | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * TpenManageColumns - Interface for managing column assignments on annotation pages. | ||||||||||||||||
|
|
@@ -633,27 +634,14 @@ class TpenManageColumns extends HTMLElement { | |||||||||||||||
| return { x: xywh[0], y: xywh[1], w: xywh[2], h: xywh[3] } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| isValidUrl(str) { | ||||||||||||||||
| try { | ||||||||||||||||
| new URL(str) | ||||||||||||||||
| return true | ||||||||||||||||
| } catch { | ||||||||||||||||
| return false | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| async getSpecificTypeData(type) { | ||||||||||||||||
| if (!type) throw new Error("No IIIF resource provided") | ||||||||||||||||
| if (typeof type === "string" && this.isValidUrl(type)) { | ||||||||||||||||
| const res = await fetch(type, { cache: "no-store" }) | ||||||||||||||||
| if (!res.ok) throw new Error(`Fetch failed: ${res.status}`) | ||||||||||||||||
| return await res.json() | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| async fetchPageViewerData(pageID = null) { | ||||||||||||||||
| const annotationPageData = pageID ? await this.getSpecificTypeData(pageID) : null | ||||||||||||||||
| const canvasData = await this.getSpecificTypeData(annotationPageData.target) | ||||||||||||||||
| if (!pageID) throw new Error("No page ID provided") | ||||||||||||||||
| const annotationPageData = await vault.getWithFallback(pageID, 'annotationpage', TPEN.activeProject?.manifest, true) | ||||||||||||||||
| if (!annotationPageData) throw new Error("Failed to load annotation page") | ||||||||||||||||
| const canvasData = await vault.getWithFallback( | ||||||||||||||||
| annotationPageData.target, 'canvas', TPEN.activeProject?.manifest | ||||||||||||||||
| ) | ||||||||||||||||
| if (!canvasData) throw new Error("Failed to load canvas data") | ||||||||||||||||
|
Comment on lines
+638
to
+644
|
||||||||||||||||
| return await this.processDirectCanvasData(canvasData, annotationPageData) | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -667,8 +655,11 @@ class TpenManageColumns extends HTMLElement { | |||||||||||||||
| if (!annotationPageData?.items) return [] | ||||||||||||||||
| const results = await Promise.all(annotationPageData.items.map(async anno => { | ||||||||||||||||
| try { | ||||||||||||||||
| const res = await fetch(anno.id, { cache: "no-store" }) | ||||||||||||||||
| const data = await res.json() | ||||||||||||||||
| let data = anno | ||||||||||||||||
| if (!data?.target) { | ||||||||||||||||
| data = await vault.get(anno.id ?? anno, 'annotation', true) | ||||||||||||||||
|
||||||||||||||||
| data = await vault.get(anno.id ?? anno, 'annotation', true) | |
| const annotationId = | |
| typeof anno === 'string' | |
| ? anno | |
| : (typeof anno?.id === 'string' ? anno.id : null) | |
| if (!annotationId) return null | |
| data = await vault.get(annotationId, 'annotation', true) |
Uh oh!
There was an error while loading. Please reload this page.