edit-orientation: add some warnings

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/653/merge
Varun Patil 2023-11-01 22:12:39 -07:00
parent e64d1e8536
commit a7e7f80745
2 changed files with 25 additions and 7 deletions

View File

@ -57,8 +57,6 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { showWarning } from '@nextcloud/dialogs';
import NcButton from '@nextcloud/vue/dist/Components/NcButton';
const NcTextField = () => import('@nextcloud/vue/dist/Components/NcTextField');
const NcProgressBar = () => import('@nextcloud/vue/dist/Components/NcProgressBar');
@ -74,7 +72,7 @@ import EditExif from './EditExif.vue';
import EditLocation from './EditLocation.vue';
import EditOrientation from './EditOrientation.vue';
import { showError } from '@nextcloud/dialogs';
import { showWarning, showError } from '@nextcloud/dialogs';
import axios from '@nextcloud/axios';
import * as dav from '@services/dav';
@ -137,12 +135,26 @@ export default defineComponent({
// Filter out forbidden MIME types
photos = photos.filter((p) => {
if (this.c.FORBIDDEN_EDIT_MIMES.includes(p.mimetype ?? String())) {
showWarning(
this.t('memories', 'Cannot edit {name} of type {type}', { name: p.basename!, type: p.mimetype! }),
);
showError(this.t('memories', 'Cannot edit {name} of type {type}', { name: p.basename!, type: p.mimetype! }));
return false;
}
// Extra filters if orientation is in the sections
if (sections.includes(5)) {
// Videos might work but we don't want to risk it
if (p.mimetype?.startsWith('video/')) {
showError(this.t('memories', 'Cannot edit rotation on videos ({name})', { name: p.basename! }));
return false;
}
// Live photos cannot be edited because the orientation of the video
// will remain the same and look wrong.
if (p.liveid) {
showError(this.t('memories', 'Cannot edit rotation on Live Photos ({name})', { name: p.basename! }));
return false;
}
}
return true;
});

View File

@ -1,5 +1,12 @@
<template>
<div class="edit-orientation" v-if="samples.length">
{{
t(
'memories',
'This feature rotates images losslessly by updating the EXIF metadata. This approach is known to sometimes not work correctly on certain image types such as HEIC. Make sure you do a test run before using it on multiple images.',
)
}}
<div class="samples">
<XImg v-for="src of samples" class="sample" :key="src" :src="src" :style="{ transform }" />
<div class="sample more" v-if="photos.length > samples.length">
@ -208,7 +215,6 @@ export default defineComponent({
<style scoped lang="scss">
.edit-orientation {
margin: 4px 0;
text-align: center;
.samples {
display: grid;