Create global preview/full res image settings and allow user to override them

pull/672/head
Rhys Tyers 2023-06-01 20:58:23 +01:00
parent 1be43bdeeb
commit 011a862367
9 changed files with 56 additions and 22 deletions

View File

@ -95,8 +95,8 @@ class OtherController extends GenericApiController
'sort_album_month' => 'true' === $getAppConfig('sortAlbumMonth', 'true'), 'sort_album_month' => 'true' === $getAppConfig('sortAlbumMonth', 'true'),
'enable_top_memories' => 'true' === $getAppConfig('enableTopMemories', 'true'), 'enable_top_memories' => 'true' === $getAppConfig('enableTopMemories', 'true'),
'public_full_res_on_zoom' => Util::getSystemConfig('memories.public_full_res_on_zoom'), 'global_full_res_on_zoom' => Util::getSystemConfig('memories.global_full_res_on_zoom'),
'public_full_res_always' => Util::getSystemConfig('memories.public_full_res_always'), 'global_full_res_always' => Util::getSystemConfig('memories.global_full_res_always'),
], Http::STATUS_OK); ], Http::STATUS_OK);
}); });
} }

View File

@ -70,6 +70,6 @@ return [
'preview_max_memory' => 128, 'preview_max_memory' => 128,
'preview_max_filesize_image' => 50, 'preview_max_filesize_image' => 50,
'memories.public_full_res_on_zoom' => true, 'memories.global_full_res_on_zoom' => true,
'memories.public_full_res_always' => false, 'memories.global_full_res_always' => false,
]; ];

View File

@ -44,11 +44,22 @@
> >
{{ t('memories', 'Show past photos on top of timeline') }} {{ t('memories', 'Show past photos on top of timeline') }}
</NcCheckboxRadioSwitch> </NcCheckboxRadioSwitch>
</NcAppSettingsSection>
<NcAppSettingsSection id="preview-settings" :title="t('memories', 'Previews')">
<NcCheckboxRadioSwitch
:checked.sync="config.override_global_full_res"
@update:checked="updateOverrideGlobalFullRes"
type="switch"
>
{{ t('memories', 'Override the global settings for loading full size images') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch <NcCheckboxRadioSwitch
:checked.sync="config.full_res_on_zoom" :checked.sync="config.full_res_on_zoom"
@update:checked="updateFullResOnZoom" @update:checked="updateFullResOnZoom"
type="switch" type="switch"
:disabled="!config.override_global_full_res"
> >
{{ t('memories', 'Load full size image on zoom') }} {{ t('memories', 'Load full size image on zoom') }}
</NcCheckboxRadioSwitch> </NcCheckboxRadioSwitch>
@ -56,6 +67,7 @@
<NcCheckboxRadioSwitch <NcCheckboxRadioSwitch
:checked.sync="config.full_res_always" :checked.sync="config.full_res_always"
@update:checked="updateFullResAlways" @update:checked="updateFullResAlways"
:disabled="!config.override_global_full_res"
type="switch" type="switch"
> >
{{ t('memories', 'Always load full size image (not recommended)') }} {{ t('memories', 'Always load full size image (not recommended)') }}
@ -219,6 +231,10 @@ export default defineComponent({
await this.updateSetting('square_thumbs'); await this.updateSetting('square_thumbs');
}, },
async updateOverrideGlobalFullRes() {
await this.updateSetting('override_global_full_res');
},
async updateFullResOnZoom() { async updateFullResOnZoom() {
await this.updateSetting('full_res_on_zoom'); await this.updateSetting('full_res_on_zoom');
}, },

View File

@ -29,8 +29,8 @@ export type ISystemConfig = {
preview_max_memory: number; preview_max_memory: number;
preview_max_filesize_image: number; preview_max_filesize_image: number;
'memories.public_full_res_on_zoom': boolean; 'memories.global_full_res_on_zoom': boolean;
'memories.public_full_res_always': boolean; 'memories.global_full_res_always': boolean;
}; };
export type IBinaryStatus = 'ok' | 'not_found' | 'not_executable' | 'test_ok' | string; export type IBinaryStatus = 'ok' | 'not_found' | 'not_executable' | 'test_ok' | string;

View File

@ -64,24 +64,34 @@
/> />
<br /> <br />
{{ t('memories', 'You can set the image viewer to always request a full size image when an image is opened for public folders (there is seperate user setting for logged in users).') }} {{
{{ t('memories', 'This is not recommended if the images require transcoding (i.e. heic images) because it will cause a large amount of CPU usage.') }} t(
'memories',
'You can set the image viewer to always request a full size image when an image is opened, or to open the full size image when an image is zoomed. Users can override this setting.'
)
}}
{{
t(
'memories',
'Always loading the full size image is not recommended if the images require transcoding (i.e. heic images) because it will cause a large amount of CPU usage.'
)
}}
<br /> <br />
<NcCheckboxRadioSwitch <NcCheckboxRadioSwitch
:checked.sync="config['memories.public_full_res_on_zoom']" :checked.sync="config['memories.global_full_res_on_zoom']"
@update:checked="update('memories.public_full_res_on_zoom',)" @update:checked="update('memories.global_full_res_on_zoom')"
type="switch" type="switch"
> >
{{ t('memories', 'Load full size image on zoom for public folders') }} {{ t('memories', 'Load full size image on zoom') }}
</NcCheckboxRadioSwitch> </NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch <NcCheckboxRadioSwitch
:checked.sync="config['memories.public_full_res_always']" :checked.sync="config['memories.global_full_res_always']"
@update:checked="update('memories.public_full_res_always',)" @update:checked="update('memories.global_full_res_always')"
type="switch" type="switch"
> >
{{ t('memories', 'Always load full size image for public folders') }} {{ t('memories', 'Always load full size image') }}
</NcCheckboxRadioSwitch> </NcCheckboxRadioSwitch>
</div> </div>
</template> </template>

View File

@ -798,8 +798,12 @@ export default defineComponent({
? nativex.API.IMAGE_FULL(photo.fileid) ? nativex.API.IMAGE_FULL(photo.fileid)
: API.IMAGE_DECODABLE(photo.fileid, photo.etag); : API.IMAGE_DECODABLE(photo.fileid, photo.etag);
const fullResOnZoom = this.routeIsPublic ? this.config.public_full_res_on_zoom : this.config.full_res_on_zoom; const fullResOnZoom = this.config.override_global_full_res
const fullResAlways = this.routeIsPublic ? this.config.public_full_res_always : this.config.full_res_always; ? this.config.full_res_on_zoom
: this.config.global_full_res_on_zoom;
const fullResAlways = this.config.override_global_full_res
? this.config.full_res_always
: this.config.global_full_res_always;
const fullLoadCond = fullResAlways ? 'always' : fullResOnZoom ? 'zoom' : 'never'; const fullLoadCond = fullResAlways ? 'always' : fullResOnZoom ? 'zoom' : 'never';
return { return {

View File

@ -1,13 +1,15 @@
import axios from '@nextcloud/axios';
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'; import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus';
import { API } from '../services/API'; import { API } from '../services/API';
import { defineComponent } from 'vue';
import { IConfig } from '../types'; import { IConfig } from '../types';
import axios from '@nextcloud/axios';
import { defineComponent } from 'vue';
import staticConfig from '../services/static-config'; import staticConfig from '../services/static-config';
const eventName = 'memories:user-config-changed'; const eventName = 'memories:user-config-changed';
const localSettings: (keyof IConfig)[] = [ const localSettings: (keyof IConfig)[] = [
'square_thumbs', 'square_thumbs',
'override_global_full_res',
'full_res_on_zoom', 'full_res_on_zoom',
'full_res_always', 'full_res_always',
'show_face_rect', 'show_face_rect',

View File

@ -117,13 +117,14 @@ class StaticConfig {
enable_top_memories: true, enable_top_memories: true,
square_thumbs: false, square_thumbs: false,
override_global_full_res: false,
full_res_on_zoom: true, full_res_on_zoom: true,
full_res_always: false, full_res_always: false,
show_face_rect: false, show_face_rect: false,
album_list_sort: 1, album_list_sort: 1,
public_full_res_on_zoom: true, global_full_res_on_zoom: true,
public_full_res_always: false, global_full_res_always: false,
}; };
for (const key in config) { for (const key in config) {

View File

@ -252,10 +252,11 @@ export type IConfig = {
enable_top_memories: boolean; enable_top_memories: boolean;
square_thumbs: boolean; square_thumbs: boolean;
override_global_full_res: boolean;
full_res_on_zoom: boolean; full_res_on_zoom: boolean;
full_res_always: boolean; full_res_always: boolean;
public_full_res_on_zoom: boolean; global_full_res_on_zoom: boolean;
public_full_res_always: boolean; global_full_res_always: boolean;
show_face_rect: boolean; show_face_rect: boolean;
album_list_sort: 1 | 2; album_list_sort: 1 | 2;
}; };