parent
001c63ad90
commit
fbcec52de4
|
@ -180,11 +180,11 @@ class ImageController extends GenericApiController
|
|||
int $id,
|
||||
bool $basic = false,
|
||||
bool $current = false,
|
||||
bool $filepath = false,
|
||||
bool $filename = false,
|
||||
bool $tags = false,
|
||||
string $clusters = ''
|
||||
): Http\Response {
|
||||
return Util::guardEx(function () use ($id, $basic, $current, $filepath, $tags, $clusters) {
|
||||
return Util::guardEx(function () use ($id, $basic, $current, $filename, $tags, $clusters) {
|
||||
$file = $this->fs->getUserFile($id);
|
||||
|
||||
// Get the image info
|
||||
|
@ -216,10 +216,10 @@ class ImageController extends GenericApiController
|
|||
}
|
||||
|
||||
// Get the path of the file for the current user
|
||||
if ($filepath) {
|
||||
if ($filename) {
|
||||
$parts = explode('/', $file->getPath());
|
||||
if (\count($parts) > 3 && $parts[1] === $user->getUID()) {
|
||||
$info['filepath'] = implode('/', \array_slice($parts, 3));
|
||||
$info['filename'] = '/'.implode('/', \array_slice($parts, 3));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,8 @@ class OtherController extends GenericApiController
|
|||
return Util::guardEx(function () {
|
||||
// get memories version
|
||||
$version = \OC::$server->get(\OCP\App\IAppManager::class)
|
||||
->getAppInfo('memories')['version'];
|
||||
->getAppInfo('memories')['version']
|
||||
;
|
||||
|
||||
// get user if logged in
|
||||
try {
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
</div>
|
||||
|
||||
<div class="section-title">{{ t('memories', 'Metadata') }}</div>
|
||||
<div class="top-field" v-for="field of topFields" :key="field.title">
|
||||
<div v-for="field of topFields" :key="field.title" :class="`top-field top-field--${field.id}`">
|
||||
<div class="icon">
|
||||
<component :is="field.icon" :size="24" />
|
||||
</div>
|
||||
|
@ -29,11 +29,11 @@
|
|||
<div class="text">
|
||||
<template v-if="field.href">
|
||||
<a :href="field.href" target="_blank" rel="noopener noreferrer">
|
||||
{{ field.title }}
|
||||
<span class="title">{{ field.title }}</span>
|
||||
</a>
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ field.title }}
|
||||
<span class="title">{{ field.title }}</span>
|
||||
</template>
|
||||
|
||||
<template v-if="field.subtitle.length">
|
||||
|
@ -88,11 +88,13 @@ import LocationIcon from 'vue-material-design-icons/MapMarker.vue';
|
|||
import TagIcon from 'vue-material-design-icons/Tag.vue';
|
||||
|
||||
import * as utils from '../services/utils';
|
||||
import * as dav from '../services/dav';
|
||||
import { API } from '../services/API';
|
||||
|
||||
import type { IAlbum, IFace, IImageInfo, IPhoto } from '../types';
|
||||
|
||||
interface TopField {
|
||||
id?: string;
|
||||
title: string;
|
||||
subtitle: string[];
|
||||
icon: any;
|
||||
|
@ -153,11 +155,13 @@ export default defineComponent({
|
|||
});
|
||||
}
|
||||
|
||||
if (this.filepath) {
|
||||
if (this.imageInfoTitle) {
|
||||
list.push({
|
||||
title: this.filepath,
|
||||
id: 'image-info', // adds class
|
||||
title: this.imageInfoTitle,
|
||||
subtitle: this.imageInfoSub,
|
||||
icon: ImageIcon,
|
||||
href: utils.truthy(this.baseInfo, 'filename') ? dav.viewInFolderUrl(this.baseInfo) : undefined,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -287,8 +291,8 @@ export default defineComponent({
|
|||
},
|
||||
|
||||
/** Image info */
|
||||
filepath(): string | null {
|
||||
return this.baseInfo.filepath ?? this.baseInfo.basename;
|
||||
imageInfoTitle(): string | null {
|
||||
return this.baseInfo.filename ?? this.baseInfo.basename;
|
||||
},
|
||||
|
||||
imageInfoSub(): string[] {
|
||||
|
@ -383,10 +387,10 @@ export default defineComponent({
|
|||
|
||||
// get tags if enabled
|
||||
const tags = Number(this.config.systemtags_enabled);
|
||||
const filepath = Number(this.config.sidebar_filepath);
|
||||
const filename = Number(this.config.sidebar_filepath);
|
||||
|
||||
// get image info
|
||||
const url = API.Q(utils.getImageInfoUrl(photo), { tags, clusters, filepath });
|
||||
const url = API.Q(utils.getImageInfoUrl(photo), { tags, clusters, filename });
|
||||
const res = await this.guardState(axios.get<IImageInfo>(url));
|
||||
if (!res) return null;
|
||||
|
||||
|
@ -526,6 +530,10 @@ export default defineComponent({
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
&--image-info .title {
|
||||
user-select: all; // filename or basename
|
||||
}
|
||||
}
|
||||
|
||||
.loading-icon {
|
||||
|
|
|
@ -9,13 +9,19 @@ import { dirname } from 'path';
|
|||
*/
|
||||
export async function viewInFolder(photo: IPhoto) {
|
||||
if (!photo) return;
|
||||
const f = await getFiles([photo]);
|
||||
if (f.length === 0) return;
|
||||
const files = await getFiles([photo]);
|
||||
if (files.length === 0) return;
|
||||
|
||||
const file = f[0];
|
||||
const url = generateUrl(`/apps/files/?dir={dirPath}&scrollto={fileid}&openfile={fileid}`, {
|
||||
const url = viewInFolderUrl(files[0]);
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the view in folder url for the given file.
|
||||
*/
|
||||
export function viewInFolderUrl(file: { filename: string; fileid: number }) {
|
||||
return generateUrl(`/apps/files/?dir={dirPath}&scrollto={fileid}&openfile={fileid}`, {
|
||||
dirPath: dirname(file.filename),
|
||||
fileid: file.fileid,
|
||||
});
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
|
|
|
@ -94,3 +94,8 @@ export function isNumber(num: any): boolean {
|
|||
const cast = Number(num);
|
||||
return !isNaN(cast) && isFinite(cast);
|
||||
}
|
||||
|
||||
/** Check if a property is truthy */
|
||||
export function truthy<T, K extends keyof T>(obj: T, prop: K): obj is T & { [P in K]-?: T[K] } {
|
||||
return !!obj[prop];
|
||||
}
|
||||
|
|
|
@ -96,15 +96,16 @@ export interface IImageInfo {
|
|||
h: number;
|
||||
w: number;
|
||||
datetaken: number;
|
||||
address?: string;
|
||||
tags: { [id: string]: string };
|
||||
|
||||
permissions: string;
|
||||
filepath?: string;
|
||||
basename: string;
|
||||
mimetype: string;
|
||||
size: number;
|
||||
|
||||
filename?: string;
|
||||
address?: string;
|
||||
tags?: { [id: string]: string };
|
||||
|
||||
exif?: {
|
||||
Rotation?: number;
|
||||
Orientation?: number;
|
||||
|
|
Loading…
Reference in New Issue