Skip to content
Merged
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
24 changes: 6 additions & 18 deletions resources/js/components/forms/album/AlbumCreateDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,22 @@
import AlbumService from "@/services/album-service";
import Dialog from "primevue/dialog";
import InputText from "@/components/forms/basic/InputText.vue";
import { computed, ref, watch } from "vue";
import { computed, ref } from "vue";
import { useRouter } from "vue-router";
import FloatLabel from "primevue/floatlabel";
import Button from "primevue/button";
import { useToast } from "primevue/usetoast";
import { useTogglablesStateStore } from "@/stores/ModalsState";
import { storeToRefs } from "pinia";
import { onKeyPressed } from "@vueuse/core";

const props = defineProps<{
parentId: string | null;
}>();
import { usePhotoRoute } from "@/composables/photo/photoRoute";

const togglableStore = useTogglablesStateStore();
const { is_create_album_visible } = storeToRefs(togglableStore);

const parentId = ref(props.parentId);
const router = useRouter();
const { getParentId } = usePhotoRoute(router);

const toast = useToast();
const router = useRouter();

const title = ref<string | undefined>(undefined);

Expand All @@ -63,12 +59,12 @@ function create() {

AlbumService.createAlbum({
title: title.value as string,
parent_id: parentId.value,
parent_id: getParentId() ?? null,
})
.then((response) => {
title.value = undefined;
is_create_album_visible.value = false;
AlbumService.clearCache(parentId.value);
AlbumService.clearCache(getParentId());
router.push(`/gallery/${response.data}`);
})
.catch((error) => {
Expand All @@ -77,12 +73,4 @@ function create() {
}

onKeyPressed("Enter", () => is_create_album_visible.value && isValid.value && create());

watch(
() => props.parentId,
(newAlbumID, _oldAlbumID) => {
title.value = undefined;
parentId.value = newAlbumID as string | null;
},
);
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ import SearchTargetAlbum from "@/components/forms/album/SearchTargetAlbum.vue";
import AlbumService from "@/services/album-service";
import { useToast } from "primevue/usetoast";
import Dialog from "primevue/dialog";
import { useRouter } from "vue-router";
import { usePhotoRoute } from "@/composables/photo/photoRoute";

const props = defineProps<{
parentId: string | undefined;
album?: App.Http.Resources.Models.ThumbAlbumResource;
albumIds: string[];
}>();

const router = useRouter();
const { getParentId } = usePhotoRoute(router);
const visible = defineModel<boolean>("visible", { default: false });

const emits = defineEmits<{
Expand Down Expand Up @@ -100,10 +103,10 @@ function execute() {
for (const id in albumMergedIds) {
AlbumService.clearCache(id);
}
if (props.parentId === undefined) {
if (getParentId() === undefined) {
AlbumService.clearAlbums();
} else {
AlbumService.clearCache(props.parentId);
AlbumService.clearCache(getParentId());
}

// RESET !
Expand Down
14 changes: 9 additions & 5 deletions resources/js/components/forms/gallery-dialogs/DeleteDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,20 @@ import { sprintf } from "sprintf-js";
import Dialog from "primevue/dialog";
import Button from "primevue/button";
import { useToast } from "primevue/usetoast";
const toast = useToast();
import { useRouter } from "vue-router";
import { usePhotoRoute } from "@/composables/photo/photoRoute";

const toast = useToast();
const props = defineProps<{
parentId: string | undefined;
photo?: App.Http.Resources.Models.PhotoResource;
photoIds?: string[];
album?: App.Http.Resources.Models.ThumbAlbumResource;
albumIds?: string[];
}>();

const router = useRouter();
const { getParentId } = usePhotoRoute(router);

const visible = defineModel<boolean>("visible", { default: false });
const emits = defineEmits<{
deleted: [];
Expand Down Expand Up @@ -83,10 +87,10 @@ function executeDeleteAlbum() {
}

AlbumService.delete(albumDeletedIds).then(() => {
if (props.parentId === undefined) {
if (getParentId() === undefined) {
AlbumService.clearAlbums();
} else {
AlbumService.clearCache(props.parentId);
AlbumService.clearCache(getParentId());
}
emits("deleted");
});
Expand All @@ -105,7 +109,7 @@ function executeDeletePhoto() {
summary: trans("dialogs.photo_delete.deleted"),
life: 3000,
});
AlbumService.clearCache(props.parentId);
AlbumService.clearCache(getParentId());
emits("deleted");
});
}
Expand Down
17 changes: 10 additions & 7 deletions resources/js/components/forms/gallery-dialogs/MoveDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ import SearchTargetAlbum from "@/components/forms/album/SearchTargetAlbum.vue";
import { useToast } from "primevue/usetoast";
import Button from "primevue/button";
import Dialog from "primevue/dialog";
import { useRouter } from "vue-router";
import { usePhotoRoute } from "@/composables/photo/photoRoute";

const props = defineProps<{
parentId: string | undefined;
album?: App.Http.Resources.Models.ThumbAlbumResource;
albumIds?: string[];
photo?: App.Http.Resources.Models.PhotoResource;
photoIds?: string[];
}>();

const router = useRouter();
const { getParentId } = usePhotoRoute(router);
const visible = defineModel<boolean>("visible", { default: false });

const emits = defineEmits<{
Expand Down Expand Up @@ -142,11 +145,12 @@ function executeMoveAlbum() {
for (const id in albumMovedIds) {
AlbumService.clearCache(id);
}
if (props.parentId === undefined) {
if (getParentId() === undefined) {
AlbumService.clearAlbums();
} else {
AlbumService.clearCache(props.parentId);
AlbumService.clearCache(getParentId());
}
close();
emits("moved");
});
}
Expand All @@ -161,19 +165,18 @@ function executeMovePhoto() {
} else {
photoMovedIds = props.photoIds as string[];
}
PhotoService.move(destination_id.value, photoMovedIds).then(() => {
PhotoService.move({ album_id: destination_id.value, photo_ids: photoMovedIds }).then(() => {
toast.add({
severity: "success",
summary: sprintf(trans("dialogs.move_photo.moved"), titleMovedTo.value),
life: 3000,
});
// Clear the cache for the current album and the destination album
AlbumService.clearCache(props.parentId);
AlbumService.clearCache(getParentId());
AlbumService.clearCache(destination_id.value);

// RESET !
destination_id.value = undefined;

close();
emits("moved");
});
}
Expand Down
1 change: 0 additions & 1 deletion resources/js/components/forms/photo/PhotoCopyDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import Dialog from "primevue/dialog";
import { trans } from "laravel-vue-i18n";

const props = defineProps<{
parentId: string | undefined;
photo?: App.Http.Resources.Models.PhotoResource;
photoIds?: string[];
}>();
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/headers/AlbumHeader.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<ImportFromLink v-if="canUpload" v-model:visible="is_import_from_link_open" :parent-id="props.album.id" @refresh="emits('refresh')" />
<ImportFromLink v-if="canUpload" v-model:visible="is_import_from_link_open" @refresh="emits('refresh')" />
<DropBox v-if="canUpload" v-model:visible="is_import_from_dropbox_open" :album-id="props.album.id" />
<Toolbar class="w-full border-0 h-14" v-if="album">
<template #start>
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/headers/AlbumsHeader.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<ImportFromLink v-if="canUpload" v-model:visible="is_import_from_link_open" :parent-id="null" />
<ImportFromLink v-if="canUpload" v-model:visible="is_import_from_link_open" />
<DropBox v-if="canUpload" v-model:visible="is_import_from_dropbox_open" :album-id="null" />
<Toolbar
class="w-full border-0 h-14"
Expand Down
8 changes: 6 additions & 2 deletions resources/js/components/modals/ImportFromLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,19 @@ import Button from "primevue/button";
import Dialog from "primevue/dialog";
import PhotoService from "@/services/photo-service";
import Textarea from "primevue/textarea";
import { useRouter } from "vue-router";
import { usePhotoRoute } from "@/composables/photo/photoRoute";

const visible = defineModel("visible", { default: false }) as Ref<boolean>;
const props = defineProps<{ parentId: string | null }>();
const emits = defineEmits<{ refresh: [] }>();

const router = useRouter();
const { getParentId } = usePhotoRoute(router);

const urls = ref<string>("");

function submit() {
PhotoService.importFromUrl(urls.value.split("\n"), props.parentId).then(() => {
PhotoService.importFromUrl(urls.value.split("\n"), getParentId() ?? null).then(() => {
urls.value = "";
visible.value = false;
emits("refresh");
Expand Down
8 changes: 6 additions & 2 deletions resources/js/composables/photo/photoRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import { ALL } from "@/config/constants";
import { Router } from "vue-router";

export function usePhotoRoute(router: Router) {
function getParentId(): string | undefined {
return router.currentRoute.value.params.albumId as string | undefined;
}

function photoRoute(photoId: string) {
const currentRoute = router.currentRoute.value.name as string;
const albumId = router.currentRoute.value.params.albumId as string | undefined;
const albumId = getParentId();

if (currentRoute.startsWith("search")) {
return { name: "search", params: { albumId: albumId ?? ALL, photoId: photoId } };
Expand All @@ -13,5 +17,5 @@ export function usePhotoRoute(router: Router) {
return { name: "album", params: { albumId: albumId ?? ALL, photoId: photoId } };
}

return { photoRoute };
return { getParentId, photoRoute };
}
9 changes: 7 additions & 2 deletions resources/js/services/photo-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ export type PhotoUpdateRequest = {
taken_at: string | null;
};

export type PhotoMove = {
photo_ids: string[];
album_id: string | null;
};

const PhotoService = {
get(photo_id: string): Promise<AxiosResponse<App.Http.Resources.Models.PhotoResource>> {
return axios.get(`${Constants.getApiUrl()}Photo`, { params: { photo_id: photo_id }, data: {} });
Expand All @@ -27,8 +32,8 @@ const PhotoService = {
return axios.patch(`${Constants.getApiUrl()}Photo::rename`, { photo_id: photo_id, title: title });
},

move(destination_id: string | null, photo_ids: string[]): Promise<AxiosResponse> {
return axios.post(`${Constants.getApiUrl()}Photo::move`, { album_id: destination_id, photo_ids: photo_ids });
move(data: PhotoMove): Promise<AxiosResponse> {
return axios.post(`${Constants.getApiUrl()}Photo::move`, data);
},

tags(photo_ids: string[], tags: string[], shall_override: boolean): Promise<AxiosResponse> {
Expand Down
4 changes: 2 additions & 2 deletions resources/js/views/DuplicatesFinder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@
</div>
</div>
<VirtualScroller :items="groupedDuplicates" :itemSize="50" class="h-screen w-full">
<template v-slot:item="{ item, options }">
<template v-slot:item="{ item }">
<DuplicateLine :duplicates="item" :selected-ids="selectedIds" @hover="onHover" @click="onClick" />
</template>
</VirtualScroller>
</div>
</div>
<DeleteDialog v-model:visible="isDeleteVisible" :parent-id="undefined" :photo-ids="selectedIds" @deleted="onDeleted" />
<DeleteDialog v-model:visible="isDeleteVisible" :photo-ids="selectedIds" @deleted="onDeleted" />
</template>
<script setup lang="ts">
import { ref, computed, onMounted } from "vue";
Expand Down
11 changes: 3 additions & 8 deletions resources/js/views/gallery-panels/Album.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<UploadPanel v-if="album?.rights.can_upload" @refresh="refresh" key="upload_modal" />
<LoginModal v-if="user?.id === null" @logged-in="refresh" />
<WebauthnModal v-if="user?.id === null" @logged-in="refresh" />
<AlbumCreateDialog v-if="album?.rights.can_upload && config?.is_model_album" v-model:parent-id="album.id" key="create_album_modal" />
<AlbumCreateDialog v-if="album?.rights.can_upload && config?.is_model_album" key="create_album_modal" />

<!-- Warnings & Locks -->
<SensitiveWarning v-if="config?.is_nsfw_warning_visible" :album-id="albumId" />
Expand Down Expand Up @@ -54,8 +54,8 @@
<!-- Dialogs -->
<template v-if="photo">
<PhotoEdit v-if="photo?.rights.can_edit" :photo="photo" v-model:visible="is_photo_edit_open" />
<MoveDialog :photo="photo" v-model:visible="is_move_visible" :parent-id="props.albumId" @moved="refresh" />
<DeleteDialog :photo="photo" v-model:visible="is_delete_visible" :parent-id="props.albumId" @deleted="refresh" />
<MoveDialog :photo="photo" v-model:visible="is_move_visible" @moved="refresh" />
<DeleteDialog :photo="photo" v-model:visible="is_delete_visible" @deleted="refresh" />
</template>
<template v-else>
<PhotoTagDialog
Expand All @@ -72,7 +72,6 @@
/>
<PhotoCopyDialog
v-model:visible="is_copy_visible"
:parent-id="albumId"
:photo="selectedPhoto"
:photo-ids="selectedPhotosIds"
@copied="
Expand All @@ -84,7 +83,6 @@
/>
<MoveDialog
v-model:visible="is_move_visible"
:parent-id="albumId"
:photo="selectedPhoto"
:photo-ids="selectedPhotosIds"
:album="selectedAlbum"
Expand All @@ -98,7 +96,6 @@
/>
<DeleteDialog
v-model:visible="is_delete_visible"
:parent-id="albumId"
:photo="selectedPhoto"
:photo-ids="selectedPhotosIds"
:album="selectedAlbum"
Expand All @@ -114,7 +111,6 @@
<!-- Dialogs for albums -->
<RenameDialog
v-model:visible="is_rename_visible"
:parent-id="undefined"
:album="selectedAlbum"
:photo="selectedPhoto"
@renamed="
Expand All @@ -126,7 +122,6 @@
/>
<AlbumMergeDialog
v-model:visible="is_merge_album_visible"
:parent-id="albumId"
:album="selectedAlbum"
:album-ids="selectedAlbumsIds"
@merged="
Expand Down
7 changes: 2 additions & 5 deletions resources/js/views/gallery-panels/Albums.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<LoadingProgress v-model:loading="isLoading" />
<UploadPanel v-if="rootRights?.can_upload" @refresh="refresh" key="upload_modal" />
<KeybindingsHelp v-model:visible="isKeybindingsHelpOpen" v-if="user?.id" />
<AlbumCreateDialog v-if="rootRights?.can_upload" :parent-id="null" key="create_album_modal" />
<AlbumCreateDialog v-if="rootRights?.can_upload" key="create_album_modal" />
<AlbumCreateTagDialog v-if="rootRights?.can_upload" key="create_tag_album_modal" />
<LoginModal v-if="user?.id === null" @logged-in="refresh" />
<WebauthnModal v-if="user?.id === null" @logged-in="refresh" />
Expand Down Expand Up @@ -48,7 +48,7 @@
@contexted="albumMenuOpen"
/>
</template>
<template v-for="sharedAlbum in sharedAlbums">
<template v-for="sharedAlbum in sharedAlbums" :key="sharedAlbum.header">
<AlbumThumbPanel
v-if="sharedAlbums.length > 0"
:header="sharedAlbum.header"
Expand Down Expand Up @@ -82,7 +82,6 @@
<!-- Dialogs for albums -->
<MoveDialog
v-model:visible="is_move_visible"
:parent-id="undefined"
:album="selectedAlbum"
:album-ids="selectedAlbumsIds"
@moved="
Expand All @@ -94,7 +93,6 @@
/>
<AlbumMergeDialog
v-model:visible="is_merge_album_visible"
:parent-id="undefined"
:album="selectedAlbum"
:album-ids="selectedAlbumsIds"
@merged="
Expand All @@ -106,7 +104,6 @@
/>
<DeleteDialog
v-model:visible="is_delete_visible"
:parent-id="undefined"
:album="selectedAlbum"
:album-ids="selectedAlbumsIds"
@deleted="
Expand Down
Loading