viewer: view in folder

pull/175/head
Varun Patil 2022-11-05 23:15:28 -07:00 committed by Varun Patil
parent 88daa0db38
commit 883800c6ac
5 changed files with 44 additions and 12 deletions

View File

@ -413,17 +413,7 @@ export default class SelectionManager extends Mixins(GlobalMixin, UserConfig) {
*/
private async viewInFolder(selection: Selection) {
if (selection.size !== 1) return;
const photo: IPhoto = selection.values().next().value;
const f = await dav.getFiles([photo]);
if (f.length === 0) return;
const file = f[0];
const dirPath = file.filename.split("/").slice(0, -1).join("/");
const url = generateUrl(
`/apps/files/?dir=${dirPath}&scrollto=${file.fileid}&openfile=${file.fileid}`
);
window.open(url, "_blank");
dav.viewInFolder(selection.values().next().value);
}
/**

View File

@ -7,7 +7,7 @@
>
<div class="inner" ref="inner">
<div class="top-bar" v-if="photoswipe" :class="{ opened }">
<NcActions :inline="4" container=".memories_viewer .pswp">
<NcActions :inline="3" container=".memories_viewer .pswp">
<NcActionButton
:aria-label="t('memories', 'Delete')"
@click="deleteCurrent"
@ -47,6 +47,16 @@
<DownloadIcon :size="24" />
</template>
</NcActionButton>
<NcActionButton
:aria-label="t('memories', 'View in folder')"
@click="viewInFolder"
:close-after-click="true"
>
{{ t("memories", "View in folder") }}
<template #icon>
<OpenInNewIcon :size="24" />
</template>
</NcActionButton>
</NcActions>
</div>
</div>
@ -79,6 +89,7 @@ import StarIcon from "vue-material-design-icons/Star.vue";
import StarOutlineIcon from "vue-material-design-icons/StarOutline.vue";
import DownloadIcon from "vue-material-design-icons/Download.vue";
import InfoIcon from "vue-material-design-icons/InformationOutline.vue";
import OpenInNewIcon from "vue-material-design-icons/OpenInNew.vue";
@Component({
components: {
@ -89,6 +100,7 @@ import InfoIcon from "vue-material-design-icons/InformationOutline.vue";
StarOutlineIcon,
DownloadIcon,
InfoIcon,
OpenInNewIcon,
},
})
export default class Viewer extends Mixins(GlobalMixin) {
@ -544,6 +556,14 @@ export default class Viewer extends Mixins(GlobalMixin) {
this.openSidebar();
}
}
/**
* Open the files app with the current file.
*/
private async viewInFolder() {
const photo = this.getCurrentPhoto();
if (photo) dav.viewInFolder(photo);
}
}
</script>

View File

@ -7,3 +7,4 @@ export * from "./dav/favorites";
export * from "./dav/folders";
export * from "./dav/onthisday";
export * from "./dav/tags";
export * from "./dav/other";

View File

@ -94,6 +94,8 @@ export function hashCode(str: string): number {
* @param key Key to use for comparison
*/
export function binarySearch(arr: any, elem: any, key?: string) {
if (arr.length === 0) return 0;
const desc = key
? arr[0][key] > arr[arr.length - 1][key]
: arr[0] > arr[arr.length - 1];

View File

@ -0,0 +1,19 @@
import { getFiles } from "./base";
import { generateUrl } from "@nextcloud/router";
import { IPhoto } from "../../types";
/**
* Open the files app with the given photo
* Opens a new window.
*/
export async function viewInFolder(photo: IPhoto) {
const f = await getFiles([photo]);
if (f.length === 0) return;
const file = f[0];
const dirPath = file.filename.split("/").slice(0, -1).join("/");
const url = generateUrl(
`/apps/files/?dir=${dirPath}&scrollto=${file.fileid}&openfile=${file.fileid}`
);
window.open(url, "_blank");
}