mizzkey/packages/frontend/src/pages/settings/statusbar.statusbar.vue

141 lines
5.2 KiB
Vue
Raw Normal View History

<template>
2023-01-06 05:40:17 +01:00
<div class="_gaps_m">
2023-01-05 13:04:56 +01:00
<FormSelect v-model="statusbar.type" placeholder="Please select">
<template #label>{{ i18n.ts.type }}</template>
<option value="rss">RSS</option>
<option value="federation">Federation</option>
<option value="userList">User list timeline</option>
</FormSelect>
2023-01-05 13:04:56 +01:00
<MkInput v-model="statusbar.name" manual-save>
2022-07-07 14:00:42 +02:00
<template #label>{{ i18n.ts.label }}</template>
</MkInput>
2023-01-05 13:04:56 +01:00
<MkSwitch v-model="statusbar.black">
<template #label>Black</template>
</MkSwitch>
2023-01-05 13:04:56 +01:00
<FormRadios v-model="statusbar.size">
2022-07-07 14:00:42 +02:00
<template #label>{{ i18n.ts.size }}</template>
2022-07-03 18:37:47 +02:00
<option value="verySmall">{{ i18n.ts.small }}+</option>
<option value="small">{{ i18n.ts.small }}</option>
<option value="medium">{{ i18n.ts.medium }}</option>
<option value="large">{{ i18n.ts.large }}</option>
<option value="veryLarge">{{ i18n.ts.large }}+</option>
</FormRadios>
<template v-if="statusbar.type === 'rss'">
2023-01-05 13:04:56 +01:00
<MkInput v-model="statusbar.props.url" manual-save type="url">
<template #label>URL</template>
</MkInput>
2023-01-05 13:04:56 +01:00
<MkSwitch v-model="statusbar.props.shuffle">
<template #label>{{ i18n.ts.shuffle }}</template>
</MkSwitch>
2023-01-05 13:04:56 +01:00
<MkInput v-model="statusbar.props.refreshIntervalSec" manual-save type="number">
2022-07-07 14:00:42 +02:00
<template #label>{{ i18n.ts.refreshInterval }}</template>
</MkInput>
2023-01-05 13:04:56 +01:00
<FormRange v-model="statusbar.props.marqueeDuration" :min="5" :max="150" :step="1">
2022-07-07 14:00:42 +02:00
<template #label>{{ i18n.ts.speed }}</template>
<template #caption>{{ i18n.ts.fast }} &lt;-&gt; {{ i18n.ts.slow }}</template>
</FormRange>
2023-01-05 13:04:56 +01:00
<MkSwitch v-model="statusbar.props.marqueeReverse">
2022-07-07 14:00:42 +02:00
<template #label>{{ i18n.ts.reverse }}</template>
</MkSwitch>
</template>
<template v-else-if="statusbar.type === 'federation'">
2023-01-05 13:04:56 +01:00
<MkInput v-model="statusbar.props.refreshIntervalSec" manual-save type="number">
2022-07-07 14:00:42 +02:00
<template #label>{{ i18n.ts.refreshInterval }}</template>
</MkInput>
2023-01-05 13:04:56 +01:00
<FormRange v-model="statusbar.props.marqueeDuration" :min="5" :max="150" :step="1">
2022-07-07 14:00:42 +02:00
<template #label>{{ i18n.ts.speed }}</template>
<template #caption>{{ i18n.ts.fast }} &lt;-&gt; {{ i18n.ts.slow }}</template>
</FormRange>
2023-01-05 13:04:56 +01:00
<MkSwitch v-model="statusbar.props.marqueeReverse">
2022-07-07 14:00:42 +02:00
<template #label>{{ i18n.ts.reverse }}</template>
</MkSwitch>
2023-01-05 13:04:56 +01:00
<MkSwitch v-model="statusbar.props.colored">
2022-07-07 14:00:42 +02:00
<template #label>{{ i18n.ts.colored }}</template>
</MkSwitch>
</template>
<template v-else-if="statusbar.type === 'userList' && userLists != null">
2023-01-05 13:04:56 +01:00
<FormSelect v-model="statusbar.props.userListId">
<template #label>{{ i18n.ts.userList }}</template>
<option v-for="list in userLists" :value="list.id">{{ list.name }}</option>
</FormSelect>
2023-01-05 13:04:56 +01:00
<MkInput v-model="statusbar.props.refreshIntervalSec" manual-save type="number">
2022-07-07 14:00:42 +02:00
<template #label>{{ i18n.ts.refreshInterval }}</template>
</MkInput>
2023-01-05 13:04:56 +01:00
<FormRange v-model="statusbar.props.marqueeDuration" :min="5" :max="150" :step="1">
2022-07-07 14:00:42 +02:00
<template #label>{{ i18n.ts.speed }}</template>
<template #caption>{{ i18n.ts.fast }} &lt;-&gt; {{ i18n.ts.slow }}</template>
</FormRange>
2023-01-05 13:04:56 +01:00
<MkSwitch v-model="statusbar.props.marqueeReverse">
2022-07-07 14:00:42 +02:00
<template #label>{{ i18n.ts.reverse }}</template>
</MkSwitch>
</template>
2023-01-06 01:41:14 +01:00
<div class="_buttons">
<MkButton danger @click="del">{{ i18n.ts.remove }}</MkButton>
</div>
</div>
</template>
<script lang="ts" setup>
import { computed, reactive, ref, watch } from 'vue';
import FormSelect from '@/components/form/select.vue';
import MkInput from '@/components/form/input.vue';
import MkSwitch from '@/components/form/switch.vue';
import FormRadios from '@/components/form/radios.vue';
2023-01-06 01:41:14 +01:00
import MkButton from '@/components/MkButton.vue';
2022-07-07 14:00:42 +02:00
import FormRange from '@/components/form/range.vue';
import * as os from '@/os';
import { defaultStore } from '@/store';
import { i18n } from '@/i18n';
2022-11-17 01:31:07 +01:00
import { deepClone } from '@/scripts/clone';
const props = defineProps<{
_id: string;
userLists: any[] | null;
}>();
2022-11-17 01:31:07 +01:00
const statusbar = reactive(deepClone(defaultStore.state.statusbars.find(x => x.id === props._id)));
watch(() => statusbar.type, () => {
if (statusbar.type === 'rss') {
statusbar.name = 'NEWS';
statusbar.props.url = 'http://feeds.afpbb.com/rss/afpbb/afpbbnews';
statusbar.props.shuffle = true;
statusbar.props.refreshIntervalSec = 120;
statusbar.props.display = 'marquee';
statusbar.props.marqueeDuration = 100;
statusbar.props.marqueeReverse = false;
} else if (statusbar.type === 'federation') {
statusbar.name = 'FEDERATION';
statusbar.props.refreshIntervalSec = 120;
statusbar.props.display = 'marquee';
statusbar.props.marqueeDuration = 100;
statusbar.props.marqueeReverse = false;
statusbar.props.colored = false;
} else if (statusbar.type === 'userList') {
statusbar.name = 'LIST TL';
statusbar.props.refreshIntervalSec = 120;
statusbar.props.display = 'marquee';
statusbar.props.marqueeDuration = 100;
statusbar.props.marqueeReverse = false;
}
});
2022-07-03 18:37:47 +02:00
watch(statusbar, save);
async function save() {
const i = defaultStore.state.statusbars.findIndex(x => x.id === props._id);
2022-11-17 01:31:07 +01:00
const statusbars = deepClone(defaultStore.state.statusbars);
statusbars[i] = deepClone(statusbar);
defaultStore.set('statusbars', statusbars);
}
function del() {
defaultStore.set('statusbars', defaultStore.state.statusbars.filter(x => x.id !== props._id));
}
</script>