diff --git a/lib/Controller/ImageController.php b/lib/Controller/ImageController.php index a62fe2e2d..5407ad784 100644 --- a/lib/Controller/ImageController.php +++ b/lib/Controller/ImageController.php @@ -180,10 +180,11 @@ public function info( int $id, bool $basic = false, bool $current = false, + bool $filepath = false, bool $tags = false, string $clusters = '' ): Http\Response { - return Util::guardEx(function () use ($id, $basic, $current, $tags, $clusters) { + return Util::guardEx(function () use ($id, $basic, $current, $filepath, $tags, $clusters) { $file = $this->fs->getUserFile($id); // Get the image info @@ -202,7 +203,8 @@ public function info( $info['basename'] = $file->getName(); // Allow these ony for logged in users - if (null !== $this->userSession->getUser()) { + $user = $this->userSession->getUser(); + if (null !== $user) { // Get list of tags for this file if ($tags) { $info['tags'] = $this->getTags($id); @@ -213,6 +215,14 @@ public function info( $info['current'] = Exif::getExifFromFile($file); } + // Get the path of the file for the current user + if ($filepath) { + $parts = explode('/', $file->getPath()); + if (\count($parts) > 3 && $parts[1] === $user->getUID()) { + $info['filepath'] = implode('/', \array_slice($parts, 3)); + } + } + // Get clusters for this file if ($clusters) { $clist = []; diff --git a/lib/Controller/OtherController.php b/lib/Controller/OtherController.php index 2e0e3f12c..3b462f7f6 100644 --- a/lib/Controller/OtherController.php +++ b/lib/Controller/OtherController.php @@ -64,24 +64,30 @@ public function setUserConfig(string $key, string $value): Http\Response public function getUserConfig(): Http\Response { return Util::guardEx(function () { - $appManager = \OC::$server->get(\OCP\App\IAppManager::class); + // get memories version + $version = \OC::$server->get(\OCP\App\IAppManager::class) + ->getAppInfo('memories')['version']; + // get user if logged in try { $uid = Util::getUID(); } catch (\Exception $e) { $uid = null; } + // helper function to get user config values $getAppConfig = function ($key, $default) use ($uid) { return $this->config->getUserValue($uid, Application::APPNAME, $key, $default); }; return new JSONResponse([ - 'version' => $appManager->getAppInfo('memories')['version'], + // general stuff + 'version' => $version, 'vod_disable' => Util::getSystemConfig('memories.vod.disable'), 'video_default_quality' => Util::getSystemConfig('memories.video_default_quality'), 'places_gis' => Util::getSystemConfig('memories.gis_type'), + // enabled apps 'systemtags_enabled' => Util::tagsIsEnabled(), 'albums_enabled' => Util::albumsIsEnabled(), 'recognize_installed' => Util::recognizeIsInstalled(), @@ -90,13 +96,21 @@ public function getUserConfig(): Http\Response 'facerecognition_enabled' => Util::facerecognitionIsEnabled(), 'preview_generator_enabled' => Util::previewGeneratorIsEnabled(), + // general settings 'timeline_path' => $getAppConfig('timelinePath', 'EMPTY'), + 'enable_top_memories' => 'true' === $getAppConfig('enableTopMemories', 'true'), + + // viewer settings + 'livephoto_autoplay' => 'true' === $getAppConfig('livephotoAutoplay', 'true'), + 'sidebar_filepath' => 'true' === $getAppConfig('sidebarFilepath', false), + + // folder settings 'folders_path' => $getAppConfig('foldersPath', '/'), 'show_hidden_folders' => 'true' === $getAppConfig('showHidden', false), 'sort_folder_month' => 'true' === $getAppConfig('sortFolderMonth', false), + + // album settings 'sort_album_month' => 'true' === $getAppConfig('sortAlbumMonth', 'true'), - 'enable_top_memories' => 'true' === $getAppConfig('enableTopMemories', 'true'), - 'livephoto_autoplay' => 'true' === $getAppConfig('livephotoAutoplay', 'true'), ], Http::STATUS_OK); }); } diff --git a/src/components/Metadata.vue b/src/components/Metadata.vue index e7a0618be..30bed0ffc 100644 --- a/src/components/Metadata.vue +++ b/src/components/Metadata.vue @@ -153,9 +153,9 @@ export default defineComponent({ }); } - if (this.imageInfo) { + if (this.filepath) { list.push({ - title: this.imageInfo, + title: this.filepath, subtitle: this.imageInfoSub, icon: ImageIcon, }); @@ -287,8 +287,8 @@ export default defineComponent({ }, /** Image info */ - imageInfo(): string | null { - return this.baseInfo.basename; + filepath(): string | null { + return this.baseInfo.filepath ?? this.baseInfo.basename; }, imageInfoSub(): string[] { @@ -382,10 +382,11 @@ export default defineComponent({ .join(','); // get tags if enabled - const tags = this.config.systemtags_enabled ? 1 : 0; + const tags = Number(this.config.systemtags_enabled); + const filepath = Number(this.config.sidebar_filepath); // get image info - const url = API.Q(utils.getImageInfoUrl(photo), { tags, clusters }); + const url = API.Q(utils.getImageInfoUrl(photo), { tags, clusters, filepath }); const res = await this.guardState(axios.get(url)); if (!res) return null; diff --git a/src/components/Settings.vue b/src/components/Settings.vue index efd926010..e634771bb 100644 --- a/src/components/Settings.vue +++ b/src/components/Settings.vue @@ -44,7 +44,9 @@ > {{ t('memories', 'Show past photos on top of timeline') }} + + {{ t('memories', 'Always load full size image (not recommended)') }} + + + {{ t('memories', 'Show full file path in sidebar') }} + @@ -197,6 +207,7 @@ export default defineComponent({ this.$emit('update:open', false); }, + // Paths settings async chooseTimelinePath() { (this.$refs.multiPathModal).open(this.config.timeline_path.split(';')); }, @@ -223,10 +234,16 @@ export default defineComponent({ } }, + // General settings async updateSquareThumbs() { await this.updateSetting('square_thumbs'); }, + async updateEnableTopMemories() { + await this.updateSetting('enable_top_memories', 'enableTopMemories'); + }, + + // Viewer settings async updateFullResOnZoom() { await this.updateSetting('full_res_on_zoom'); }, @@ -235,14 +252,15 @@ export default defineComponent({ await this.updateSetting('full_res_always'); }, - async updateEnableTopMemories() { - await this.updateSetting('enable_top_memories', 'enableTopMemories'); - }, - async updateLivephotoAutoplay() { await this.updateSetting('livephoto_autoplay', 'livephotoAutoplay'); }, + async updateSidebarFilepath() { + await this.updateSetting('sidebar_filepath', 'sidebarFilepath'); + }, + + // Folders settings async updateShowHidden() { await this.updateSetting('show_hidden_folders', 'showHidden'); }, @@ -251,6 +269,7 @@ export default defineComponent({ await this.updateSetting('sort_folder_month', 'sortFolderMonth'); }, + // Albums settings async updateSortAlbumMonth() { await this.updateSetting('sort_album_month', 'sortAlbumMonth'); }, diff --git a/src/components/viewer/Viewer.vue b/src/components/viewer/Viewer.vue index f6190e479..5d2eebb1b 100644 --- a/src/components/viewer/Viewer.vue +++ b/src/components/viewer/Viewer.vue @@ -1108,7 +1108,7 @@ export default defineComponent({ * Open the files app with the current file. */ async viewInFolder() { - if (this.currentPhoto) dav.viewInFolder(this.currentPhoto); + dav.viewInFolder(this.currentPhoto!); }, /** diff --git a/src/services/dav/other.ts b/src/services/dav/other.ts index 03c995c4f..7204266be 100644 --- a/src/services/dav/other.ts +++ b/src/services/dav/other.ts @@ -8,6 +8,7 @@ import { dirname } from 'path'; * Opens a new window. */ export async function viewInFolder(photo: IPhoto) { + if (!photo) return; const f = await getFiles([photo]); if (f.length === 0) return; diff --git a/src/services/static-config.ts b/src/services/static-config.ts index 1dd57b374..bc035c948 100644 --- a/src/services/static-config.ts +++ b/src/services/static-config.ts @@ -97,11 +97,13 @@ class StaticConfig { } const config: IConfig = { + // general stuff version: '', vod_disable: false, video_default_quality: '0', places_gis: -1, + // enabled apps systemtags_enabled: false, albums_enabled: false, recognize_installed: false, @@ -110,14 +112,23 @@ class StaticConfig { facerecognition_enabled: false, preview_generator_enabled: false, + // general settings timeline_path: '', + enable_top_memories: true, + + // viewer settings + livephoto_autoplay: true, + sidebar_filepath: false, + + // folder settings folders_path: '', show_hidden_folders: false, sort_folder_month: false, + + // album settings sort_album_month: true, - enable_top_memories: true, - livephoto_autoplay: true, + // local settings square_thumbs: false, full_res_on_zoom: true, full_res_always: false, diff --git a/src/types.ts b/src/types.ts index 09fc7187a..e545240b0 100644 --- a/src/types.ts +++ b/src/types.ts @@ -100,6 +100,7 @@ export interface IImageInfo { tags: { [id: string]: string }; permissions: string; + filepath?: string; basename: string; mimetype: string; size: number; @@ -230,11 +231,13 @@ export type ITick = { }; export type IConfig = { + // general stuff version: string; vod_disable: boolean; video_default_quality: string; places_gis: number; + // enabled apps systemtags_enabled: boolean; albums_enabled: boolean; recognize_installed: boolean; @@ -243,14 +246,23 @@ export type IConfig = { facerecognition_enabled: boolean; preview_generator_enabled: boolean; + // general settings timeline_path: string; + enable_top_memories: boolean; + + // viewer settings + livephoto_autoplay: boolean; + sidebar_filepath: boolean; + + // folder settings folders_path: string; show_hidden_folders: boolean; sort_folder_month: boolean; + + // album settings sort_album_month: boolean; - enable_top_memories: boolean; - livephoto_autoplay: boolean; + // local settings square_thumbs: boolean; full_res_on_zoom: boolean; full_res_always: boolean;