Files
raucao 2cb54813b9 Add weekly and daily wallpaper rotation
Rotate through photos from enabled feeds with a persisted shuffle-bag queue. Weekly changes at local Monday midnight and daily at local midnight; Off keeps the selected photo. Legacy configs migrate to the weekly default, and Rotation now sits above Feeds in the Photos settings.
2026-11-08 22:25:59 +04:00

70 lines
2.1 KiB
Plaintext

import Component from '@glimmer/component';
import { fn } from '@ember/helper';
import { on } from '@ember/modifier';
import { service } from '@ember/service';
const ROTATION_OPTIONS = [
{ value: 'weekly', label: 'Weekly' },
{ value: 'daily', label: 'Daily' },
{ value: 'off', label: 'Off' },
];
// Rotation mode controls for the Photos settings section.
export default class SettingsRotationSettingsComponent extends Component {
@service photos;
rotationOptions = ROTATION_OPTIONS;
isRotation = (mode) => this.photos.rotation === mode;
setRotation = async (mode) => {
await this.photos.setRotation(mode);
};
get rotationDescription() {
switch (this.photos.rotation) {
case 'daily':
return 'Every day at local midnight.';
case 'weekly':
return 'Every Monday at local midnight.';
default:
return 'Keep the selected photo.';
}
}
<template>
<fieldset class="mt-6" data-test-rotation>
<legend class="text-sm font-semibold text-gray-900">Rotation</legend>
<p class="mt-1 text-sm text-gray-500">
How often the wallpaper changes.
</p>
<div class="mt-3 grid grid-cols-3 gap-2">
{{#each this.rotationOptions as |option|}}
<label
class="cursor-pointer rounded-md border px-3 py-2 text-center text-sm font-medium transition-colors
{{if
(this.isRotation option.value)
'border-indigo-600 bg-indigo-50 text-indigo-700'
'border-gray-200 text-gray-600 hover:bg-gray-50'
}}"
>
<input
type="radio"
name="photo-rotation"
value={{option.value}}
checked={{this.isRotation option.value}}
data-test-rotation-option={{option.value}}
{{on "change" (fn this.setRotation option.value)}}
class="sr-only"
/>
{{option.label}}
</label>
{{/each}}
</div>
<p class="mt-2 text-xs text-gray-400">{{this.rotationDescription}}</p>
</fieldset>
</template>
}