Skip to content

Commit

Permalink
When an image can't be laoded the image viewer is covered by an error…
Browse files Browse the repository at this point in the history
… message and the annotator is read-only.
  • Loading branch information
geoffroy-noel-ddh committed Aug 18, 2023
1 parent 78a42e9 commit acc406e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/annotator.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@
</button>
</span>
</p>
<div class="panel-block">
<div class="panel-block panel-image">
<div :class="['image-viewer-overlay', `image-loaded-${isImageLoaded}`]">{{ imageLoadingMessage }}</div>
<div id="image-viewer" style="width: 100%; height: 300px;"></div>
</div>
<p class="panel-heading">
Expand Down
14 changes: 12 additions & 2 deletions app/assets/annotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function loadOpenSeaDragon(vueApp) {
vueApp.anno = anno;
window.anno = anno;
vueApp.viewer = viewer;
window.osd = viewer;

let eventNames = [
'createSelection', 'createAnnotation', 'updateAnnotation',
Expand All @@ -104,7 +105,7 @@ function loadOpenSeaDragon(vueApp) {
for (let eventName of eventNames) {
anno.on(eventName, vueApp[`on${eventName[0].toUpperCase()}${eventName.substring(1)}`]);
}
anno.on('open-failed', vueApp.onImageOpenFailed);
viewer.addHandler('open-failed', vueApp.onImageOpenFailed);
// setAnnotations() is defered by Annotorious until tiles are loaded.
// So we wait until it's ready to do things based on getAnnotations().
viewer.addHandler('open', () => {
Expand Down Expand Up @@ -207,6 +208,8 @@ createApp({
annotationId: '',
},
isUnsaved: 0,
// null: no asked; -1: error; 0: loading; 1: loaded
isImageLoaded: null,
messages: [
],
queryString: '',
Expand Down Expand Up @@ -366,7 +369,7 @@ createApp({
tabs: () => utils.tabs(),
canSave() {
// return !!this.selection.gtoken
return this.getOctokit() !== null
return (this.isImageLoaded == 1) && (this.getOctokit() !== null)
},
lastMessage() {
let ret = {
Expand All @@ -388,6 +391,9 @@ createApp({
image() {
return this.images[this.selection.image] || null
},
imageLoadingMessage() {
return (this.isImageLoaded == 1) ? '' : (this.isImageLoaded == -1) ? 'ERROR: could not load the image': 'loading'
},
userId() {
return this?.user?.url || ''
},
Expand Down Expand Up @@ -822,6 +828,8 @@ createApp({
async onSelectImage(img) {
await this.saveAnnotationsToGithub()
this.clearDescription()

this.isImageLoaded = 0
this.selection.image = img.uri
if (img) {
let options = {}
Expand All @@ -846,6 +854,7 @@ createApp({
// Events - Other
onImageOpenFailed() {
// TODO
this.isImageLoaded = -1
console.log('OPEN FAILED')
},
// Persistence backend
Expand Down Expand Up @@ -947,6 +956,7 @@ createApp({
return this.octokit
},
loadAnnotations() {
this.isImageLoaded = 1
return this.loadAnnotationsFromGithub()
},
async loadAnnotationsFromGithub() {
Expand Down
18 changes: 18 additions & 0 deletions app/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,21 @@ br[data-tei-n="1"] {
display: none;
}

/* --- */

.panel-image {
position: relative;
}

.image-viewer-overlay {
position: absolute;
background-color: white;
width: 100%;
height: 100%;
z-index: 10;
padding: 1em;
}

.image-loaded-1 {
display: none;
}

0 comments on commit acc406e

Please sign in to comment.