-
-
Notifications
You must be signed in to change notification settings - Fork 167
Expand file tree
/
Copy pathSettings.vue
More file actions
542 lines (460 loc) · 15.2 KB
/
Copy pathSettings.vue
File metadata and controls
542 lines (460 loc) · 15.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
<template>
<div>
<NcAppSettingsDialog
id="memories-settings"
class="memories-modal"
:open="open"
:show-navigation="true"
:name="names.header"
@update:open="onClose"
>
<NcAppSettingsSection id="general-settings" :name="names.general">
<NcTextField
:label="t('memories', 'Timeline Path')"
:label-visible="true"
v-model="config.timeline_path"
@click="chooseTimelinePath"
readonly
/>
<NcCheckboxRadioSwitch :checked.sync="config.square_thumbs" @update:checked="updateSquareThumbs" type="switch">
{{ t('memories', 'Square grid mode') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch
:checked.sync="config.enable_top_memories"
@update:checked="updateEnableTopMemories"
type="switch"
>
{{ t('memories', 'Show past photos on top of timeline') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch
:checked.sync="config.stack_raw_files"
@update:checked="updateStackRawFiles"
type="switch"
>
{{ t('memories', 'Stack RAW files with same name') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch
:checked.sync="config.dedup_identical"
@update:checked="updateDedupIdentical"
type="switch"
>
{{ t('memories', 'De-duplicate identical files') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch
:checked.sync="config.show_owner_name_timeline"
@update:checked="updateShowOwnerNameTimeline"
type="switch"
>
{{ t('memories', 'Show photo owner name on timeline') }}
</NcCheckboxRadioSwitch>
</NcAppSettingsSection>
<NcAppSettingsSection id="viewer-settings" :name="names.viewer">
<NcCheckboxRadioSwitch
:checked.sync="config.livephoto_autoplay"
@update:checked="updateLivephotoAutoplay"
type="switch"
>
{{ t('memories', 'Autoplay Live Photos') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch
:checked.sync="config.livephoto_loop"
@update:checked="updateLivephotoLoop"
type="switch"
>
{{ t('memories', 'Loop Live Photos') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch :checked.sync="config.video_loop" @update:checked="updateVideoLoop" type="switch">
{{ t('memories', 'Loop Videos') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch
:checked.sync="config.sidebar_filepath"
@update:checked="updateSidebarFilepath"
type="switch"
>
{{ t('memories', 'Show full file path in sidebar') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch
:checked.sync="config.metadata_in_slideshow"
@update:checked="updateMetadataInSlideshow"
type="switch"
>
{{ t('memories', 'Show metadata in slideshow') }}
</NcCheckboxRadioSwitch>
<div class="radio-group">
<div class="title">{{ t('memories', 'High resolution image loading behavior') }}</div>
<NcCheckboxRadioSwitch
:checked="highResCond"
value="zoom"
name="vhrc_radio"
type="radio"
@update:checked="updateHighResCond($event)"
>{{ t('memories', 'Load high resolution image on zoom') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch
:checked="highResCond"
value="always"
name="vhrc_radio"
type="radio"
@update:checked="updateHighResCond($event)"
>{{ t('memories', 'Always load high resolution image (not recommended)') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch
:checked="highResCond"
value="never"
name="vhrc_radio"
type="radio"
@update:checked="updateHighResCond($event)"
>{{ t('memories', 'Never load high resolution image') }}
</NcCheckboxRadioSwitch>
</div>
</NcAppSettingsSection>
<NcAppSettingsSection id="onthisday-settings" :name="names.onthisday">
<div class="setting-row">
<label for="onthisday-range">
{{ t('memories', 'Day range:') }}
</label>
<input
id="onthisday-range"
v-model.number="config.onthisday_day_range"
type="number"
min="0"
max="7"
step="1"
@change="updateOnThisDayRange"
/>
<span class="hint">{{ t('memories', '(0-7 days)') }}</span>
</div>
<p class="settings-hint">
{{
t(
'memories',
'Number of days before and after each anniversary to include. For example, 3 means photos from 3 days before to 3 days after.',
)
}}
</p>
<div class="setting-row">
<label for="onthisday-photos">
{{ t('memories', 'Photos per year:') }}
</label>
<input
id="onthisday-photos"
v-model.number="config.onthisday_photos_per_year"
type="number"
min="1"
max="50"
step="1"
@change="updateOnThisDayPhotos"
/>
<span class="hint">{{ t('memories', '(1-50)') }}</span>
</div>
<p class="settings-hint">
{{ t('memories', 'Maximum number of photos to show per year when opening the viewer.') }}
</p>
</NcAppSettingsSection>
<NcAppSettingsSection id="account-settings" :name="names.account" v-if="isNative">
{{ t('memories', 'Logged in as {user}', { user }) }}
<NcButton @click="logout" id="sign-out">
{{ t('memories', 'Sign out') }}
</NcButton>
</NcAppSettingsSection>
<NcAppSettingsSection id="device-settings" :name="t('memories', 'Device Folders')" v-if="isNative">
{{ t('memories', 'Local folders to include in the timeline view') }}
<NcCheckboxRadioSwitch
v-for="folder in localFolders"
:key="folder.id"
:checked.sync="folder.enabled"
@update:checked="updateDeviceFolders"
type="switch"
>
{{ folder.name }}
</NcCheckboxRadioSwitch>
<NcButton @click="runNxSetup()" type="secondary">
{{ t('memories', 'Run initial device setup') }}
</NcButton>
</NcAppSettingsSection>
<NcAppSettingsSection id="folders-settings" :name="names.folders">
<NcTextField
:label="t('memories', 'Folders Path')"
:label-visible="true"
v-model="config.folders_path"
@click="chooseFoldersPath"
readonly
/>
<NcCheckboxRadioSwitch
:checked.sync="config.show_hidden_folders"
@update:checked="updateShowHidden"
type="switch"
>
{{ t('memories', 'Show hidden folders') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch
:checked.sync="config.sort_folder_month"
@update:checked="updateSortFolderMonth"
type="switch"
>
{{ t('memories', 'Sort folders oldest-first') }}
</NcCheckboxRadioSwitch>
</NcAppSettingsSection>
<NcAppSettingsSection id="albums-settings" :name="names.albums">
<NcCheckboxRadioSwitch
:checked.sync="config.sort_album_month"
@update:checked="updateSortAlbumMonth"
type="switch"
>
{{ t('memories', 'Sort albums oldest-first') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch
:checked.sync="config.show_hidden_albums"
@update:checked="updateShowHidden"
type="switch"
>
{{ t('memories', 'Show hidden albums') }}
</NcCheckboxRadioSwitch>
</NcAppSettingsSection>
</NcAppSettingsDialog>
<MultiPathSelectionModal ref="multiPathModal" :title="pathSelTitle" @close="saveTimelinePath" />
</div>
</template>
<style scoped>
input[type='text'] {
width: 100%;
}
.setting-row {
display: flex;
align-items: center;
gap: 10px;
margin: 10px 0;
}
.setting-row label {
min-width: 150px;
}
.setting-row input[type='number'] {
width: 80px;
padding: 5px;
}
.setting-row .hint {
color: var(--color-text-maxcontrast);
font-size: 0.9em;
}
.settings-hint {
margin: 0 0 15px 0;
color: var(--color-text-maxcontrast);
font-size: 0.9em;
}
</style>
<script lang="ts">
import { defineComponent } from 'vue';
import UserConfig from '@mixins/UserConfig';
import { translate as t } from '@services/l10n';
import * as utils from '@services/utils';
import * as nativex from '@native';
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js';
const NcTextField = () => import('@nextcloud/vue/dist/Components/NcTextField.js');
const NcAppSettingsDialog = () => import('@nextcloud/vue/dist/Components/NcAppSettingsDialog.js');
const NcAppSettingsSection = () => import('@nextcloud/vue/dist/Components/NcAppSettingsSection.js');
const NcCheckboxRadioSwitch = () => import('@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js');
import MultiPathSelectionModal from '@components/modal/MultiPathSelectionModal.vue';
import type { IConfig } from '@typings';
export default defineComponent({
name: 'Settings',
components: {
NcButton,
NcTextField,
NcAppSettingsDialog,
NcAppSettingsSection,
NcCheckboxRadioSwitch,
MultiPathSelectionModal,
},
mixins: [UserConfig],
emits: {
'update:open': (open: boolean) => true,
},
data: () => ({
localFolders: [] as nativex.LocalFolderConfig[],
names: {
header: t('memories', 'Memories Settings'),
general: t('memories', 'General'),
viewer: t('memories', 'Photo Viewer'),
onthisday: t('memories', 'On This Day'),
account: t('memories', 'Account'),
folders: t('memories', 'Folders'),
albums: t('memories', 'Albums'),
},
}),
props: {
open: {
type: Boolean,
required: true,
},
},
computed: {
refs() {
return this.$refs as {
multiPathModal: InstanceType<typeof MultiPathSelectionModal>;
};
},
pathSelTitle(): string {
return this.t('memories', 'Choose Timeline Paths');
},
isNative(): boolean {
return nativex.has();
},
user(): string {
return utils.uid ?? String();
},
highResCond(): IConfig['high_res_cond_default'] {
return this.config.high_res_cond || this.config.high_res_cond_default || 'zoom';
},
},
watch: {
open(value: boolean) {
utils.fragment.if(value, utils.fragment.types.settings);
},
},
mounted() {
if (this.isNative) {
this.refreshNativeConfig();
}
// Fragment navigation
utils.bus.on('memories:fragment:pop:settings', this.onClose);
},
beforeDestroy() {
utils.bus.off('memories:fragment:pop:settings', this.onClose);
},
methods: {
onClose() {
this.$emit('update:open', false);
},
// Paths settings
async chooseTimelinePath() {
this.refs.multiPathModal.open(this.config.timeline_path.split(';'));
},
async saveTimelinePath(paths: string[]) {
if (!paths || !paths.length) return;
const newPath = paths.join(';');
if (newPath !== this.config.timeline_path) {
this.config.timeline_path = newPath;
await this.updateSetting('timeline_path', 'timelinePath');
}
},
async chooseFoldersPath() {
const newPath = await utils.chooseNcFolder(
this.t('memories', 'Choose the root for the folders view'),
this.config.folders_path,
);
if (newPath !== this.config.folders_path) {
this.config.folders_path = newPath;
await this.updateSetting('folders_path', 'foldersPath');
}
},
// General settings
async updateSquareThumbs() {
await this.updateSetting('square_thumbs');
},
async updateEnableTopMemories() {
await this.updateSetting('enable_top_memories', 'enableTopMemories');
},
async updateStackRawFiles() {
await this.updateSetting('stack_raw_files', 'stackRawFiles');
},
async updateDedupIdentical() {
await this.updateSetting('dedup_identical', 'dedupIdentical');
},
async updateShowOwnerNameTimeline() {
await this.updateSetting('show_owner_name_timeline', 'showOwnerNameTimeline');
},
// Viewer settings
async updateHighResCond(val: IConfig['high_res_cond']) {
this.config.high_res_cond = val;
await this.updateSetting('high_res_cond');
},
async updateLivephotoAutoplay() {
await this.updateSetting('livephoto_autoplay', 'livephotoAutoplay');
},
async updateLivephotoLoop() {
await this.updateSetting('livephoto_loop', 'livephotoLoop');
},
async updateVideoLoop() {
await this.updateSetting('video_loop', 'videoLoop');
},
async updateSidebarFilepath() {
await this.updateSetting('sidebar_filepath', 'sidebarFilepath');
},
async updateMetadataInSlideshow() {
await this.updateSetting('metadata_in_slideshow', 'metadataInSlideshow');
},
// On This Day settings
async updateOnThisDayRange() {
await this.updateSetting('onthisday_day_range', 'onthisdayDayRange');
},
async updateOnThisDayPhotos() {
await this.updateSetting('onthisday_photos_per_year', 'onthisdayPhotosPerYear');
},
// Folders settings
async updateShowHidden() {
await this.updateSetting('show_hidden_folders', 'showHidden');
await this.updateSetting('show_hidden_albums', 'showHiddenAlbums');
},
async updateSortFolderMonth() {
await this.updateSetting('sort_folder_month', 'sortFolderMonth');
},
// Albums settings
async updateSortAlbumMonth() {
await this.updateSetting('sort_album_month', 'sortAlbumMonth');
},
// --------------- Native APIs start -----------------------------
refreshNativeConfig() {
this.localFolders = nativex.getLocalFolders();
},
updateDeviceFolders() {
nativex.setLocalFolders(this.localFolders);
},
runNxSetup() {
this.$router.replace('/nxsetup');
},
async logout() {
if (
await utils.confirmDestructive({
title: this.t('memories', 'Sign out'),
message: this.t('memories', 'Are you sure you want to log out {user}?', { user: this.user }),
confirm: this.t('memories', 'Sign out'),
confirmClasses: 'error',
cancel: this.t('memories', 'Cancel'),
})
) {
nativex.logout();
}
},
},
});
</script>
<style lang="scss" scoped>
#memories-settings:deep {
.app-settings__content {
// Fix weirdness when focusing on toggle input on mobile
position: relative;
}
input[readonly] {
cursor: pointer;
user-select: none;
}
.app-settings-section {
margin-bottom: 20px !important;
}
#sign-out {
margin-top: 10px;
}
.checkbox-radio-switch__label {
padding: 1px 14px; // was 4px 14px, make it more compact
}
.radio-group {
margin-top: 6px;
.title {
font-weight: 500;
}
.checkbox-radio-switch-radio {
margin: 2px 16px; // indent for radio button
}
}
}
</style>