admin: allow preview configuration (close #587)
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/672/head
parent
8b37c33154
commit
b2bb64e83d
|
@ -62,7 +62,11 @@ return [
|
|||
// 1080 => 1080p (and so on)
|
||||
'memories.video_default_quality' => '0',
|
||||
|
||||
// Preview providers for Nextcloud
|
||||
// Memories only provides an admin interface for these
|
||||
// https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#previews
|
||||
'enabledPreviewProviders' => [],
|
||||
'preview_max_x' => 4096,
|
||||
'preview_max_y' => 4096,
|
||||
'preview_max_memory' => 128,
|
||||
'preview_max_filesize_image' => 50,
|
||||
];
|
||||
|
|
10
lib/Util.php
10
lib/Util.php
|
@ -370,6 +370,9 @@ class Util
|
|||
throw new \InvalidArgumentException("Invalid system config key: {$key}");
|
||||
}
|
||||
|
||||
// Key belongs to memories namespace
|
||||
$isAppKey = str_starts_with($key, Application::APPNAME.'.');
|
||||
|
||||
// Check if the value has the correct type
|
||||
if (null !== $value && \gettype($value) !== \gettype($defaults[$key])) {
|
||||
$expected = \gettype($defaults[$key]);
|
||||
|
@ -378,7 +381,12 @@ class Util
|
|||
throw new \InvalidArgumentException("Invalid type for system config {$key}, expected {$expected}, got {$got}");
|
||||
}
|
||||
|
||||
if ($value === $defaults[$key] || null === $value) {
|
||||
// Do not allow null for non-app keys
|
||||
if (!$isAppKey && null === $value) {
|
||||
throw new \InvalidArgumentException("Invalid value for system config {$key}, null is not allowed");
|
||||
}
|
||||
|
||||
if ($isAppKey && ($value === $defaults[$key] || null === $value)) {
|
||||
$config->deleteSystemValue($key);
|
||||
} else {
|
||||
$config->setSystemValue($key, $value);
|
||||
|
|
|
@ -24,6 +24,10 @@ export type ISystemConfig = {
|
|||
'memories.vod.nvenc.scale': string;
|
||||
|
||||
enabledPreviewProviders: string[];
|
||||
preview_max_x: number;
|
||||
preview_max_y: number;
|
||||
preview_max_memory: number;
|
||||
preview_max_filesize_image: number;
|
||||
};
|
||||
|
||||
export type IBinaryStatus = 'ok' | 'not_found' | 'not_executable' | 'test_ok' | string;
|
||||
|
|
|
@ -25,6 +25,43 @@
|
|||
<code v-if="status"
|
||||
><template v-for="mime in status.mimes">{{ mime }}<br :key="mime" /></template
|
||||
></code>
|
||||
|
||||
<br />
|
||||
|
||||
{{ t('memories', 'Max preview size (trade-off between quality and storage requirements).') }}
|
||||
<a href="https://memories.gallery/config/#preview-storage" target="_blank">
|
||||
{{ t('memories', 'Documentation.') }}
|
||||
</a>
|
||||
<br />
|
||||
<NcCheckboxRadioSwitch
|
||||
class="preview-box"
|
||||
v-for="size in previewSizes"
|
||||
:key="size"
|
||||
:checked="config['preview_max_x']"
|
||||
:value="size"
|
||||
name="previewsize_radio"
|
||||
type="radio"
|
||||
@update:checked="updatePreviewSize(size)"
|
||||
>{{ size }}px
|
||||
</NcCheckboxRadioSwitch>
|
||||
|
||||
<NcTextField
|
||||
type="number"
|
||||
placeholder="1024"
|
||||
:label="t('memories', 'Max memory for preview generation (MB)')"
|
||||
:label-visible="true"
|
||||
:value="config['preview_max_memory']"
|
||||
@change="update('preview_max_memory', Number($event.target.value))"
|
||||
/>
|
||||
|
||||
<NcTextField
|
||||
type="number"
|
||||
placeholder="50"
|
||||
:label="t('memories', 'Max size of preview files (MB)')"
|
||||
:label-visible="true"
|
||||
:value="config['preview_max_filesize_image']"
|
||||
@change="update('preview_max_filesize_image', Number($event.target.value))"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -54,6 +91,8 @@ export default defineComponent({
|
|||
name: t('memories', 'Videos (ffmpeg)'),
|
||||
},
|
||||
},
|
||||
|
||||
previewSizes: [512, 1024, 2048, 4096, 8192],
|
||||
}),
|
||||
|
||||
methods: {
|
||||
|
@ -76,6 +115,19 @@ export default defineComponent({
|
|||
|
||||
this.update('enabledPreviewProviders');
|
||||
},
|
||||
|
||||
async updatePreviewSize(size: number) {
|
||||
this.update('preview_max_x', size);
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000)); // Hack to prevent config race
|
||||
this.update('preview_max_y', size);
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.preview-box {
|
||||
display: inline-block !important;
|
||||
margin: 0 10px;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Reference in New Issue