parent
991babb2b5
commit
001c63ad90
|
@ -180,10 +180,11 @@ class ImageController extends GenericApiController
|
|||
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 @@ class ImageController extends GenericApiController
|
|||
$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 @@ class ImageController extends GenericApiController
|
|||
$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 = [];
|
||||
|
|
|
@ -64,24 +64,30 @@ class OtherController extends GenericApiController
|
|||
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 @@ class OtherController extends GenericApiController
|
|||
'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);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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<IImageInfo>(url));
|
||||
if (!res) return null;
|
||||
|
||||
|
|
|
@ -44,7 +44,9 @@
|
|||
>
|
||||
{{ t('memories', 'Show past photos on top of timeline') }}
|
||||
</NcCheckboxRadioSwitch>
|
||||
</NcAppSettingsSection>
|
||||
|
||||
<NcAppSettingsSection id="viewer-settings" :title="t('memories', 'Viewer')">
|
||||
<NcCheckboxRadioSwitch
|
||||
:checked.sync="config.livephoto_autoplay"
|
||||
@update:checked="updateLivephotoAutoplay"
|
||||
|
@ -68,6 +70,14 @@
|
|||
>
|
||||
{{ t('memories', 'Always load full size image (not recommended)') }}
|
||||
</NcCheckboxRadioSwitch>
|
||||
|
||||
<NcCheckboxRadioSwitch
|
||||
:checked.sync="config.sidebar_filepath"
|
||||
@update:checked="updateSidebarFilepath"
|
||||
type="switch"
|
||||
>
|
||||
{{ t('memories', 'Show full file path in sidebar') }}
|
||||
</NcCheckboxRadioSwitch>
|
||||
</NcAppSettingsSection>
|
||||
|
||||
<NcAppSettingsSection id="account-settings" :title="t('memories', 'Account')" v-if="isNative">
|
||||
|
@ -197,6 +207,7 @@ export default defineComponent({
|
|||
this.$emit('update:open', false);
|
||||
},
|
||||
|
||||
// Paths settings
|
||||
async chooseTimelinePath() {
|
||||
(<any>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');
|
||||
},
|
||||
|
|
|
@ -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!);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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,
|
||||
sort_album_month: true,
|
||||
enable_top_memories: true,
|
||||
livephoto_autoplay: true,
|
||||
|
||||
// album settings
|
||||
sort_album_month: true,
|
||||
|
||||
// local settings
|
||||
square_thumbs: false,
|
||||
full_res_on_zoom: true,
|
||||
full_res_always: false,
|
||||
|
|
18
src/types.ts
18
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;
|
||||
sort_album_month: boolean;
|
||||
enable_top_memories: boolean;
|
||||
livephoto_autoplay: boolean;
|
||||
|
||||
// album settings
|
||||
sort_album_month: boolean;
|
||||
|
||||
// local settings
|
||||
square_thumbs: boolean;
|
||||
full_res_on_zoom: boolean;
|
||||
full_res_always: boolean;
|
||||
|
|
Loading…
Reference in New Issue