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) { private async viewInFolder(selection: Selection) {
if (selection.size !== 1) return; if (selection.size !== 1) return;
dav.viewInFolder(selection.values().next().value);
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");
} }
/** /**

View File

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

View File

@ -7,3 +7,4 @@ export * from "./dav/favorites";
export * from "./dav/folders"; export * from "./dav/folders";
export * from "./dav/onthisday"; export * from "./dav/onthisday";
export * from "./dav/tags"; 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 * @param key Key to use for comparison
*/ */
export function binarySearch(arr: any, elem: any, key?: string) { export function binarySearch(arr: any, elem: any, key?: string) {
if (arr.length === 0) return 0;
const desc = key const desc = key
? arr[0][key] > arr[arr.length - 1][key] ? arr[0][key] > arr[arr.length - 1][key]
: arr[0] > arr[arr.length - 1]; : 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");
}