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

feat: Allow comparing images, videos, audio #1862

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/models/audios.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ export default {
'audio/webm',
],
component: Audios,
canCompare: true,
}
1 change: 1 addition & 0 deletions src/models/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,5 @@ export default {
...enabledMimes,
],
component: Images,
canCompare: true,
}
1 change: 1 addition & 0 deletions src/models/videos.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ export default {
'video/x-matroska': 'video/webm',
},
component: Videos,
canCompare: true,
}
134 changes: 72 additions & 62 deletions src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,65 +113,67 @@

<div class="viewer__content" :class="contentClass" @click.self.exact="close">
<!-- COMPARE FILE -->
<component :is="comparisonFile.modal"
v-if="comparisonFile && !comparisonFile.failed && showComparison"
:key="comparisonFile | uniqueKey"
ref="comparison-content"
v-bind="comparisonFile"
:active="true"
:can-swipe="false"
:can-zoom="false"
:editing="false"
:is-full-screen="isFullscreen"
:is-sidebar-shown="isSidebarShown"
:loaded.sync="comparisonFile.loaded"
class="viewer__file viewer__file--active"
@error="comparisonFailed" />

<!-- PREVIOUS -->
<component :is="previousFile.modal"
v-if="previousFile && !previousFile.failed"
:key="previousFile | uniqueKey"
ref="previous-content"
v-bind="previousFile"
:file-list="fileList"
class="viewer__file--hidden viewer__file"
@error="previousFailed" />
<Error v-else-if="previousFile"
class="hidden-visually"
:name="previousFile.basename" />

<!-- CURRENT -->
<component :is="currentFile.modal"
v-if="!currentFile.failed"
:key="currentFile | uniqueKey"
ref="content"
v-bind="currentFile"
:active="true"
:can-swipe.sync="canSwipe"
:can-zoom="canZoom"
:editing.sync="editing"
:file-list="fileList"
:is-full-screen="isFullscreen"
:is-sidebar-shown="isSidebarShown"
:loaded.sync="currentFile.loaded"
class="viewer__file viewer__file--active"
@error="currentFailed" />
<Error v-else
:name="currentFile.basename" />

<!-- NEXT -->
<component :is="nextFile.modal"
v-if="nextFile && !nextFile.failed"
:key="nextFile | uniqueKey"
ref="next-content"
v-bind="nextFile"
:file-list="fileList"
class="viewer__file--hidden viewer__file"
@error="nextFailed" />
<Error v-else-if="nextFile"
class="hidden-visually"
:name="nextFile.basename" />
<div v-if="comparisonFile && !comparisonFile.failed && showComparison" class="viewer__content--component">
<component :is="comparisonFile.modal"
:key="comparisonFile | uniqueKey"
ref="comparison-content"
v-bind="comparisonFile"
:active="true"
:can-swipe="false"
:can-zoom="true"
:editing="false"
:is-full-screen="isFullscreen"
:is-sidebar-shown="isSidebarShown"
:loaded.sync="comparisonFile.loaded"
class="viewer__file viewer__file--active"
@error="comparisonFailed" />
</div>
<div class="viewer__content--component">
<!-- PREVIOUS -->
<component :is="previousFile.modal"
v-if="previousFile && !previousFile.failed"
:key="previousFile | uniqueKey"
ref="previous-content"
v-bind="previousFile"
:file-list="fileList"
class="viewer__file--hidden viewer__file"
@error="previousFailed" />
<Error v-else-if="previousFile"
class="hidden-visually"
:name="previousFile.basename" />

<!-- CURRENT -->
<component :is="currentFile.modal"
v-if="!currentFile.failed"
:key="currentFile | uniqueKey"
ref="content"
v-bind="currentFile"
:active="true"
:can-swipe.sync="canSwipe"
:can-zoom="canZoom"
:editing.sync="editing"
:file-list="fileList"
:is-full-screen="isFullscreen"
:is-sidebar-shown="isSidebarShown"
:loaded.sync="currentFile.loaded"
class="viewer__file viewer__file--active"
@error="currentFailed" />
<Error v-else
:name="currentFile.basename" />

<!-- NEXT -->
<component :is="nextFile.modal"
v-if="nextFile && !nextFile.failed"
:key="nextFile | uniqueKey"
ref="next-content"
v-bind="nextFile"
:file-list="fileList"
class="viewer__file--hidden viewer__file"
@error="nextFailed" />
<Error v-else-if="nextFile"
class="hidden-visually"
:name="nextFile.basename" />
</div>
</div>
</NcModal>
</template>
Expand Down Expand Up @@ -685,7 +687,7 @@

// store current position
this.currentIndex = this.fileList.findIndex(file => file.basename === fileInfo.basename)
} else if (group && this.el === null) {
} else if (group && this.el === null && false) {

Check failure on line 690 in src/views/Viewer.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Unexpected constant condition
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to find a more sane way to not fail on loading the file list for versions

const mimes = this.mimeGroups[group]
? this.mimeGroups[group]
: [mime]
Expand Down Expand Up @@ -1215,8 +1217,16 @@
cursor: pointer;
}

.viewer__content--component {
width: 100%;
align-self: stretch;
display: flex;
align-content: center;
justify-content: center;
}

&--split {
.viewer__file--active {
.viewer__content--component {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably need to address #1588 to have clean styles for apps like pdfviewer and richdocuments to work with this.

width: 50%;
}
}
Expand All @@ -1225,7 +1235,6 @@
.modal-container {
// Ensure some space at the bottom
top: var(--header-height);
bottom: var(--header-height);
height: auto;
// let the mime components manage their own background-color
background-color: transparent;
Expand All @@ -1236,6 +1245,7 @@
&__content {
// center views
display: flex;
align-self: center;
align-items: center;
justify-content: center;
width: 100%;
Expand Down
Loading