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

No dialogs with Download and Share plugins in Angular 9 #3281

Closed
daynewss opened this issue Oct 7, 2020 · 11 comments · Fixed by ProjectMirador/mirador-annotations#30 · May be fixed by #3284
Closed

No dialogs with Download and Share plugins in Angular 9 #3281

daynewss opened this issue Oct 7, 2020 · 11 comments · Fixed by ProjectMirador/mirador-annotations#30 · May be fixed by #3284

Comments

@daynewss
Copy link

daynewss commented Oct 7, 2020

Mirador 3
Hello
I am working with Angular 9 project.
I have working Mirador, with Annotation, ImageTools, Share and Download plugins. Problem is that I can see Share and Download plugins in menu, but when I select these item nothing happens. Nothing at all. No exceptions in console.
I see target: 'Window' in MiradorDownloadDialog.js and MiradorShareDialog.js. Maybe it must be something else in Angular?

My Mirador config in TS file:

Mirador.viewer(
      {
        annotation: {
          adapter: (canvasId) => new LocalStorageAdapter(`localStorage://?canvasId=${canvasId}`)
        },
        id: 'mirador',
        mainMenuSettings: {
          show: false
        },
        selectedTheme: 'dark',
        data: [this.manifestLink],
        windows: [{
          manifestId: this.manifestLink,
          imageToolsEnabled: true,
          imageToolsOpen: false
        }],
        miradorSharePlugin: {
          dragAndDropInfoLink: 'https://iiif.io',
          embedOption: {
            enabled: false,
            embedUrlReplacePattern: [
              /.*\.edu\/(\w+)\/iiif\/manifest/,
              this.manifestLink
            ],
            syncIframeDimensions: {
              height: {param: 'maxheight'},
            },
          },
          shareLink: {
            enabled: true,
            manifestIdReplacePattern: [
              /\/iiif\/manifest/,
              '',
            ],
          },
        },
        miradorDownloadPlugin: {
          restrictDownloadOnSizeDefinition: false
        },
        window: {
          loadManifest: this.manifestLink,
          allowClose: false,
          sideBarOpenByDefault: true,
          allowFullscreen: true,
          allowMaximize: false,
          views: [
            {key: 'single'},
            {key: 'book'},
            {key: 'gallery'}
          ],
          sideBarPanel: 'canvas',
        },
        workspace: {
          allowNewWindows: false,
          showZoomControls: true,
          type: 'mosaic'
        },
        workspaceControlPanel: {
          enabled: false
        }
      },
      [
        miradorAnnotationPlugin,
        miradorImageToolsPlugin,
        miradorShareDialogPlugin,
        miradorSharePlugin,
        miradorDownloadDialogPlugin,
        miradorDownloadPlugin,
      ]
    );

@daynewss
Copy link
Author

daynewss commented Oct 7, 2020

dependencies in package.json are:

"@angular/animations": "~9.0.1", "@angular/common": "~9.0.1", "@angular/compiler": "~9.0.1", "@angular/core": "~9.0.1", "@angular/forms": "~9.0.1", "@angular/platform-browser": "~9.0.1", "@angular/platform-browser-dynamic": "~9.0.1", "@angular/router": "~9.0.1", "@blueprintjs/core": "^3.31.0", "mirador": "^3.0.0-rc.4", "mirador-annotations": "^0.3.0", "mirador-dl-plugin": "^0.12.0", "mirador-image-tools": "^0.8.0", "mirador-share-plugin": "^0.9.0", "ngx-masonry": "^10.0.5", "react": "^16.13.1", "react-dom": "^16.13.1", "react-mosaic-component": "^4.1.1", "rxjs": "~6.5.4", "tslib": "^1.10.0", "zone.js": "~0.10.2"

Maybe there are other react dependencies that must be included?

@daynewss
Copy link
Author

daynewss commented Oct 7, 2020

OK. I figured it out that it happens only when miradorAnnotationPlugin and
annotation: { adapter: (canvasId) => new LocalStorageAdapter(localStorage://?canvasId=${canvasId}), // adapter: (canvasId) => new AnnototAdapter(canvasId, endpointUrl), },
are added to Miradors' config.

I import Mirador like this:
import miradorAnnotationPlugin from 'mirador-annotations/es/index.js';

Maybe I do something wrong with imports? Or it's a bug witj annotations plugin?

@mejackreed
Copy link
Collaborator

I have an example of using mirador-image-tools, mirador-dl-plugin, and mirador-annotations together here: https://github.com/ProjectMirador/mirador-integration/pull/2/files that works. Does yours look similar?

@daynewss
Copy link
Author

daynewss commented Oct 7, 2020

That is my code.

import {Component, OnInit} from '@angular/core';
import {default as LocalStorageAdapter} from 'node_modules/mirador-annotations/lib/LocalStorageAdapter.js';
import Mirador from 'node_modules/mirador/dist/es/src/index.js';
import miradorAnnotationPlugin from 'mirador-annotations/es/index.js';
import miradorImageToolsPlugin from 'mirador-image-tools/es/plugins/miradorImageToolsPlugin.js';

import miradorShareDialogPlugin from 'mirador-share-plugin/es/MiradorShareDialog.js';
import miradorSharePlugin from 'mirador-share-plugin/es/miradorSharePlugin.js';
import miradorDownloadPlugin from 'mirador-dl-plugin/es/miradorDownloadPlugin.js';
import miradorDownloadDialogPlugin from 'mirador-dl-plugin/es/MiradorDownloadDialog.js';

@Component({
  selector: 'app-viewer-mirador',
  templateUrl: './viewer-mirador.component.html',
  styleUrls: ['./viewer-mirador.component.scss']
})
export class ViewerMiradorComponent implements OnInit {
  manifestLink = 'https://digital.library.villanova.edu/Item/vudl:24299/Manifest';
  // manifestLink = 'https://purl.stanford.edu/sn904cj3429/iiif/manifest';

  constructor() {
  }

  ngOnInit(): void {
    this.initMirador();
  }

  initMirador() {
    Mirador.viewer(
      {
        annotation: {
          adapter: (canvasId) => new LocalStorageAdapter(`localStorage://?canvasId=${canvasId}`),
          // adapter: (canvasId) => new AnnototAdapter(canvasId, endpointUrl),
        },
        id: 'mirador',
        mainMenuSettings: {
          show: false
        },
        selectedTheme: 'dark',
        data: [this.manifestLink],
        windows: [{
          manifestId: this.manifestLink,
          imageToolsEnabled: true,
          imageToolsOpen: false
        }],
        miradorSharePlugin: {
          dragAndDropInfoLink: 'https://iiif.io',
          embedOption: {
            enabled: false,
            embedUrlReplacePattern: [
              /.*\.edu\/(\w+)\/iiif\/manifest/,
              this.manifestLink
            ],
            syncIframeDimensions: {
              height: {param: 'maxheight'},
            },
          },
          shareLink: {
            enabled: true,
            manifestIdReplacePattern: [
              /\/iiif\/manifest/,
              '',
            ],
          },
        },
        miradorDownloadPlugin: {
          restrictDownloadOnSizeDefinition: false
        },
        window: {
          loadManifest: this.manifestLink,
          allowClose: false,
          sideBarOpenByDefault: true,
          allowFullscreen: true,
          allowMaximize: false,
          views: [
            {key: 'single'},
            {key: 'book'},
            {key: 'gallery'}
          ],
          sideBarPanel: 'canvas',
        },
        workspace: {
          allowNewWindows: false,
          showZoomControls: true,
          type: 'mosaic'
        },
        workspaceControlPanel: {
          enabled: false
        }
      },
      [
        ...miradorImageToolsPlugin,
        miradorShareDialogPlugin,
        miradorSharePlugin,
        miradorDownloadDialogPlugin,
        miradorDownloadPlugin,
        ...miradorAnnotationPlugin,
      ]
    );
  }
}

What are those three dots in front of plugin variable name?
import miradorAnnotationPlugins from 'mirador-annotations/es/index'; - is that works? because I can't find "miradorAnnotationPlugins" in mirador-annotations
Same with import MiradorDownload from 'mirador-dl-plugin'; and
import MiradorDownloadDialogPlugin from 'mirador-dl-plugin';

My code works only if I disable annotations plugin. Then it works OK. But if I add annotations then this bug appears.

@mejackreed
Copy link
Collaborator

The three dots are the JavaScript spread syntax.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax

Try changing this:

- import {default as LocalStorageAdapter} from 'node_modules/mirador-annotations/lib/LocalStorageAdapter.js';
+ import LocalStorageAdapter from 'mirador-annotations/es/LocalStorageAdapter';

@daynewss
Copy link
Author

daynewss commented Oct 8, 2020

No, no luck.
My current imports are:
import {Component, OnInit} from '@angular/core'; import LocalStorageAdapter from 'mirador-annotations/es/LocalStorageAdapter'; import Mirador from 'mirador/dist/es/src/index'; import miradorAnnotationPlugin from 'mirador-annotations/es/index'; import miradorImageToolsPlugin from 'mirador-image-tools/es/plugins/miradorImageToolsPlugin'; import miradorShareDialogPlugin from 'mirador-share-plugin/es/MiradorShareDialog'; import miradorSharePlugin from 'mirador-share-plugin/es/miradorSharePlugin'; import MiradorDownloadDialog from 'mirador-dl-plugin/es/MiradorDownloadDialog'; import miradorDownloadPlugin from 'mirador-dl-plugin/es/MiradorDownloadPlugin';

As I said before, if I import miradorAnnotationPlugin only and add annotation: to Mirador config, then annotations are working fine. If I import miradorDownloadPlugin/MiradorDownloadDialog or/and miradorSharePlugin/miradorShareDialogPlugin without adding miradorAnnotationPlugin to Mirador, then download and share plugins are working. I can see "Share" and "Download" buttons on the window menu. And if I press these menu options, download or share dialogs appear.
But if I add annotations plugin and add annotation: to Mirador config, then no download or/and share dialogs apper after selecting these options from menu and annotations are working just fine.

I can create Angular project and push it to my github and share it with you, so you could see it by your self.

@daynewss
Copy link
Author

daynewss commented Oct 8, 2020

Here is the link: Mirador Angular bug

@mejackreed
Copy link
Collaborator

Thanks for providing the example that is very helpful. I'm seeing perhaps an issue with the interaction between MiradorDownloadDialog and externalStorageAnnotationPlugin as they both are Window plugins. I'll look into this a bit further.

@daynewss
Copy link
Author

daynewss commented Oct 8, 2020

Your welcome. I hope that it will be useful.

@mejackreed
Copy link
Collaborator

@daynewss please try updating to mirador-annotations@v0.3.1

@daynewss
Copy link
Author

Yes, it's working.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants