Pridan fotoeditor

This commit is contained in:
Michal Kváček
2023-10-27 22:30:47 +02:00
parent 4c8952117b
commit 100e1fa33b
18 changed files with 502 additions and 23 deletions
+20 -5
View File
@@ -1,6 +1,7 @@
import {defineStore} from "pinia";
import {apolloWrapper} from "src/graphql/apollo";
import {DELETE_PHOTO, EDIT_PHOTO, ROTATE_PHOTO, UPLOAD_PHOTO} from "src/graphql/mutations/photo";
import {ADJUST_PHOTO, CHANGE_PHOTO_ORIENTATION, DELETE_PHOTO, EDIT_PHOTO, UPLOAD_PHOTO} from "src/graphql/mutations/photo";
import {PHOTO_DETAIL} from "src/graphql/queries/photo";
export const usePhotosStore = defineStore('Photos', {
state: () => ({
@@ -8,6 +9,11 @@ export const usePhotosStore = defineStore('Photos', {
}),
actions: {
fetchDetail(id) {
return apolloWrapper.query(PHOTO_DETAIL, {id}).then(({data}) => {
return data.photo;
});
},
upload(flightId, formData) {
if (!flightId) {
console.error("No flightId specified for photo upload! Aborting");
@@ -35,16 +41,25 @@ export const usePhotosStore = defineStore('Photos', {
return data.editPhoto;
}).finally(() => this.isMutationRunning = false);
},
rotate(id, angle) {
changeOrientation(id, direction) {
this.isMutationRunning = true;
return apolloWrapper.mutate(ROTATE_PHOTO, {id, angle}).then(({data}) => {
return data.rotatePhoto;
return apolloWrapper.mutate(CHANGE_PHOTO_ORIENTATION, {id, direction}).then(({data}) => {
return data.changeOrientation;
}).finally(() => this.isMutationRunning = false);
},
adjust(id, adjustment) {
this.isMutationRunning = true;
return apolloWrapper.mutate(ADJUST_PHOTO, {id, adjustment}).then(({data}) => {
return data.adjustPhoto;
}).finally(() => this.isMutationRunning = false);
},
delete(photoId) {
this.isMutationRunning = true;
return apolloWrapper.mutate(DELETE_PHOTO, {id: photoId}).then(({data}) => {
return data.deletePhoto;
});
}).finally(() => this.isMutationRunning = false);
}
}
});