Commit d36ed1a7 authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

debug pagination/osd

parent c3731fae
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
{
  "name": "@pdn-certic/vue-jama",
  "version": "0.5.2",
  "version": "0.5.3",
  "scripts": {
    "serve": "rimraf -rf ./node_modules/.cache/vue-loader && vue-cli-service serve",
    "build": "vue-cli-service build",
+27 −22
Original line number Diff line number Diff line
@@ -40,8 +40,7 @@
    <div
      :id="'collection-seadragon-'+collection.id"
      class="ma-0 pa-0 collection-seadragon flex-grow-1"
      @keyup.right="nextResource()"
      @keyup.left="previousResource()"

    />
  </v-container>
</template>
@@ -50,6 +49,8 @@
import OpenSeadragon from 'openseadragon';
import {mapGetters} from "vuex";

//next / prev key handler

export default {
    name: "JamaCollectionSeadragon",

@@ -68,6 +69,21 @@ export default {
        return {
            viewer: null,
            fullscreen: false,
            keyHandler: (e) => {
                // if (e.defaultPrevented) {
                //     return;
                // }
                // handler stopped if dialog box is displayed
                if (document.querySelector('.v-dialog.v-dialog--active'))
                    return;
                if (e.key === 'ArrowRight') {
                    this.nextResource();
                    e.preventDefault();
                } else if (e.key === 'ArrowLeft') {
                    this.previousResource();
                    e.preventDefault();
                }
            }
        }
    },

@@ -80,12 +96,10 @@ export default {
            this.updateViewerImages();
        },

        // page() {
        //     this.updateViewerImages();
        // },

        resources(newResources, oldResources){
            if(newResources[0].id !== oldResources[0].id) {

            if(newResources && newResources.length > 0 && newResources[0].id !== oldResources[0].id) {
                this.updateViewerImages();
            }
        },
@@ -130,22 +144,12 @@ export default {
        })


        //next / prev key bindings
        let keyHandler = (e) => {
            if (e.defaultPrevented) {
                return;
            }
            // handler stopped if dialog box is displayed
            if (document.querySelector('.v-dialog.v-dialog--active'))
                return;
            if (e.key === 'ArrowRight') {
                this.nextResource()
            } else if (e.key === 'ArrowLeft') {
                this.previousResource()
            }
        }

        document.addEventListener('keydown', keyHandler);
        document.addEventListener('keyup', this.keyHandler);
    },

    beforeDestroy() {
        document.removeEventListener('keyup', this.keyHandler);
    },

    methods: {
@@ -173,10 +177,11 @@ export default {
        nextResource() {
            if (this.viewer.currentPage() + 1 === this.resources.length) {
                this.$emit('page-after')
            } else
            } else {
                this.viewer.goToPage(this.viewer.currentPage() + 1);
            }
        }
    }

}
</script>
+45 −37
Original line number Diff line number Diff line
@@ -226,7 +226,7 @@
                          <v-pagination
                            v-model="currentPage"
                            :length="nbPages"
                            @input="gotoPage"
                            @input="gotoPage()"
                          />
                        </v-row>
                      </v-col>
@@ -457,6 +457,35 @@ export default {
            hiddenRightPanel: false,
            rightPaneMaximized: false,
            rootCollectionInfos: null,//usefull for root coll pagination
            navHandler : (e) => {
                if (!this.currentResource || this.promptOptions) {
                    return;
                }
                let offset = null;
                switch (e.key) {
                    case "ArrowLeft":
                        offset = -1;
                        break;
                    case "ArrowRight":
                        offset = 1
                        break;
                    default :
                        return;
                }

                if (offset) {
                    let target = this.resources[this.currentResourceIndex + offset];

                    if (target) {
                        try {
                            document.querySelector('#jama-resource-tile-' + target.id).click();
                        } catch (e) {
                            return false
                        }
                    }
                }

            }
        }
    },

@@ -618,35 +647,11 @@ export default {
        Vue.prototype.$jamaPrompt = this.jamaPrompt
        Vue.prototype.$jamaConfirm = this.jamaConfirm

        document.addEventListener('keydown', (e) => {
            if (!this.currentResource || this.promptOptions) {
                return;
            }
            let offset = null;
            switch (e.key) {
                case "ArrowLeft":
                    offset = -1;
                    break;
                case "ArrowRight":
                    offset = 1
                    break;
                default :
                    return;
            }

            if (offset) {
                let target = this.resources[this.currentResourceIndex + offset];

                if (target) {
                    try {
                        document.querySelector('#jama-resource-tile-' + target.id).click();
                    } catch (e) {
                        return false
                    }
                }
            }
        document.addEventListener('keyup', this.navHandler)
    },

        })
    beforeDestroy() {
        document.removeEventListener('keyup', this.navHandler)
    },

    methods: {
@@ -826,7 +831,6 @@ export default {


        resumeFileUpload(uploadInfos, file) {
            console.log("resume upload", uploadInfos)
            this.$jamaClient.resumeUpload(file, uploadInfos).then(() => this.loadCollection(this.currentCollection));
        },

@@ -889,7 +893,7 @@ export default {
        },

        //pagination
        async gotoPage(selectedIndex = -1) {
        async gotoPage(selectedIndex = null) {
            let start = (this.currentPage - 1) * this.pageLength;
            let end = start + this.pageLength;
            this.loading = true;
@@ -903,11 +907,15 @@ export default {
                }
            ).then(() => {
                this.loading = false;
                if(selectedIndex > -1)
                if(selectedIndex !== null) {
                    if(selectedIndex >= 0)
                      this.resourceSelected(this.resources[selectedIndex])
                // if(lastItemSelect){
                //     this.$store.commit('setCurrentResource', this.resources[this.resources.length - 1])
                // }
                    else
                       this.resourceSelected(this.resources[this.resources.length + selectedIndex])
                }
                else {
                    console.debug('no preselected resouces in page.')
                }

            });

@@ -922,7 +930,7 @@ export default {
        tryPreviousPage() {
            if(this.currentPage > 1){
                this.currentPage--;
                this.gotoPage(this.resources.length-1);
                this.gotoPage(-1);
            }
        }