text
stringlengths
9
39.2M
dir
stringlengths
26
295
lang
stringclasses
185 values
created_date
timestamp[us]
updated_date
timestamp[us]
repo_name
stringlengths
1
97
repo_full_name
stringlengths
7
106
star
int64
1k
183k
len_tokens
int64
1
13.8M
```vue <template> <div class="public-page"> <div class="card p-2"> <div class="card-body"> <div class="row mb-4"> <div class="col-sm"> <h2 v-if="hideProductName" class="card-title text-center" > {{ $gettext('Welcome!') }} </h2> <h2 v-else class="card-title text-center" > {{ $gettext('Welcome to AzuraCast!') }} </h2> <h3 v-if="instanceName" class="card-subtitle text-center text-muted" > {{ instanceName }} </h3> </div> </div> <form id="login-form" action="" method="post" > <div class="form-group"> <label for="username" class="mb-2 d-flex align-items-center gap-2" > <icon :icon="IconMail" /> <strong> {{ $gettext('E-mail Address') }} </strong> </label> <input id="username" type="email" name="username" class="form-control" autocomplete="username webauthn" :placeholder="$gettext('name@example.com')" :aria-label="$gettext('E-mail Address')" required autofocus > </div> <div class="form-group mt-3"> <label for="password" class="mb-2 d-flex align-items-center gap-2" > <icon :icon="IconVpnKey" /> <strong>{{ $gettext('Password') }}</strong> </label> <input id="password" type="password" name="password" class="form-control" autocomplete="current-password" :placeholder="$gettext('Enter your password')" :aria-label="$gettext('Password')" required > </div> <div class="form-group mt-4"> <div class="custom-control custom-checkbox"> <input id="frm_remember_me" type="checkbox" name="remember" value="1" class="toggle-switch custom-control-input" > <label for="frm_remember_me" class="custom-control-label" > {{ $gettext('Remember me') }} </label> </div> </div> <div class="block-buttons mt-3 mb-3"> <button type="submit" role="button" :title="$gettext('Sign In')" class="btn btn-login btn-primary" > {{ $gettext('Sign In') }} </button> </div> </form> <form v-if="passkeySupported" id="webauthn-form" ref="$webAuthnForm" :action="webAuthnUrl" method="post" > <input type="hidden" name="validateData" :value="validateData" > <div class="block-buttons mb-3"> <button type="button" role="button" :title="$gettext('Sign In with Passkey')" class="btn btn-sm btn-secondary" @click="logInWithPasskey" > {{ $gettext('Sign In with Passkey') }} </button> </div> </form> <p class="text-center m-0"> {{ $gettext('Please log in to continue.') }} <a :href="forgotPasswordUrl"> {{ $gettext('Forgot your password?') }} </a> </p> </div> </div> </div> </template> <script setup lang="ts"> import Icon from "~/components/Common/Icon.vue"; import {IconMail, IconVpnKey} from "~/components/Common/icons.ts"; import useWebAuthn from "~/functions/useWebAuthn.ts"; import {useAxios} from "~/vendor/axios.ts"; import {nextTick, onMounted, ref} from "vue"; const props = defineProps({ hideProductName: { type: Boolean, default: true }, instanceName: { type: String, default: null }, forgotPasswordUrl: { type: String, default: null }, webAuthnUrl: { type: String, default: null } }); const { isSupported: passkeySupported, isConditionalSupported: passkeyConditionalSupported, doValidate } = useWebAuthn(); const {axios} = useAxios(); const $webAuthnForm = ref<HTMLFormElement | null>(null); const validateArgs = ref<object | null>(null); const validateData = ref<string | null>(null); const handleValidationResponse = async (validateResp) => { validateData.value = JSON.stringify(validateResp); await nextTick(); $webAuthnForm.value?.submit(); } const logInWithPasskey = async () => { if (validateArgs.value === null) { validateArgs.value = await axios.get(props.webAuthnUrl).then(r => r.data); } try { const validateResp = await doValidate(validateArgs.value, false); await handleValidationResponse(validateResp); } catch (e) { console.error(e); } }; onMounted(async () => { const isConditionalSupported = await passkeyConditionalSupported(); if (!isConditionalSupported) { return; } // Call WebAuthn authentication validateArgs.value = await axios.get(props.webAuthnUrl).then(r => r.data); try { const validateResp = await doValidate(validateArgs.value, true); await handleValidationResponse(validateResp); } catch (e) { console.error(e); } }); </script> ```
/content/code_sandbox/frontend/components/Login.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,281
```vue <template> <loading :loading="chartsLoading" > <tabs> <tab :label="$gettext('Average Listeners')"> <time-series-chart style="width: 100%;" :data="chartsData.average.metrics" :alt="chartsData.average.alt" :aspect-ratio="3" /> </tab> <tab :label="$gettext('Unique Listeners')"> <time-series-chart style="width: 100%;" :data="chartsData.unique.metrics" :alt="chartsData.unique.alt" :aspect-ratio="3" /> </tab> </tabs> </loading> </template> <script setup lang="ts"> import TimeSeriesChart from '~/components/Common/Charts/TimeSeriesChart.vue'; import {useAsyncState} from "@vueuse/core"; import {useAxios} from "~/vendor/axios"; import Loading from "~/components/Common/Loading.vue"; import Tabs from "~/components/Common/Tabs.vue"; import Tab from "~/components/Common/Tab.vue"; const props = defineProps({ chartsUrl: { type: String, required: true } }); const {axios} = useAxios(); const {state: chartsData, isLoading: chartsLoading} = useAsyncState( () => axios.get(props.chartsUrl).then((r) => r.data), { average: { metrics: [], alt: [] }, unique: { metrics: [], alt: [] } } ); </script> ```
/content/code_sandbox/frontend/components/DashboardCharts.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
332
```vue <template> <div id="dashboard" class="row-of-cards" > <section class="card" role="region" :aria-label="$gettext('Account Details')" > <user-info-panel> <a class="btn btn-dark" role="button" :href="profileUrl" > <icon :icon="IconAccountCircle" /> <span>{{ $gettext('My Account') }}</span> </a> <a v-if="showAdmin" class="btn btn-dark" role="button" :href="adminUrl" > <icon :icon="IconSettings" /> <span>{{ $gettext('Administration') }}</span> </a> </user-info-panel> <template v-if="!notificationsLoading && notifications.length > 0"> <div v-for="notification in notifications" :key="notification.title" class="card-body d-flex align-items-center alert flex-md-row flex-column" :class="'alert-'+notification.type" role="alert" aria-live="polite" > <div v-if="'info' === notification.type" class="flex-shrink-0 me-3" > <icon :icon="IconInfo" class="lg" /> </div> <div v-else class="flex-shrink-0 me-3" > <icon :icon="IconWarning" class="lg" /> </div> <div class="flex-fill"> <h4>{{ notification.title }}</h4> <p class="card-text"> {{ notification.body }} </p> </div> <div v-if="notification.actionLabel && notification.actionUrl" class="flex-shrink-0 ms-md-3 mt-3 mt-md-0" > <a class="btn btn-sm" :class="'btn-'+notification.type" :href="notification.actionUrl" target="_blank" > {{ notification.actionLabel }} </a> </div> </div> </template> </section> <card-page v-if="showCharts" header-id="hdr_listeners_per_station" > <template #header="{id}"> <div class="d-flex align-items-center"> <div class="flex-fill"> <h3 :id="id" class="card-title" > {{ $gettext('Listeners Per Station') }} </h3> </div> <div class="flex-shrink-0"> <button type="button" class="btn btn-sm btn-dark py-2" @click="chartsVisible = !chartsVisible" > {{ langShowHideCharts }} </button> </div> </div> </template> <div v-if="chartsVisible" id="charts" class="card-body" > <dashboard-charts :charts-url="chartsUrl" /> </div> </card-page> <card-page header-id="hdr_stations"> <template #header="{id}"> <div class="d-flex flex-wrap align-items-center"> <div class="flex-fill"> <h2 :id="id" class="card-title" > {{ $gettext('Station Overview') }} </h2> </div> <div v-if="showAdmin" class="flex-shrink-0" > <a class="btn btn-dark py-2" :href="manageStationsUrl" > <icon :icon="IconSettings" /> <span> {{ $gettext('Manage Stations') }} </span> </a> </div> </div> </template> <data-table id="dashboard_stations" ref="$datatable" :fields="stationFields" :api-url="stationsUrl" paginated responsive show-toolbar :hide-on-loading="false" > <template #cell(play_button)="{ item }"> <play-button class="file-icon btn-lg" :url="item.station.listen_url" is-stream /> </template> <template #cell(name)="{ item }"> <div class="h5 m-0"> {{ item.station.name }} </div> <div v-if="item.station.is_public"> <a :href="item.links.public" target="_blank" > {{ $gettext('Public Page') }} </a> </div> </template> <template #cell(listeners)="{ item }"> <span class="pe-1"> <icon class="sm align-middle" :icon="IconHeadphones" /> </span> <template v-if="item.links.listeners"> <a :href="item.links.listeners" :aria-label="$gettext('View Listener Report')" > {{ item.listeners.total }} </a> </template> <template v-else> {{ item.listeners.total }} </template> </template> <template #cell(now_playing)="{ item }"> <div class="d-flex align-items-center"> <album-art v-if="showAlbumArt" :src="item.now_playing.song.art" class="flex-shrink-0 pe-3" /> <div v-if="!item.is_online" class="flex-fill text-muted" > {{ $gettext('Station Offline') }} </div> <div v-else-if="item.now_playing.song.title !== ''" class="flex-fill" > <strong><span class="nowplaying-title"> {{ item.now_playing.song.title }} </span></strong><br> <span class="nowplaying-artist">{{ item.now_playing.song.artist }}</span> </div> <div v-else class="flex-fill" > <strong><span class="nowplaying-title"> {{ item.now_playing.song.text }} </span></strong> </div> </div> </template> <template #cell(actions)="{ item }"> <a class="btn btn-primary" :href="item.links.manage" role="button" > {{ $gettext('Manage') }} </a> </template> </data-table> </card-page> </div> <header-inline-player /> <lightbox ref="$lightbox" /> </template> <script setup lang="ts"> import Icon from '~/components/Common/Icon.vue'; import PlayButton from "~/components/Common/PlayButton.vue"; import AlbumArt from "~/components/Common/AlbumArt.vue"; import {useAxios} from "~/vendor/axios"; import {useAsyncState, useIntervalFn} from "@vueuse/core"; import {computed, ref} from "vue"; import DashboardCharts from "~/components/DashboardCharts.vue"; import {useTranslate} from "~/vendor/gettext"; import Lightbox from "~/components/Common/Lightbox.vue"; import CardPage from "~/components/Common/CardPage.vue"; import HeaderInlinePlayer from "~/components/HeaderInlinePlayer.vue"; import {LightboxTemplateRef, useProvideLightbox} from "~/vendor/lightbox"; import useOptionalStorage from "~/functions/useOptionalStorage"; import {IconAccountCircle, IconHeadphones, IconInfo, IconSettings, IconWarning} from "~/components/Common/icons"; import UserInfoPanel from "~/components/Account/UserInfoPanel.vue"; import {getApiUrl} from "~/router.ts"; import DataTable, {DataTableField} from "~/components/Common/DataTable.vue"; import useHasDatatable, {DataTableTemplateRef} from "~/functions/useHasDatatable.ts"; const props = defineProps({ profileUrl: { type: String, required: true }, adminUrl: { type: String, required: true }, showAdmin: { type: Boolean, required: true }, showCharts: { type: Boolean, required: true }, manageStationsUrl: { type: String, required: true }, showAlbumArt: { type: Boolean, required: true } }); const notificationsUrl = getApiUrl('/frontend/dashboard/notifications'); const chartsUrl = getApiUrl('/frontend/dashboard/charts'); const stationsUrl = getApiUrl('/frontend/dashboard/stations'); const chartsVisible = useOptionalStorage<boolean>('dashboard_show_chart', true); const {$gettext} = useTranslate(); const langShowHideCharts = computed(() => { return (chartsVisible.value) ? $gettext('Hide Charts') : $gettext('Show Charts') }); const {axios} = useAxios(); const {state: notifications, isLoading: notificationsLoading} = useAsyncState( () => axios.get(notificationsUrl.value).then((r) => r.data), [] ); const stationFields: DataTableField[] = [ { key: 'play_button', sortable: false, class: 'shrink' }, { key: 'name', label: $gettext('Station Name'), sortable: true, }, { key: 'listeners', label: $gettext('Listeners'), sortable: true }, { key: 'now_playing', label: $gettext('Now Playing'), sortable: true }, { key: 'actions', sortable: false, class: 'shrink' } ]; const $datatable = ref<DataTableTemplateRef>(null); const {refresh} = useHasDatatable($datatable); useIntervalFn( refresh, computed(() => (document.hidden) ? 30000 : 15000) ); const $lightbox = ref<LightboxTemplateRef>(null); useProvideLightbox($lightbox); </script> ```
/content/code_sandbox/frontend/components/Dashboard.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
2,160
```vue <template> <audio-player ref="$player" :volume="volume" :is-muted="isMuted" @update:duration="onUpdateDuration" @update:current-time="onUpdateCurrentTime" @update:progress="onUpdateProgress" /> <div v-if="isPlaying" v-bind="$attrs" class="player-inline" > <div v-if="!current.isStream && duration !== 0" class="inline-seek d-inline-flex align-items-center ms-1" > <div class="flex-shrink-0 mx-1 text-white-50 time-display"> {{ currentTimeText }} </div> <div class="flex-fill mx-2"> <input v-model="progress" type="range" :title="$gettext('Seek')" class="player-seek-range form-range" min="0" max="100" step="1" > </div> <div class="flex-shrink-0 mx-1 text-white-50 time-display"> {{ durationText }} </div> </div> <button type="button" class="btn p-2 ms-2 text-reset" :aria-label="$gettext('Stop')" @click="stop()" > <icon :icon="IconStop" /> </button> <div class="inline-volume-controls d-inline-flex align-items-center ms-2"> <div class="flex-shrink-0"> <mute-button class="btn p-2 text-reset" :volume="volume" :is-muted="isMuted" @toggle-mute="toggleMute" /> </div> <div class="flex-fill mx-1"> <input v-model.number="volume" type="range" :title="$gettext('Volume')" class="player-volume-range form-range" min="0" max="100" step="1" > </div> </div> </div> </template> <script setup lang="ts"> import AudioPlayer from '~/components/Common/AudioPlayer.vue'; import formatTime from '~/functions/formatTime'; import Icon from '~/components/Common/Icon.vue'; import {computed, Ref, ref} from "vue"; import MuteButton from "~/components/Common/MuteButton.vue"; import usePlayerVolume from "~/functions/usePlayerVolume"; import {IconStop} from "~/components/Common/icons"; import {usePlayerStore} from "~/functions/usePlayerStore.ts"; defineOptions({ inheritAttrs: false }); const {isPlaying, current, stop} = usePlayerStore(); const volume = usePlayerVolume(); const isMuted = ref(false); const duration: Ref<number> = ref(0); const currentTime: Ref<number> = ref(0); const rawProgress: Ref<number> = ref(0); const onUpdateDuration = (newValue: number) => { duration.value = newValue; }; const onUpdateCurrentTime = (newValue: number) => { currentTime.value = newValue; }; const onUpdateProgress = (newValue: number) => { rawProgress.value = newValue; }; const durationText = computed(() => formatTime(duration.value)); const currentTimeText = computed(() => formatTime(currentTime.value)); const $player = ref<InstanceType<typeof AudioPlayer> | null>(null); const progress = computed({ get: () => { return rawProgress.value; }, set: (prog) => { $player.value?.setProgress(prog); rawProgress.value = prog; } }); const toggleMute = () => { isMuted.value = !isMuted.value; }; defineExpose({ stop }); </script> <style lang="scss"> .player-inline { .inline-seek { width: 300px; div.time-display { font-size: 90%; } } .inline-volume-controls { width: 125px; } input.player-volume-range, input.player-seek-range { width: 100%; height: 10px; } } </style> ```
/content/code_sandbox/frontend/components/InlinePlayer.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
885
```vue <template> <teleport to="#radio-player-controls"> <inline-player class="ms-3" /> </teleport> </template> <script setup lang="ts"> import InlinePlayer from "~/components/InlinePlayer.vue"; </script> ```
/content/code_sandbox/frontend/components/HeaderInlinePlayer.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
53
```vue <template> <h2 class="outside-card-header mb-1"> {{ $gettext('My Account') }} </h2> <section class="card mb-4" role="region" :aria-label="$gettext('Account Details')" > <user-info-panel ref="$userInfoPanel"> <button type="button" class="btn btn-dark" @click="doEditProfile" > <icon :icon="IconEdit" /> <span> {{ $gettext('Edit Profile') }} </span> </button> </user-info-panel> </section> <div class="row row-of-cards"> <div class="col-sm-12 col-md-6"> <security-panel /> </div> <div class="col-sm-12 col-md-6"> <api-keys-panel /> </div> </div> <account-edit-modal ref="$editModal" :supported-locales="supportedLocales" @reload="onProfileEdited" /> </template> <script setup lang="ts"> import Icon from "~/components/Common/Icon.vue"; import AccountEditModal from "./Account/EditModal.vue"; import {ref} from "vue"; import {IconEdit} from "~/components/Common/icons"; import UserInfoPanel from "~/components/Account/UserInfoPanel.vue"; import SecurityPanel from "~/components/Account/SecurityPanel.vue"; import ApiKeysPanel from "~/components/Account/ApiKeysPanel.vue"; const props = defineProps({ supportedLocales: { type: Object, default: () => { return {}; } } }); const $editModal = ref<InstanceType<typeof AccountEditModal> | null>(null); const doEditProfile = () => { $editModal.value?.open(); }; const onProfileEdited = () => { location.reload(); }; </script> ```
/content/code_sandbox/frontend/components/Account.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
404
```vue <template> <slot /> </template> <script setup lang="ts"> import {useProvidePlayerStore} from "~/functions/usePlayerStore.ts"; import {nextTick, onMounted} from "vue"; useProvidePlayerStore('global'); onMounted(async () => { await nextTick(); document.dispatchEvent(new CustomEvent("vue-ready")); }); </script> ```
/content/code_sandbox/frontend/components/MinimalLayout.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
76
```vue <template> <div class="d-flex justify-content-center align-items-center text-center mb-3 mt-2 px-5"> <div class="rounded border p-2 m-2" :class="getStepperClass(1)" > <small>{{ $gettext('Step %{step}', {step: 1}) }}</small><br> {{ $gettext('Create Account') }} </div> <div> <icon :icon="IconArrowRight" class="xl" /> </div> <div class="rounded border p-2 m-2" :class="getStepperClass(2)" > <small>{{ $gettext('Step %{step}', {step: 2}) }}</small><br> {{ $gettext('Create Station') }} </div> <div> <icon :icon="IconArrowRight" class="xl" /> </div> <div class="rounded border p-2 m-2" :class="getStepperClass(3)" > <small>{{ $gettext('Step %{step}', {step: 3}) }}</small><br> {{ $gettext('System Settings') }} </div> </div> </template> <script setup lang="ts"> import Icon from "~/components/Common/Icon.vue"; import {IconArrowRight} from "~/components/Common/icons"; const props = defineProps({ step: { type: Number, default: 1 } }); const getStepperClass = (currentStep) => { if (props.step === currentStep) { return ['text-primary-emphasis', 'bg-primary-subtle', 'border-primary-subtle']; } else { return ['text-secondary-emphasis', 'bg-secondary-subtle', 'border-secondary-subtle']; } } </script> ```
/content/code_sandbox/frontend/components/Setup/SetupStep.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
406
```vue <template> <setup-step :step="2" /> <section class="card" role="region" aria-labelledby="hdr_new_station" > <div class="card-header text-bg-primary"> <h3 id="hdr_new_station" class="card-title" > {{ $gettext('Create a New Radio Station') }} </h3> </div> <info-card> {{ $gettext('Continue the setup process by creating your first radio station below. You can edit any of these details later.') }} </info-card> <div class="card-body"> <admin-stations-form v-bind="$props" ref="$adminForm" :is-edit-mode="false" :create-url="createUrl" @submitted="onSubmitted" > <template #submitButtonText> {{ $gettext('Create and Continue') }} </template> </admin-stations-form> </div> </section> </template> <script setup lang="ts"> import AdminStationsForm from "~/components/Admin/Stations/StationForm.vue"; import SetupStep from "./SetupStep.vue"; import InfoCard from "~/components/Common/InfoCard.vue"; import {onMounted, ref} from "vue"; import stationFormProps from "~/components/Admin/Stations/stationFormProps"; const props = defineProps({ ...stationFormProps, createUrl: { type: String, required: true }, continueUrl: { type: String, required: true } }); const $adminForm = ref<InstanceType<typeof AdminStationsForm> | null>(null); onMounted(() => { $adminForm.value?.reset(); }); const onSubmitted = () => { window.location.href = props.continueUrl; } </script> ```
/content/code_sandbox/frontend/components/Setup/Station.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
390
```vue <template> <a class="visually-hidden-focusable" href="#content" > {{ $gettext('Skip to main content') }} </a> <header class="navbar bg-primary-dark shadow-sm fixed-top"> <template v-if="slots.sidebar"> <button id="navbar-toggle" data-bs-toggle="offcanvas" data-bs-target="#sidebar" aria-controls="sidebar" aria-expanded="false" :aria-label="$gettext('Toggle Sidebar')" class="navbar-toggler d-inline-flex d-lg-none me-3" > <icon :icon="IconMenu" class="lg" /> </button> </template> <a class="navbar-brand ms-0 me-auto" :href="homeUrl" > azura<strong>cast</strong> <small v-if="instanceName">{{ instanceName }}</small> </a> <div id="radio-player-controls" /> <div class="dropdown ms-3 d-inline-flex align-items-center"> <div class="me-2"> {{ userDisplayName }} </div> <button aria-expanded="false" aria-haspopup="true" class="navbar-toggler" :aria-label="$gettext('Toggle Menu')" data-bs-toggle="dropdown" type="button" > <icon :icon="IconMenuOpen" class="lg" /> </button> <ul class="dropdown-menu dropdown-menu-end"> <li> <a class="dropdown-item" :href="homeUrl" > <icon :icon="IconHome" /> {{ $gettext('Dashboard') }} </a> </li> <li class="dropdown-divider"> &nbsp; </li> <li v-if="showAdmin"> <a class="dropdown-item" :href="adminUrl" > <icon :icon="IconSettings" /> {{ $gettext('System Administration') }} </a> </li> <li> <a class="dropdown-item" :href="profileUrl" > <icon :icon="IconAccountCircle" /> {{ $gettext('My Account') }} </a> </li> <li> <a class="dropdown-item theme-switcher" href="#" @click.prevent="toggleTheme" > <icon :icon="IconInvertColors" /> {{ $gettext('Switch Theme') }} </a> </li> <li class="dropdown-divider"> &nbsp; </li> <li> <a class="dropdown-item" href="/docs/" target="_blank" > <icon :icon="IconSupport" /> {{ $gettext('Documentation') }} </a> </li> <li> <a class="dropdown-item" href="/docs/help/troubleshooting/" target="_blank" > <icon :icon="IconHelp" /> {{ $gettext('Help') }} </a> </li> <li class="dropdown-divider"> &nbsp; </li> <li> <a class="dropdown-item" :href="logoutUrl" > <icon :icon="IconExitToApp" /> {{ $gettext('Sign Out') }} </a> </li> </ul> </div> </header> <nav v-if="slots.sidebar" id="sidebar" class="navdrawer offcanvas offcanvas-start" tabindex="-1" :aria-label="$gettext('Sidebar')" > <slot name="sidebar" /> </nav> <div id="page-wrapper" :class="[(slots.sidebar) ? 'has-sidebar' : '']" > <main id="main"> <div class="container"> <slot /> </div> </main> <footer id="footer"> {{ $gettext('Powered by') }} <a href="path_to_url" target="_blank" >AzuraCast</a> &bull; <span v-html="version" /> &bull; <span v-html="platform" /><br> {{ $gettext('Like our software?') }} <a href="path_to_url" target="_blank" > {{ $gettext('Donate to support AzuraCast!') }} </a> </footer> </div> </template> <script setup lang="ts"> import {nextTick, onMounted, useSlots, watch} from "vue"; import Icon from "~/components/Common/Icon.vue"; import useTheme from "~/functions/theme"; import { IconAccountCircle, IconExitToApp, IconHelp, IconHome, IconInvertColors, IconMenu, IconMenuOpen, IconSettings, IconSupport } from "~/components/Common/icons"; import {useProvidePlayerStore} from "~/functions/usePlayerStore.ts"; const props = defineProps({ instanceName: { type: String, required: true }, userDisplayName: { type: String, required: true }, homeUrl: { type: String, required: true, }, profileUrl: { type: String, required: true, }, adminUrl: { type: String, required: true }, logoutUrl: { type: String, required: true }, showAdmin: { type: Boolean, default: false }, version: { type: String, required: true }, platform: { type: String, required: true } }); const slots = useSlots(); const handleSidebar = () => { if (slots.sidebar) { document.body.classList.add('has-sidebar'); } else { document.body.classList.remove('has-sidebar'); } } const {toggleTheme} = useTheme(); watch( () => slots.sidebar, handleSidebar, { immediate: true } ); useProvidePlayerStore('global'); onMounted(async () => { await nextTick(); document.dispatchEvent(new CustomEvent("vue-ready")); }); </script> ```
/content/code_sandbox/frontend/components/PanelLayout.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,367
```vue <template> <admin-settings v-bind="props" @saved="onSaved" > <template #preCard> <setup-step :step="3" /> </template> <template #cardTitle> {{ $gettext('Customize AzuraCast Settings') }} </template> <template #cardUpper> <info-card> {{ $gettext('Complete the setup process by providing some information about your broadcast environment. These settings can be changed later from the administration panel.') }} </info-card> </template> <template #submitButtonName> {{ $gettext('Save and Continue') }} </template> </admin-settings> </template> <script setup lang="ts"> import AdminSettings from "~/components/Admin/Settings.vue"; import SetupStep from "./SetupStep.vue"; import InfoCard from "~/components/Common/InfoCard.vue"; import settingsProps from "~/components/Admin/settingsProps"; const props = defineProps({ ...settingsProps, continueUrl: { type: String, required: true } }); const onSaved = () => { window.location.href = props.continueUrl; } </script> ```
/content/code_sandbox/frontend/components/Setup/Settings.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
249
```vue <template> <div class="public-page"> <section class="card" role="region" aria-labelledby="hdr_first_time_setup" > <div class="card-body p-4"> <div class="row mb-2"> <div class="col-sm"> <h2 id="hdr_first_time_setup" class="card-title mb-0 text-center" > {{ $gettext('AzuraCast First-Time Setup') }} </h2> <h3 class="text-center"> <small class="text-muted"> {{ $gettext('Welcome to AzuraCast!') }} </small> </h3> </div> </div> <div class="row mb-3"> <div class="col-sm"> <p class="card-text"> {{ $gettext('Let\'s get started by creating your Super Administrator account.') }} </p> <p class="card-text"> {{ $gettext('This account will have full access to the system, and you\'ll automatically be logged in to it for the rest of setup.') }} </p> </div> </div> <div v-show="error != null" class="alert alert-danger" > {{ error }} </div> <form id="login-form" class="form vue-form" action="" method="post" > <input type="hidden" name="csrf" :value="csrf" > <form-group-field id="username" name="username" label-class="mb-2" :field="v$.username" input-type="email" > <template #label> <icon :icon="IconMail" class="me-1" /> {{ $gettext('E-mail Address') }} </template> </form-group-field> <form-group-field id="password" name="password" label-class="mb-2" :field="v$.password" input-type="password" > <template #label> <icon :icon="IconVpnKey" class="me-1" /> {{ $gettext('Password') }} </template> </form-group-field> <div class="block-buttons mt-2"> <button type="submit" class="btn btn-block btn-primary" :disabled="v$.$invalid" > {{ $gettext('Create Account') }} </button> </div> </form> </div> </section> </div> </template> <script setup lang="ts"> import FormGroupField from "~/components/Form/FormGroupField.vue"; import Icon from "~/components/Common/Icon.vue"; import {reactive} from "vue"; import {email, required} from "@vuelidate/validators"; import validatePassword from "~/functions/validatePassword"; import useVuelidate from "@vuelidate/core"; import {IconMail, IconVpnKey} from "~/components/Common/icons"; const props = defineProps({ csrf: { type: String, required: true }, error: { type: String, default: null }, }); const form = reactive({ username: null, password: null, }); const formValidations = { username: {required, email}, password: {required, validatePassword} }; const v$ = useVuelidate(formValidations, form); </script> ```
/content/code_sandbox/frontend/components/Setup/Register.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
774
```vue <template> <full-height-card> <template #header> <div class="d-flex align-items-center"> <div class="flex-shrink"> <h2 class="card-title py-2"> <template v-if="stationName"> {{ stationName }} </template> <template v-else> {{ $gettext('On-Demand Media') }} </template> </h2> </div> <div class="flex-fill text-end"> <inline-player ref="player" /> </div> </div> </template> <template #default> <data-table id="public_on_demand" ref="datatable" paginated select-fields :fields="fields" :api-url="listUrl" > <template #cell(download_url)="row"> <play-button class="btn-lg" :url="row.item.download_url" /> <template v-if="showDownloadButton"> <a class="name btn btn-lg p-0 ms-2" :href="row.item.download_url" target="_blank" :title="$gettext('Download')" > <icon :icon="IconDownload" /> </a> </template> </template> <template #cell(art)="row"> <album-art :src="row.item.media.art" /> </template> <template #cell(size)="row"> <template v-if="!row.item.size"> &nbsp; </template> <template v-else> {{ formatFileSize(row.item.size) }} </template> </template> </data-table> </template> </full-height-card> </template> <script setup lang="ts"> import InlinePlayer from '../InlinePlayer.vue'; import DataTable, {DataTableField} from '~/components/Common/DataTable.vue'; import {forEach} from 'lodash'; import Icon from '~/components/Common/Icon.vue'; import PlayButton from "~/components/Common/PlayButton.vue"; import {useTranslate} from "~/vendor/gettext"; import AlbumArt from "~/components/Common/AlbumArt.vue"; import {IconDownload} from "~/components/Common/icons"; import FullHeightCard from "~/components/Public/FullHeightCard.vue"; const props = defineProps({ listUrl: { type: String, required: true }, stationName: { type: String, required: true }, customFields: { type: Array, default: () => { return []; } }, showDownloadButton: { type: Boolean, default: false } }); const {$gettext} = useTranslate(); const fields: DataTableField[] = [ {key: 'download_url', label: ' ', class: 'shrink'}, {key: 'art', label: $gettext('Art'), class: 'shrink'}, { key: 'title', label: $gettext('Title'), sortable: true, selectable: true, formatter: (_value, _key, item) => item.media.title, }, { key: 'artist', label: $gettext('Artist'), sortable: true, selectable: true, formatter: (_value, _key, item) => item.media.artist, }, { key: 'album', label: $gettext('Album'), sortable: true, selectable: true, visible: false, formatter: (_value, _key, item) => item.media.album } ]; forEach(props.customFields.slice(), (field) => { fields.push({ key: field.display_key, label: field.label, sortable: true, selectable: true, visible: false, formatter: (_value, _key, item) => item.media.custom_fields[field.key] }); }); </script> ```
/content/code_sandbox/frontend/components/Public/OnDemand.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
828
```vue <template> <full-height-card> <template #title> <template v-if="stationName"> {{ stationName }} </template> <template v-else> {{ $gettext('Schedule') }} </template> </template> <template #default> <div id="station-schedule-calendar"> <schedule ref="schedule" :timezone="stationTimeZone" :schedule-url="scheduleUrl" :station-time-zone="stationTimeZone" /> </div> </template> </full-height-card> </template> <script setup lang="ts"> import Schedule from '~/components/Common/ScheduleView.vue'; import FullHeightCard from "~/components/Public/FullHeightCard.vue"; const props = defineProps({ scheduleUrl: { type: String, required: true }, stationName: { type: String, required: true }, stationTimeZone: { type: String, required: true } }); </script> <style lang="scss" scoped> #station-schedule-calendar { overflow-y: auto; } </style> ```
/content/code_sandbox/frontend/components/Public/Schedule.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
241
```vue <template> <div class="public-page"> <div class="card"> <div class="card-body"> <h2 class="card-title mb-3"> {{ stationName }} </h2> <div class="stations nowplaying"> <radio-player v-bind="pickProps(props, playerProps)" @np_updated="onNowPlayingUpdate" /> </div> </div> <div class="card-body buttons pt-0"> <a class="btn btn-link text-secondary" @click.prevent="openSongHistoryModal" > <icon :icon="IconHistory" /> <span> {{ $gettext('Song History') }} </span> </a> <a v-if="enableRequests" class="btn btn-link text-secondary" @click.prevent="openRequestModal" > <icon :icon="IconHelp" /> <span> {{ $gettext('Request Song') }} </span> </a> <a class="btn btn-link text-secondary" :href="downloadPlaylistUri" > <icon :icon="IconDownload" /> <span> {{ $gettext('Playlist') }} </span> </a> </div> </div> </div> <song-history-modal ref="$songHistoryModal" :show-album-art="showAlbumArt" :history="history" /> <request-modal v-if="enableRequests" ref="$requestModal" v-bind="pickProps(props, requestsProps)" /> <lightbox ref="$lightbox" /> </template> <script setup lang="ts"> import SongHistoryModal from './FullPlayer/SongHistoryModal.vue'; import RequestModal from './FullPlayer/RequestModal.vue'; import Icon from '~/components/Common/Icon.vue'; import RadioPlayer from './Player.vue'; import {ref} from "vue"; import playerProps from "~/components/Public/playerProps"; import {pickProps} from "~/functions/pickProps"; import Lightbox from "~/components/Common/Lightbox.vue"; import {LightboxTemplateRef, useProvideLightbox} from "~/vendor/lightbox"; import {IconDownload, IconHelp, IconHistory} from "~/components/Common/icons"; import requestsProps from "~/components/Public/Requests/requestsProps.ts"; const props = defineProps({ ...playerProps, ...requestsProps, stationName: { type: String, required: true }, enableRequests: { type: Boolean, default: false }, downloadPlaylistUri: { type: String, required: true }, }); const history = ref({}); const onNowPlayingUpdate = (newNowPlaying) => { history.value = newNowPlaying?.song_history; } const $songHistoryModal = ref<InstanceType<typeof SongHistoryModal> | null>(null); const openSongHistoryModal = () => { $songHistoryModal.value?.open(); } const $requestModal = ref<InstanceType<typeof RequestModal> | null>(null); const openRequestModal = () => { $requestModal.value?.open(); } const $lightbox = ref<LightboxTemplateRef>(null); useProvideLightbox($lightbox); </script> ```
/content/code_sandbox/frontend/components/Public/FullPlayer.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
701
```vue <template> <section id="content" role="main" style="flex: 1" > <div class="container pt-5"> <div class="row g-3"> <div class="col-md-4 mb-sm-4"> <settings-panel /> </div> <div class="col-md-8"> <div class="row g-3 mb-3"> <div class="col-md-12"> <microphone-panel /> </div> </div> <div class="row g-3 mb-3"> <div class="col-md-12"> <mixer-panel /> </div> </div> <div class="row g-3 mb-4"> <div class="col-md-6 mb-sm-4"> <playlist-panel id="playlist_1" /> </div> <div class="col-md-6"> <playlist-panel id="playlist_2" /> </div> </div> </div> </div> </div> </section> </template> <script setup lang="ts"> import MixerPanel from './WebDJ/MixerPanel.vue'; import MicrophonePanel from './WebDJ/MicrophonePanel.vue'; import PlaylistPanel from './WebDJ/PlaylistPanel.vue'; import SettingsPanel from './WebDJ/SettingsPanel.vue'; import {useProvideWebDjNode} from "~/components/Public/WebDJ/useWebDjNode"; import {useProvideWebcaster, webcasterProps} from "~/components/Public/WebDJ/useWebcaster"; import {useProvideMixer} from "~/components/Public/WebDJ/useMixerValue"; import {useProvidePassthroughSync} from "~/components/Public/WebDJ/usePassthroughSync"; const props = defineProps({ ...webcasterProps }); const webcaster = useProvideWebcaster(props); useProvideWebDjNode(webcaster); useProvideMixer(1.0); useProvidePassthroughSync(''); </script> ```
/content/code_sandbox/frontend/components/Public/WebDJ.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
430
```vue <template> <div id="song_history"> <song-history :show-album-art="showAlbumArt" :history="history" /> </div> </template> <script setup lang="ts"> import useNowPlaying, {nowPlayingProps} from '~/functions/useNowPlaying'; import {computed} from "vue"; import SongHistory from "~/components/Public/FullPlayer/SongHistory.vue"; const props = defineProps({ ...nowPlayingProps, showAlbumArt: { type: Boolean, default: true }, }); const {np} = useNowPlaying(props); const history = computed(() => { return np.value.song_history ?? {}; }); </script> ```
/content/code_sandbox/frontend/components/Public/History.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
149
```vue <template> <div class="container-fluid"> <requests-data-table v-bind="props" /> </div> </template> <script setup lang="ts"> import RequestsDataTable from "~/components/Public/Requests/RequestsDataTable.vue"; import requestsProps from "~/components/Public/Requests/requestsProps.ts"; const props = defineProps(requestsProps); </script> ```
/content/code_sandbox/frontend/components/Public/Requests.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
76
```vue <template> <div class="radio-player-widget"> <audio-player :title="np.now_playing.song.text" :volume="volume" :is-muted="isMuted" /> <div class="now-playing-details"> <div v-if="showAlbumArt && np.now_playing.song.art" class="now-playing-art" > <album-art :src="np.now_playing.song.art" /> </div> <div class="now-playing-main"> <h6 v-if="np.live.is_live" class="now-playing-live" > <span class="badge text-bg-primary me-2"> {{ $gettext('Live') }} </span> {{ np.live.streamer_name }} </h6> <div v-if="!np.is_online"> <h4 class="now-playing-title text-muted"> {{ offlineText ?? $gettext('Station Offline') }} </h4> </div> <div v-else-if="np.now_playing.song.title !== ''"> <h4 class="now-playing-title"> {{ np.now_playing.song.title }} </h4> <h5 class="now-playing-artist"> {{ np.now_playing.song.artist }} </h5> </div> <div v-else> <h4 class="now-playing-title"> {{ np.now_playing.song.text }} </h4> </div> <div v-if="currentTrackElapsedDisplay != null" class="time-display" > <div class="time-display-played text-secondary"> {{ currentTrackElapsedDisplay }} </div> <div class="time-display-progress"> <div class="progress h-5"> <div class="progress-bar bg-secondary" role="progressbar" :style="{ width: currentTrackPercent+'%' }" /> </div> </div> <div class="time-display-total text-secondary"> {{ currentTrackDurationDisplay }} </div> </div> </div> </div> <hr class="my-2"> <div class="radio-controls"> <play-button class="radio-control-play-button btn-xl" :url="currentStream.url" :is-hls="currentStream.hls" is-stream /> <div class="radio-control-select-stream"> <div v-if="streams.length > 1" class="dropdown" > <button id="btn-select-stream" class="btn btn-sm btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" > {{ currentStream.name }} <span class="caret" /> </button> <ul class="dropdown-menu" aria-labelledby="btn-select-stream" > <li v-for="stream in streams" :key="stream.url" > <button type="button" class="dropdown-item" @click="switchStream(stream)" > {{ stream.name }} </button> </li> </ul> </div> </div> <div class="radio-control-volume d-flex align-items-center"> <div class="flex-shrink-0 mx-2"> <mute-button class="p-0 text-secondary" :volume="volume" :is-muted="isMuted" @toggle-mute="toggleMute" /> </div> <div class="flex-fill radio-control-volume-slider"> <input v-model.number="volume" type="range" :title="$gettext('Volume')" class="form-range" min="0" max="100" step="1" > </div> </div> </div> </div> </template> <script setup lang="ts"> import AudioPlayer from '~/components/Common/AudioPlayer.vue'; import PlayButton from "~/components/Common/PlayButton.vue"; import {computed, nextTick, onMounted, ref, shallowRef, watch} from "vue"; import {useTranslate} from "~/vendor/gettext"; import useNowPlaying from "~/functions/useNowPlaying"; import playerProps from "~/components/Public/playerProps"; import MuteButton from "~/components/Common/MuteButton.vue"; import AlbumArt from "~/components/Common/AlbumArt.vue"; import {useAzuraCastStation} from "~/vendor/azuracast"; import usePlayerVolume from "~/functions/usePlayerVolume"; import {usePlayerStore} from "~/functions/usePlayerStore.ts"; import {useEventListener} from "@vueuse/core"; const props = defineProps({ ...playerProps }); const emit = defineEmits(['np_updated']); const {offlineText} = useAzuraCastStation(); const { np, currentTrackPercent, currentTrackDurationDisplay, currentTrackElapsedDisplay } = useNowPlaying(props); interface CurrentStreamDescriptor { name: string, url: string, hls: boolean, } const currentStream = shallowRef<CurrentStreamDescriptor>({ name: '', url: '', hls: false, }); const enableHls = computed(() => { return props.showHls && np.value?.station?.hls_enabled; }); const hlsIsDefault = computed(() => { return enableHls.value && np.value?.station?.hls_is_default; }); const {$gettext} = useTranslate(); const streams = computed<CurrentStreamDescriptor[]>(() => { const allStreams = []; if (enableHls.value) { allStreams.push({ name: $gettext('HLS'), url: np.value?.station?.hls_url, hls: true, }); } np.value?.station?.mounts.forEach(function (mount) { allStreams.push({ name: mount.name, url: mount.url, hls: false, }); }); np.value?.station?.remotes.forEach(function (remote) { allStreams.push({ name: remote.name, url: remote.url, hls: false, }); }); return allStreams; }); const volume = usePlayerVolume(); const urlParamVolume = (new URL(document.location.href)).searchParams.get('volume'); if (null !== urlParamVolume) { volume.value = Number(urlParamVolume); } const isMuted = ref(false); const toggleMute = () => { isMuted.value = !isMuted.value; } const {toggle} = usePlayerStore(); const switchStream = (new_stream: CurrentStreamDescriptor) => { currentStream.value = new_stream; toggle({ url: new_stream.url, isStream: true, isHls: new_stream.hls }); }; if (props.autoplay) { const stop = useEventListener(document, "now-playing", async () => { await nextTick(); switchStream(currentStream.value); stop(); }); } onMounted(() => { document.dispatchEvent(new CustomEvent("player-ready")); }); const onNowPlayingUpdated = (np_new) => { emit('np_updated', np_new); // Set a "default" current stream if none exists. const $streams = streams.value; let $currentStream = currentStream.value; if ($currentStream.url === '' && $streams.length > 0) { if (hlsIsDefault.value) { currentStream.value = $streams[0]; } else { $currentStream = null; if (np_new.station.listen_url !== '') { $streams.forEach(function (stream) { if (stream.url === np_new.station.listen_url) { $currentStream = stream; } }); } if ($currentStream === null) { $currentStream = $streams[0]; } currentStream.value = $currentStream; } } }; watch(np, onNowPlayingUpdated, {immediate: true}); </script> <style lang="scss"> .radio-player-widget { .now-playing-details { display: flex; align-items: center; .now-playing-art { padding-right: .5rem; img { width: 75px; height: auto; border-radius: 5px; @media (max-width: 575px) { width: 50px; } } } .now-playing-main { flex: 1; min-width: 0; } h4, h5, h6 { margin: 0; line-height: 1.3; } h4 { font-size: 15px; } h5 { font-size: 13px; font-weight: normal; } h6 { font-size: 11px; font-weight: normal; } .now-playing-title, .now-playing-artist { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; &:hover { text-overflow: clip; white-space: normal; word-break: break-all; } } .time-display { font-size: 10px; margin-top: .25rem; flex-direction: row; align-items: center; display: flex; .time-display-played { margin-right: .5rem; } .time-display-progress { flex: 1 1 auto; .progress-bar { -webkit-transition: width 1s; /* Safari */ transition: width 1s; transition-timing-function: linear; } } .time-display-total { margin-left: .5rem; } } } .radio-controls { display: flex; flex-direction: row; align-items: center; flex-wrap: wrap; .radio-control-play-button { margin-right: .25rem; } .radio-control-select-stream { flex: 1 1 auto; max-width: 60%; #btn-select-stream { text-overflow: clip; white-space: normal; word-break: break-all; } } .radio-control-volume { .radio-control-volume-slider { max-width: 30%; } } } } </style> ```
/content/code_sandbox/frontend/components/Public/Player.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
2,229
```vue <template> <section id="content" class="full-height-wrapper" role="main" > <div class="card"> <div class="card-header text-bg-primary"> <slot name="header"> <h2 class="card-title py-2"> <slot name="title" /> </h2> </slot> </div> <slot name="default" /> </div> </section> <lightbox ref="$lightbox" /> </template> <script setup lang="ts"> import Lightbox from "~/components/Common/Lightbox.vue"; import {ref} from "vue"; import {LightboxTemplateRef, useProvideLightbox} from "~/vendor/lightbox.ts"; const $lightbox = ref<LightboxTemplateRef>(null); useProvideLightbox($lightbox); </script> ```
/content/code_sandbox/frontend/components/Public/FullHeightCard.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
180
```vue <template> <div class="card"> <div class="card-header text-bg-primary"> <div class="d-flex align-items-center"> <div class="flex-fill text-nowrap"> <h5 class="card-title"> {{ langHeader }} </h5> </div> <div class="flex-shrink-0 ps-3"> <volume-slider v-model.number="localGain" /> </div> </div> </div> <div class="card-body"> <div class="control-group d-flex justify-content-center"> <div class="btn-group btn-group-sm"> <button v-if="!isPlaying || isPaused" type="button" class="btn btn-sm btn-success" @click="play" > <icon :icon="IconPlayCircle" /> </button> <button v-if="isPlaying && !isPaused" type="button" class="btn btn-sm btn-warning" @click="togglePause()" > <icon :icon="IconPauseCircle" /> </button> <button type="button" class="btn btn-sm" @click="previous()" > <icon :icon="IconFastRewind" /> </button> <button type="button" class="btn btn-sm" @click="next()" > <icon :icon="IconFastForward" /> </button> <button type="button" class="btn btn-sm btn-danger" @click="stop()" > <icon :icon="IconStop" /> </button> <button type="button" class="btn btn-sm" :class="{ 'btn-primary': trackPassThrough }" @click="trackPassThrough = !trackPassThrough" > {{ $gettext('Cue') }} </button> </div> </div> <div v-if="isPlaying" class="mt-3" > <div class="d-flex flex-row mb-2"> <div class="flex-shrink-0 pt-1 pe-2"> {{ formatTime(position) }} </div> <div class="flex-fill"> <input v-model="seekingPosition" type="range" min="0" max="100" step="0.1" class="form-range slider" @mousedown="isSeeking = true" @mouseup="isSeeking = false" > </div> <div class="flex-shrink-0 pt-1 ps-2"> {{ formatTime(duration) }} </div> </div> <div class="progress"> <div class="progress-bar" :style="{ width: volume+'%' }" /> </div> </div> <div class="form-group mt-2"> <div class="custom-file"> <input :id="id + '_files'" type="file" class="custom-file-input files" accept="audio/*" multiple @change="addNewFiles($event.target.files)" > <label :for="id + '_files'" class="custom-file-label" > {{ $gettext('Add Files to Playlist') }} </label> </div> </div> <div class="form-group mb-0"> <div class="controls"> <div class="custom-control custom-checkbox custom-control-inline"> <input :id="id + '_playthrough'" v-model="playThrough" type="checkbox" class="custom-control-input" > <label :for="id + '_playthrough'" class="custom-control-label" > {{ $gettext('Continuous Play') }} </label> </div> <div class="custom-control custom-checkbox custom-control-inline"> <input :id="id + '_loop'" v-model="loop" type="checkbox" class="custom-control-input" > <label :for="id + '_loop'" class="custom-control-label" > {{ $gettext('Repeat') }} </label> </div> </div> </div> </div> <div v-if="files.length > 0" class="list-group list-group-flush" > <a v-for="(rowFile, rowIndex) in files" :key="rowFile.file.name" href="#" class="list-group-item list-group-item-action flex-column align-items-start" :class="{ active: rowIndex === fileIndex }" @click.prevent="play({ fileIndex: rowIndex })" > <div class="d-flex w-100 justify-content-between"> <h5 class="mb-0">{{ rowFile.metadata?.title ?? $gettext('Unknown Title') }}</h5> <small class="pt-1">{{ formatTime(rowFile.audio.length) }}</small> </div> <p class="mb-0">{{ rowFile.metadata?.artist ?? $gettext('Unknown Artist') }}</p> </a> </div> </div> </template> <script setup lang="ts"> import Icon from '~/components/Common/Icon.vue'; import VolumeSlider from "~/components/Public/WebDJ/VolumeSlider.vue"; import formatTime from "~/functions/formatTime"; import {computed, ref, watch} from "vue"; import {useWebDjTrack} from "~/components/Public/WebDJ/useWebDjTrack"; import {useTranslate} from "~/vendor/gettext"; import {forEach} from "lodash"; import {useInjectMixer} from "~/components/Public/WebDJ/useMixerValue"; import {usePassthroughSync} from "~/components/Public/WebDJ/usePassthroughSync"; import {useWebDjSource} from "~/components/Public/WebDJ/useWebDjSource"; import {useInjectWebcaster} from "~/components/Public/WebDJ/useWebcaster"; import {IconFastForward, IconFastRewind, IconPauseCircle, IconPlayCircle, IconStop} from "~/components/Common/icons"; const props = defineProps({ id: { type: String, required: true } }); const isLeftPlaylist = computed(() => { return props.id === 'playlist_1'; }); const { source, isPlaying, isPaused, trackGain, trackPassThrough, position, volume, prepare, togglePause, stop } = useWebDjTrack(); const { createAudioSource } = useWebDjSource(); const { sendMetadata } = useInjectWebcaster(); usePassthroughSync(trackPassThrough, props.id); const fileIndex = ref(-1); const files = ref([]); const duration = ref(0.0); const loop = ref(false); const playThrough = ref(false); const isSeeking = ref(false); const seekingPosition = computed({ get: () => { return (100.0 * (position.value / Number(duration.value))); }, set: (val) => { if (!isSeeking.value || !source.value) { return; } source.value.seek(val / 100); } }); // Factor in mixer and local gain to calculate total gain. const localGain = ref(55); const {mixer} = useInjectMixer(); const computedGain = computed(() => { let multiplier; if (isLeftPlaylist.value) { multiplier = (mixer.value > 1) ? 2.0 - (mixer.value) : 1.0; } else { multiplier = (mixer.value < 1) ? mixer.value : 1.0; } return localGain.value * multiplier; }); watch(computedGain, (newGain) => { trackGain.value = newGain; }, {immediate: true}); const {$gettext} = useTranslate(); const langHeader = computed(() => { return isLeftPlaylist.value ? $gettext('Playlist 1') : $gettext('Playlist 2'); }); const addNewFiles = (newFiles) => { forEach(newFiles, (file) => { file.readTaglibMetadata((data) => { files.value.push({ file: file, audio: data.audio, metadata: data.metadata || {title: '', artist: ''} }); }); }); }; const selectFile = (options = {}) => { if (files.value.length === 0) { return; } if (options.fileIndex) { fileIndex.value = options.fileIndex; } else { fileIndex.value += options.backward ? -1 : 1; if (fileIndex.value < 0) { fileIndex.value = files.value.length - 1; } if (fileIndex.value >= files.value.length) { if (options.isAutoPlay && !loop.value) { fileIndex.value = -1; return; } if (fileIndex.value < 0) { fileIndex.value = files.value.length - 1; } else { fileIndex.value = 0; } } } return files.value[fileIndex.value]; }; const play = (options = {}) => { const file = selectFile(options); if (!file) { return; } if (isPaused.value) { togglePause(); return; } stop(); const destination = prepare(); createAudioSource(file, (newSource) => { source.value = newSource; newSource.connect(destination); if (newSource.duration !== null) { duration.value = newSource.duration(); } else if (file.audio !== null) { duration.value = parseFloat(file.audio.length); } newSource.play(file); sendMetadata({ title: file.metadata.title, artist: file.metadata.artist }); }, () => { stop(); if (playThrough.value) { play({ isAutoPlay: true }); } }); }; const previous = () => { if (!isPlaying.value) { return; } play({backward: true}); }; const next = () => { if (!isPlaying.value) { return; } play(); }; </script> ```
/content/code_sandbox/frontend/components/Public/WebDJ/PlaylistPanel.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
2,240
```vue <template> <div class="mixer card"> <div class="card-header text-bg-primary"> <div class="d-flex align-items-center"> <div class="flex-fill"> <h5 class="card-title"> {{ $gettext('Mixer') }} </h5> </div> <div class="flex-shrink-0 ps-3"> <div class="d-flex flex-row align-items-center"> <div class="flex-shrink-0"> {{ $gettext('Playlist 1') }} </div> <div class="flex-fill px-2"> <input v-model.number="mixer" type="range" min="0" max="2" step="0.05" class="form-range slider" style="width: 200px; height: 10px;" @click.right.prevent="mixer = 1.0" > </div> <div class="flex-shrink-0"> {{ $gettext('Playlist 2') }} </div> </div> </div> </div> </div> </div> </template> <script setup lang="ts"> import {useInjectMixer} from "~/components/Public/WebDJ/useMixerValue"; const {mixer} = useInjectMixer(); </script> ```
/content/code_sandbox/frontend/components/Public/WebDJ/MixerPanel.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
295
```vue <template> <div class="card settings"> <div class="card-header text-bg-primary"> <h5 class="card-title"> {{ $gettext('WebDJ') }} <br> <small>{{ stationName }}</small> </h5> </div> <template v-if="isConnected"> <div class="card-body"> <div class="form-group"> <label for="metadata_title" class="mb-2" > {{ $gettext('Title') }} </label> <div class="controls"> <input id="metadata_title" v-model="shownMetadata.title" class="form-control" type="text" > </div> </div> <div class="form-group"> <label for="metadata_artist" class="mb-2" > {{ $gettext('Artist') }} </label> <div class="controls"> <input id="metadata_artist" v-model="shownMetadata.artist" class="form-control" type="text" > </div> </div> <div class="form-group"> <button type="button" class="btn btn-primary" @click="updateMetadata" > {{ $gettext('Update Metadata') }} </button> </div> </div> </template> <template v-else> <div class="card-body alert-info"> <p class="card-text"> {{ $gettext('The WebDJ lets you broadcast live to your station using just your web browser.') }} </p> <p class="card-text"> {{ $gettext('To use this feature, a secure (HTTPS) connection is required. Firefox is recommended to avoid static when broadcasting.') }} </p> </div> <div class="card-body"> <div class="row g-3"> <div class="col-md-6"> <div class="form-group"> <label for="dj_username" class="mb-2" > {{ $gettext('Username') }} </label> <div class="controls"> <input id="dj_username" v-model="djUsername" type="text" class="form-control" > </div> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="dj_password" class="mb-2" > {{ $gettext('Password') }} </label> <div class="controls"> <input id="dj_password" v-model="djPassword" type="password" class="form-control" > </div> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="select_samplerate" class="mb-2" > {{ $gettext('Sample Rate') }} </label> <div class="controls"> <select id="select_samplerate" v-model.number="sampleRate" class="form-control" > <option value="8000"> 8 kHz </option> <option value="11025"> 11.025 kHz </option> <option value="12000"> 12 kHz </option> <option value="16000"> 16 kHz </option> <option value="22050"> 22.05 kHz </option> <option value="24000"> 24 kHz </option> <option value="32000"> 32 kHz </option> <option value="44100"> 44.1 kHz </option> <option value="48000"> 48 kHz </option> </select> </div> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="select_bitrate" class="mb-2" > {{ $gettext('Bit Rate') }} </label> <div class="controls"> <select id="select_bitrate" v-model.number="bitrate" class="form-control" > <option value="8"> 8 kbps </option> <option value="16"> 16 kbps </option> <option value="24"> 24 kbps </option> <option value="32"> 32 kbps </option> <option value="40"> 40 kbps </option> <option value="48"> 48 kbps </option> <option value="56"> 56 kbps </option> <option value="64"> 64 kbps </option> <option value="80"> 80 kbps </option> <option value="96"> 96 kbps </option> <option value="112"> 112 kbps </option> <option value="128"> 128 kbps </option> <option value="144"> 144 kbps </option> <option value="160"> 160 kbps </option> <option value="192"> 192 kbps </option> <option value="224"> 224 kbps </option> <option value="256"> 256 kbps </option> <option value="320"> 320 kbps </option> </select> </div> </div> </div> </div> </div> </template> <div class="card-body"> <button v-if="!isConnected" type="button" class="btn btn-success" @click="startStream(djUsername, djPassword)" > {{ langStreamButton }} </button> <button v-if="isConnected" type="button" class="btn btn-danger" @click="stopStream" > {{ langStreamButton }} </button> <button type="button" class="btn" :class="{ 'btn-primary': doPassThrough }" @click="doPassThrough = !doPassThrough" > {{ $gettext('Cue') }} </button> </div> </div> </template> <script setup lang="ts"> import {computed, ref, watch} from "vue"; import {useTranslate} from "~/vendor/gettext"; import {useInjectWebDjNode} from "~/components/Public/WebDJ/useWebDjNode"; import {usePassthroughSync} from "~/components/Public/WebDJ/usePassthroughSync"; import {useInjectWebcaster} from "~/components/Public/WebDJ/useWebcaster"; import {useAzuraCastStation} from "~/vendor/azuracast.ts"; const {name: stationName} = useAzuraCastStation(); const djUsername = ref(null); const djPassword = ref(null); const { doPassThrough, bitrate, sampleRate, startStream, stopStream } = useInjectWebDjNode(); const { metadata, sendMetadata, isConnected } = useInjectWebcaster(); usePassthroughSync(doPassThrough, 'global'); const {$gettext} = useTranslate(); const langStreamButton = computed(() => { return (isConnected.value) ? $gettext('Stop Streaming') : $gettext('Start Streaming'); }); const shownMetadata = ref({}); watch(metadata, (newMeta) => { if (newMeta === null) { newMeta = { artist: '', title: '' }; } shownMetadata.value = newMeta; }); const updateMetadata = () => { sendMetadata(shownMetadata.value); }; </script> ```
/content/code_sandbox/frontend/components/Public/WebDJ/SettingsPanel.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,766
```vue <template> <div class="d-flex flex-row align-items-center"> <div class="flex-shrink-0 me-2"> <mute-button class="p-0" :volume="volume" :is-muted="isMuted" @toggle-mute="toggleMute" /> </div> <div class="flex-fill px-2"> <input v-model.number="volume" type="range" min="0" max="100" class="form-range slider" style="height: 10px; width: 125px;" @click.right.prevent="reset" > </div> </div> </template> <script setup lang="ts"> import {computed, onMounted, ref} from "vue"; import {useVModel} from "@vueuse/core"; import MuteButton from "~/components/Common/MuteButton.vue"; const props = defineProps({ modelValue: { type: Number, required: true } }); const emit = defineEmits(['update:modelValue']); const volume = useVModel(props, 'modelValue', emit); const initial = ref(75); const preMute = ref(75); onMounted(() => { initial.value = props.modelValue; preMute.value = props.modelValue; }); const isMuted = computed(() => { return volume.value === 0; }); const toggleMute = () => { if (isMuted.value) { volume.value = preMute.value; } else { preMute.value = volume.value; volume.value = 0; } } const reset = () => { volume.value = initial.value; } </script> ```
/content/code_sandbox/frontend/components/Public/WebDJ/VolumeSlider.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
371
```vue <template> <div class="card"> <div class="card-header text-bg-primary"> <div class="d-flex align-items-center"> <div class="flex-fill"> <h5 class="card-title"> {{ $gettext('Microphone') }} </h5> </div> <div class="flex-shrink-0 ps-3"> <volume-slider v-model.number="trackGain" /> </div> </div> </div> <div class="card-body"> <div class="d-flex align-items-center"> <div class="d-flex-shrink-0"> <div class="control-group"> <div class="btn-group btn-group-sm"> <button type="button" class="btn btn-danger" :class="{ active: isPlaying }" @click="togglePlaying" > <icon :icon="IconMic" /> </button> <button type="button" class="btn" :class="{ 'btn-primary': trackPassThrough }" @click="trackPassThrough = !trackPassThrough" > {{ $gettext('Cue') }} </button> </div> </div> </div> <div class="flex-fill ps-3"> <div class="form-group microphone-entry mb-0"> <label for="select_microphone_source" class="mb-2" > {{ $gettext('Microphone Source') }} </label> <div class="controls"> <select id="select_microphone_source" v-model="device" class="form-control" > <option v-for="device_row in audioInputs" :key="device_row.deviceId" :value="device_row.deviceId" > {{ device_row.label }} </option> </select> </div> </div> </div> </div> <div v-if="isPlaying" class="mt-3" > <div class="progress mb-2"> <div class="progress-bar" :style="{ width: volume+'%' }" /> </div> </div> </div> </div> </template> <script setup lang="ts"> import Icon from '~/components/Common/Icon.vue'; import VolumeSlider from "~/components/Public/WebDJ/VolumeSlider.vue"; import {useDevicesList} from "@vueuse/core"; import {ref, watch} from "vue"; import {useWebDjTrack} from "~/components/Public/WebDJ/useWebDjTrack"; import {usePassthroughSync} from "~/components/Public/WebDJ/usePassthroughSync"; import {useWebDjSource} from "~/components/Public/WebDJ/useWebDjSource"; import {IconMic} from "~/components/Common/icons"; const { source, isPlaying, trackGain, trackPassThrough, volume, prepare, stop } = useWebDjTrack(); const { createMicrophoneSource } = useWebDjSource(); usePassthroughSync(trackPassThrough, 'microphone'); const {audioInputs} = useDevicesList({ requestPermissions: true, constraints: {audio: true, video: false} }); const device = ref(null); watch(audioInputs, (inputs) => { if (device.value === null) { device.value = inputs[0]?.deviceId; } }); let destination = null; const createSource = () => { if (source.value != null) { source.value.disconnect(destination); } createMicrophoneSource(device.value, (newSource) => { source.value = newSource; newSource.connect(destination); }); }; watch(device, () => { if (source.value === null || destination === null) { return; } createSource(); }); const play = () => { destination = prepare(); createSource(); } const togglePlaying = () => { if (isPlaying.value) { stop(); } else { play(); } } </script> ```
/content/code_sandbox/frontend/components/Public/WebDJ/MicrophonePanel.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
885
```vue <template> <modal id="request_modal" ref="$modal" size="lg" :title="$gettext('Request a Song')" hide-footer > <song-request v-bind="props" @submitted="hide" /> </modal> </template> <script setup lang="ts"> import SongRequest from '../Requests.vue'; import {ref} from "vue"; import Modal from "~/components/Common/Modal.vue"; import {ModalTemplateRef, useHasModal} from "~/functions/useHasModal.ts"; import requestsProps from "~/components/Public/Requests/requestsProps.ts"; const props = defineProps({ ...requestsProps }); const $modal = ref<ModalTemplateRef>(null); const {show: open, hide} = useHasModal($modal); defineExpose({ open }); </script> ```
/content/code_sandbox/frontend/components/Public/FullPlayer/RequestModal.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
179
```vue <template> <div id="station-history"> <p v-if="history.length <= 0"> {{ $gettext('No records to display.') }} </p> <div v-for="(row, index) in history" :key="row.sh_id" class="song" > <strong class="order">{{ history.length - index }}</strong> <album-art v-if="showAlbumArt" class="me-3" :src="row.song.art" /> <div class="name"> <strong>{{ row.song.title }}</strong> <span> {{ albumAndArtist(row.song) }} </span> </div> <small class="date-played text-muted ms-3"> {{ unixTimestampToDate(row.played_at) }} </small> </div> </div> </template> <script setup lang="ts"> import AlbumArt from "~/components/Common/AlbumArt.vue"; import {useLuxon} from "~/vendor/luxon"; const props = defineProps({ history: { type: Object, default: () => { return {}; } }, showAlbumArt: { type: Boolean, default: true } }); const {timestampToRelative} = useLuxon(); const unixTimestampToDate = (timestamp) => (!timestamp) ? '' : timestampToRelative(timestamp); const albumAndArtist = (song) => { return [song.artist, song.album].filter(str => !!str).join(' - '); }; </script> <style lang="scss"> #station-history { .song { display: flex; flex-direction: row; flex-wrap: wrap; width: 100%; line-height: normal; margin-bottom: 15px; &:last-child { margin-bottom: 0; } .order { display: flex; flex-direction: column; width: 35px; justify-content: center; margin-right: 5px; text-align: center; } a.album-art { display: flex; flex-direction: column; justify-content: center; } .name { display: flex; flex: 1; flex-direction: column; justify-content: center; } .date-played { display: flex; flex-direction: column; justify-content: center; } } } </style> ```
/content/code_sandbox/frontend/components/Public/FullPlayer/SongHistory.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
527
```vue <template> <data-table id="public_requests" ref="datatable" paginated select-fields :page-options="pageOptions" :fields="fields" :api-url="requestListUri" > <template #cell(name)="row"> <div class="d-flex align-items-center"> <album-art v-if="showAlbumArt" :src="row.item.song.art" :width="40" class="flex-shrink-1 pe-3" /> <div class="flex-fill"> {{ row.item.song.title }}<br> <small>{{ row.item.song.artist }}</small> </div> </div> </template> <template #cell(actions)="row"> <button type="button" class="btn btn-sm btn-primary" @click="doSubmitRequest(row.item.request_url)" > {{ $gettext('Request') }} </button> </template> </data-table> </template> <script setup lang="ts"> import DataTable, {DataTableField} from '~/components/Common/DataTable.vue'; import {forEach} from 'lodash'; import AlbumArt from '~/components/Common/AlbumArt.vue'; import {computed} from "vue"; import {useTranslate} from "~/vendor/gettext"; import {useAxios} from "~/vendor/axios"; import {useNotify} from "~/functions/useNotify"; import requestsProps from "~/components/Public/Requests/requestsProps.ts"; const props = defineProps({ ...requestsProps }); const emit = defineEmits(['submitted']); const {$gettext} = useTranslate(); const fields = computed<DataTableField[]>(() => { const fields = [ { key: 'name', isRowHeader: true, label: $gettext('Name'), sortable: false, selectable: true }, { key: 'title', label: $gettext('Title'), sortable: true, selectable: true, visible: false, formatter: (_value, _key, item) => item.song.title }, { key: 'artist', label: $gettext('Artist'), sortable: true, selectable: true, visible: false, formatter: (_value, _key, item) => item.song.artist }, { key: 'album', label: $gettext('Album'), sortable: true, selectable: true, visible: false, formatter: (_value, _key, item) => item.song.album }, { key: 'genre', label: $gettext('Genre'), sortable: true, selectable: true, visible: false, formatter: (_value, _key, item) => item.song.genre } ]; forEach({...props.customFields}, (field) => { fields.push({ key: 'custom_field_' + field.id, label: field.name, sortable: false, selectable: true, visible: false, formatter: (_value, _key, item) => item.song.custom_fields[field.short_name] }); }); fields.push( {key: 'actions', label: $gettext('Actions'), class: 'shrink', sortable: false} ); return fields; }); const pageOptions = [10, 25]; const {notifySuccess, notifyError} = useNotify(); const {axios} = useAxios(); const doSubmitRequest = (url) => { axios.post(url).then((resp) => { if (resp.data.success) { notifySuccess(resp.data.message); } else { notifyError(resp.data.message); } }).finally(() => { emit('submitted'); }); }; </script> ```
/content/code_sandbox/frontend/components/Public/Requests/RequestsDataTable.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
800
```vue <template> <modal id="song_history_modal" ref="$modal" size="md" :title="$gettext('Song History')" centered > <song-history :show-album-art="showAlbumArt" :history="history" /> </modal> </template> <script setup lang="ts"> import SongHistory from './SongHistory.vue'; import Modal from "~/components/Common/Modal.vue"; import {ref} from "vue"; import {ModalTemplateRef, useHasModal} from "~/functions/useHasModal.ts"; const props = defineProps({ history: { type: Object, default: () => { return {}; } }, showAlbumArt: { type: Boolean, default: true }, }); const $modal = ref<ModalTemplateRef>(null); const {show: open} = useHasModal($modal); defineExpose({ open }); </script> ```
/content/code_sandbox/frontend/components/Public/FullPlayer/SongHistoryModal.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
203
```vue <template> <data-table v-if="groupLayout === 'table'" id="podcasts" ref="$datatable" paginated :fields="fields" :api-url="apiUrl" > <template #cell(art)="{item}"> <album-art :src="item.art" :width="96" /> </template> <template #cell(title)="{item}"> <h5 class="m-0"> <router-link :to="{name: 'public:podcast', params: {podcast_id: item.id}}" > {{ item.title }} </router-link> <br> <small> {{ $gettext('by') }} <a :href="'mailto:'+item.email" target="_blank" >{{ item.author }}</a> </small> </h5> <div class="badges my-2"> <span class="badge text-bg-info"> {{ item.language_name }} </span> <span v-for="category in item.categories" :key="category.category" class="badge text-bg-secondary" > {{ category.text }} </span> </div> <p class="card-text"> {{ item.description_short }} </p> </template> <template #cell(actions)="{item}"> <div class="btn-group btn-group-sm"> <router-link :to="{name: 'public:podcast', params: {podcast_id: item.id}}" class="btn btn-primary" > {{ $gettext('Episodes') }} </router-link> <a class="btn btn-warning" :href="item.links.public_feed" target="_blank" > <icon :icon="IconRss" /> {{ $gettext('RSS') }} </a> </div> </template> </data-table> <grid-layout v-else id="podcasts_grid" ref="$grid" paginated :api-url="apiUrl" > <template #item="{item}"> <div class="card mb-4"> <div class="card-header d-flex align-items-center"> <h5 class="card-title m-0 flex-fill"> <router-link :to="{name: 'public:podcast', params: {podcast_id: item.id}}" > {{ item.title }} </router-link> <br> <small> {{ $gettext('by') }} <a :href="'mailto:'+item.email" target="_blank" >{{ item.author }}</a> </small> </h5> <div class="flex-shrink-0 ps-2"> <album-art :src="item.art" :width="64" /> </div> </div> <div class="card-body"> <div class="badges my-2"> <span class="badge text-bg-info"> {{ item.language_name }} </span> <span v-for="category in item.categories" :key="category.category" class="badge text-bg-secondary" > {{ category.text }} </span> </div> <p class="card-text"> {{ item.description_short }} </p> </div> </div> </template> </grid-layout> </template> <script setup lang="ts"> import AlbumArt from "~/components/Common/AlbumArt.vue"; import DataTable, {DataTableField} from "~/components/Common/DataTable.vue"; import {getStationApiUrl} from "~/router.ts"; import {useTranslate} from "~/vendor/gettext.ts"; import {IconRss} from "~/components/Common/icons.ts"; import Icon from "~/components/Common/Icon.vue"; import {usePodcastGroupLayout} from "~/components/Public/Podcasts/usePodcastGroupLayout.ts"; import GridLayout from "~/components/Common/GridLayout.vue"; const {groupLayout} = usePodcastGroupLayout(); const apiUrl = getStationApiUrl('/public/podcasts'); const {$gettext} = useTranslate(); const fields: DataTableField[] = [ {key: 'art', label: '', sortable: false, class: 'shrink pe-0'}, {key: 'title', label: $gettext('Podcast'), sortable: true}, {key: 'actions', label: $gettext('Actions'), sortable: false, class: 'shrink'} ]; </script> ```
/content/code_sandbox/frontend/components/Public/Podcasts/PodcastList.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
979
```vue <template> <minimal-layout> <full-height-card> <template #header> <div class="d-flex align-items-center"> <div class="flex-shrink"> <h2 class="card-title py-2"> <slot name="title"> {{ name }} </slot> </h2> </div> <div class="flex-fill text-end"> <inline-player ref="player" /> </div> </div> </template> <template #default> <router-view /> </template> </full-height-card> </minimal-layout> </template> <script setup lang="ts"> import FullHeightCard from "~/components/Public/FullHeightCard.vue"; import InlinePlayer from "~/components/InlinePlayer.vue"; import {useAzuraCastStation} from "~/vendor/azuracast.ts"; import MinimalLayout from "~/components/MinimalLayout.vue"; import {useProvidePodcastGroupLayout} from "~/components/Public/Podcasts/usePodcastGroupLayout.ts"; const props = defineProps({ baseUrl: { type: String, required: true }, groupLayout: { type: String, default: 'table' } }); useProvidePodcastGroupLayout(props.groupLayout); const {name} = useAzuraCastStation(); </script> ```
/content/code_sandbox/frontend/components/Public/Podcasts/PodcastsLayout.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
285
```vue <template> <div class="full-height-scrollable"> <div class="card-body"> <loading :loading="podcastLoading || episodeLoading" lazy > <nav aria-label="breadcrumb"> <ol class="breadcrumb m-0"> <li class="breadcrumb-item"> <router-link :to="{name: 'public:podcasts'}"> {{ $gettext('Podcasts') }} </router-link> </li> <li class="breadcrumb-item"> <router-link :to="{name: 'public:podcast', params: {podcast_id: podcast.id}}"> {{ podcast.title }} </router-link> </li> <li class="breadcrumb-item"> {{ episode.title }} </li> </ol> </nav> </loading> </div> <div class="card-body alert alert-secondary" aria-live="polite" > <loading :loading="podcastLoading" lazy > <podcast-common :podcast="podcast" /> </loading> </div> <div class="card-body"> <loading :loading="episodeLoading" lazy > <div class="d-flex"> <div class="flex-shrink-0 pe-3"> <play-button icon-class="xl" :url="episode.links.download" /> </div> <div class="flex-fill"> <h4 class="card-title mb-1"> {{ episode.title }} </h4> <div class="badges my-2"> <span v-if="episode.publish_at" class="badge text-bg-secondary" > {{ formatTimestampAsDateTime(episode.publish_at) }} </span> <span v-else class="badge text-bg-secondary" > {{ formatTimestampAsDateTime(episode.created_at) }} </span> <span v-if="episode.explicit" class="badge text-bg-danger" > {{ $gettext('Explicit') }} </span> </div> <p class="card-text"> {{ episode.description }} </p> </div> <div class="flex-shrink-0 ps-3"> <album-art :src="episode.art" :width="96" /> </div> </div> </loading> </div> </div> </template> <script setup lang="ts"> import Loading from "~/components/Common/Loading.vue"; import {useRoute} from "vue-router"; import {getStationApiUrl} from "~/router.ts"; import {useAxios} from "~/vendor/axios.ts"; import useRefreshableAsyncState from "~/functions/useRefreshableAsyncState.ts"; import AlbumArt from "~/components/Common/AlbumArt.vue"; import PlayButton from "~/components/Common/PlayButton.vue"; import useStationDateTimeFormatter from "~/functions/useStationDateTimeFormatter.ts"; import PodcastCommon from "./PodcastCommon.vue"; const {params} = useRoute(); const podcastUrl = getStationApiUrl(`/public/podcast/${params.podcast_id}`); const episodeUrl = getStationApiUrl(`/public/podcast/${params.podcast_id}/episode/${params.episode_id}`); const {axios} = useAxios(); const {state: podcast, isLoading: podcastLoading} = useRefreshableAsyncState( () => axios.get(podcastUrl.value).then((r) => r.data), {}, ); const {state: episode, isLoading: episodeLoading} = useRefreshableAsyncState( () => axios.get(episodeUrl.value).then((r) => r.data), {}, ); const {formatTimestampAsDateTime} = useStationDateTimeFormatter(); </script> ```
/content/code_sandbox/frontend/components/Public/Podcasts/PodcastEpisode.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
812
```vue <template> <h4 class="card-title mb-1"> {{ podcast.title }} <span v-if="podcast.author"> <br> <small> {{ $gettext('by') }} <a :href="'mailto:'+podcast.email" target="_blank" >{{ podcast.author }}</a> </small> </span> </h4> <div class="badges my-2"> <span class="badge text-bg-info"> {{ podcast.language_name }} </span> <span v-for="category in podcast.categories" :key="category.category" class="badge text-bg-secondary" > {{ category.text }} </span> </div> <p class="card-text"> {{ podcast.description }} </p> <p v-if="podcast.branding_config.public_custom_html" class="card-text" v-html="podcast.branding_config.public_custom_html" /> </template> <script setup lang="ts"> import {ApiPodcast} from "~/entities/ApiInterfaces.ts"; const props = defineProps<{ podcast: ApiPodcast }>(); </script> ```
/content/code_sandbox/frontend/components/Public/Podcasts/PodcastCommon.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
256
```vue <template> <modal-form ref="$modal" size="md" centered :title="$gettext('Change Password')" :disable-save-button="v$.$invalid" @submit="onSubmit" @hidden="clearContents" > <form-group-field id="form_current_password" :field="v$.current_password" input-type="password" autofocus :label="$gettext('Current Password')" /> <form-group-field id="form_new_password" :field="v$.new_password" input-type="password" :label="$gettext('New Password')" /> <form-group-field id="form_current_password" :field="v$.new_password2" input-type="password" :label="$gettext('Confirm New Password')" /> <template #save-button-name> {{ $gettext('Change Password') }} </template> </modal-form> </template> <script setup lang="ts"> import FormGroupField from "~/components/Form/FormGroupField.vue"; import ModalForm from "~/components/Common/ModalForm.vue"; import {helpers, required} from "@vuelidate/validators"; import validatePassword from "~/functions/validatePassword"; import {useVuelidateOnForm} from "~/functions/useVuelidateOnForm"; import {ref} from "vue"; import {useAxios} from "~/vendor/axios"; import {useTranslate} from "~/vendor/gettext"; import {ModalFormTemplateRef} from "~/functions/useBaseEditModal.ts"; import {getApiUrl} from "~/router.ts"; const emit = defineEmits(['relist']); const changePasswordUrl = getApiUrl('/frontend/account/password'); const passwordsMatch = (value, siblings) => { return siblings.new_password === value; }; const {$gettext} = useTranslate(); const {form, resetForm, v$, ifValid} = useVuelidateOnForm( { current_password: {required}, new_password: {required, validatePassword}, new_password2: { required, passwordsMatch: helpers.withMessage($gettext('Must match new password.'), passwordsMatch) } }, { current_password: null, new_password: null, new_password2: null } ); const error = ref(null); const clearContents = () => { error.value = null; resetForm(); }; const $modal = ref<ModalFormTemplateRef>(null); const open = () => { clearContents(); $modal.value?.show(); }; const {axios} = useAxios(); const onSubmit = () => { ifValid(() => { axios .put(changePasswordUrl.value, form.value) .finally(() => { $modal.value?.hide(); emit('relist'); }); }); }; defineExpose({ open }); </script> ```
/content/code_sandbox/frontend/components/Account/ChangePasswordModal.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
614
```vue <template> <div class="full-height-scrollable"> <loading :loading="isLoading" lazy > <div class="card-body"> <div class="d-flex"> <div class="flex-fill"> <nav aria-label="breadcrumb"> <ol class="breadcrumb"> <li class="breadcrumb-item"> <router-link :to="{name: 'public:podcasts'}"> {{ $gettext('Podcasts') }} </router-link> </li> <li class="breadcrumb-item"> {{ podcast.title }} </li> </ol> </nav> <podcast-common :podcast="podcast" /> <div class="buttons"> <a class="btn btn-warning btn-sm" :href="podcast.links.public_feed" target="_blank" > <icon :icon="IconRss" /> {{ $gettext('RSS') }} </a> </div> </div> <div class="flex-shrink ps-3"> <album-art :src="podcast.art" :width="128" /> </div> </div> </div> </loading> <data-table v-if="groupLayout === 'table'" id="podcast-episodes" ref="$datatable" paginated :fields="fields" :api-url="episodesUrl" > <template #cell(play_button)="{item}"> <play-button icon-class="lg" :url="item.links.download" /> </template> <template #cell(art)="{item}"> <album-art :src="item.art" :width="64" /> </template> <template #cell(title)="{item}"> <h5 class="m-0"> <router-link :to="{name: 'public:podcast:episode', params: {podcast_id: podcast.id, episode_id: item.id}}" > {{ item.title }} </router-link> </h5> <div class="badges my-2"> <span v-if="item.publish_at" class="badge text-bg-secondary" > {{ formatTimestampAsDateTime(item.publish_at) }} </span> <span v-else class="badge text-bg-secondary" > {{ formatTimestampAsDateTime(item.created_at) }} </span> <span v-if="item.explicit" class="badge text-bg-danger" > {{ $gettext('Explicit') }} </span> </div> <p class="card-text"> {{ item.description_short }} </p> </template> <template #cell(actions)="{item}"> <div class="btn-group btn-group-sm"> <router-link :to="{name: 'public:podcast:episode', params: {podcast_id: podcast.id, episode_id: item.id}}" class="btn btn-primary" > {{ $gettext('Details') }} </router-link> </div> </template> </data-table> <grid-layout v-else id="podcast-episodes-grid" ref="$grid" paginated :api-url="episodesUrl" > <template #item="{item}"> <div class="card mb-4"> <div class="card-header d-flex align-items-center"> <div class="flex-shrink-0 pe-2"> <play-button icon-class="lg" :url="item.links.download" /> </div> <h5 class="card-title flex-fill m-0"> <router-link :to="{name: 'public:podcast:episode', params: {podcast_id: podcast.id, episode_id: item.id}}" > {{ item.title }} </router-link> </h5> <div class="flex-shrink-0 ps-2"> <album-art :src="item.art" :width="64" /> </div> </div> <div class="card-body"> <div class="badges my-2"> <span v-if="item.publish_at" class="badge text-bg-secondary" > {{ formatTimestampAsDateTime(item.publish_at) }} </span> <span v-else class="badge text-bg-secondary" > {{ formatTimestampAsDateTime(item.created_at) }} </span> <span v-if="item.explicit" class="badge text-bg-danger" > {{ $gettext('Explicit') }} </span> </div> <p class="card-text"> {{ item.description_short }} </p> </div> </div> </template> </grid-layout> </div> </template> <script setup lang="ts"> import {getStationApiUrl} from "~/router.ts"; import {useRoute} from "vue-router"; import DataTable, {DataTableField} from "~/components/Common/DataTable.vue"; import useRefreshableAsyncState from "~/functions/useRefreshableAsyncState.ts"; import {useAxios} from "~/vendor/axios.ts"; import Loading from "~/components/Common/Loading.vue"; import AlbumArt from "~/components/Common/AlbumArt.vue"; import {useTranslate} from "~/vendor/gettext.ts"; import {IconRss} from "~/components/Common/icons.ts"; import Icon from "~/components/Common/Icon.vue"; import PlayButton from "~/components/Common/PlayButton.vue"; import useStationDateTimeFormatter from "~/functions/useStationDateTimeFormatter.ts"; import PodcastCommon from "./PodcastCommon.vue"; import GridLayout from "~/components/Common/GridLayout.vue"; import {usePodcastGroupLayout} from "~/components/Public/Podcasts/usePodcastGroupLayout.ts"; const {groupLayout} = usePodcastGroupLayout(); const {params} = useRoute(); const podcastUrl = getStationApiUrl(`/public/podcast/${params.podcast_id}`); const {axios} = useAxios(); const {state: podcast, isLoading} = useRefreshableAsyncState( () => axios.get(podcastUrl.value).then((r) => r.data), {}, ); const episodesUrl = getStationApiUrl(`/public/podcast/${params.podcast_id}/episodes`); const {$gettext} = useTranslate(); const fields: DataTableField[] = [ {key: 'play_button', label: '', sortable: false, class: 'shrink pe-0'}, {key: 'art', label: '', sortable: false, class: 'shrink pe-0'}, {key: 'title', label: $gettext('Episode'), sortable: true}, {key: 'actions', label: $gettext('Actions'), sortable: false, class: 'shrink'} ]; const {formatTimestampAsDateTime} = useStationDateTimeFormatter(); </script> ```
/content/code_sandbox/frontend/components/Public/Podcasts/Podcast.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,502
```vue <template> <card-page header-id="hdr_api_keys" :title="$gettext('API Keys')" > <template #info> {{ $gettext('Use API keys to authenticate with the AzuraCast API using the same permissions as your user account.') }} <a href="/api" class="alert-link" target="_blank" > {{ $gettext('API Documentation') }} </a> </template> <template #actions> <button type="button" class="btn btn-primary" @click="createApiKey" > <icon :icon="IconAdd" /> <span> {{ $gettext('Add API Key') }} </span> </button> </template> <data-table id="account_api_keys" ref="$dataTable" :show-toolbar="false" :fields="apiKeyFields" :api-url="apiKeysApiUrl" > <template #cell(actions)="row"> <div class="btn-group btn-group-sm"> <button type="button" class="btn btn-danger" @click="deleteApiKey(row.item.links.self)" > {{ $gettext('Delete') }} </button> </div> </template> </data-table> </card-page> <account-api-key-modal ref="$apiKeyModal" :create-url="apiKeysApiUrl" @relist="relist" /> </template> <script setup lang="ts"> import {IconAdd} from "~/components/Common/icons.ts"; import DataTable, {DataTableField} from "~/components/Common/DataTable.vue"; import CardPage from "~/components/Common/CardPage.vue"; import Icon from "~/components/Common/Icon.vue"; import AccountApiKeyModal from "~/components/Account/ApiKeyModal.vue"; import {ref} from "vue"; import useConfirmAndDelete from "~/functions/useConfirmAndDelete.ts"; import {useTranslate} from "~/vendor/gettext.ts"; import useHasDatatable, {DataTableTemplateRef} from "~/functions/useHasDatatable.ts"; import {getApiUrl} from "~/router.ts"; const apiKeysApiUrl = getApiUrl('/frontend/account/api-keys'); const {$gettext} = useTranslate(); const apiKeyFields: DataTableField[] = [ { key: 'comment', isRowHeader: true, label: $gettext('API Key Description/Comments'), sortable: false }, { key: 'actions', label: $gettext('Actions'), sortable: false, class: 'shrink' } ]; const $apiKeyModal = ref<InstanceType<typeof AccountApiKeyModal> | null>(null); const createApiKey = () => { $apiKeyModal.value?.create(); }; const $dataTable = ref<DataTableTemplateRef>(null); const {relist} = useHasDatatable($dataTable); const {doDelete: deleteApiKey} = useConfirmAndDelete( $gettext('Delete API Key?'), relist ); </script> ```
/content/code_sandbox/frontend/components/Account/ApiKeysPanel.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
647
```vue <template> <canvas ref="$canvas" /> </template> <script setup lang="ts"> import {onMounted, ref} from "vue"; import {toCanvas} from "qrcode"; const props = defineProps<{ uri: string }>(); const $canvas = ref<HTMLCanvasElement | null>(); onMounted(() => { toCanvas($canvas.value, props.uri, (error) => { if (error) console.error(error) }) }); </script> ```
/content/code_sandbox/frontend/components/Account/QrCode.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
101
```vue <template> <div class="card-header text-bg-primary d-flex flex-wrap align-items-center"> <avatar v-if="user.avatar.url_128" class="flex-shrink-0 me-3" :url="user.avatar.url_128" :service="user.avatar.service_name" :service-url="user.avatar.service_url" /> <div class="flex-fill"> <h2 v-if="user.name" class="card-title mt-0" > {{ user.name }} </h2> <h2 v-else class="card-title" > {{ $gettext('AzuraCast User') }} </h2> <h3 class="card-subtitle"> {{ user.email }} </h3> <div v-if="user.roles.length > 0" class="mt-2" > <span v-for="role in user.roles" :key="role.id" class="badge text-bg-secondary me-2" >{{ role.name }}</span> </div> </div> <div v-if="slots.default" class="flex-md-shrink-0 mt-3 mt-md-0 buttons" > <slot /> </div> </div> </template> <script setup lang="ts"> import Avatar from "~/components/Common/Avatar.vue"; import {useAxios} from "~/vendor/axios.ts"; import useRefreshableAsyncState from "~/functions/useRefreshableAsyncState.ts"; import {getApiUrl} from "~/router.ts"; const slots = defineSlots(); const {axios} = useAxios(); const userUrl = getApiUrl('/frontend/account/me'); const {state: user, execute: reload} = useRefreshableAsyncState( () => axios.get(userUrl.value).then((r) => r.data), { name: null, email: null, avatar: { url_128: null, service_name: null, service_url: null }, roles: [], }, ); defineExpose({ reload }); </script> ```
/content/code_sandbox/frontend/components/Account/UserInfoPanel.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
462
```vue <template> <modal-form ref="$modal" :loading="loading" :title="$gettext('Enable Two-Factor Authentication')" :error="error" :disable-save-button="v$.$invalid" no-enforce-focus @submit="doSubmit" @hidden="clearContents" > <div class="row"> <div class="col-md-7"> <h5 class="mt-2"> {{ $gettext('Step 1: Scan QR Code') }} </h5> <p class="card-text"> {{ $gettext('From your smartphone, scan the code to the right using an authentication app of your choice (FreeOTP, Authy, etc).') }} </p> <h5 class="mt-0"> {{ $gettext('Step 2: Verify Generated Code') }} </h5> <p class="card-text"> {{ $gettext('To verify that the code was set up correctly, enter the 6-digit code the app shows you.') }} </p> <form-fieldset> <form-group-field id="form_otp" :field="v$.otp" autofocus :label="$gettext('Code from Authenticator App')" :description="$gettext('Enter the current code provided by your authenticator app to verify that it\'s working correctly.')" /> </form-fieldset> </div> <div class="col-md-5"> <div v-if="totp.totp_uri" > <qr-code :uri="totp.totp_uri" /> <code id="totp_uri" class="d-inline-block text-truncate mt-2" style="width: 100%;" > {{ totp.totp_uri }} </code> <copy-to-clipboard-button :text="totp.totp_uri" /> </div> </div> </div> <template #save-button-name> {{ $gettext('Submit Code') }} </template> </modal-form> </template> <script setup lang="ts"> import ModalForm from "~/components/Common/ModalForm.vue"; import CopyToClipboardButton from "~/components/Common/CopyToClipboardButton.vue"; import FormFieldset from "~/components/Form/FormFieldset.vue"; import FormGroupField from "~/components/Form/FormGroupField.vue"; import {minLength, required} from "@vuelidate/validators"; import {useVuelidateOnForm} from "~/functions/useVuelidateOnForm"; import {ref} from "vue"; import {useResettableRef} from "~/functions/useResettableRef"; import {useNotify} from "~/functions/useNotify"; import {useAxios} from "~/vendor/axios"; import {ModalFormTemplateRef} from "~/functions/useBaseEditModal.ts"; import QrCode from "~/components/Account/QrCode.vue"; import {useHasModal} from "~/functions/useHasModal.ts"; const props = defineProps({ twoFactorUrl: { type: String, required: true } }); const emit = defineEmits(['relist']); const loading = ref(true); const error = ref(null); const {form, resetForm, v$, ifValid} = useVuelidateOnForm( { otp: { required, minLength: minLength(6) } }, { otp: '' } ); const {record: totp, reset: resetTotp} = useResettableRef({ secret: null, totp_uri: null, qr_code: null }); const clearContents = () => { resetForm(); resetTotp(); loading.value = false; error.value = null; }; const $modal = ref<ModalFormTemplateRef>(null); const {hide, show} = useHasModal($modal); const {notifySuccess} = useNotify(); const {axios} = useAxios(); const open = () => { clearContents(); loading.value = true; show(); axios.put(props.twoFactorUrl).then((resp) => { totp.value = resp.data; loading.value = false; }).catch(() => { hide(); }); }; const doSubmit = () => { ifValid(() => { error.value = null; axios({ method: 'PUT', url: props.twoFactorUrl, data: { secret: totp.value.secret, otp: form.value.otp } }).then(() => { notifySuccess(); emit('relist'); hide(); }).catch((error) => { error.value = error.response.data.message; }); }); }; defineExpose({ open }); </script> ```
/content/code_sandbox/frontend/components/Account/TwoFactorModal.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,021
```vue <template> <modal id="api_keys_modal" ref="$modal" size="md" centered :title="$gettext('Add New Passkey')" no-enforce-focus @hidden="onHidden" > <template #default> <div v-show="error != null" class="alert alert-danger" > {{ error }} </div> <form v-if="isSupported" class="form vue-form" @submit.prevent="doSubmit" > <form-group-field id="form_name" :field="v$.name" autofocus class="mb-3" :label="$gettext('Passkey Nickname')" /> <form-markup id="form_select_passkey"> <template #label> {{ $gettext('Select Passkey') }} </template> <p class="card-text"> {{ $gettext('Click the button below to open your browser window to select a passkey.') }} </p> <p v-if="form.createResponse" class="card-text" > {{ $gettext('A passkey has been selected. Submit this form to add it to your account.') }} </p> <div v-else class="buttons" > <button type="button" class="btn btn-primary" @click="selectPasskey" > {{ $gettext('Select Passkey') }} </button> </div> </form-markup> <invisible-submit-button /> </form> <div v-else> <p class="card-text"> {{ $gettext('Your browser does not support passkeys. Consider updating your browser to the latest version.') }} </p> </div> </template> <template #modal-footer="slotProps"> <slot name="modal-footer" v-bind="slotProps" > <button type="button" class="btn btn-secondary" @click="hide" > {{ $gettext('Close') }} </button> <button type="submit" class="btn" :class="(v$.$invalid) ? 'btn-danger' : 'btn-primary'" @click="doSubmit" > {{ $gettext('Add New Passkey') }} </button> </slot> </template> </modal> </template> <script setup lang="ts"> import InvisibleSubmitButton from "~/components/Common/InvisibleSubmitButton.vue"; import FormGroupField from "~/components/Form/FormGroupField.vue"; import {required} from '@vuelidate/validators'; import {ref} from "vue"; import {useVuelidateOnForm} from "~/functions/useVuelidateOnForm"; import {useAxios} from "~/vendor/axios"; import Modal from "~/components/Common/Modal.vue"; import {ModalTemplateRef, useHasModal} from "~/functions/useHasModal.ts"; import FormMarkup from "~/components/Form/FormMarkup.vue"; import {getApiUrl} from "~/router.ts"; import useWebAuthn from "~/functions/useWebAuthn.ts"; const emit = defineEmits(['relist']); const registerWebAuthnUrl = getApiUrl('/frontend/account/webauthn/register'); const error = ref(null); const {form, resetForm, v$, validate} = useVuelidateOnForm( { name: {required}, createResponse: {required} }, { name: '', createResponse: null } ); const clearContents = () => { resetForm(); error.value = null; }; const $modal = ref<ModalTemplateRef>(null); const {show, hide} = useHasModal($modal); const create = () => { clearContents(); show(); }; const {isSupported, doRegister, cancel} = useWebAuthn(); const onHidden = () => { clearContents(); cancel(); emit('relist'); }; const {axios} = useAxios(); const selectPasskey = async () => { const registerArgs = await axios.get(registerWebAuthnUrl.value).then(r => r.data); try { form.value.createResponse = await doRegister(registerArgs); } catch (err) { if (err.name === 'InvalidStateError') { error.value = 'Error: Authenticator was probably already registered by user'; } else { error.value = err; } throw err; } }; const doSubmit = async () => { const isValid = await validate(); if (!isValid) { return; } error.value = null; axios({ method: 'PUT', url: registerWebAuthnUrl.value, data: form.value }).then(() => { hide(); }).catch((error) => { error.value = error.response.data.message; }); }; defineExpose({ create }); </script> ```
/content/code_sandbox/frontend/components/Account/PasskeyModal.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,072
```vue <template> <modal id="api_keys_modal" ref="$modal" size="md" centered :title="$gettext('Add API Key')" no-enforce-focus @shown="onShown" @hidden="clearContents" > <template #default> <div v-show="error != null" class="alert alert-danger" > {{ error }} </div> <form v-if="newKey === null" class="form vue-form" @submit.prevent="doSubmit" > <form-group-field id="form_comments" ref="$field" :field="v$.comment" autofocus :label="$gettext('API Key Description/Comments')" /> <invisible-submit-button /> </form> <div v-else> <account-api-key-new-key :new-key="newKey" /> </div> </template> <template #modal-footer="slotProps"> <slot name="modal-footer" v-bind="slotProps" > <button type="button" class="btn btn-secondary" @click="hide" > {{ $gettext('Close') }} </button> <button v-if="newKey === null" type="submit" class="btn" :class="(v$.$invalid) ? 'btn-danger' : 'btn-primary'" @click="doSubmit" > {{ $gettext('Create New Key') }} </button> </slot> </template> </modal> </template> <script setup lang="ts"> import InvisibleSubmitButton from "~/components/Common/InvisibleSubmitButton.vue"; import AccountApiKeyNewKey from "./ApiKeyNewKey.vue"; import FormGroupField from "~/components/Form/FormGroupField.vue"; import {required} from '@vuelidate/validators'; import {nextTick, ref} from "vue"; import {useVuelidateOnForm} from "~/functions/useVuelidateOnForm"; import {useAxios} from "~/vendor/axios"; import Modal from "~/components/Common/Modal.vue"; import {ModalTemplateRef, useHasModal} from "~/functions/useHasModal.ts"; const props = defineProps({ createUrl: { type: String, required: true } }); const emit = defineEmits(['relist']); const error = ref(null); const newKey = ref(null); const {form, resetForm, v$, validate} = useVuelidateOnForm( { comment: {required} }, { comment: '' } ); const clearContents = () => { resetForm(); error.value = null; newKey.value = null; }; const $modal = ref<ModalTemplateRef>(null); const {show, hide} = useHasModal($modal); const create = () => { clearContents(); show(); }; const $field = ref<InstanceType<typeof FormGroupField> | null>(null); const onShown = () => { nextTick(() => { $field.value?.focus(); }) }; const {axios} = useAxios(); const doSubmit = async () => { const isValid = await validate(); if (!isValid) { return; } error.value = null; axios({ method: 'POST', url: props.createUrl, data: form.value }).then((resp) => { newKey.value = resp.data.key; emit('relist'); }).catch((error) => { error.value = error.response.data.message; }); }; defineExpose({ create }); </script> ```
/content/code_sandbox/frontend/components/Account/ApiKeyModal.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
788
```vue <template> <div class="row g-3"> <div class="col-md-6"> <form-group-field id="form_name" class="mb-3" tabindex="1" :field="form.name" :label="$gettext('Name')" /> <form-group-field id="form_email" class="mb-3" tabindex="2" :field="form.email" :label="$gettext('E-mail Address')" /> <form-group-multi-check id="edit_form_show_24_hour_time" class="mb-3" tabindex="3" :field="form.show_24_hour_time" :options="show24hourOptions" stacked radio :label="$gettext('Time Display')" /> </div> <div class="col-md-6"> <form-group-multi-check id="edit_form_locale" tabindex="4" :field="form.locale" :options="localeOptions" stacked radio :label="$gettext('Language')" /> </div> </div> </template> <script setup lang="ts"> import FormGroupField from "~/components/Form/FormGroupField.vue"; import objectToFormOptions from "~/functions/objectToFormOptions"; import {computed} from "vue"; import {useTranslate} from "~/vendor/gettext"; import FormGroupMultiCheck from "~/components/Form/FormGroupMultiCheck.vue"; const props = defineProps({ form: { type: Object, required: true }, supportedLocales: { type: Object, required: true } }); const {$gettext} = useTranslate(); const localeOptions = computed(() => { const localeOptions = objectToFormOptions(props.supportedLocales); localeOptions.unshift({ text: $gettext('Use Browser Default'), value: 'default' }); return localeOptions; }); const show24hourOptions = computed(() => { return [ { text: $gettext('Prefer System Default'), value: null }, { text: $gettext('12 Hour'), value: false }, { text: $gettext('24 Hour'), value: true } ]; }); </script> ```
/content/code_sandbox/frontend/components/Account/EditForm.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
489
```vue <template> <modal-form ref="$modal" :loading="loading" :title="$gettext('Edit Profile')" :error="error" :disable-save-button="v$.$invalid" @submit="doSubmit" @hidden="clearContents" > <account-edit-form :form="v$" :supported-locales="supportedLocales" /> </modal-form> </template> <script setup lang="ts"> import mergeExisting from "~/functions/mergeExisting"; import {email, required} from '@vuelidate/validators'; import AccountEditForm from "./EditForm.vue"; import ModalForm from "~/components/Common/ModalForm.vue"; import {ref} from "vue"; import {useVuelidateOnForm} from "~/functions/useVuelidateOnForm"; import {useNotify} from "~/functions/useNotify"; import {useAxios} from "~/vendor/axios"; import {ModalFormTemplateRef} from "~/functions/useBaseEditModal.ts"; import {getApiUrl} from "~/router.ts"; import {useHasModal} from "~/functions/useHasModal.ts"; const props = defineProps({ supportedLocales: { type: Object, required: true } }); const emit = defineEmits(['reload']); const userUrl = getApiUrl('/frontend/account/me'); const loading = ref(true); const error = ref(null); const {form, resetForm, v$, ifValid} = useVuelidateOnForm( { name: {}, email: {required, email}, locale: {required}, show_24_hour_time: {} }, { name: '', email: '', locale: 'default', show_24_hour_time: null, } ); const clearContents = () => { resetForm(); loading.value = false; error.value = null; }; const $modal = ref<ModalFormTemplateRef>(null); const {show, hide} = useHasModal($modal); const {notifySuccess} = useNotify(); const {axios} = useAxios(); const open = () => { clearContents(); show(); axios.get(userUrl.value).then((resp) => { form.value = mergeExisting(form.value, resp.data); loading.value = false; }).catch(() => { hide(); }); }; const doSubmit = () => { ifValid(() => { error.value = null; axios({ method: 'PUT', url: userUrl.value, data: form.value }).then(() => { notifySuccess(); emit('reload'); hide(); }).catch((error) => { error.value = error.response.data.message; }); }); }; defineExpose({ open }); </script> ```
/content/code_sandbox/frontend/components/Account/EditModal.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
593
```vue <template> <card-page header-id="hdr_security"> <template #header="{id}"> <div class="d-flex align-items-center"> <div class="flex-fill"> <h3 :id="id" class="card-title" > {{ $gettext('Security') }} </h3> </div> <div class="flex-shrink-0"> <button type="button" class="btn btn-dark" @click="doChangePassword" > <icon :icon="IconVpnKey" /> <span> {{ $gettext('Change Password') }} </span> </button> </div> </div> </template> <loading :loading="securityLoading"> <div class="card-body"> <h5> {{ $gettext('Two-Factor Authentication') }} <enabled-badge :enabled="security.twoFactorEnabled" /> </h5> <p class="card-text mt-2"> {{ $gettext('Two-factor authentication improves the security of your account by requiring a second one-time access code in addition to your password when you log in.') }} </p> <div class="buttons"> <button v-if="security.twoFactorEnabled" type="button" class="btn btn-danger" @click="disableTwoFactor" > <icon :icon="IconLockOpen" /> <span> {{ $gettext('Disable Two-Factor') }} </span> </button> <button v-else type="button" class="btn btn-success" @click="enableTwoFactor" > <icon :icon="IconLock" /> <span> {{ $gettext('Enable Two-Factor') }} </span> </button> </div> </div> </loading> <div class="card-body"> <h5> {{ $gettext('Passkey Authentication') }} </h5> <p class="card-text mt-2"> {{ $gettext('Using a passkey (like Windows Hello, YubiKey, or your smartphone) allows you to securely log in without needing to enter your password or two-factor code.') }} </p> <div class="buttons"> <button type="button" class="btn btn-primary" @click="doAddPasskey" > <icon :icon="IconAdd" /> <span> {{ $gettext('Add New Passkey') }} </span> </button> </div> </div> <data-table id="account_passkeys" ref="$dataTable" :show-toolbar="false" :fields="passkeyFields" :api-url="passkeysApiUrl" > <template #cell(actions)="row"> <div class="btn-group btn-group-sm"> <button type="button" class="btn btn-danger" @click="deletePasskey(row.item.links.self)" > {{ $gettext('Delete') }} </button> </div> </template> </data-table> </card-page> <account-change-password-modal ref="$changePasswordModal" /> <account-two-factor-modal ref="$twoFactorModal" :two-factor-url="twoFactorUrl" @relist="reloadSecurity" /> <passkey-modal ref="$passkeyModal" @relist="reloadPasskeys" /> </template> <script setup lang="ts"> import {IconAdd, IconLock, IconLockOpen, IconVpnKey} from "~/components/Common/icons.ts"; import CardPage from "~/components/Common/CardPage.vue"; import EnabledBadge from "~/components/Common/Badges/EnabledBadge.vue"; import Icon from "~/components/Common/Icon.vue"; import Loading from "~/components/Common/Loading.vue"; import AccountTwoFactorModal from "~/components/Account/TwoFactorModal.vue"; import AccountChangePasswordModal from "~/components/Account/ChangePasswordModal.vue"; import {useAxios} from "~/vendor/axios.ts"; import {getApiUrl} from "~/router.ts"; import useRefreshableAsyncState from "~/functions/useRefreshableAsyncState.ts"; import {ref} from "vue"; import useConfirmAndDelete from "~/functions/useConfirmAndDelete.ts"; import {useTranslate} from "~/vendor/gettext.ts"; import DataTable, {DataTableField} from "~/components/Common/DataTable.vue"; import useHasDatatable, {DataTableTemplateRef} from "~/functions/useHasDatatable.ts"; import PasskeyModal from "~/components/Account/PasskeyModal.vue"; const {axios} = useAxios(); const twoFactorUrl = getApiUrl('/frontend/account/two-factor'); const {state: security, isLoading: securityLoading, execute: reloadSecurity} = useRefreshableAsyncState( () => axios.get(twoFactorUrl.value).then((r) => { return { twoFactorEnabled: r.data.two_factor_enabled }; }), { twoFactorEnabled: false, }, ); const $changePasswordModal = ref<InstanceType<typeof AccountChangePasswordModal> | null>(null); const doChangePassword = () => { $changePasswordModal.value?.open(); }; const $twoFactorModal = ref<InstanceType<typeof AccountTwoFactorModal> | null>(null); const enableTwoFactor = () => { $twoFactorModal.value?.open(); }; const {$gettext} = useTranslate(); const {doDelete: doDisableTwoFactor} = useConfirmAndDelete( $gettext('Disable two-factor authentication?'), reloadSecurity ); const disableTwoFactor = () => doDisableTwoFactor(twoFactorUrl.value); const passkeysApiUrl = getApiUrl('/frontend/account/passkeys'); const passkeyFields: DataTableField[] = [ { key: 'name', isRowHeader: true, label: $gettext('Passkey Nickname'), sortable: false }, { key: 'actions', label: $gettext('Actions'), sortable: false, class: 'shrink' } ]; const $dataTable = ref<DataTableTemplateRef>(null); const {relist: reloadPasskeys} = useHasDatatable($dataTable); const {doDelete: deletePasskey} = useConfirmAndDelete( $gettext('Delete Passkey?'), reloadPasskeys ); const $passkeyModal = ref<InstanceType<typeof PasskeyModal> | null>(null); const doAddPasskey = () => { $passkeyModal.value?.create(); }; </script> ```
/content/code_sandbox/frontend/components/Account/SecurityPanel.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,420
```vue <template> <h3 class="card-subtitle"> {{ $gettext('New Key Generated') }} </h3> <p class="card-text"> <b>{{ $gettext('Important: copy the key below before continuing!') }}</b> {{ $gettext('You will not be able to retrieve it again.') }} </p> <p class="card-text"> {{ $gettext('Your full API key is below:') }} </p> <div class="px-2"> <code id="api_key">{{ newKey }}</code> <div class="buttons pt-2"> <copy-to-clipboard-button :text="newKey" /> </div> </div> <p class="card-text pt-3"> {{ $gettext('When making API calls, you can pass this value in the "X-API-Key" header to authenticate as yourself.') }} </p> <p class="card-text"> {{ $gettext('You can only perform the actions your user account is allowed to perform.') }} </p> </template> <script setup lang="ts"> import CopyToClipboardButton from "~/components/Common/CopyToClipboardButton.vue"; defineProps({ newKey: { type: String, required: true } }); </script> ```
/content/code_sandbox/frontend/components/Account/ApiKeyNewKey.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
283
```vue <template> <input v-model="checkboxValue" class="form-check-input" type="checkbox" role="switch" > </template> <script setup lang="ts"> import {useVModel} from "@vueuse/core"; const props = defineProps<{ modelValue: boolean | null }>(); const emit = defineEmits(['update:modelValue']); const checkboxValue = useVModel(props, 'modelValue', emit); </script> ```
/content/code_sandbox/frontend/components/Form/FormCheckbox.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
100
```vue <template> <slot name="default" /> <span v-if="isRequired" class="text-danger" > <span aria-hidden="true">*</span> <span class="visually-hidden">{{ $gettext('Required') }}</span> </span> <span v-if="advanced" class="badge small text-bg-primary ms-2" > {{ $gettext('Advanced') }} </span> <span v-if="highCpu" class="badge small text-bg-warning ms-2" :title="$gettext('This setting can result in excessive CPU consumption and should be used with caution.')" > {{ $gettext('High CPU') }} </span> </template> <script setup lang="ts"> import formLabelProps from "~/components/Form/formLabelProps.ts"; const props = defineProps({ isRequired: { type: Boolean, default: false }, ...formLabelProps }); </script> ```
/content/code_sandbox/frontend/components/Form/FormLabel.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
213
```vue <template> <form-group v-bind="$attrs" :id="id" > <template v-if="label || slots.label" #label="slotProps" > <form-label :is-required="isRequired" v-bind="pickProps(props, formLabelProps)" > <slot name="label" v-bind="slotProps" > {{ label }} </slot> </form-label> </template> <template #default> <slot name="default" v-bind="{ id, field, model }" > <form-multi-check :id="id" v-model="model" :name="name || id" :options="options" :radio="radio" :stacked="stacked" > <template v-for="(_, slot) of useSlotsExcept(['default', 'label', 'description'])" #[slot]="scope" > <slot :name="slot" v-bind="scope" /> </template> </form-multi-check> </slot> <vuelidate-error v-if="isVuelidateField" :field="field" /> </template> <template v-if="description || slots.description" #description="slotProps" > <slot v-bind="slotProps" name="description" > {{ description }} </slot> </template> </form-group> </template> <script setup lang="ts"> import VuelidateError from "./VuelidateError.vue"; import FormLabel from "~/components/Form/FormLabel.vue"; import FormGroup from "~/components/Form/FormGroup.vue"; import FormMultiCheck from "~/components/Form/FormMultiCheck.vue"; import useSlotsExcept from "~/functions/useSlotsExcept"; import {formFieldProps, useFormField} from "~/components/Form/useFormField"; import {useSlots} from "vue"; import formLabelProps from "~/components/Form/formLabelProps.ts"; import {pickProps} from "~/functions/pickProps.ts"; const props = defineProps({ ...formFieldProps, ...formLabelProps, id: { type: String, required: true }, name: { type: String, default: null, }, label: { type: String, default: null }, description: { type: String, default: null }, options: { type: Array, required: true }, radio: { type: Boolean, default: false }, stacked: { type: Boolean, default: false } }); const slots = useSlots(); const emit = defineEmits(['update:modelValue']); const {model, isVuelidateField, isRequired} = useFormField(props, emit); </script> ```
/content/code_sandbox/frontend/components/Form/FormGroupMultiCheck.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
627
```vue <template> <div class="form-group" v-bind="$attrs" > <label v-if="slots.label" :for="id" > <slot name="label" /> </label> <slot :id="id" name="default" /> <div v-if="slots.description" class="form-text" > <slot name="description" /> </div> </div> </template> <script setup lang="ts"> const props = defineProps({ id: { type: String, required: true } }); const slots = defineSlots(); </script> ```
/content/code_sandbox/frontend/components/Form/FormGroup.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
146
```vue <template> <div v-for="message in errorMessages" :key="message" class="invalid-feedback" > {{ message }} </div> </template> <script setup lang="ts"> import {useTranslate} from "~/vendor/gettext"; import {get, map} from "lodash"; import {computed} from "vue"; const props = defineProps({ field: { type: Object, required: true } }); const {$gettext} = useTranslate(); const messages = { required: () => { return $gettext('This field is required.'); }, minLength: (params) => { return $gettext( 'This field must have at least %{ min } letters.', params ); }, maxLength: (params) => { return $gettext( 'This field must have at most %{ max } letters.', params ); }, between: (params) => { return $gettext( 'This field must be between %{ min } and %{ max }.', params ); }, alpha: () => { return $gettext('This field must only contain alphabetic characters.'); }, alphaNum: () => { return $gettext('This field must only contain alphanumeric characters.'); }, numeric: () => { return $gettext('This field must only contain numeric characters.'); }, integer: () => { return $gettext('This field must be a valid integer.'); }, decimal: () => { return $gettext('This field must be a valid decimal number.'); }, email: () => { return $gettext('This field must be a valid e-mail address.'); }, ipAddress: () => { return $gettext('This field must be a valid IP address.'); }, url: () => { return $gettext('This field must be a valid URL.'); }, validatePassword: () => { return $gettext('This password is too common or insecure.'); } }; const errorMessages = computed(() => { return map( props.field.$errors, (error) => { const message = get(messages, error.$validator, null); if (null !== message) { return message(error.$params); } else { return error.$message; } } ); }); </script> ```
/content/code_sandbox/frontend/components/Form/VuelidateError.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
500
```vue <template> <form-group v-bind="$attrs" :id="id" > <template v-if="label || slots.label" #label="slotProps" > <form-label :is-required="isRequired" v-bind="pickProps(props, formLabelProps)" > <slot name="label" v-bind="slotProps" > {{ label }} </slot> </form-label> </template> <template #default> <slot name="default" v-bind="{ id, field, class: fieldClass }" > <textarea v-if="inputType === 'textarea'" v-bind="inputAttrs" :id="id" ref="$input" v-model="filteredModel" :name="name" :required="isRequired" class="form-control" :class="fieldClass" /> <input v-else v-bind="inputAttrs" :id="id" ref="$input" v-model="filteredModel" :type="inputType" :name="name" :required="isRequired" class="form-control" :class="fieldClass" > </slot> <vuelidate-error v-if="isVuelidateField" :field="field" /> </template> <template v-if="description || slots.description || clearable" #description="slotProps" > <div v-if="clearable" class="buttons" > <button type="button" class="btn btn-sm btn-outline-secondary" @click.prevent="clear" > {{ $gettext('Clear Field') }} </button> </div> <slot v-bind="slotProps" name="description" > {{ description }} </slot> </template> </form-group> </template> <script setup lang="ts"> import VuelidateError from "./VuelidateError.vue"; import {computed, nextTick, onMounted, ref, useSlots} from "vue"; import FormGroup from "~/components/Form/FormGroup.vue"; import FormLabel from "~/components/Form/FormLabel.vue"; import {formFieldProps, useFormField} from "~/components/Form/useFormField"; import formLabelProps from "~/components/Form/formLabelProps.ts"; import {pickProps} from "~/functions/pickProps.ts"; const props = defineProps({ ...formFieldProps, ...formLabelProps, id: { type: String, required: true }, name: { type: String, default: null }, label: { type: String, default: null }, description: { type: String, default: null }, inputType: { type: String, default: 'text' }, inputNumber: { type: Boolean, default: false }, inputTrim: { type: Boolean, default: false }, inputEmptyIsNull: { type: Boolean, default: false }, inputAttrs: { type: Object, default() { return {}; } }, autofocus: { type: Boolean, default: false }, clearable: { type: Boolean, default: false } }); const slots = useSlots(); const emit = defineEmits(['update:modelValue']); const {model, isVuelidateField, fieldClass, isRequired} = useFormField(props, emit); const isNumeric = computed(() => { return props.inputNumber || props.inputType === "number" || props.inputType === "range"; }); const filteredModel = computed({ get() { return model.value; }, set(newValue) { if ((isNumeric.value || props.inputEmptyIsNull) && '' === newValue) { model.value = null; } else { if (props.inputTrim && null !== newValue) { newValue = newValue.replace(/^\s+|\s+$/gm, ''); } if (isNumeric.value) { newValue = Number(newValue); } model.value = newValue; } } }); const $input = ref<HTMLInputElement | HTMLTextAreaElement | null>(null); const focus = () => { $input.value?.focus(); }; const clear = () => { filteredModel.value = ''; } onMounted(() => { if (props.autofocus) { nextTick(() => { focus(); }); } }) defineExpose({ focus }); </script> ```
/content/code_sandbox/frontend/components/Form/FormGroupField.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
999
```vue <template> <form-group :id="id"> <template v-if="label || slots.label" #label="slotProps" > <slot name="label" v-bind="slotProps" > {{ label }} </slot> </template> <template #default="slotProps"> <div :id="id"> <slot v-bind="slotProps" :id="id" name="default" /> </div> </template> <template v-if="description || slots.description" #description="slotProps" > <slot v-bind="slotProps" name="description" > {{ description }} </slot> </template> </form-group> </template> <script setup lang="ts"> import FormGroup from "~/components/Form/FormGroup.vue"; import {useSlots} from "vue"; const props = defineProps({ id: { type: String, required: true }, label: { type: String, default: null }, description: { type: String, default: null }, }); const slots = useSlots(); </script> ```
/content/code_sandbox/frontend/components/Form/FormMarkup.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
263
```vue <template> <form-group v-bind="$attrs" :id="id" > <template #default> <slot name="default" v-bind="{ id, field, model }" > <div class="form-check form-switch"> <form-checkbox v-bind="inputAttrs" :id="id" v-model="model" role="switch" :name="name" /> <label class="form-check-label" :for="id" > <form-label :is-required="isRequired" v-bind="pickProps(props, formLabelProps)" > <slot name="label">{{ label }}</slot> </form-label> </label> </div> </slot> <vuelidate-error v-if="isVuelidateField" :field="field" /> </template> <template v-if="description || slots.description" #description="slotProps" > <slot name="description" v-bind="slotProps" > {{ description }} </slot> </template> </form-group> </template> <script setup lang="ts"> import VuelidateError from "./VuelidateError.vue"; import FormLabel from "~/components/Form/FormLabel.vue"; import FormGroup from "~/components/Form/FormGroup.vue"; import {formFieldProps, useFormField} from "~/components/Form/useFormField"; import {useSlots} from "vue"; import FormCheckbox from "~/components/Form/FormCheckbox.vue"; import formLabelProps from "~/components/Form/formLabelProps.ts"; import {pickProps} from "~/functions/pickProps.ts"; const props = defineProps({ ...formFieldProps, ...formLabelProps, id: { type: String, required: true }, name: { type: String, default: null }, label: { type: String, default: null }, description: { type: String, default: null }, inputAttrs: { type: Object, default() { return {}; } }, }); const slots = useSlots(); const emit = defineEmits(['update:modelValue']); const {model, isVuelidateField, isRequired} = useFormField(props, emit); </script> ```
/content/code_sandbox/frontend/components/Form/FormGroupCheckbox.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
511
```vue <template> <fieldset class="form-group"> <legend v-if="slots.label || label"> <slot name="label"> {{ label }} </slot> </legend> <p v-if="slots.description || description"> <slot name="description"> {{ description }} </slot> </p> <slot name="default" /> </fieldset> </template> <script setup lang="ts"> const props = defineProps({ label: { type: String, default: null }, description: { type: String, default: null } }); const slots = defineSlots(); </script> ```
/content/code_sandbox/frontend/components/Form/FormFieldset.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
141
```vue <template> <template v-for="(option, index) in parsedOptions" :key="index" > <optgroup v-if="Array.isArray(option.options)" :label="option.label" > <select-options :options="option.options" /> </optgroup> <option v-else :value="option.value" > {{ option.text }} </option> </template> </template> <script setup lang="ts"> import {computed} from "vue"; import objectToFormOptions from "~/functions/objectToFormOptions"; const props = defineProps({ options: { type: Array<any>, required: true } }); const parsedOptions = computed(() => { if (Array.isArray(props.options)) { return props.options; } return objectToFormOptions(props.options); }); </script> ```
/content/code_sandbox/frontend/components/Form/SelectOptions.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
187
```vue <template> <input v-bind="$attrs" type="file" class="form-control" @change="uploaded" > </template> <script setup lang="ts"> const props = defineProps({ modelValue: { type: [Object], default: null } }); const emit = defineEmits(['update:modelValue', 'uploaded']); const uploaded = (event) => { const file = event.target.files[0]; emit('update:modelValue', file); emit('uploaded', file); }; </script> ```
/content/code_sandbox/frontend/components/Form/FormFile.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
119
```vue <template> <form-group v-bind="$attrs" :id="id" > <template v-if="label || slots.label" #label="slotProps" > <form-label :is-required="isRequired" v-bind="pickProps(props, formLabelProps)" > <slot name="label" v-bind="slotProps" > {{ label }} </slot> </form-label> </template> <template #default> <slot name="default" v-bind="{ id, field, model, class: fieldClass }" > <select :id="id" v-model="model" class="form-select" :class="fieldClass" :multiple="multiple" > <select-options :options="options" /> </select> </slot> <vuelidate-error v-if="isVuelidateField" :field="field" /> </template> <template v-if="description || slots.description" #description="slotProps" > <slot v-bind="slotProps" name="description" > {{ description }} </slot> </template> </form-group> </template> <script setup lang="ts"> import VuelidateError from "./VuelidateError.vue"; import FormLabel from "~/components/Form/FormLabel.vue"; import FormGroup from "~/components/Form/FormGroup.vue"; import {formFieldProps, useFormField} from "~/components/Form/useFormField"; import SelectOptions from "~/components/Form/SelectOptions.vue"; import {useSlots} from "vue"; import formLabelProps from "~/components/Form/formLabelProps.ts"; import {pickProps} from "~/functions/pickProps.ts"; const props = defineProps({ ...formFieldProps, ...formLabelProps, id: { type: String, required: true }, name: { type: String, default: null }, label: { type: String, default: null }, description: { type: String, default: null }, options: { type: Array, required: true }, multiple: { type: Boolean, default: false }, }); const slots = useSlots(); const emit = defineEmits(['update:modelValue']); const {model, isVuelidateField, fieldClass, isRequired} = useFormField(props, emit); </script> ```
/content/code_sandbox/frontend/components/Form/FormGroupSelect.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
549
```vue <template> <div> <div v-for="option in options" :key="option.value" class="form-check" :class="!stacked ? 'form-check-inline' : ''" > <input :id="id+'_'+option.value" v-model="value" :value="option.value" class="form-check-input" :class="fieldClass" :type="radio ? 'radio' : 'checkbox'" :name="name" > <label class="form-check-label" :for="id+'_'+option.value" > <slot :name="'label('+option.value+')'"> <template v-if="option.description"> <strong>{{ option.text }}</strong> <br> <small>{{ option.description }}</small> </template> <template v-else> {{ option.text }} </template> </slot> </label> </div> </div> </template> <script setup lang="ts"> import {useVModel} from "@vueuse/core"; const props = defineProps({ modelValue: { type: [String, Number, Boolean, Array], required: true }, id: { type: String, required: true }, name: { type: String, default: (props) => props.id }, fieldClass: { type: String, default: null, }, options: { type: Array<any>, required: true }, radio: { type: Boolean, default: false }, stacked: { type: Boolean, default: false }, }); const emit = defineEmits(['update:modelValue']); const value = useVModel(props, 'modelValue', emit); </script> ```
/content/code_sandbox/frontend/components/Form/FormMultiCheck.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
399
```vue <template> <div class="navdrawer-header"> <router-link :to="{ name: 'admin:index'}" class="navbar-brand px-0" > {{ $gettext('Administration') }} </router-link> </div> <div class="offcanvas-body"> <sidebar-menu :menu="menuItems" /> </div> </template> <script setup lang="ts"> import SidebarMenu from "~/components/Common/SidebarMenu.vue"; import {useAdminMenu} from "~/components/Admin/menu"; const menuItems = useAdminMenu(); </script> ```
/content/code_sandbox/frontend/components/Admin/Sidebar.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
125
```vue <template> <card-page :title="$gettext('API Keys')"> <template #info> <p class="card-text"> {{ $gettext('This page lists all API keys assigned to all users across the system. To manage your own API keys, visit your account profile.') }} </p> </template> <data-table id="api_keys" ref="$datatable" :fields="fields" :api-url="apiUrl" > <template #cell(actions)="row"> <div class="btn-group btn-group-sm"> <button type="button" class="btn btn-sm btn-danger" @click="doDelete(row.item.links.self)" > {{ $gettext('Delete') }} </button> </div> </template> </data-table> </card-page> </template> <script setup lang="ts"> import DataTable, { DataTableField } from "~/components/Common/DataTable.vue"; import {ref} from "vue"; import {useTranslate} from "~/vendor/gettext"; import useConfirmAndDelete from "~/functions/useConfirmAndDelete"; import useHasDatatable, {DataTableTemplateRef} from "~/functions/useHasDatatable"; import CardPage from "~/components/Common/CardPage.vue"; import {getApiUrl} from "~/router"; const apiUrl = getApiUrl('/admin/api-keys'); const {$gettext} = useTranslate(); const fields: DataTableField[] = [ { key: 'comment', isRowHeader: true, label: $gettext('API Key Description/Comments'), sortable: false }, { key: 'user.email', label: $gettext('Owner'), sortable: false }, { key: 'actions', label: $gettext('Actions'), sortable: false, class: 'shrink' } ]; const $datatable = ref<DataTableTemplateRef>(null); const {relist} = useHasDatatable($datatable); const {doDelete} = useConfirmAndDelete( $gettext('Delete API Key?'), relist ); </script> ```
/content/code_sandbox/frontend/components/Admin/ApiKeys.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
451
```vue <template> <h2 class="outside-card-header mb-1"> {{ $gettext('Custom Branding') }} </h2> <card-page class="mb-3" header-id="hdr_upload_custom_assets" :title="$gettext('Upload Custom Assets')" > <div class="card-body"> <ul class="list-unstyled"> <custom-asset-form id="asset_background" class="mb-3" :api-url="backgroundApiUrl" :caption="$gettext('Public Page Background')" /> <custom-asset-form id="asset_album_art" class="mb-3" :api-url="albumArtApiUrl" :caption="$gettext('Default Album Art')" /> <custom-asset-form id="asset_browser_icon" :api-url="browserIconApiUrl" :caption="$gettext('Browser Icon')" /> </ul> </div> </card-page> <branding-form :api-url="settingsApiUrl" /> <lightbox ref="$lightbox" /> </template> <script setup lang="ts"> import CustomAssetForm from "./Branding/CustomAssetForm.vue"; import BrandingForm from "./Branding/BrandingForm.vue"; import CardPage from "~/components/Common/CardPage.vue"; import Lightbox from "~/components/Common/Lightbox.vue"; import {ref} from "vue"; import {LightboxTemplateRef, useProvideLightbox} from "~/vendor/lightbox"; import {getApiUrl} from "~/router"; const settingsApiUrl = getApiUrl('/admin/settings/branding'); const browserIconApiUrl = getApiUrl('/admin/custom_assets/browser_icon'); const backgroundApiUrl = getApiUrl('/admin/custom_assets/background'); const albumArtApiUrl = getApiUrl('/admin/custom_assets/album_art'); const $lightbox = ref<LightboxTemplateRef>(null); useProvideLightbox($lightbox); </script> ```
/content/code_sandbox/frontend/components/Admin/Branding.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
416
```vue <template> <card-page :title="$gettext('Users')"> <template #actions> <add-button :text="$gettext('Add User')" @click="doCreate" /> </template> <data-table id="users" ref="$datatable" paginated :fields="fields" :api-url="listUrl" > <template #cell(name)="row"> <h5 v-if="row.item.name !== ''" class="mb-0" > {{ row.item.name }} </h5> <a :href="'mailto:'+row.item.email">{{ row.item.email }}</a> <span v-if="row.item.is_me" class="badge text-bg-primary ms-1" > {{ $gettext('You') }} </span> </template> <template #cell(roles)="row"> <div v-for="role in row.item.roles" :key="role.id" > {{ role.name }} </div> </template> <template #cell(actions)="row"> <div v-if="!row.item.is_me" class="btn-group btn-group-sm" > <a class="btn btn-secondary" :href="row.item.links.masquerade" target="_blank" > {{ $gettext('Log In') }} </a> <button type="button" class="btn btn-primary" @click="doEdit(row.item.links.self)" > {{ $gettext('Edit') }} </button> <button type="button" class="btn btn-danger" @click="doDelete(row.item.links.self)" > {{ $gettext('Delete') }} </button> </div> </template> </data-table> </card-page> <edit-modal ref="$editModal" :create-url="listUrl" :roles="roles" @relist="relist" /> </template> <script setup lang="ts"> import DataTable, { DataTableField } from '~/components/Common/DataTable.vue'; import EditModal from './Users/EditModal.vue'; import {useTranslate} from "~/vendor/gettext"; import {ref} from "vue"; import useHasDatatable, {DataTableTemplateRef} from "~/functions/useHasDatatable"; import useHasEditModal, {EditModalTemplateRef} from "~/functions/useHasEditModal"; import useConfirmAndDelete from "~/functions/useConfirmAndDelete"; import CardPage from "~/components/Common/CardPage.vue"; import {getApiUrl} from "~/router"; import AddButton from "~/components/Common/AddButton.vue"; const props = defineProps({ roles: { type: Object, required: true } }); const listUrl = getApiUrl('/admin/users'); const {$gettext} = useTranslate(); const fields: DataTableField[] = [ {key: 'name', isRowHeader: true, label: $gettext('User Name'), sortable: true}, {key: 'roles', label: $gettext('Roles'), sortable: false}, {key: 'actions', label: $gettext('Actions'), sortable: false, class: 'shrink'} ]; const $datatable = ref<DataTableTemplateRef>(null); const {relist} = useHasDatatable($datatable); const $editModal = ref<EditModalTemplateRef>(null); const {doCreate, doEdit} = useHasEditModal($editModal); const {doDelete} = useConfirmAndDelete( $gettext('Delete User?'), relist ); </script> ```
/content/code_sandbox/frontend/components/Admin/Users.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
783
```vue <template> <div class="row-of-cards"> <card-page header-id="hdr_system_logs" :title="$gettext('System Logs')" > <log-list :url="systemLogsUrl" @view="viewLog" /> </card-page> <card-page v-if="stationLogs.length > 0" header-id="hdr_logs_by_station" :title="$gettext('Logs by Station')" > <div class="card-body"> <tabs content-class="mt-3"> <tab v-for="row in stationLogs" :key="row.id" :label="row.name" > <div class="card-body-flush"> <log-list :url="row.url" @view="viewLog" /> </div> </tab> </tabs> </div> </card-page> </div> <streaming-log-modal ref="$modal" /> </template> <script setup lang="ts"> import LogList from "~/components/Common/LogList.vue"; import StreamingLogModal from "~/components/Common/StreamingLogModal.vue"; import {Ref, ref} from "vue"; import CardPage from "~/components/Common/CardPage.vue"; import Tabs from "~/components/Common/Tabs.vue"; import Tab from "~/components/Common/Tab.vue"; defineProps({ systemLogsUrl: { type: String, required: true, }, stationLogs: { type: Array, default: () => { return []; } } }); const $modal: Ref<InstanceType<typeof StreamingLogModal> | null> = ref(null); const viewLog = (url, isStreaming) => { $modal.value?.show(url, isStreaming); }; </script> ```
/content/code_sandbox/frontend/components/Admin/Logs.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
384
```vue <template> <card-page header-id="hdr_storage_locations" :title="$gettext('Storage Locations')" > <div class="card-body pb-0"> <nav class="nav nav-tabs" role="tablist" > <div v-for="tab in tabs" :key="tab.type" class="nav-item" role="presentation" > <button class="nav-link" :class="(activeType === tab.type) ? 'active' : ''" type="button" role="tab" @click="setType(tab.type)" > {{ tab.title }} </button> </div> </nav> </div> <div class="card-body buttons"> <add-button :text="$gettext('Add Storage Location')" @click="doCreate" /> </div> <data-table id="admin_storage_locations" ref="$datatable" :show-toolbar="false" :fields="fields" :api-url="listUrlForType" > <template #cell(actions)="{item}"> <div class="btn-group btn-group-sm"> <button type="button" class="btn btn-primary" @click="doEdit(item.links.self)" > {{ $gettext('Edit') }} </button> <button type="button" class="btn btn-danger" @click="doDelete(item.links.self)" > {{ $gettext('Delete') }} </button> </div> </template> <template #cell(adapter)="{item}"> <h5 class="m-0"> {{ getAdapterName(item.adapter) }} </h5> <p class="card-text"> {{ item.uri }} </p> </template> <template #cell(stations)="{item}"> {{ item.stations.join(', ') }} </template> <template #cell(space)="{item}"> <template v-if="item.storageAvailable"> <div class="progress h-20 mb-3" role="progressbar" :aria-label="item.storageUsedPercent+'%'" :aria-valuenow="item.storageUsedPercent" aria-valuemin="0" aria-valuemax="100" > <div class="progress-bar" :class="getProgressVariant(item.storageUsedPercent)" :style="{ width: item.storageUsedPercent+'%' }" > {{ item.storageUsedPercent }}% </div> </div> </template> {{ getSpaceUsed(item) }} </template> </data-table> </card-page> <edit-modal ref="$editModal" :create-url="listUrl" :type="activeType" @relist="relist" /> </template> <script setup lang="ts"> import DataTable, { DataTableField } from '~/components/Common/DataTable.vue'; import EditModal from './StorageLocations/EditModal.vue'; import {computed, nextTick, ref} from "vue"; import {useTranslate} from "~/vendor/gettext"; import useHasDatatable, {DataTableTemplateRef} from "~/functions/useHasDatatable"; import useHasEditModal, {EditModalTemplateRef} from "~/functions/useHasEditModal"; import useConfirmAndDelete from "~/functions/useConfirmAndDelete"; import CardPage from "~/components/Common/CardPage.vue"; import {getApiUrl} from "~/router"; import AddButton from "~/components/Common/AddButton.vue"; const activeType = ref('station_media'); const listUrl = getApiUrl('/admin/storage_locations'); const listUrlForType = computed(() => { return listUrl.value + '?type=' + activeType.value; }); const {$gettext} = useTranslate(); const fields: DataTableField[] = [ {key: 'adapter', label: $gettext('Adapter'), sortable: false}, {key: 'space', label: $gettext('Space Used'), class: 'text-nowrap', sortable: false}, {key: 'stations', label: $gettext('Station(s)'), sortable: false}, {key: 'actions', label: $gettext('Actions'), class: 'shrink', sortable: false} ]; const tabs = [ { type: 'station_media', title: $gettext('Station Media') }, { type: 'station_recordings', title: $gettext('Station Recordings') }, { type: 'station_podcasts', title: $gettext('Station Podcasts'), }, { type: 'backup', title: $gettext('Backups') } ]; const $datatable = ref<DataTableTemplateRef>(null); const {relist} = useHasDatatable($datatable); const $editModal = ref<EditModalTemplateRef>(null); const {doCreate, doEdit} = useHasEditModal($editModal); const setType = (type) => { activeType.value = type; nextTick(relist); }; const getAdapterName = (adapter) => { switch (adapter) { case 'local': return $gettext('Local'); case 's3': return $gettext('Remote: S3 Compatible'); case 'dropbox': return $gettext('Remote: Dropbox'); case 'sftp': return $gettext('Remote: SFTP'); } }; const getSpaceUsed = (item) => { return (item.storageAvailable) ? item.storageUsed + ' / ' + item.storageAvailable : item.storageUsed; }; const getProgressVariant = (percent) => { if (percent > 85) { return 'text-bg-danger'; } else if (percent > 65) { return 'text-bg-warning'; } else { return 'text-bg-primary'; } }; const {doDelete} = useConfirmAndDelete( $gettext('Delete Storage Location?'), relist ); </script> ```
/content/code_sandbox/frontend/components/Admin/StorageLocations.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,283
```vue <template> <h2 class="outside-card-header mb-1"> {{ $gettext('Update AzuraCast') }} </h2> <div class="row row-of-cards"> <div class="col col-md-8"> <card-page header-id="hdr_update_details" :title="$gettext('Update Details')" > <div class="card-body"> <div v-if="needsUpdates" class="text-warning" > {{ $gettext('Your installation needs to be updated. Updating is recommended for performance and security improvements.') }} </div> <div v-else class="text-success" > {{ $gettext('Your installation is up to date! No update is required.') }} </div> </div> <template #footer_actions> <button type="button" class="btn btn-info" @click="checkForUpdates()" > <icon :icon="IconSync" /> {{ $gettext('Check for Updates') }} </button> </template> </card-page> </div> <div class="col col-md-4"> <card-page header-id="hdr_release_channel" :title="$gettext('Release Channel')" > <div class="card-body"> <p class="card-text"> {{ $gettext('Your installation is currently on this release channel:') }} </p> <p class="card-text typography-subheading"> {{ langReleaseChannel }} </p> </div> <template #footer_actions> <a class="btn btn-info" href="/docs/getting-started/updates/release-channels/" target="_blank" > <icon :icon="IconInfo" /> {{ $gettext('About Release Channels') }} </a> </template> </card-page> </div> </div> <div class="row"> <div class="col col-md-6"> <card-page header-id="hdr_update_via_web" :title="$gettext('Update AzuraCast via Web')" > <template v-if="enableWebUpdates"> <div class="card-body"> <p class="card-text"> {{ $gettext('For simple updates where you want to keep your current configuration, you can update directly via your web browser. You will be disconnected from the web interface and listeners will be disconnected from all stations.') }} </p> <p class="card-text"> {{ $gettext('Backing up your installation is strongly recommended before any update.') }} </p> </div> </template> <template v-else> <div class="card-body"> <p class="card-text"> {{ $gettext('Web updates are not available for your installation. To update your installation, perform the manual update process instead.') }} </p> </div> </template> <template v-if="enableWebUpdates" #footer_actions > <router-link :to="{ name: 'admin:backups:index' }" class="btn btn-dark" > <icon :icon="IconUpload" /> <span> {{ $gettext('Backup') }} </span> </router-link> <button type="button" class="btn btn-success" @click="doUpdate()" > <icon :icon="IconUpdate" /> <span> {{ $gettext('Update via Web') }} </span> </button> </template> </card-page> </div> <div class="col col-md-6"> <card-page header-id="hdr_manual_updates" :title="$gettext('Manual Updates')" > <div class="card-body"> <p class="card-text"> {{ $gettext('To customize installation settings, or if automatic updates are disabled, you can follow our standard update instructions to update via your SSH console.') }} </p> <a class="btn btn-info" href="/docs/getting-started/updates/" target="_blank" > <icon :icon="IconInfo" /> <span> {{ $gettext('Update Instructions') }} </span> </a> </div> </card-page> </div> </div> </template> <script setup lang="ts"> import {computed, ref} from "vue"; import Icon from "~/components/Common/Icon.vue"; import {useTranslate} from "~/vendor/gettext"; import {useNotify} from "~/functions/useNotify"; import {useAxios} from "~/vendor/axios"; import {useSweetAlert} from "~/vendor/sweetalert"; import CardPage from "~/components/Common/CardPage.vue"; import {getApiUrl} from "~/router"; import {IconInfo, IconSync, IconUpdate, IconUpload} from "~/components/Common/icons"; const props = defineProps({ releaseChannel: { type: String, required: true }, initialUpdateInfo: { type: Object, default: () => { return {}; } }, enableWebUpdates: { type: Boolean, required: true } }); const updatesApiUrl = getApiUrl('/admin/updates'); const updateInfo = ref(props.initialUpdateInfo); const {$gettext} = useTranslate(); const langReleaseChannel = computed(() => { return (props.releaseChannel === 'stable') ? $gettext('Stable') : $gettext('Rolling Release'); }); const needsUpdates = computed(() => { if (props.releaseChannel === 'stable') { return updateInfo.value?.needs_release_update ?? true; } else { return updateInfo.value?.needs_rolling_update ?? true; } }); const {notifySuccess} = useNotify(); const {axios} = useAxios(); const checkForUpdates = () => { axios.get(updatesApiUrl.value).then((resp) => { updateInfo.value = resp.data; }); }; const {showAlert} = useSweetAlert(); const doUpdate = () => { showAlert({ title: $gettext('Update AzuraCast? Your installation will restart.') }).then((result) => { if (result.value) { axios.put(updatesApiUrl.value).then(() => { notifySuccess( $gettext('Update started. Your installation will restart shortly.') ); }); } }); }; </script> ```
/content/code_sandbox/frontend/components/Admin/Updates.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,410
```vue <template> <card-page header-id="hdr_install_geolite" :title="$gettext('Install GeoLite IP Database')" > <template #info> {{ $gettext('IP Geolocation is used to guess the approximate location of your listeners based on the IP address they connect with. Use the free built-in IP Geolocation library or enter a license key on this page to use MaxMind GeoLite.') }} </template> <div class="card-body"> <loading :loading="isLoading"> <div class="row g-3"> <div class="col-md-7"> <fieldset> <legend>{{ $gettext('Instructions') }}</legend> <p class="card-text"> {{ $gettext('AzuraCast ships with a built-in free IP geolocation database. You may prefer to use the MaxMind GeoLite service instead to achieve more accurate results. Using MaxMind GeoLite requires a license key, but once the key is provided, we will automatically keep the database updated.') }} </p> <p class="card-text"> {{ $gettext('To download the GeoLite database:') }} </p> <ul> <li> {{ $gettext('Create an account on the MaxMind developer site.') }} <br> <a href="path_to_url" target="_blank" > {{ $gettext('MaxMind Developer Site') }} </a> </li> <li> </li> <li> {{ $gettext('Click "Generate new license key".') }} </li> <li> {{ $gettext('Paste the generated license key into the field on this page.') }} </li> </ul> </fieldset> </div> <div class="col-md-5"> <fieldset class="mb-3"> <legend> {{ $gettext('Current Installed Version') }} </legend> <p v-if="version" class="text-success card-text" > {{ langInstalledVersion }} </p> <p v-else class="text-danger card-text" > {{ $gettext('GeoLite is not currently installed on this installation.') }} </p> </fieldset> <form @submit.prevent="doUpdate"> <fieldset> <form-group-field id="edit_form_key" :field="v$.key" > <template #label> </template> </form-group-field> </fieldset> <div class="buttons"> <button type="submit" class="btn btn-primary" > {{ $gettext('Save Changes') }} </button> <button type="button" class="btn btn-danger" @click="doDelete" > {{ $gettext('Remove Key') }} </button> </div> </form> </div> </div> </loading> </div> </card-page> </template> <script setup lang="ts"> import FormGroupField from "~/components/Form/FormGroupField.vue"; import {computed, onMounted, ref} from "vue"; import {useVuelidateOnForm} from "~/functions/useVuelidateOnForm"; import {useSweetAlert} from "~/vendor/sweetalert"; import {useAxios} from "~/vendor/axios"; import {useTranslate} from "~/vendor/gettext"; import Loading from "~/components/Common/Loading.vue"; import CardPage from "~/components/Common/CardPage.vue"; import {getApiUrl} from "~/router"; const apiUrl = getApiUrl('/admin/geolite'); const isLoading = ref(true); const version = ref(null); const {form, v$} = useVuelidateOnForm( { key: {} }, { key: null } ); const {$gettext} = useTranslate(); const langInstalledVersion = computed(() => { return $gettext( 'GeoLite version "%{ version }" is currently installed.', { version: version.value } ); }); const {axios} = useAxios(); const doFetch = () => { isLoading.value = true; axios.get(apiUrl.value).then((resp) => { form.value.key = resp.data.key; version.value = resp.data.version; isLoading.value = false; }); }; onMounted(doFetch); const doUpdate = () => { isLoading.value = true; axios.post(apiUrl.value, { geolite_license_key: form.value.key }).then((resp) => { version.value = resp.data.version; }).finally(() => { isLoading.value = false; }); }; const {confirmDelete} = useSweetAlert(); const doDelete = () => { confirmDelete().then((result) => { if (result.value) { form.value.key = null; doUpdate(); } }); } </script> ```
/content/code_sandbox/frontend/components/Admin/GeoLite.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,065
```vue <template> <card-page :title="$gettext('Custom Fields')"> <template #info> <p class="card-text"> {{ $gettext('Create custom fields to store extra metadata about each media file uploaded to your station libraries.') }} </p> </template> <template #actions> <add-button :text="$gettext('Add Custom Field')" @click="doCreate" /> </template> <data-table id="custom_fields" ref="$dataTable" :fields="fields" :show-toolbar="false" :api-url="listUrl" > <template #cell(name)="row"> {{ row.item.name }} <code>{{ row.item.short_name }}</code> </template> <template #cell(actions)="row"> <div class="btn-group btn-group-sm"> <button type="button" class="btn btn-primary" @click="doEdit(row.item.links.self)" > {{ $gettext('Edit') }} </button> <button type="button" class="btn btn-danger" @click="doDelete(row.item.links.self)" > {{ $gettext('Delete') }} </button> </div> </template> </data-table> </card-page> <edit-modal ref="$editModal" :create-url="listUrl" :auto-assign-types="autoAssignTypes" @relist="relist" /> </template> <script setup lang="ts"> import DataTable, { DataTableField } from '~/components/Common/DataTable.vue'; import EditModal from './CustomFields/EditModal.vue'; import {get} from 'lodash'; import {useTranslate} from "~/vendor/gettext"; import {ref} from "vue"; import useHasDatatable, {DataTableTemplateRef} from "~/functions/useHasDatatable"; import useHasEditModal, {EditModalTemplateRef} from "~/functions/useHasEditModal"; import useConfirmAndDelete from "~/functions/useConfirmAndDelete"; import CardPage from "~/components/Common/CardPage.vue"; import {getApiUrl} from "~/router"; import AddButton from "~/components/Common/AddButton.vue"; const props = defineProps({ autoAssignTypes: { type: Object, required: true } }); const listUrl = getApiUrl('/admin/custom_fields'); const {$gettext} = useTranslate(); const fields: DataTableField[] = [ { key: 'name', isRowHeader: true, label: $gettext('Field Name'), sortable: false }, { key: 'auto_assign', label: $gettext('Auto-Assign Value'), sortable: false, formatter: (value) => { return get(props.autoAssignTypes, value, $gettext('None')); } }, { key: 'actions', label: $gettext('Actions'), sortable: false, class: 'shrink' } ]; const $dataTable = ref<DataTableTemplateRef>(null); const {relist} = useHasDatatable($dataTable); const $editModal = ref<EditModalTemplateRef>(null); const {doCreate, doEdit} = useHasEditModal($editModal); const {doDelete} = useConfirmAndDelete( $gettext('Delete Custom Field?'), relist ); </script> ```
/content/code_sandbox/frontend/components/Admin/CustomFields.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
723
```vue <template> <card-page :title="$gettext('Connected AzuraRelays')"> <template #info> <p class="card-text"> {{ $gettext('AzuraRelay is a standalone service that connects to your AzuraCast instance, automatically relays your stations via its own server, then reports the listener details back to your main instance. This page shows all currently connected instances.') }} </p> <a class="btn btn-sm btn-light" target="_blank" href="path_to_url" > {{ $gettext('About AzuraRelay') }} </a> </template> <data-table id="relays" ref="$datatable" paginated :fields="fields" :api-url="listUrl" > <template #cell(name)="row"> <h5> <a :href="row.item.base_url" target="_blank" > {{ row.item.name }} </a> </h5> </template> <template #cell(is_visible_on_public_pages)="row"> <span v-if="row.item.is_visible_on_public_pages"> {{ $gettext('Yes') }} </span> <span v-else> {{ $gettext('No') }} </span> </template> </data-table> </card-page> </template> <script setup lang="ts"> import DataTable, { DataTableField } from '~/components/Common/DataTable.vue'; import {useTranslate} from "~/vendor/gettext"; import {ref} from "vue"; import useHasDatatable, {DataTableTemplateRef} from "~/functions/useHasDatatable"; import {useAzuraCast} from "~/vendor/azuracast"; import CardPage from "~/components/Common/CardPage.vue"; import {useLuxon} from "~/vendor/luxon"; import {getApiUrl} from "~/router"; const listUrl = getApiUrl('/admin/relays/list'); const {$gettext} = useTranslate(); const {timeConfig} = useAzuraCast(); const {DateTime} = useLuxon(); const dateTimeFormatter = (value) => { return DateTime.fromSeconds(value).toLocaleString( { ...DateTime.DATETIME_SHORT, ...timeConfig } ); } const fields: DataTableField[] = [ {key: 'name', isRowHeader: true, label: $gettext('Relay'), sortable: true}, {key: 'is_visible_on_public_pages', label: $gettext('Is Public'), sortable: true}, {key: 'created_at', label: $gettext('First Connected'), formatter: dateTimeFormatter, sortable: true}, {key: 'updated_at', label: $gettext('Latest Update'), formatter: dateTimeFormatter, sortable: true} ]; const $datatable = ref<DataTableTemplateRef>(null); useHasDatatable($datatable); </script> ```
/content/code_sandbox/frontend/components/Admin/Relays.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
621
```vue <template> <panel-layout v-bind="panelProps"> <template v-if="!isHome" #sidebar > <sidebar v-bind="sidebarProps" /> </template> <template #default> <router-view /> </template> </panel-layout> </template> <script setup lang="ts"> import PanelLayout from "~/components/PanelLayout.vue"; import {useAzuraCast} from "~/vendor/azuracast.ts"; import {useRoute} from "vue-router"; import {ref, watch} from "vue"; import Sidebar from "~/components/Admin/Sidebar.vue"; const {panelProps, sidebarProps} = useAzuraCast(); const isHome = ref(true); const route = useRoute(); watch(route, (newRoute) => { isHome.value = newRoute.name === 'admin:index'; }); </script> ```
/content/code_sandbox/frontend/components/Admin/AdminLayout.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
186
```vue <template> <div> <h2 class="outside-card-header mb-1"> {{ $gettext('Administration') }} </h2> <div class="row row-of-cards"> <div v-for="panel in menuItems" :key="panel.key" class="col-sm-12 col-lg-4" > <section class="card"> <div class="card-header text-bg-primary d-flex align-items-center"> <div class="flex-fill"> <h2 class="card-title"> {{ panel.label }} </h2> </div> <div class="flex-shrink-0 pt-1"> <icon class="lg" :icon="panel.icon" /> </div> </div> <div class="list-group list-group-flush"> <router-link v-for="item in panel.items" :key="item.key" :to="item.url" class="list-group-item list-group-item-action" > {{ item.label }} </router-link> </div> </section> </div> </div> <h2 class="outside-card-header mb-1"> {{ $gettext('Server Status') }} </h2> <div class="row row-of-cards"> <div class="col-sm-12 col-lg-6 col-xl-6"> <loading :loading="isLoading" lazy > <memory-stats-panel :stats="stats" /> </loading> </div> <div class="col-sm-12 col-lg-6 col-xl-6"> <loading :loading="isLoading" lazy > <disk-usage-panel :stats="stats" /> </loading> </div> </div> <div class="row row-of-cards"> <div class="col-sm-12 col-lg-8 col-xl-6"> <loading :loading="isLoading" lazy > <cpu-stats-panel :stats="stats" /> </loading> </div> <div class="col-sm-12 col-lg-4 col-xl-6"> <services-panel /> </div> </div> <div class="row row-of-cards"> <div class="col"> <loading :loading="isLoading" lazy > <network-stats-panel :stats="stats" /> </loading> </div> </div> </div> </template> <script setup lang="ts"> import Icon from '~/components/Common/Icon.vue'; import {useAxios} from "~/vendor/axios"; import {getApiUrl} from "~/router"; import {useAdminMenu} from "~/components/Admin/menu"; import CpuStatsPanel from "~/components/Admin/Index/CpuStatsPanel.vue"; import MemoryStatsPanel from "~/components/Admin/Index/MemoryStatsPanel.vue"; import DiskUsagePanel from "~/components/Admin/Index/DiskUsagePanel.vue"; import ServicesPanel from "~/components/Admin/Index/ServicesPanel.vue"; import NetworkStatsPanel from "~/components/Admin/Index/NetworkStatsPanel.vue"; import Loading from "~/components/Common/Loading.vue"; import useAutoRefreshingAsyncState from "~/functions/useAutoRefreshingAsyncState.ts"; const statsUrl = getApiUrl('/admin/server/stats'); const menuItems = useAdminMenu(); const {axiosSilent} = useAxios(); const {state: stats, isLoading} = useAutoRefreshingAsyncState( () => axiosSilent.get(statsUrl.value).then(r => r.data), { cpu: { total: { name: 'Total', steal: 0, io_wait: 0, usage: 0 }, cores: [], load: [ 0, 0, 0 ] }, memory: { bytes: { total: 0, used: 0, cached: 0 }, readable: { total: '', used: '', cached: '' } }, disk: { bytes: { total: 0, used: 0 }, readable: { total: '', used: '' } }, network: [] }, { shallow: true, timeout: 5000 } ); </script> ```
/content/code_sandbox/frontend/components/Admin/Index.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
942
```vue <template> <card-page :title="$gettext('Roles & Permissions')"> <template #info> <p class="card-text"> {{ $gettext('AzuraCast uses a role-based access control system. Roles are given permissions to certain sections of the site, then users are assigned into those roles.') }} </p> </template> <template #actions> <add-button :text="$gettext('Add Role')" @click="doCreate" /> </template> <data-table id="permissions" ref="$datatable" paginated :fields="fields" :api-url="listUrl" > <template #cell(permissions)="row"> <div v-if="row.item.permissions.global.length > 0"> {{ $gettext('Global') }} : {{ getGlobalPermissionNames(row.item.permissions.global).join(', ') }} </div> <div v-for="(permissions, stationId) in row.item.permissions.station" :key="stationId" > <b>{{ getStationName(stationId) }}</b>: {{ getStationPermissionNames(permissions).join(', ') }} </div> </template> <template #cell(actions)="row"> <div v-if="!row.item.is_super_admin" class="btn-group btn-group-sm" > <button type="button" class="btn btn-primary" @click="doEdit(row.item.links.self)" > {{ $gettext('Edit') }} </button> <button v-if="row.item.id !== 1" type="button" class="btn btn-danger" @click="doDelete(row.item.links.self)" > {{ $gettext('Delete') }} </button> </div> </template> </data-table> </card-page> <edit-modal ref="$editModal" :create-url="listUrl" :station-permissions="stationPermissions" :stations="stations" :global-permissions="globalPermissions" @relist="relist" /> </template> <script setup lang="ts"> import DataTable, { DataTableField } from '~/components/Common/DataTable.vue'; import EditModal from './Permissions/EditModal.vue'; import {filter, get, map} from 'lodash'; import {useTranslate} from "~/vendor/gettext"; import {ref} from "vue"; import useHasDatatable, {DataTableTemplateRef} from "~/functions/useHasDatatable"; import useHasEditModal, {EditModalTemplateRef} from "~/functions/useHasEditModal"; import useConfirmAndDelete from "~/functions/useConfirmAndDelete"; import CardPage from "~/components/Common/CardPage.vue"; import {getApiUrl} from "~/router"; import AddButton from "~/components/Common/AddButton.vue"; const props = defineProps({ stations: { type: Array, required: true }, globalPermissions: { type: Array, required: true }, stationPermissions: { type: Array, required: true } }); const listUrl = getApiUrl('/admin/roles'); const {$gettext} = useTranslate(); const fields: DataTableField[] = [ {key: 'name', isRowHeader: true, label: $gettext('Role Name'), sortable: true}, {key: 'permissions', label: $gettext('Permissions'), sortable: false}, {key: 'actions', label: $gettext('Actions'), sortable: false, class: 'shrink'} ]; const getGlobalPermissionNames = (permissions) => { return filter(map(permissions, (permission) => { return get(props.globalPermissions, permission, null); })); }; const getStationPermissionNames = (permissions) => { return filter(map(permissions, (permission) => { return get(props.stationPermissions, permission, null); })); }; const getStationName = (stationId) => { return get(props.stations, stationId, null); }; const $datatable = ref<DataTableTemplateRef>(null); const {relist} = useHasDatatable($datatable); const $editModal = ref<EditModalTemplateRef>(null); const {doCreate, doEdit} = useHasEditModal($editModal); const {doDelete} = useConfirmAndDelete( $gettext('Delete Role?'), relist ); </script> ```
/content/code_sandbox/frontend/components/Admin/Permissions.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
945
```vue <template> <h2 class="outside-card-header mb-1"> {{ $gettext('Backups') }} </h2> <div class="row row-of-cards"> <div class="col-md-6"> <card-page header-id="hdr_automatic_backups"> <template #header="{id}"> <h2 :id="id" class="card-title" > {{ $gettext('Automatic Backups') }} <enabled-badge :enabled="settings.backupEnabled" /> </h2> </template> <loading :loading="settingsLoading"> <div v-if="settings.backupEnabled" class="card-body" > <p v-if="settings.backupLastRun > 0" class="card-text" > {{ $gettext('Last run:') }} {{ timestampToRelative(settings.backupLastRun) }} </p> <p v-else class="card-text" > {{ $gettext('Never run') }} </p> </div> </loading> <template #footer_actions> <button type="button" class="btn btn-primary" @click="doConfigure" > <icon :icon="IconSettings" /> <span> {{ $gettext('Configure') }} </span> </button> <button v-if="settings.backupEnabled && settings.backupLastOutput !== ''" type="button" class="btn btn-secondary" @click="showLastOutput" > <icon :icon="IconLogs" /> <span> {{ $gettext('Most Recent Backup Log') }} </span> </button> </template> </card-page> </div> <div class="col-md-6"> <card-page header-id="hdr_restoring_backups" :title="$gettext('Restoring Backups')" > <div class="card-body"> <p class="card-text"> {{ $gettext('To restore a backup from your host computer, run:') }} </p> <pre v-if="isDocker"><code>./docker.sh restore path_to_backup.zip</code></pre> <pre v-else><code>/var/azuracast/www/bin/console azuracast:restore path_to_backup.zip</code></pre> <p class="card-text text-warning"> {{ $gettext('Note that restoring a backup will clear your existing database. Never restore backup files from untrusted users.') }} </p> </div> </card-page> </div> </div> <card-page header-id="hdr_backups" :title="$gettext('Backups')" > <template #actions> <button type="button" class="btn btn-primary" @click="doRunBackup" > <icon :icon="IconSend" /> <span> {{ $gettext('Run Manual Backup') }} </span> </button> </template> <data-table id="api_keys" ref="$datatable" :fields="fields" :api-url="listUrl" > <template #cell(actions)="row"> <div class="btn-group btn-group-sm"> <a class="btn btn-primary" :href="row.item.links.download" target="_blank" > {{ $gettext('Download') }} </a> <button type="button" class="btn btn-danger" @click="doDelete(row.item.links.delete)" > {{ $gettext('Delete') }} </button> </div> </template> </data-table> </card-page> <admin-backups-configure-modal ref="$configureModal" :settings-url="settingsUrl" :storage-locations="storageLocations" @relist="relist" /> <admin-backups-run-backup-modal ref="$runBackupModal" :run-backup-url="runBackupUrl" :storage-locations="storageLocations" @relist="relist" /> <admin-backups-last-output-modal ref="$lastOutputModal" :last-output="settings.backupLastOutput" /> </template> <script setup lang="ts"> import Icon from "~/components/Common/Icon.vue"; import DataTable, {DataTableField} from "~/components/Common/DataTable.vue"; import AdminBackupsLastOutputModal from "./Backups/LastOutputModal.vue"; import formatFileSize from "~/functions/formatFileSize"; import AdminBackupsConfigureModal from "~/components/Admin/Backups/ConfigureModal.vue"; import AdminBackupsRunBackupModal from "~/components/Admin/Backups/RunBackupModal.vue"; import EnabledBadge from "~/components/Common/Badges/EnabledBadge.vue"; import {useAzuraCast} from "~/vendor/azuracast"; import {onMounted, ref} from "vue"; import {useTranslate} from "~/vendor/gettext"; import {useAxios} from "~/vendor/axios"; import useConfirmAndDelete from "~/functions/useConfirmAndDelete"; import Loading from "~/components/Common/Loading.vue"; import CardPage from "~/components/Common/CardPage.vue"; import {useLuxon} from "~/vendor/luxon"; import {getApiUrl} from "~/router"; import {IconLogs, IconSend, IconSettings} from "~/components/Common/icons"; import {DataTableTemplateRef} from "~/functions/useHasDatatable.ts"; const props = defineProps({ storageLocations: { type: Object, required: true }, isDocker: { type: Boolean, default: true }, }); const listUrl = getApiUrl('/admin/backups'); const runBackupUrl = getApiUrl('/admin/backups/run'); const settingsUrl = getApiUrl('/admin/settings/backup'); const settingsLoading = ref(false); const blankSettings = { backupEnabled: false, backupLastRun: null, backupLastOutput: '', }; const settings = ref({...blankSettings}); const {$gettext} = useTranslate(); const {timeConfig} = useAzuraCast(); const {DateTime, timestampToRelative} = useLuxon(); const fields: DataTableField[] = [ { key: 'basename', isRowHeader: true, label: $gettext('File Name'), sortable: false }, { key: 'timestamp', label: $gettext('Last Modified'), sortable: false, formatter: (value) => { return DateTime.fromSeconds(value).toLocaleString( {...DateTime.DATETIME_SHORT, ...timeConfig} ); } }, { key: 'size', label: $gettext('Size'), sortable: false, formatter: (value) => formatFileSize(value) }, { key: 'actions', label: $gettext('Actions'), sortable: false, class: 'shrink' } ]; const $datatable = ref<DataTableTemplateRef>(null); const {axios} = useAxios(); const relist = () => { settingsLoading.value = true; axios.get(settingsUrl.value).then((resp) => { settings.value = { backupEnabled: resp.data.backup_enabled, backupLastRun: resp.data.backup_last_run, backupLastOutput: resp.data.backup_last_output }; settingsLoading.value = false; }); $datatable.value?.relist(); }; onMounted(relist); const $lastOutputModal = ref<InstanceType<typeof AdminBackupsLastOutputModal> | null>(null); const showLastOutput = () => { $lastOutputModal.value?.show(); }; const $configureModal = ref<InstanceType<typeof AdminBackupsConfigureModal> | null>(null); const doConfigure = () => { $configureModal.value?.open(); }; const $runBackupModal = ref<InstanceType<typeof AdminBackupsRunBackupModal> | null>(null); const doRunBackup = () => { $runBackupModal.value?.open(); }; const {doDelete} = useConfirmAndDelete( $gettext('Delete Backup?'), relist, ); </script> ```
/content/code_sandbox/frontend/components/Admin/Backups.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,760
```vue <template> <form class="form vue-form" @submit.prevent="submit" > <slot name="preCard" /> <section class="card" role="region" aria-labelledby="hdr_system_settings" > <div class="card-header text-bg-primary"> <h2 id="hdr_system_settings" class="card-title" > <slot name="cardTitle"> {{ $gettext('System Settings') }} </slot> </h2> </div> <slot name="cardUpper" /> <div v-show="error != null" class="alert alert-danger" > {{ error }} </div> <div class="card-body"> <loading :loading="isLoading"> <tabs content-class="mt-3"> <settings-general-tab v-model:form="form" /> <settings-security-privacy-tab v-model:form="form" /> <settings-services-tab v-model:form="form" :release-channel="releaseChannel" :test-message-url="testMessageUrl" :acme-url="acmeUrl" /> </tabs> </loading> </div> <div class="card-body"> <button type="submit" class="btn btn-lg" :class="(v$.$invalid) ? 'btn-danger' : 'btn-primary'" > <slot name="submitButtonName"> {{ $gettext('Save Changes') }} </slot> </button> </div> </section> </form> </template> <script setup lang="ts"> import SettingsGeneralTab from "./Settings/GeneralTab.vue"; import SettingsServicesTab from "./Settings/ServicesTab.vue"; import SettingsSecurityPrivacyTab from "~/components/Admin/Settings/SecurityPrivacyTab.vue"; import {onMounted, ref} from "vue"; import {useAxios} from "~/vendor/axios"; import mergeExisting from "~/functions/mergeExisting"; import {useNotify} from "~/functions/useNotify"; import {useTranslate} from "~/vendor/gettext"; import {useVuelidateOnForm} from "~/functions/useVuelidateOnForm"; import Loading from "~/components/Common/Loading.vue"; import settingsProps from "~/components/Admin/settingsProps"; import Tabs from "~/components/Common/Tabs.vue"; const props = defineProps({ ...settingsProps }); const emit = defineEmits(['saved']); const {form, resetForm, v$, ifValid} = useVuelidateOnForm(); const isLoading = ref(true); const error = ref(null); const {axios} = useAxios(); const populateForm = (data) => { resetForm(); form.value = mergeExisting(form.value, data); }; const relist = () => { resetForm(); isLoading.value = true; axios.get(props.apiUrl).then((resp) => { populateForm(resp.data); isLoading.value = false; }); }; onMounted(relist); const {notifySuccess} = useNotify(); const {$gettext} = useTranslate(); const submit = () => { ifValid(() => { axios({ method: 'PUT', url: props.apiUrl, data: form.value }).then(() => { emit('saved'); notifySuccess($gettext('Changes saved.')); relist(); }); }); } </script> ```
/content/code_sandbox/frontend/components/Admin/Settings.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
723
```vue <template> <card-page header-id="hdr_install_stereo_tool" :title="$gettext('Install Stereo Tool')" > <template #info> <p class="card-text"> {{ $gettext('Stereo Tool is a popular, proprietary tool for software audio processing. Using Stereo Tool, you can customize the sound of your stations using preset configuration files.') }} </p> <p class="card-text"> {{ $gettext('Note that Stereo Tool can be resource-intensive for both CPU and Memory. Please ensure you have sufficient resources before proceeding.') }} </p> </template> <div class="card-body"> <loading :loading="isLoading"> <div class="row g-3"> <div class="col-md-7"> <fieldset> <legend> {{ $gettext('Instructions') }} </legend> <p class="card-text"> {{ $gettext('Stereo Tool is not free software, and its restrictive license does not allow AzuraCast to distribute the Stereo Tool binary.') }} </p> <p class="card-text"> {{ $gettext('In order to install Stereo Tool:') }} </p> <ol type="1"> <li> <p class="card-text"> {{ $gettext('Download the appropriate binary from the Stereo Tool downloads page:') }} </p> <div class="buttons mb-3"> <a href="path_to_url" target="_blank" class="btn btn-sm btn-secondary" > {{ $gettext('Stereo Tool Downloads') }} </a> </div> <ul> <li> {{ $gettext('For x86/64 installations, choose "x86/64 Linux Thimeo-ST plugin".') }} </li> <li> {{ $gettext('For ARM (Raspberry Pi, etc.) installations, choose "Raspberry Pi Thimeo-ST plugin".') }} </li> </ul> </li> <li class="mt-3"> <p class="card-text"> {{ $gettext('Upload the file on this page to automatically extract it into the proper directory.') }} </p> <p class="card-text"> {{ $gettext('Any of the following file types are accepted:') }} </p> <ul> <li> <code>libStereoTool_*.so</code> ({{ $gettext('Ensure the library matches your system architecture') }}) </li> <li><code>Stereo_Tool_Generic_plugin.zip</code></li> <li><code>stereo_tool</code> ({{ $gettext('For the legacy version') }})</li> </ul> </li> </ol> </fieldset> </div> <div class="col-md-5"> <fieldset class="mb-3"> <legend> {{ $gettext('Current Installed Version') }} </legend> <p v-if="version" class="text-success card-text" > {{ langInstalledVersion }} </p> <p v-else class="text-danger card-text" > {{ $gettext('Stereo Tool is not currently installed on this installation.') }} </p> </fieldset> <flow-upload :target-url="apiUrl" @complete="relist" @error="onError" /> <div v-if="version" class="buttons block-buttons mt-3" > <button type="button" class="btn btn-danger" @click="doDelete" > {{ $gettext('Uninstall') }} </button> </div> </div> </div> </loading> </div> </card-page> </template> <script setup lang="ts"> import FlowUpload from "~/components/Common/FlowUpload.vue"; import {computed, onMounted, ref} from "vue"; import {useTranslate} from "~/vendor/gettext"; import {useNotify} from "~/functions/useNotify"; import {useAxios} from "~/vendor/axios"; import Loading from "~/components/Common/Loading.vue"; import CardPage from "~/components/Common/CardPage.vue"; import {useSweetAlert} from "~/vendor/sweetalert"; import {getApiUrl} from "~/router"; const apiUrl = getApiUrl('/admin/stereo_tool'); const isLoading = ref(true); const version = ref(null); const {$gettext} = useTranslate(); const langInstalledVersion = computed(() => { return $gettext( 'Stereo Tool version %{ version } is currently installed.', { version: version.value } ); }); const {notifyError} = useNotify(); const onError = (_file, message) => { notifyError(message); }; const {axios} = useAxios(); const relist = () => { isLoading.value = true; axios.get(apiUrl.value).then((resp) => { version.value = resp.data.version; isLoading.value = false; }); }; const {confirmDelete} = useSweetAlert(); const doDelete = () => { confirmDelete().then((result) => { if (result.value) { axios.delete(apiUrl.value).then(relist); } }); } onMounted(relist); </script> ```
/content/code_sandbox/frontend/components/Admin/StereoTool.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,165
```vue <template> <card-page :title="$gettext('Stations')"> <template #actions> <add-button :text="$gettext('Add Station')" @click="doCreate" /> </template> <data-table id="stations" ref="$datatable" paginated :fields="fields" :api-url="listUrl" > <template #cell(name)="{item}"> <div class="typography-subheading"> {{ item.name }} <span v-if="!item.is_enabled" class="badge text-bg-secondary" >{{ $gettext('Disabled') }}</span> </div> <code>{{ item.short_name }}</code> </template> <template #cell(actions)="row"> <div class="btn-group btn-group-sm"> <a class="btn btn-secondary" :href="row.item.links.manage" target="_blank" > {{ $gettext('Manage') }} </a> <button type="button" class="btn btn-secondary" @click="doClone(row.item.name, row.item.links.clone)" > {{ $gettext('Clone') }} </button> <button type="button" class="btn btn-sm" :class="(row.item.is_enabled) ? 'btn-warning' : 'btn-success'" @click="doToggle(row.item)" > {{ (row.item.is_enabled) ? $gettext('Disable') : $gettext('Enable') }} </button> <button type="button" class="btn btn-primary" @click="doEdit(row.item.links.self)" > {{ $gettext('Edit') }} </button> <button type="button" class="btn btn-danger" @click="doDelete(row.item.links.self)" > {{ $gettext('Delete') }} </button> </div> </template> </data-table> </card-page> <admin-stations-edit-modal v-bind="pickProps(props, stationFormProps)" ref="$editModal" :create-url="listUrl" @relist="relist" /> <admin-stations-clone-modal ref="$cloneModal" @relist="relist" /> </template> <script setup lang="ts"> import DataTable, {DataTableField} from '~/components/Common/DataTable.vue'; import AdminStationsEditModal from "./Stations/EditModal.vue"; import {get} from "lodash"; import AdminStationsCloneModal from "./Stations/CloneModal.vue"; import stationFormProps from "./Stations/stationFormProps"; import {pickProps} from "~/functions/pickProps"; import {useTranslate} from "~/vendor/gettext"; import {ref} from "vue"; import useHasDatatable, {DataTableTemplateRef} from "~/functions/useHasDatatable"; import useHasEditModal, {EditModalTemplateRef} from "~/functions/useHasEditModal"; import useConfirmAndDelete from "~/functions/useConfirmAndDelete"; import CardPage from "~/components/Common/CardPage.vue"; import {getApiUrl} from "~/router"; import AddButton from "~/components/Common/AddButton.vue"; import CloneModal from "~/components/Admin/Stations/CloneModal.vue"; import {useSweetAlert} from "~/vendor/sweetalert.ts"; import {useNotify} from "~/functions/useNotify.ts"; import {useAxios} from "~/vendor/axios.ts"; const props = defineProps({ ...stationFormProps, frontendTypes: { type: Object, required: true }, backendTypes: { type: Object, required: true } }); const listUrl = getApiUrl('/admin/stations'); const {$gettext} = useTranslate(); const fields: DataTableField[] = [ { key: 'name', isRowHeader: true, label: $gettext('Name'), sortable: true }, { key: 'frontend_type', label: $gettext('Broadcasting'), sortable: false, formatter: (value) => { return get(props.frontendTypes, [value, 'name'], ''); } }, { key: 'backend_type', label: $gettext('AutoDJ'), sortable: false, formatter: (value) => { return get(props.backendTypes, [value, 'name'], ''); } }, { key: 'actions', label: $gettext('Actions'), sortable: false, class: 'shrink' } ]; const $datatable = ref<DataTableTemplateRef>(null); const {relist} = useHasDatatable($datatable); const $editModal = ref<EditModalTemplateRef>(null); const {doCreate, doEdit} = useHasEditModal($editModal); const $cloneModal = ref<InstanceType<typeof CloneModal> | null>(null); const doClone = (stationName, url) => { $cloneModal.value.create(stationName, url); }; const {showAlert} = useSweetAlert(); const {notifySuccess} = useNotify(); const {axios} = useAxios(); const doToggle = (station) => { const title = (station.is_enabled) ? $gettext('Disable station?') : $gettext('Enable station?'); showAlert({ title: title }).then((result) => { if (result.value) { axios.put(station.links.self, { is_enabled: !station.is_enabled }).then((resp) => { notifySuccess(resp.data.message); relist(); }); } }); }; const {doDelete} = useConfirmAndDelete( $gettext('Delete Station?'), relist ); </script> ```
/content/code_sandbox/frontend/components/Admin/Stations.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,234
```vue <template> <card-page header-id="hdr_audit_log"> <template #header="{id}"> <div class="d-flex align-items-center"> <h2 :id="id" class="card-title flex-fill my-0" > {{ $gettext('Audit Log') }} </h2> <div class="flex-shrink"> <date-range-dropdown v-model="dateRange" /> </div> </div> </template> <data-table ref="$datatable" paginated :fields="fields" :api-url="apiUrl" > <template #cell(operation)="row"> <span v-if="row.item.operation_text === 'insert'" class="text-success" :title="$gettext('Insert')" > <icon class="lg inline" :icon="IconAddCircle" /> </span> <span v-else-if="row.item.operation_text === 'delete'" class="text-danger" :title="$gettext('Delete')" > <icon class="lg inline" :icon="IconRemoveCircle" /> </span> <span v-else class="text-primary" :title="$gettext('Update')" > <icon class="lg inline" :icon="IconSwapHorizontalCircle" /> </span> </template> <template #cell(identifier)="row"> <small>{{ row.item.class }}</small><br> {{ row.item.identifier }} </template> <template #cell(target)="row"> <template v-if="row.item.target"> <small>{{ row.item.target_class }}</small><br> {{ row.item.target }} </template> <template v-else> {{ $gettext('N/A') }} </template> </template> <template #cell(actions)="row"> <template v-if="row.item.changes.length > 0"> <button type="button" class="btn btn-sm btn-primary" @click="showDetails(row.item.changes)" > {{ $gettext('Changes') }} </button> </template> </template> </data-table> </card-page> <details-modal ref="$detailsModal" /> </template> <script setup lang="ts"> import {computed, ref, watch} from "vue"; import {useTranslate} from "~/vendor/gettext"; import {useAzuraCast} from "~/vendor/azuracast"; import DataTable, { DataTableField } from "~/components/Common/DataTable.vue"; import DateRangeDropdown from "~/components/Common/DateRangeDropdown.vue"; import Icon from "~/components/Common/Icon.vue"; import useHasDatatable, {DataTableTemplateRef} from "~/functions/useHasDatatable"; import DetailsModal from "./AuditLog/DetailsModal.vue"; import CardPage from "~/components/Common/CardPage.vue"; import {useLuxon} from "~/vendor/luxon"; import {getApiUrl} from "~/router"; import {IconAddCircle, IconRemoveCircle, IconSwapHorizontalCircle} from "~/components/Common/icons"; const baseApiUrl = getApiUrl('/admin/auditlog'); const {DateTime} = useLuxon(); const dateRange = ref({ startDate: DateTime.now().minus({days: 13}).toJSDate(), endDate: DateTime.now().toJSDate(), }); const {$gettext} = useTranslate(); const {timeConfig} = useAzuraCast(); const fields: DataTableField[] = [ { key: 'timestamp', label: $gettext('Date/Time'), sortable: false, formatter: (value) => { return DateTime.fromSeconds(value).toLocaleString( { ...DateTime.DATETIME_SHORT, ...timeConfig } ); } }, {key: 'user', label: $gettext('User'), sortable: false}, {key: 'operation', isRowHeader: true, label: $gettext('Operation'), sortable: false}, {key: 'identifier', label: $gettext('Identifier'), sortable: false}, {key: 'target', label: $gettext('Target'), sortable: false}, {key: 'actions', label: $gettext('Actions'), sortable: false} ]; const apiUrl = computed(() => { const apiUrl = new URL(baseApiUrl.value, document.location.href); const apiUrlParams = apiUrl.searchParams; apiUrlParams.set('start', DateTime.fromJSDate(dateRange.value.startDate).toISO()); apiUrlParams.set('end', DateTime.fromJSDate(dateRange.value.endDate).toISO()); return apiUrl.toString(); }); const $datatable = ref<DataTableTemplateRef>(null); const {navigate} = useHasDatatable($datatable); watch(dateRange, navigate); const $detailsModal = ref<InstanceType<typeof DetailsModal> | null>(null); const showDetails = (changes) => { $detailsModal.value?.open(changes); } </script> ```
/content/code_sandbox/frontend/components/Admin/AuditLog.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,066
```vue <template> <card-page header-id="hdr_install_shoutcast" :title="$gettext('Install Shoutcast 2 DNAS')" > <div class="card-body"> <loading :loading="isLoading"> <div class="row g-3"> <div class="col-md-7"> <fieldset> <legend> {{ $gettext('Instructions') }} </legend> <p class="card-text"> {{ $gettext('Shoutcast 2 DNAS is not free software, and its restrictive license does not allow AzuraCast to distribute the Shoutcast binary.') }} </p> <p class="card-text"> {{ $gettext('In order to install Shoutcast:') }} </p> <ul> <li> {{ $gettext('Download the Linux x64 binary from the Shoutcast Radio Manager:') }} <br> <a href="path_to_url" target="_blank" > {{ $gettext('Shoutcast Radio Manager') }} </a> </li> <li> {{ $gettext('The file name should look like:') }} <br> <code>sc_serv2_linux_x64-latest.tar.gz</code> </li> <li> {{ $gettext('Upload the file on this page to automatically extract it into the proper directory.') }} </li> </ul> </fieldset> </div> <div class="col-md-5"> <fieldset class="mb-3"> <legend> {{ $gettext('Current Installed Version') }} </legend> <p v-if="version" class="text-success card-text" > {{ langInstalledVersion }} </p> <p v-else class="text-danger card-text" > {{ $gettext('Shoutcast 2 DNAS is not currently installed on this installation.') }} </p> </fieldset> <flow-upload :target-url="apiUrl" @complete="relist" /> </div> </div> </loading> </div> </card-page> </template> <script setup lang="ts"> import FlowUpload from "~/components/Common/FlowUpload.vue"; import {computed, onMounted, ref} from "vue"; import {useTranslate} from "~/vendor/gettext"; import {useAxios} from "~/vendor/axios"; import Loading from "~/components/Common/Loading.vue"; import CardPage from "~/components/Common/CardPage.vue"; import {getApiUrl} from "~/router"; const apiUrl = getApiUrl('/admin/shoutcast'); const isLoading = ref(true); const version = ref(null); const {$gettext} = useTranslate(); const langInstalledVersion = computed(() => { return $gettext( 'Shoutcast version "%{ version }" is currently installed.', { version: version.value } ); }); const {axios} = useAxios(); const relist = () => { isLoading.value = true; axios.get(apiUrl.value).then((resp) => { version.value = resp.data.version; isLoading.value = false; }); }; onMounted(relist); </script> ```
/content/code_sandbox/frontend/components/Admin/Shoutcast.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
703
```vue <template> <div class="row g-3"> <form-group-field id="edit_form_name" class="col-md-6" :field="form.name" :label="$gettext('Field Name')" :description="$gettext('This will be used as the label when editing individual songs, and will show in API results.')" /> <form-group-field id="edit_form_short_name" class="col-md-6" :field="form.short_name" :label="$gettext('Programmatic Name')" > <template #description> {{ $gettext('Optionally specify an API-friendly name, such as "field_name". Leave this field blank to automatically create one based on the name.') }} </template> </form-group-field> <form-group-select id="edit_form_auto_assign" class="col-md-6" :field="form.auto_assign" :label="$gettext('Automatically Set from ID3v2 Value')" :options="autoAssignOptions" :description="$gettext('Optionally select an ID3v2 metadata field that, if present, will be used to set this field\'s value.')" /> </div> </template> <script setup lang="ts"> import FormGroupField from "~/components/Form/FormGroupField.vue"; import {computed} from "vue"; import {useTranslate} from "~/vendor/gettext"; import {forEach} from "lodash"; import FormGroupSelect from "~/components/Form/FormGroupSelect.vue"; const props = defineProps({ form: { type: Object, required: true }, autoAssignTypes: { type: Object, required: true } }); const {$gettext} = useTranslate(); const autoAssignOptions = computed(() => { const autoAssignOptions = [ { text: $gettext('Disable'), value: '', } ]; forEach(props.autoAssignTypes, (typeName, typeKey) => { autoAssignOptions.push({ text: typeName, value: typeKey }); }); return autoAssignOptions; }); </script> ```
/content/code_sandbox/frontend/components/Admin/CustomFields/Form.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
454
```vue <template> <modal-form ref="$modal" :loading="loading" :title="langTitle" :error="error" :disable-save-button="v$.$invalid" @submit="doSubmit" @hidden="clearContents" > <admin-custom-fields-form :form="v$" :auto-assign-types="autoAssignTypes" /> </modal-form> </template> <script setup lang="ts"> import {required} from '@vuelidate/validators'; import ModalForm from "~/components/Common/ModalForm.vue"; import AdminCustomFieldsForm from "~/components/Admin/CustomFields/Form.vue"; import {computed, ref} from "vue"; import {baseEditModalProps, ModalFormTemplateRef, useBaseEditModal} from "~/functions/useBaseEditModal"; import {useTranslate} from "~/vendor/gettext"; const props = defineProps({ ...baseEditModalProps, autoAssignTypes: { type: Object, required: true } }); const emit = defineEmits(['relist']); const $modal = ref<ModalFormTemplateRef>(null); const { loading, error, isEditMode, v$, clearContents, create, edit, doSubmit, close } = useBaseEditModal( props, emit, $modal, { 'name': {required}, 'short_name': {}, 'auto_assign': {} }, { 'name': '', 'short_name': '', 'auto_assign': '' }, ); const {$gettext} = useTranslate(); const langTitle = computed(() => { return isEditMode.value ? $gettext('Edit Custom Field') : $gettext('Add Custom Field'); }); defineExpose({ create, edit, close }); </script> ```
/content/code_sandbox/frontend/components/Admin/CustomFields/EditModal.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
394
```vue <template> <modal ref="$modal" :title="$gettext('Log Output')" size="lg" > <div style="max-height: 300px; overflow-y: scroll"> <task-output :logs="logOutput" /> </div> </modal> </template> <script setup lang="ts"> import Modal from "~/components/Common/Modal.vue"; import {ref, Ref} from "vue"; import TaskOutput from "~/components/Admin/Debug/TaskOutput.vue"; import {ModalTemplateRef, useHasModal} from "~/functions/useHasModal.ts"; const $modal: Ref<ModalTemplateRef> = ref(null); const {show} = useHasModal($modal); const logOutput: Ref<Array<object>> = ref([]); const open = (newLogOutput: Array<object>) => { logOutput.value = newLogOutput; show(); } defineExpose({ open }); </script> ```
/content/code_sandbox/frontend/components/Admin/Debug/TaskOutputModal.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
198
```vue <template> <h2 class="outside-card-header mb-1"> {{ $gettext('System Debugger') }} </h2> <div class="row row-of-cards"> <div class="col-md-6"> <card-page header-id="hdr_clear_cache" :title="$gettext('Clear Cache')" > <div class="card-body"> <p class="card-text"> {{ $gettext('Clearing the application cache may log you out of your session.') }} </p> </div> <template #footer_actions> <button type="button" class="btn btn-sm btn-primary" @click="makeDebugCall(clearCacheUrl)" > {{ $gettext('Clear Cache') }} </button> </template> </card-page> </div> <div class="col-md-6"> <card-page header-id="hdr_clear_queues" :title="$gettext('Clear All Message Queues')" > <div class="card-body"> <p class="card-text"> {{ $gettext('This will clear any pending unprocessed messages in all message queues.') }} </p> </div> <template #footer_actions> <button type="button" class="btn btn-sm btn-primary" @click="makeDebugCall(clearQueuesUrl)" > {{ $gettext('Clear All Message Queues') }} </button> </template> </card-page> </div> </div> <card-page class="mb-3" header-id="hdr_sync_tasks" > <template #header="{id}"> <div class="d-md-flex align-items-center"> <div class="flex-fill my-0"> <h2 :id="id" class="card-title" > {{ $gettext('Synchronization Tasks') }} </h2> </div> <div class="flex-shrink buttons mt-2 mt-md-0"> <button type="button" class="btn btn-dark" @click="resetSyncTasks()" > <icon :icon="IconRefresh" /> <span>{{ $gettext('Refresh') }}</span> </button> </div> </div> </template> <data-table ref="$datatable" :fields="syncTaskFields" :items="syncTasks" :loading="syncTasksLoading" handle-client-side :show-toolbar="false" > <template #cell(name)="row"> <h5>{{ row.item.task }}</h5> <span v-if="row.item.pattern"> {{ row.item.pattern }} </span> <span v-else> {{ $gettext('Custom') }} </span> </template> <template #cell(actions)="row"> <button type="button" class="btn btn-sm btn-primary" @click="makeDebugCall(row.item.url)" > {{ $gettext('Run Task') }} </button> </template> </data-table> </card-page> <card-page class="mb-3" header-id="hdr_message_queues" > <template #header="{id}"> <div class="d-md-flex align-items-center"> <div class="flex-fill my-0"> <h2 :id="id" class="card-title" > {{ $gettext('Message Queues') }} </h2> </div> <div class="flex-shrink buttons mt-2 mt-md-0"> <button type="button" class="btn btn-dark" @click="resetQueueTotals()" > <icon :icon="IconRefresh" /> <span>{{ $gettext('Refresh') }}</span> </button> </div> </div> </template> <div class="card-body"> <loading :loading="queueTotalsLoading"> <div class="row"> <div v-for="row in queueTotals" :key="row.name" class="col" > <h5 class="mb-0"> {{ row.name }} </h5> <p> {{ $gettext( '%{messages} queued messages', {messages: row.count} ) }} </p> <div class="buttons"> <button type="button" class="btn btn-sm btn-primary" @click="makeDebugCall(row.url)" > {{ $gettext('Clear Queue') }} </button> </div> </div> </div> </loading> </div> </card-page> <card-page header-id="hdr_station_debugging" :title="$gettext('Station-Specific Debugging')" > <div class="card-body"> <loading :loading="stationsLoading" lazy > <tabs> <tab v-for="station in stations" :key="station.id" :label="station.name" > <h3>{{ station.name }}</h3> <div class="row"> <div class="col-md-4"> <h5>{{ $gettext('AutoDJ Queue') }}</h5> <div class="buttons"> <button type="button" class="btn btn-sm btn-primary" @click="makeDebugCall(station.clearQueueUrl)" > {{ $gettext('Clear Queue') }} </button> <button type="button" class="btn btn-sm btn-primary" @click="makeDebugCall(station.getNextSongUrl)" > {{ $gettext('Get Next Song') }} </button> </div> </div> <div class="col-md-4"> <h5>{{ $gettext('Get Now Playing') }}</h5> <div class="buttons"> <button type="button" class="btn btn-sm btn-primary" @click="makeDebugCall(station.getNowPlayingUrl)" > {{ $gettext('Run Task') }} </button> </div> </div> </div> </tab> </tabs> </loading> </div> </card-page> <task-output-modal ref="$modal" /> </template> <script setup lang="ts"> import {ref} from "vue"; import useHasDatatable, {DataTableTemplateRef} from "~/functions/useHasDatatable"; import DataTable, {DataTableField} from "~/components/Common/DataTable.vue"; import {useTranslate} from "~/vendor/gettext"; import CardPage from "~/components/Common/CardPage.vue"; import {useLuxon} from "~/vendor/luxon"; import TaskOutputModal from "~/components/Admin/Debug/TaskOutputModal.vue"; import {useAxios} from "~/vendor/axios"; import {useNotify} from "~/functions/useNotify"; import Tabs from "~/components/Common/Tabs.vue"; import Tab from "~/components/Common/Tab.vue"; import {getApiUrl} from "~/router.ts"; import useRefreshableAsyncState from "~/functions/useRefreshableAsyncState.ts"; import Loading from "~/components/Common/Loading.vue"; import {IconRefresh} from "~/components/Common/icons.ts"; import Icon from "~/components/Common/Icon.vue"; import useAutoRefreshingAsyncState from "~/functions/useAutoRefreshingAsyncState.ts"; const listSyncTasksUrl = getApiUrl('/admin/debug/sync-tasks'); const listQueueTotalsUrl = getApiUrl('/admin/debug/queues'); const listStationsUrl = getApiUrl('/admin/debug/stations'); const clearCacheUrl = getApiUrl('/admin/debug/clear-cache'); const clearQueuesUrl = getApiUrl('/admin/debug/clear-queue'); const {axios} = useAxios(); const {state: syncTasks, isLoading: syncTasksLoading, execute: resetSyncTasks} = useAutoRefreshingAsyncState( () => axios.get(listSyncTasksUrl.value).then(r => r.data), [], { timeout: 60000 } ); const {state: queueTotals, isLoading: queueTotalsLoading, execute: resetQueueTotals} = useAutoRefreshingAsyncState( () => axios.get(listQueueTotalsUrl.value).then(r => r.data), [], { timeout: 60000 } ); const {state: stations, isLoading: stationsLoading} = useRefreshableAsyncState( () => axios.get(listStationsUrl.value).then(r => r.data), [], ); const {$gettext} = useTranslate(); const {timestampToRelative} = useLuxon(); const syncTaskFields: DataTableField[] = [ {key: 'name', isRowHeader: true, label: $gettext('Task Name'), sortable: true}, { key: 'time', label: $gettext('Last Run'), formatter: (value) => (value === 0) ? $gettext('Not Run') : timestampToRelative(value), sortable: true }, { key: 'nextRun', label: $gettext('Next Run'), formatter: (value) => timestampToRelative(value), sortable: true }, {key: 'actions', label: $gettext('Actions')} ]; const $datatable = ref<DataTableTemplateRef>(null); useHasDatatable($datatable); const $modal = ref<InstanceType<typeof TaskOutputModal> | null>(null); const {notifySuccess} = useNotify(); const makeDebugCall = (url) => { axios.put(url).then((resp) => { if (resp.data.logs) { $modal.value?.open(resp.data.logs); } else { notifySuccess(resp.data.message); } }); } </script> ```
/content/code_sandbox/frontend/components/Admin/Debug.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
2,125
```vue <template> <div v-for="(row, id) in logs" id="log-view" :key="id" class="card mb-3" > <div :id="'log-row-'+id" class="card-header" > <h4 class="mb-0"> <span class="badge" :class="getBadgeClass(row.level)" >{{ getBadgeLabel(row.level) }}</span> {{ row.message }} </h4> <div v-if="row.context || row.extra" class="buttons mt-3" > <button class="btn btn-sm btn-bg" type="button" data-bs-toggle="collapse" :data-bs-target="'#detail-row-'+id" :aria-controls="'detail-row-'+id" > {{ $gettext('Details') }} </button> </div> </div> <div v-if="row.context || row.extra" :id="'detail-row-'+id" class="collapse" :aria-labelledby="'log-row-'+id" data-parent="#log-view" > <div class="card-body pb-0"> <dl> <template v-for="(context_value, context_header) in row.context" :key="context_header" > <dt>{{ context_header }}</dt> <dd>{{ dump(context_value) }}</dd> </template> <template v-for="(context_value, context_header) in row.extra" :key="context_header" > <dt>{{ context_header }}</dt> <dd>{{ dump(context_value) }}</dd> </template> </dl> </div> </div> </div> </template> <script setup lang="ts"> import {useTranslate} from "~/vendor/gettext.ts"; import {get} from 'lodash'; const props = defineProps<{ logs: Array<any> }>(); const badgeClasses = { 100: 'text-bg-info', 200: 'text-bg-info', 250: 'text-bg-info', 300: 'text-bg-warning', 400: 'text-bg-danger', 500: 'text-bg-danger', 550: 'text-bg-danger', 600: 'text-bg-danger' }; const getBadgeClass = (logLevel) => { return get(badgeClasses, logLevel, badgeClasses[100]); }; const {$gettext} = useTranslate(); const badgeLabels = { 100: $gettext('Debug'), 200: $gettext('Info'), 250: $gettext('Notice'), 300: $gettext('Warning'), 400: $gettext('Error'), 500: $gettext('Critical'), 550: $gettext('Alert'), 600: $gettext('Emergency') }; const getBadgeLabel = (logLevel) => { return get(badgeLabels, logLevel, badgeLabels[100]); }; const dump = (value) => { return JSON.stringify(value); } </script> ```
/content/code_sandbox/frontend/components/Admin/Debug/TaskOutput.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
665
```vue <template> <tab :label="$gettext('Basic Info')" :item-header-class="tabClass" > <div class="row g-3"> <form-group-multi-check id="form_edit_adapter" class="col-md-12" :field="v$.adapter" :options="adapterOptions" stacked radio :label="$gettext('Storage Adapter')" /> <form-group-field id="form_edit_path" class="col-md-12" :field="v$.path" :label="$gettext('Path/Suffix')" :description="$gettext('For local filesystems, this is the base path of the directory. For remote filesystems, this is the folder prefix.')" /> <form-group-field id="form_edit_storageQuota" class="col-md-12" :field="v$.storageQuota" > <template #label> {{ $gettext('Storage Quota') }} </template> <template #description> {{ $gettext('Set a maximum disk space that this storage location can use. Specify the size with unit, i.e. "8 GB". Units are measured in 1024 bytes. Leave blank to default to the available space on the disk.') }} </template> </form-group-field> </div> </tab> </template> <script setup lang="ts"> import FormGroupField from "~/components/Form/FormGroupField.vue"; import {computed} from "vue"; import FormGroupMultiCheck from "~/components/Form/FormGroupMultiCheck.vue"; import {useTranslate} from "~/vendor/gettext"; import {useVModel} from "@vueuse/core"; import {useVuelidateOnFormTab} from "~/functions/useVuelidateOnFormTab"; import {required} from "@vuelidate/validators"; import Tab from "~/components/Common/Tab.vue"; const props = defineProps({ form: { type: Object, required: true } }); const emit = defineEmits(['update:form']); const form = useVModel(props, 'form', emit); const {v$, tabClass} = useVuelidateOnFormTab( { adapter: {required}, path: {}, storageQuota: {}, }, form, { adapter: 'local', path: '', storageQuota: '', } ); const {$gettext} = useTranslate(); const adapterOptions = computed(() => { return [ { value: 'local', text: $gettext('Local Filesystem') }, { value: 's3', text: $gettext('Remote: S3 Compatible') }, { value: 'dropbox', text: $gettext('Remote: Dropbox') }, { value: 'sftp', text: $gettext('Remote: SFTP') } ]; }); </script> ```
/content/code_sandbox/frontend/components/Admin/StorageLocations/Form.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
629
```vue <template> <modal-form ref="$modal" :loading="loading" :title="langTitle" :error="error" :disable-save-button="v$.$invalid" @submit="doSubmit" @hidden="clearContents" > <tabs content-class="mt-3"> <storage-location-form v-model:form="form" /> <s3 v-if="form.adapter === 's3'" v-model:form="form" /> <dropbox v-if="form.adapter === 'dropbox'" v-model:form="form" /> <sftp v-if="form.adapter === 'sftp'" v-model:form="form" /> </tabs> </modal-form> </template> <script setup lang="ts"> import {baseEditModalProps, ModalFormTemplateRef, useBaseEditModal} from "~/functions/useBaseEditModal"; import {computed, ref} from "vue"; import {useTranslate} from "~/vendor/gettext"; import ModalForm from "~/components/Common/ModalForm.vue"; import StorageLocationForm from "./Form.vue"; import Sftp from "~/components/Admin/StorageLocations/Form/Sftp.vue"; import S3 from "~/components/Admin/StorageLocations/Form/S3.vue"; import Dropbox from "~/components/Admin/StorageLocations/Form/Dropbox.vue"; import Tabs from "~/components/Common/Tabs.vue"; const props = defineProps({ ...baseEditModalProps, type: { type: String, required: true } }); const emit = defineEmits(['relist']); const $modal = ref<ModalFormTemplateRef>(null); const { loading, error, isEditMode, form, v$, clearContents, create, edit, doSubmit, close } = useBaseEditModal( props, emit, $modal, {}, { // These have to be defined here because the sub-items conditionally render. dropboxAppKey: null, dropboxAppSecret: null, dropboxAuthToken: null, s3CredentialKey: null, s3CredentialSecret: null, s3Region: null, s3Version: 'latest', s3Bucket: null, s3Endpoint: null, s3UsePathStyle: false, sftpHost: null, sftpPort: '22', sftpUsername: null, sftpPassword: null, sftpPrivateKey: null, sftpPrivateKeyPassPhrase: null, }, { getSubmittableFormData: (formRef, isEditModeRef) => { if (isEditModeRef.value) { return formRef.value; } return { ...formRef.value, type: props.type }; } } ); const {$gettext} = useTranslate(); const langTitle = computed(() => { return isEditMode.value ? $gettext('Edit Storage Location') : $gettext('Add Storage Location'); }); defineExpose({ create, edit, close }); </script> ```
/content/code_sandbox/frontend/components/Admin/StorageLocations/EditModal.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
666
```vue <template> <tab :label="$gettext('Remote: SFTP')" :item-header-class="tabClass" > <div class="row g-3"> <form-group-field id="form_edit_sftpHost" class="col-md-12 col-lg-6" :field="v$.sftpHost" :label="$gettext('SFTP Host')" /> <form-group-field id="form_edit_sftpPort" class="col-md-12 col-lg-6" input-type="number" min="1" step="1" :field="v$.sftpPort" :label="$gettext('SFTP Port')" /> <form-group-field id="form_edit_sftpUsername" class="col-md-12 col-lg-6" :field="v$.sftpUsername" :label="$gettext('SFTP Username')" /> <form-group-field id="form_edit_sftpPassword" class="col-md-12 col-lg-6" :field="v$.sftpPassword" :label="$gettext('SFTP Password')" /> <form-group-field id="form_edit_sftpPrivateKeyPassPhrase" class="col-md-12" :field="v$.sftpPrivateKeyPassPhrase" :label="$gettext('SFTP Private Key Pass Phrase')" /> <form-group-field id="form_edit_sftpPrivateKey" class="col-md-12" input-type="textarea" :field="v$.sftpPrivateKey" :label="$gettext('SFTP Private Key')" /> </div> </tab> </template> <script setup lang="ts"> import FormGroupField from "~/components/Form/FormGroupField.vue"; import {useVModel} from "@vueuse/core"; import {useVuelidateOnFormTab} from "~/functions/useVuelidateOnFormTab"; import {required} from "@vuelidate/validators"; import Tab from "~/components/Common/Tab.vue"; const props = defineProps({ form: { type: Object, required: true } }); const emit = defineEmits(['update:form']); const form = useVModel(props, 'form', emit); const {v$, tabClass} = useVuelidateOnFormTab( { sftpHost: {required}, sftpPort: {required}, sftpUsername: {required}, sftpPassword: {}, sftpPrivateKey: {}, sftpPrivateKeyPassPhrase: {} }, form ); </script> ```
/content/code_sandbox/frontend/components/Admin/StorageLocations/Form/Sftp.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
562
```vue <template> <tab :label="$gettext('Remote: Dropbox')" :item-header-class="tabClass" > <div class="row g-3"> <div class="col-md-12"> <h3>{{ $gettext('Dropbox Setup Instructions') }}</h3> <ul> <li> {{ $gettext('Visit the Dropbox App Console:') }}<br> <a href="path_to_url" target="_blank" > {{ $gettext('Dropbox App Console') }} </a> </li> <li> {{ $gettext('Create a new application. Choose "Scoped Access", select your preferred level of access, then name your app. Do not name it "AzuraCast", but rather use a name specific to your installation.') }} </li> <li> {{ $gettext('Enter your app secret and app key below.') }} </li> </ul> </div> <form-group-field id="form_edit_dropboxAppKey" class="col-md-6" :field="v$.dropboxAppKey" :label="$gettext('App Key')" /> <form-group-field id="form_edit_dropboxAppSecret" class="col-md-6" :field="v$.dropboxAppSecret" :label="$gettext('App Secret')" /> <div class="col-md-12"> <ul> <li> {{ $gettext('Visit the link below to sign in and generate an access code:') }}<br> <a :href="authUrl" target="_blank" > {{ $gettext('Generate Access Code') }} </a> </li> <li> {{ $gettext('Enter the access code you receive below.') }} </li> </ul> </div> <form-group-field id="form_edit_dropboxAuthToken" class="col-md-12" :field="v$.dropboxAuthToken" :label="$gettext('Access Code')" /> </div> </tab> </template> <script setup lang="ts"> import FormGroupField from "~/components/Form/FormGroupField.vue"; import {computed} from "vue"; import {useVModel} from "@vueuse/core"; import {useVuelidateOnFormTab} from "~/functions/useVuelidateOnFormTab"; import {required} from "@vuelidate/validators"; import Tab from "~/components/Common/Tab.vue"; const props = defineProps({ form: { type: Object, required: true } }); const emit = defineEmits(['update:form']); const form = useVModel(props, 'form', emit); const {v$, tabClass} = useVuelidateOnFormTab( { dropboxAppKey: {}, dropboxAppSecret: {}, dropboxAuthToken: {required}, }, form ); const baseAuthUrl = 'path_to_url const authUrl = computed(() => { const params = new URLSearchParams(); params.append('client_id', form.value?.dropboxAppKey); params.append('response_type', 'code'); params.append('token_access_type', 'offline'); return baseAuthUrl + '?' + params.toString(); }); </script> ```
/content/code_sandbox/frontend/components/Admin/StorageLocations/Form/Dropbox.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
722
```vue <template> <tab :label="$gettext('Remote: S3 Compatible')" :item-header-class="tabClass" > <div class="row g-3"> <form-group-field id="form_edit_s3CredentialKey" class="col-md-6" :field="v$.s3CredentialKey" :label="$gettext('Access Key ID')" /> <form-group-field id="form_edit_s3CredentialSecret" class="col-md-6" :field="v$.s3CredentialSecret" :label="$gettext('Secret Key')" /> <form-group-field id="form_edit_s3Bucket" class="col-md-6" :field="v$.s3Bucket" :label="$gettext('Bucket Name')" /> <form-group-field id="form_edit_s3Region" class="col-md-6" :field="v$.s3Region" :label="$gettext('Region')" /> <form-group-field id="form_edit_s3Endpoint" class="col-md-6" :field="v$.s3Endpoint" :label="$gettext('Endpoint')" /> <form-group-field id="form_edit_s3Version" class="col-md-6" :field="v$.s3Version" :label="$gettext('API Version')" /> <form-group-checkbox id="form_edit_s3UsePathStyle" class="col-md-12" :field="v$.s3UsePathStyle" :label="$gettext('Use Path Instead of Subdomain Endpoint Style')" :description="$gettext('Enable this option if your S3 provider is using paths instead of sub-domains for their S3 endpoint; for example, when using MinIO or with other self-hosted S3 storage solutions that are accessible via a path on a domain/IP instead of a subdomain.')" advanced /> </div> </tab> </template> <script setup lang="ts"> import FormGroupField from "~/components/Form/FormGroupField.vue"; import {useVModel} from "@vueuse/core"; import {useVuelidateOnFormTab} from "~/functions/useVuelidateOnFormTab"; import {required} from "@vuelidate/validators"; import Tab from "~/components/Common/Tab.vue"; import FormGroupCheckbox from "~/components/Form/FormGroupCheckbox.vue"; const props = defineProps({ form: { type: Object, required: true } }); const emit = defineEmits(['update:form']); const form = useVModel(props, 'form', emit); const {v$, tabClass} = useVuelidateOnFormTab( { s3CredentialKey: {required}, s3CredentialSecret: {required}, s3Region: {required}, s3Version: {required}, s3Bucket: {required}, s3Endpoint: {required}, s3UsePathStyle: {} }, form ); </script> ```
/content/code_sandbox/frontend/components/Admin/StorageLocations/Form/S3.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
659
```vue <template> <div class="d-flex"> <div class="flex-shrink-0"> <a v-lightbox :href="url" target="_blank" > <img :src="url" width="125" :alt="caption" > </a> </div> <div class="flex-grow-1 ms-3"> <loading :loading="isLoading"> <form-group :id="id"> <template #label> {{ caption }} </template> <form-file :id="id" @uploaded="uploaded" /> </form-group> <button v-if="isUploaded" type="button" class="btn btn-danger mt-3" @click="clear()" > {{ $gettext('Clear Image') }} </button> </loading> </div> </div> </template> <script setup lang="ts"> import {onMounted, ref} from "vue"; import {useAxios} from "~/vendor/axios"; import Loading from "~/components/Common/Loading.vue"; import FormGroup from "~/components/Form/FormGroup.vue"; import FormFile from "~/components/Form/FormFile.vue"; import {useLightbox} from "~/vendor/lightbox"; const props = defineProps({ id: { type: String, required: true }, apiUrl: { type: String, required: true }, caption: { type: String, required: true } }); const isLoading = ref(true); const isUploaded = ref(false); const url = ref(null); const {axios} = useAxios(); const relist = () => { isLoading.value = true; axios.get(props.apiUrl).then((resp) => { isUploaded.value = resp.data.is_uploaded; url.value = resp.data.url; isLoading.value = false; }); }; onMounted(relist); const uploaded = (newFile) => { if (null === newFile) { return; } const formData = new FormData(); formData.append('file', newFile); axios.post(props.apiUrl, formData).finally(() => { relist(); }); }; const clear = () => { axios.delete(props.apiUrl).finally(() => { relist(); }); }; const {vLightbox} = useLightbox(); </script> ```
/content/code_sandbox/frontend/components/Admin/Branding/CustomAssetForm.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
513
```vue <template> <div class="row g-3"> <form-group-field id="edit_form_email" class="col-md-6" :field="v$.email" input-type="email" :label="$gettext('E-mail Address')" /> <form-group-field id="edit_form_new_password" class="col-md-6" :field="v$.new_password" input-type="password" :label="$gettext('Password')" > <template v-if="isEditMode" #description > {{ $gettext('Leave blank to use the current password.') }} </template> </form-group-field> <form-group-field id="edit_form_name" class="col-md-12" :field="v$.name" :label="$gettext('Display Name')" /> <form-group-multi-check id="edit_form_roles" class="col-md-12" :field="v$.roles" :options="roleOptions" :label="$gettext('Roles')" /> </div> </template> <script setup lang="ts"> import FormGroupField from "~/components/Form/FormGroupField.vue"; import objectToFormOptions from "~/functions/objectToFormOptions"; import {computed} from "vue"; import FormGroupMultiCheck from "~/components/Form/FormGroupMultiCheck.vue"; import {useVModel} from "@vueuse/core"; import {useVuelidateOnFormTab} from "~/functions/useVuelidateOnFormTab"; import {email, required} from "@vuelidate/validators"; import validatePassword from "~/functions/validatePassword"; const props = defineProps({ form: { type: Object, required: true }, roles: { type: Object, required: true }, isEditMode: { type: Boolean, required: true } }); const emit = defineEmits(['update:form']); const form = useVModel(props, 'form', emit); const {v$} = useVuelidateOnFormTab( computed(() => { return { email: {required, email}, new_password: (props.isEditMode) ? {validatePassword} : {required, validatePassword}, name: {}, roles: {} } }), form, { email: '', new_password: '', name: '', roles: [], } ); const roleOptions = computed(() => { return objectToFormOptions(props.roles); }); </script> ```
/content/code_sandbox/frontend/components/Admin/Users/Form.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
548
```vue <template> <modal-form ref="$modal" :loading="loading" :title="langTitle" :error="error" :disable-save-button="v$.$invalid" @submit="doSubmit" @hidden="clearContents" > <admin-users-form v-model:form="form" :roles="roles" :is-edit-mode="isEditMode" /> </modal-form> </template> <script setup lang="ts"> import AdminUsersForm from './Form.vue'; import {map} from 'lodash'; import {computed, ref} from "vue"; import {baseEditModalProps, ModalFormTemplateRef, useBaseEditModal} from "~/functions/useBaseEditModal"; import {useTranslate} from "~/vendor/gettext"; import ModalForm from "~/components/Common/ModalForm.vue"; const props = defineProps({ ...baseEditModalProps, roles: { type: Object, required: true } }); const emit = defineEmits(['relist']); const $modal = ref<ModalFormTemplateRef>(null); const { loading, error, isEditMode, form, v$, clearContents, create, edit, doSubmit, close } = useBaseEditModal( props, emit, $modal, {}, {}, { populateForm: (data, formRef) => { formRef.value = { name: data.name, email: data.email, new_password: '', roles: map(data.roles, 'id') }; }, } ); const {$gettext} = useTranslate(); const langTitle = computed(() => { return isEditMode.value ? $gettext('Edit User') : $gettext('Add User'); }); defineExpose({ create, edit, close }); </script> ```
/content/code_sandbox/frontend/components/Admin/Users/EditModal.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
399
```vue <template> <form class="form vue-form" @submit.prevent="submit" > <section class="card mb-3" role="region" > <div class="card-header text-bg-primary"> <h2 class="card-title"> {{ $gettext('Branding Settings') }} </h2> </div> <div v-show="error != null" class="alert alert-danger" > {{ error }} </div> <div class="card-body"> <loading :loading="isLoading"> <div class="row g-3"> <form-group-multi-check id="edit_form_public_theme" class="col-md-6" :field="v$.public_theme" :options="publicThemeOptions" stacked radio :label="$gettext('Base Theme for Public Pages')" :description="$gettext('Select a theme to use as a base for station public pages and the login page.')" /> <div class="col-md-6"> <form-group-checkbox id="form_edit_hide_album_art" class="mb-2" :field="v$.hide_album_art" :label="$gettext('Hide Album Art on Public Pages')" :description="$gettext('If selected, album art will not display on public-facing radio pages.')" /> <form-group-checkbox id="form_edit_hide_product_name" :field="v$.hide_product_name" :label="$gettext('Hide AzuraCast Branding on Public Pages')" :description="$gettext('If selected, this will remove the AzuraCast branding from public-facing pages.')" /> </div> <form-group-field id="form_edit_homepage_redirect_url" class="col-md-6" :field="v$.homepage_redirect_url" :label="$gettext('Homepage Redirect URL')" :description="$gettext('If a visitor is not signed in and visits the AzuraCast homepage, you can automatically redirect them to the URL specified here. Leave blank to redirect them to the login screen by default.')" /> <form-group-field id="form_edit_default_album_art_url" class="col-md-6" :field="v$.default_album_art_url" :label="$gettext('Default Album Art URL')" :description="$gettext('If a song has no album art, this URL will be listed instead. Leave blank to use the standard placeholder art.')" /> <form-group-field id="edit_form_public_custom_css" class="col-md-12" :field="v$.public_custom_css" :label="$gettext('Custom CSS for Public Pages')" :description="$gettext('This CSS will be applied to the station public pages and login page.')" > <template #default="slotProps"> <codemirror-textarea :id="slotProps.id" v-model="slotProps.field.$model" mode="css" /> </template> </form-group-field> <form-group-field id="edit_form_public_custom_js" class="col-md-12" :field="v$.public_custom_js" :label="$gettext('Custom JS for Public Pages')" :description="$gettext('This javascript code will be applied to the station public pages and login page.')" > <template #default="slotProps"> <codemirror-textarea :id="slotProps.id" v-model="slotProps.field.$model" mode="javascript" /> </template> </form-group-field> <form-group-field id="edit_form_internal_custom_css" class="col-md-12" :field="v$.internal_custom_css" :label="$gettext('Custom CSS for Internal Pages')" :description="$gettext('This CSS will be applied to the main management pages, like this one.')" > <template #default="slotProps"> <codemirror-textarea :id="slotProps.id" v-model="slotProps.field.$model" mode="css" /> </template> </form-group-field> </div> <button class="btn btn-primary mt-3" type="submit" > {{ $gettext('Save Changes') }} </button> </loading> </div> </section> </form> </template> <script setup lang="ts"> import CodemirrorTextarea from "~/components/Common/CodemirrorTextarea.vue"; import FormGroupField from "~/components/Form/FormGroupField.vue"; import FormGroupCheckbox from "~/components/Form/FormGroupCheckbox.vue"; import {computed, onMounted, ref} from "vue"; import {useAxios} from "~/vendor/axios"; import mergeExisting from "~/functions/mergeExisting"; import {useNotify} from "~/functions/useNotify"; import {useTranslate} from "~/vendor/gettext"; import {useVuelidateOnForm} from "~/functions/useVuelidateOnForm"; import FormGroupMultiCheck from "~/components/Form/FormGroupMultiCheck.vue"; import Loading from "~/components/Common/Loading.vue"; const props = defineProps({ apiUrl: { type: String, required: true }, }); const isLoading = ref(true); const error = ref(null); const {form, resetForm, v$, ifValid} = useVuelidateOnForm( { 'public_theme': {}, 'hide_album_art': {}, 'homepage_redirect_url': {}, 'default_album_art_url': {}, 'hide_product_name': {}, 'public_custom_css': {}, 'public_custom_js': {}, 'internal_custom_css': {} }, { 'public_theme': '', 'hide_album_art': false, 'homepage_redirect_url': '', 'default_album_art_url': '', 'hide_product_name': false, 'public_custom_css': '', 'public_custom_js': '', 'internal_custom_css': '' } ); const {$gettext} = useTranslate(); const publicThemeOptions = computed(() => { return [ { text: $gettext('Prefer System Default'), value: 'browser', }, { text: $gettext('Light'), value: 'light', }, { text: $gettext('Dark'), value: 'dark', } ]; }); const {axios} = useAxios(); const populateForm = (data) => { form.value = mergeExisting(form.value, data); }; const relist = () => { resetForm(); isLoading.value = true; axios.get(props.apiUrl).then((resp) => { populateForm(resp.data); isLoading.value = false; }); } onMounted(relist); const {notifySuccess} = useNotify(); const submit = () => { ifValid(() => { axios({ method: 'PUT', url: props.apiUrl, data: form.value }).then(() => { notifySuccess($gettext('Changes saved.')); relist(); }); }); } </script> ```
/content/code_sandbox/frontend/components/Admin/Branding/BrandingForm.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,512
```vue <template> <div class="row g-3"> <form-group-field id="edit_form_name" class="col-md-12" :field="form.name" :label="$gettext('New Station Name')" /> <form-group-field id="edit_form_description" class="col-md-12" :field="form.description" input-type="textarea" :label="$gettext('New Station Description')" /> <form-group-multi-check id="edit_form_clone" class="col-md-12" :field="form.clone" :options="cloneOptions" stacked :label="$gettext('Copy to New Station')" /> </div> </template> <script setup lang="ts"> import FormGroupField from "~/components/Form/FormGroupField.vue"; import {computed} from "vue"; import {useTranslate} from "~/vendor/gettext"; import FormGroupMultiCheck from "~/components/Form/FormGroupMultiCheck.vue"; const props = defineProps({ form: { type: Object, required: true } }); const {$gettext} = useTranslate(); const cloneOptions = computed(() => { return [ { text: $gettext('Share Media Storage Location'), value: 'media_storage' }, { text: $gettext('Share Recordings Storage Location'), value: 'recordings_storage' }, { text: $gettext('Share Podcasts Storage Location'), value: 'podcasts_storage' }, { text: $gettext('Playlists'), value: 'playlists', }, { text: $gettext('Mount Points'), value: 'mounts' }, { text: $gettext('Remote Relays'), value: 'remotes' }, { text: $gettext('Streamers/DJs'), value: 'streamers' }, { text: $gettext('User Permissions'), value: 'permissions' }, { text: $gettext('Web Hooks'), value: 'webhooks' } ]; }); </script> ```
/content/code_sandbox/frontend/components/Admin/Stations/CloneModalForm.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
450
```vue <template> <modal-form ref="$modal" :loading="loading" :title="$gettext('Clone Station')" :error="error" :disable-save-button="v$.$invalid" @submit="doSubmit" @hidden="clearContents" > <admin-stations-clone-modal-form :form="v$" /> </modal-form> </template> <script setup lang="ts"> import {required} from '@vuelidate/validators'; import ModalForm from "~/components/Common/ModalForm.vue"; import AdminStationsCloneModalForm from "~/components/Admin/Stations/CloneModalForm.vue"; import {ref} from "vue"; import {useTranslate} from "~/vendor/gettext"; import {useNotify} from "~/functions/useNotify"; import {useAxios} from "~/vendor/axios"; import {useVuelidateOnForm} from "~/functions/useVuelidateOnForm"; import {ModalFormTemplateRef} from "~/functions/useBaseEditModal.ts"; import {useHasModal} from "~/functions/useHasModal.ts"; const emit = defineEmits(['relist']); const loading = ref(true); const cloneUrl = ref(null); const error = ref(null); const {form, resetForm, v$, ifValid} = useVuelidateOnForm( { name: {required}, description: {}, clone: {} }, { name: '', description: '', clone: [], } ); const $modal = ref<ModalFormTemplateRef>(null); const {hide, show} = useHasModal($modal); const {$gettext} = useTranslate(); const create = (stationName, stationCloneUrl) => { resetForm(); form.value.name = $gettext( '%{station} - Copy', {station: stationName} ); loading.value = false; error.value = null; cloneUrl.value = stationCloneUrl; show(); }; const clearContents = () => { resetForm(); cloneUrl.value = null; }; const {notifySuccess} = useNotify(); const {axios} = useAxios(); const doSubmit = () => { ifValid(() => { error.value = null; axios({ method: 'POST', url: cloneUrl.value, data: form.value }).then(() => { notifySuccess(); emit('relist'); hide(); }).catch((error) => { error.value = error.response.data.message; }); }); }; defineExpose({ create }); </script> ```
/content/code_sandbox/frontend/components/Admin/Stations/CloneModal.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
543
```vue <template> <loading :loading="isLoading"> <div v-show="error != null" class="alert alert-danger" > {{ error }} </div> <form class="form vue-form" @submit.prevent="submit" > <tabs content-class="mt-3"> <admin-stations-profile-form v-model:form="form" :timezones="timezones" /> <admin-stations-frontend-form v-model:form="form" :is-shoutcast-installed="isShoutcastInstalled" :countries="countries" /> <admin-stations-backend-form v-model:form="form" :station="station" :is-stereo-tool-installed="isStereoToolInstalled" /> <admin-stations-hls-form v-model:form="form" :station="station" /> <admin-stations-requests-form v-model:form="form" :station="station" /> <admin-stations-streamers-form v-model:form="form" :station="station" /> <admin-stations-admin-form v-if="showAdminTab" v-model:form="form" :is-edit-mode="isEditMode" /> </tabs> <slot name="submitButton"> <div class="buttons mt-3"> <button type="submit" class="btn btn-lg" :class="(!isValid) ? 'btn-danger' : 'btn-primary'" > <slot name="submitButtonText"> {{ $gettext('Save Changes') }} </slot> </button> </div> </slot> </form> </loading> </template> <script setup lang="ts"> import AdminStationsProfileForm from "./Form/ProfileForm.vue"; import AdminStationsFrontendForm from "./Form/FrontendForm.vue"; import AdminStationsBackendForm from "./Form/BackendForm.vue"; import AdminStationsAdminForm from "./Form/AdminForm.vue"; import AdminStationsHlsForm from "./Form/HlsForm.vue"; import AdminStationsRequestsForm from "./Form/RequestsForm.vue"; import AdminStationsStreamersForm from "./Form/StreamersForm.vue"; import {computed, nextTick, ref, watch} from "vue"; import {useNotify} from "~/functions/useNotify"; import {useAxios} from "~/vendor/axios"; import mergeExisting from "~/functions/mergeExisting"; import {useVuelidateOnForm} from "~/functions/useVuelidateOnForm"; import stationFormProps from "~/components/Admin/Stations/stationFormProps"; import {useResettableRef} from "~/functions/useResettableRef"; import Loading from '~/components/Common/Loading.vue'; import Tabs from "~/components/Common/Tabs.vue"; import {GlobalPermission, userAllowed} from "~/acl"; const props = defineProps({ ...stationFormProps, createUrl: { type: String, default: null }, editUrl: { type: String, default: null }, isEditMode: { type: Boolean, required: true }, isModal: { type: Boolean, default: false } }); const emit = defineEmits(['error', 'submitted', 'loadingUpdate', 'validUpdate']); const showAdminTab = userAllowed(GlobalPermission.Stations); const {form, resetForm, v$, ifValid} = useVuelidateOnForm(); const isValid = computed(() => { return !v$.value?.$invalid; }); watch(isValid, (newValue) => { emit('validUpdate', newValue); }); const isLoading = ref(true); watch(isLoading, (newValue) => { emit('loadingUpdate', newValue); }); const error = ref(null); const blankStation = { stereo_tool_configuration_file_path: null, links: { stereo_tool_configuration: null } }; const {record: station, reset: resetStation} = useResettableRef(blankStation); const clear = () => { resetForm(); resetStation(); isLoading.value = false; error.value = null; }; const populateForm = (data) => { form.value = mergeExisting(form.value, data); }; const {notifySuccess} = useNotify(); const {axios} = useAxios(); const doLoad = () => { isLoading.value = true; axios.get(props.editUrl).then((resp) => { populateForm(resp.data); }).catch((err) => { emit('error', err); }).finally(() => { isLoading.value = false; }); }; const reset = () => { nextTick(() => { clear(); if (props.isEditMode) { doLoad(); } }); }; const submit = () => { ifValid(() => { error.value = null; axios({ method: (props.isEditMode) ? 'PUT' : 'POST', url: (props.isEditMode) ? props.editUrl : props.createUrl, data: form.value }).then(() => { notifySuccess(); emit('submitted'); }).catch((err) => { error.value = err.response.data.message; }); }); }; defineExpose({ reset, submit }); </script> ```
/content/code_sandbox/frontend/components/Admin/Stations/StationForm.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,147
```vue <template> <modal id="station_edit_modal" ref="$modal" size="lg" :title="langTitle" :busy="false" @shown="resetForm" @hidden="clearContents" > <admin-stations-form v-bind="pickProps(props, stationFormProps)" ref="$form" is-modal :create-url="createUrl" :edit-url="editUrl" :is-edit-mode="isEditMode" @error="close" @submitted="onSubmit" @valid-update="onValidUpdate" > <template #submitButton> <invisible-submit-button /> </template> </admin-stations-form> <template #modal-footer> <button class="btn btn-secondary" type="button" @click="hide" > {{ $gettext('Close') }} </button> <button class="btn" :class="(disableSaveButton) ? 'btn-danger' : 'btn-primary'" type="submit" @click="doSubmit" > {{ $gettext('Save Changes') }} </button> </template> </modal> </template> <script setup lang="ts"> import AdminStationsForm from "~/components/Admin/Stations/StationForm.vue"; import InvisibleSubmitButton from "~/components/Common/InvisibleSubmitButton.vue"; import {computed, ref} from "vue"; import {useTranslate} from "~/vendor/gettext"; import stationFormProps from "~/components/Admin/Stations/stationFormProps"; import {pickProps} from "~/functions/pickProps"; import Modal from "~/components/Common/Modal.vue"; import {ModalTemplateRef, useHasModal} from "~/functions/useHasModal.ts"; const props = defineProps({ ...stationFormProps, createUrl: { type: String, required: true } }); const emit = defineEmits(['relist']); const editUrl = ref(null); const disableSaveButton = ref(true); const isEditMode = computed(() => { return editUrl.value !== null; }); const {$gettext} = useTranslate(); const langTitle = computed(() => { return isEditMode.value ? $gettext('Edit Station') : $gettext('Add Station'); }); const $modal = ref<ModalTemplateRef>(null); const {show, hide} = useHasModal($modal); const onValidUpdate = (newValue) => { disableSaveButton.value = !newValue; }; const create = () => { editUrl.value = null; show(); }; const edit = (recordUrl) => { editUrl.value = recordUrl; show(); }; const $form = ref<InstanceType<typeof AdminStationsForm> | null>(null); const resetForm = () => { $form.value?.reset(); }; const onSubmit = () => { emit('relist'); hide(); }; const doSubmit = () => { $form.value?.submit(); }; const clearContents = () => { editUrl.value = null; }; defineExpose({ create, edit }); </script> ```
/content/code_sandbox/frontend/components/Admin/Stations/EditModal.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
661
```vue <template> <tab :label="$gettext('Song Requests')" :item-header-class="tabClassWithBackend" > <form-fieldset v-if="isBackendEnabled"> <template #label> {{ $gettext('Song Requests') }} </template> <template #description> {{ $gettext('Some stream licensing providers may have specific rules regarding song requests. Check your local regulations for more information.') }} </template> <div class="row g-3 mb-3"> <form-group-checkbox id="edit_form_enable_requests" class="col-md-12" :field="v$.enable_requests" :label="$gettext('Allow Song Requests')" :description="$gettext('Enable listeners to request a song for play on your station. Only songs that are already in your playlists are requestable.')" /> </div> <div v-if="form.enable_requests" class="row g-3 mb-3" > <form-group-field id="edit_form_request_delay" class="col-md-6" :field="v$.request_delay" input-type="number" :input-attrs="{ min: '0', max: '1440' }" :label="$gettext('Request Minimum Delay (Minutes)')" :description="$gettext('If requests are enabled, this specifies the minimum delay (in minutes) between a request being submitted and being played. If set to zero, a minor delay of 15 seconds is applied to prevent request floods.')" /> <form-group-field id="edit_form_request_threshold" class="col-md-6" :field="v$.request_threshold" input-type="number" :input-attrs="{ min: '0', max: '1440' }" :label="$gettext('Request Last Played Threshold (Minutes)')" :description="$gettext('This specifies the minimum time (in minutes) between a song playing on the radio and being available to request again. Set to 0 for no threshold.')" /> </div> </form-fieldset> <backend-disabled v-else /> </tab> </template> <script setup lang="ts"> import FormFieldset from "~/components/Form/FormFieldset.vue"; import FormGroupField from "~/components/Form/FormGroupField.vue"; import {BackendAdapter} from "~/entities/RadioAdapters"; import FormGroupCheckbox from "~/components/Form/FormGroupCheckbox.vue"; import BackendDisabled from "./Common/BackendDisabled.vue"; import {computed} from "vue"; import {useVModel} from "@vueuse/core"; import {useVuelidateOnFormTab} from "~/functions/useVuelidateOnFormTab"; import {numeric} from "@vuelidate/validators"; import Tab from "~/components/Common/Tab.vue"; const props = defineProps({ form: { type: Object, required: true }, station: { type: Object, required: true } }); const emit = defineEmits(['update:form']); const form = useVModel(props, 'form', emit); const {v$, tabClass} = useVuelidateOnFormTab( { enable_requests: {}, request_delay: {numeric}, request_threshold: {numeric}, }, form, { enable_requests: false, request_delay: 5, request_threshold: 15, } ); const isBackendEnabled = computed(() => { return form.value.backend_type !== BackendAdapter.None; }); const tabClassWithBackend = computed(() => { if (tabClass.value) { return tabClass.value; } return (isBackendEnabled.value) ? null : 'text-muted'; }); </script> ```
/content/code_sandbox/frontend/components/Admin/Stations/Form/RequestsForm.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
800
```vue <template> <tab :label="$gettext('Profile')" :item-header-class="tabClass" > <div class="row g-3 mb-3"> <form-group-field id="edit_form_name" class="col-md-12" :field="v$.name" :label="$gettext('Name')" /> <form-group-field id="edit_form_description" class="col-md-12" :field="v$.description" input-type="textarea" :label="$gettext('Description')" /> <form-group-field id="edit_form_genre" class="col-md-6" :field="v$.genre" :label="$gettext('Genre')" > <template #description> {{ $gettext('The primary genre this station plays, such as "rock", "electronic", or "talk".') }} </template> </form-group-field> <form-group-field id="edit_form_url" class="col-md-6" :field="v$.url" input-type="url" :label="$gettext('Web Site URL')" :description="$gettext('Note: This should be the public-facing homepage of the radio station, not the AzuraCast URL. It will be included in broadcast details.')" /> <form-group-select id="edit_form_timezone" class="col-md-12" :field="v$.timezone" :options="timezoneOptions" :label="$gettext('Time Zone')" :description="$gettext('Scheduled playlists and other timed items will be controlled by this time zone.')" /> <form-group-field v-if="enableAdvancedFeatures" id="edit_form_short_name" class="col-md-6" :field="v$.short_name" advanced :label="$gettext('URL Stub')" > <template #description> {{ $gettext('Optionally specify a short URL-friendly name, such as "my_station_name", that will be used in this station\'s URLs. Leave this field blank to automatically create one based on the station name.') }} </template> </form-group-field> <form-group-select v-if="enableAdvancedFeatures" id="edit_form_api_history_items" class="col-md-6" :field="v$.api_history_items" advanced :options="historyItemsOptions" :label="$gettext('Number of Visible Recent Songs')" > <template #description> {{ $gettext('Customize the number of songs that will appear in the "Song History" section for this station and in all public APIs.') }} </template> </form-group-select> </div> <form-fieldset> <template #label> {{ $gettext('Public Pages') }} </template> <div class="row g-3"> <form-group-checkbox id="edit_form_enable_public_page" class="col-md-12" :field="v$.enable_public_page" :label="$gettext('Enable Public Pages')" :description="$gettext('Show the station in public pages and general API results.')" /> </div> </form-fieldset> <form-fieldset> <template #label> {{ $gettext('On-Demand Streaming') }} </template> <div class="row g-3"> <form-group-checkbox id="edit_form_enable_on_demand" class="col-md-12" :field="v$.enable_on_demand" :label="$gettext('Enable On-Demand Streaming')" :description="$gettext('If enabled, music from playlists with on-demand streaming enabled will be available to stream via a specialized public page.')" /> <form-group-checkbox v-if="form.enable_on_demand" id="edit_form_enable_on_demand_download" class="col-md-12" :field="v$.enable_on_demand_download" :label="$gettext('Enable Downloads on On-Demand Page')" > <template #description> {{ $gettext('If enabled, a download button will also be present on the public "On-Demand" page.') }} </template> </form-group-checkbox> </div> </form-fieldset> </tab> </template> <script setup lang="ts"> import FormFieldset from "~/components/Form/FormFieldset.vue"; import FormGroupField from "~/components/Form/FormGroupField.vue"; import objectToFormOptions from "~/functions/objectToFormOptions"; import FormGroupCheckbox from "~/components/Form/FormGroupCheckbox.vue"; import {computed} from "vue"; import {useTranslate} from "~/vendor/gettext"; import FormGroupSelect from "~/components/Form/FormGroupSelect.vue"; import {useVModel} from "@vueuse/core"; import {useVuelidateOnFormTab} from "~/functions/useVuelidateOnFormTab"; import {required, url} from "@vuelidate/validators"; import {useAzuraCast} from "~/vendor/azuracast"; import Tab from "~/components/Common/Tab.vue"; const props = defineProps({ form: { type: Object, required: true }, timezones: { type: Object, required: true }, }); const {enableAdvancedFeatures} = useAzuraCast(); const emit = defineEmits(['update:form']); const form = useVModel(props, 'form', emit); const {v$, tabClass} = useVuelidateOnFormTab( computed(() => { let validations: { [key: string | number]: any } = { name: {required}, description: {}, genre: {}, url: {url}, timezone: {}, enable_public_page: {}, enable_on_demand: {}, enable_on_demand_download: {}, }; if (enableAdvancedFeatures) { validations = { ...validations, short_name: {}, api_history_items: {}, }; } return validations; }), form, () => { let blankForm: { [key: string | number]: any } = { name: '', description: '', genre: '', url: '', timezone: 'UTC', enable_public_page: true, enable_on_demand: false, enable_on_demand_download: true, }; if (enableAdvancedFeatures) { blankForm = { ...blankForm, short_name: '', api_history_items: 5, } } return blankForm; } ); const timezoneOptions = computed(() => { return objectToFormOptions(props.timezones); }); const {$gettext} = useTranslate(); const historyItemsOptions = computed(() => { return [ { text: $gettext('Disabled'), value: 0, }, {text: '1', value: 1}, {text: '5', value: 5}, {text: '10', value: 10}, {text: '15', value: 15} ]; }); </script> ```
/content/code_sandbox/frontend/components/Admin/Stations/Form/ProfileForm.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,528
```vue <template> <tab :label="$gettext('HLS')" :item-header-class="tabClassWithBackend" > <form-fieldset v-if="isBackendEnabled"> <template #label> {{ $gettext('HTTP Live Streaming (HLS)') }} </template> <template #description> {{ $gettext('HTTP Live Streaming (HLS) is a new adaptive-bitrate technology supported by some clients. It does not use the standard broadcasting frontends.') }} </template> <div class="row g-3 mb-3"> <form-group-checkbox id="edit_form_enable_hls" class="col-md-12" :field="v$.enable_hls" :label="$gettext('Enable HTTP Live Streaming (HLS)')" /> </div> <div v-if="form.enable_hls" class="row g-3 mb-3" > <form-group-checkbox id="edit_form_backend_hls_enable_on_public_player" class="col-md-12" :field="v$.backend_config.hls_enable_on_public_player" :label="$gettext('Show HLS Stream on Public Player')" /> <form-group-checkbox id="edit_form_backend_hls_is_default" class="col-md-12" :field="v$.backend_config.hls_is_default" :label="$gettext('Make HLS Stream Default in Public Player')" /> </div> <div v-if="enableAdvancedFeatures && form.enable_hls" class="row g-3 mb-3" > <form-group-field id="edit_form_backend_hls_segment_length" class="col-md-4" :field="v$.backend_config.hls_segment_length" input-type="number" :input-attrs="{ min: '0', max: '9999' }" advanced :label="$gettext('Segment Length (Seconds)')" /> <form-group-field id="edit_form_backend_hls_segments_in_playlist" class="col-md-4" :field="v$.backend_config.hls_segments_in_playlist" input-type="number" :input-attrs="{ min: '0', max: '60' }" advanced :label="$gettext('Segments in Playlist')" /> <form-group-field id="edit_form_backend_hls_segments_overhead" class="col-md-4" :field="v$.backend_config.hls_segments_overhead" input-type="number" :input-attrs="{ min: '0', max: '60' }" advanced :label="$gettext('Segments Overhead')" /> </div> </form-fieldset> <backend-disabled v-else /> </tab> </template> <script setup lang="ts"> import FormFieldset from "~/components/Form/FormFieldset.vue"; import FormGroupField from "~/components/Form/FormGroupField.vue"; import {BackendAdapter} from "~/entities/RadioAdapters"; import FormGroupCheckbox from "~/components/Form/FormGroupCheckbox.vue"; import BackendDisabled from "./Common/BackendDisabled.vue"; import {computed} from "vue"; import {useVModel} from "@vueuse/core"; import {useVuelidateOnFormTab} from "~/functions/useVuelidateOnFormTab"; import {numeric} from "@vuelidate/validators"; import {useAzuraCast} from "~/vendor/azuracast"; import Tab from "~/components/Common/Tab.vue"; const props = defineProps({ form: { type: Object, required: true }, station: { type: Object, required: true } }); const {enableAdvancedFeatures} = useAzuraCast(); const emit = defineEmits(['update:form']); const form = useVModel(props, 'form', emit); const {v$, tabClass} = useVuelidateOnFormTab( computed(() => { let validations: { [key: string | number]: any } = { enable_hls: {}, backend_config: { hls_enable_on_public_player: {}, hls_is_default: {}, }, }; if (enableAdvancedFeatures) { validations = { ...validations, backend_config: { ...validations.backend_config, hls_segment_length: {numeric}, hls_segments_in_playlist: {numeric}, hls_segments_overhead: {numeric}, }, }; } return validations; }), form, () => { let blankForm: { [key: string | number]: any } = { enable_hls: false, backend_config: { hls_enable_on_public_player: false, hls_is_default: false, } }; if (enableAdvancedFeatures) { blankForm = { ...blankForm, backend_config: { ...blankForm.backend_config, hls_segment_length: 4, hls_segments_in_playlist: 5, hls_segments_overhead: 2, } }; } return blankForm; }, ); const isBackendEnabled = computed(() => { return form.value.backend_type !== BackendAdapter.None; }); const tabClassWithBackend = computed(() => { if (tabClass.value) { return tabClass.value; } return (isBackendEnabled.value) ? null : 'text-muted'; }); </script> ```
/content/code_sandbox/frontend/components/Admin/Stations/Form/HlsForm.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,180
```vue <template> <tab :label="$gettext('Administration')" :item-header-class="tabClass" > <div class="row g-3 mb-3"> <form-group-checkbox id="edit_form_is_enabled" class="col-md-6" :field="v$.is_enabled" :label="$gettext('Enable Broadcasting')" :description="$gettext('If disabled, the station will not broadcast or shuffle its AutoDJ.')" /> <form-group-field v-if="enableAdvancedFeatures" id="edit_form_radio_base_dir" class="col-md-6" :field="v$.radio_base_dir" advanced :label="$gettext('Base Station Directory')" :description="$gettext('The parent directory where station playlist and configuration files are stored. Leave blank to use default directory.')" /> </div> <loading :loading="storageLocationsLoading"> <div class="row g-3"> <form-group-select id="edit_form_media_storage_location" class="col-md-12" :field="v$.media_storage_location" :options="storageLocationOptions.media_storage_location" :label="$gettext('Media Storage Location')" /> <form-group-select id="edit_form_recordings_storage_location" class="col-md-12" :field="v$.recordings_storage_location" :options="storageLocationOptions.recordings_storage_location" :label="$gettext('Live Recordings Storage Location')" /> <form-group-select id="edit_form_podcasts_storage_location" class="col-md-12" :field="v$.podcasts_storage_location" :options="storageLocationOptions.podcasts_storage_location" :label="$gettext('Podcasts Storage Location')" /> </div> </loading> </tab> </template> <script setup lang="ts"> import FormGroupField from "~/components/Form/FormGroupField.vue"; import objectToFormOptions from "~/functions/objectToFormOptions"; import FormGroupCheckbox from "~/components/Form/FormGroupCheckbox.vue"; import {computed, onMounted, reactive, ref} from "vue"; import {useAxios} from "~/vendor/axios"; import Loading from "~/components/Common/Loading.vue"; import FormGroupSelect from "~/components/Form/FormGroupSelect.vue"; import {useVModel} from "@vueuse/core"; import {useVuelidateOnFormTab} from "~/functions/useVuelidateOnFormTab"; import {useAzuraCast} from "~/vendor/azuracast"; import Tab from "~/components/Common/Tab.vue"; import {getApiUrl} from "~/router"; const props = defineProps({ form: { type: Object, required: true }, isEditMode: { type: Boolean, required: true } }); const storageLocationApiUrl = getApiUrl('/admin/stations/storage-locations'); const {enableAdvancedFeatures} = useAzuraCast(); const emit = defineEmits(['update:form']); const form = useVModel(props, 'form', emit); const {v$, tabClass} = useVuelidateOnFormTab( computed(() => { let validations: { [key: string | number]: any } = { is_enabled: {}, media_storage_location: {}, recordings_storage_location: {}, podcasts_storage_location: {}, }; if (enableAdvancedFeatures) { validations = { ...validations, radio_base_dir: {}, }; } return validations; }), form, () => { let blankForm: { [key: string]: any } = { media_storage_location: '', recordings_storage_location: '', podcasts_storage_location: '', is_enabled: true, }; if (enableAdvancedFeatures) { blankForm = { ...blankForm, radio_base_dir: '', }; } return blankForm; } ); const storageLocationsLoading = ref(true); const storageLocationOptions = reactive({ media_storage_location: [], recordings_storage_location: [], podcasts_storage_location: [] }); const filterLocations = (group) => { if (!props.isEditMode) { return group; } const newGroup = {}; for (const oldKey in group) { if (oldKey !== "") { newGroup[oldKey] = group[oldKey]; } } return newGroup; } const {axios} = useAxios(); const loadLocations = () => { axios.get(storageLocationApiUrl.value).then((resp) => { storageLocationOptions.media_storage_location = objectToFormOptions( filterLocations(resp.data.media_storage_location) ); storageLocationOptions.recordings_storage_location = objectToFormOptions( filterLocations(resp.data.recordings_storage_location) ); storageLocationOptions.podcasts_storage_location = objectToFormOptions( filterLocations(resp.data.podcasts_storage_location) ); }).finally(() => { storageLocationsLoading.value = false; }); }; onMounted(loadLocations); </script> ```
/content/code_sandbox/frontend/components/Admin/Stations/Form/AdminForm.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,082
```vue <template> <tab :label="$gettext('Streamers/DJs')" :item-header-class="tabClassWithBackend" > <form-fieldset v-if="isBackendEnabled"> <template #label> {{ $gettext('Streamers/DJs') }} </template> <div class="row g-3 mb-3"> <form-group-checkbox id="edit_form_enable_streamers" class="col-md-12" :field="v$.enable_streamers" :label="$gettext('Allow Streamers / DJs')" :description="$gettext('If enabled, streamers (or DJs) will be able to connect directly to your stream and broadcast live music that interrupts the AutoDJ stream.')" /> </div> <template v-if="form.enable_streamers"> <div class="row g-3 mb-3"> <form-group-checkbox id="edit_form_backend_record_streams" class="col-md-12" :field="v$.backend_config.record_streams" :label="$gettext('Record Live Broadcasts')" :description="$gettext('If enabled, AzuraCast will automatically record any live broadcasts made to this station to per-broadcast recordings.')" /> </div> <div v-if="form.backend_config.record_streams" class="row g-3 mb-3" > <form-group-multi-check id="edit_form_backend_record_streams_format" class="col-md-6" :field="v$.backend_config.record_streams_format" :options="recordStreamsOptions" stacked radio :label="$gettext('Live Broadcast Recording Format')" /> <bitrate-options id="edit_form_backend_record_streams_bitrate" class="col-md-6" :field="v$.backend_config.record_streams_bitrate" :label="$gettext('Live Broadcast Recording Bitrate (kbps)')" /> </div> <div class="row g-3 mb-3"> <form-group-field id="edit_form_disconnect_deactivate_streamer" class="col-md-6" :field="v$.disconnect_deactivate_streamer" input-type="number" :input-attrs="{ min: '0' }" > <template #label> {{ $gettext('Deactivate Streamer on Disconnect (Seconds)') }} </template> <template #description> {{ $gettext('This is the number of seconds until a streamer who has been manually disconnected can reconnect to the stream. Set to 0 to allow the streamer to immediately reconnect.') }} </template> </form-group-field> <form-group-field v-if="enableAdvancedFeatures" id="edit_form_backend_dj_port" class="col-md-6" :field="v$.backend_config.dj_port" input-type="number" :input-attrs="{ min: '0' }" advanced :label="$gettext('Customize DJ/Streamer Port')" > <template #description> {{ $gettext('No other program can be using this port. Leave blank to automatically assign a port.') }} <br> {{ $gettext('Note: the port after this one will automatically be used for legacy connections.') }} </template> </form-group-field> <form-group-field id="edit_form_backend_dj_buffer" class="col-md-6" :field="v$.backend_config.dj_buffer" input-type="number" :input-attrs="{ min: '0', max: '60' }" :label="$gettext('DJ/Streamer Buffer Time (Seconds)')" :description="$gettext('The number of seconds of signal to store in case of interruption. Set to the lowest value that your DJs can use without stream interruptions.')" /> <form-group-field v-if="enableAdvancedFeatures" id="edit_form_backend_dj_mount_point" class="col-md-6" :field="v$.backend_config.dj_mount_point" advanced :label="$gettext('Customize DJ/Streamer Mount Point')" :description="$gettext('If your streaming software requires a specific mount point path, specify it here. Otherwise, use the default.')" /> <form-group-field id="edit_form_backend_live_broadcast_text" class="col-md-6" :field="v$.backend_config.live_broadcast_text" :label="$gettext('Default Live Broadcast Message')" :description="$gettext('If a live DJ connects but has not yet sent metadata, this is the message that will display on player pages.')" /> </div> </template> </form-fieldset> <backend-disabled v-else /> </tab> </template> <script setup lang="ts"> import FormFieldset from "~/components/Form/FormFieldset.vue"; import FormGroupField from "~/components/Form/FormGroupField.vue"; import {BackendAdapter} from "~/entities/RadioAdapters"; import FormGroupCheckbox from "~/components/Form/FormGroupCheckbox.vue"; import BackendDisabled from "./Common/BackendDisabled.vue"; import {computed} from "vue"; import FormGroupMultiCheck from "~/components/Form/FormGroupMultiCheck.vue"; import {useVModel} from "@vueuse/core"; import {useVuelidateOnFormTab} from "~/functions/useVuelidateOnFormTab"; import {numeric} from "@vuelidate/validators"; import {useAzuraCast} from "~/vendor/azuracast"; import Tab from "~/components/Common/Tab.vue"; import BitrateOptions from "~/components/Common/BitrateOptions.vue"; const props = defineProps({ form: { type: Object, required: true }, station: { type: Object, required: true } }); const {enableAdvancedFeatures} = useAzuraCast(); const emit = defineEmits(['update:form']); const form = useVModel(props, 'form', emit); const {v$, tabClass} = useVuelidateOnFormTab( computed(() => { let validations: { [key: string | number]: any } = { enable_streamers: {}, disconnect_deactivate_streamer: {}, backend_config: { record_streams: {}, record_streams_format: {}, record_streams_bitrate: {}, dj_buffer: {numeric}, live_broadcast_text: {} } }; if (enableAdvancedFeatures) { validations = { ...validations, backend_config: { ...validations.backend_config, dj_port: {numeric}, dj_mount_point: {}, } }; } return validations; }), form, () => { let blankForm: { [key: string | number]: any } = { enable_streamers: false, disconnect_deactivate_streamer: 0, backend_config: { record_streams: false, record_streams_format: 'mp3', record_streams_bitrate: 128, dj_buffer: 5, live_broadcast_text: 'Live Broadcast' } }; if (enableAdvancedFeatures) { blankForm = { ...blankForm, backend_config: { ...blankForm.backend_config, dj_port: '', dj_mount_point: '/', } } } return blankForm; } ); const isBackendEnabled = computed(() => { return form.value.backend_type !== BackendAdapter.None; }); const tabClassWithBackend = computed(() => { if (tabClass.value) { return tabClass.value; } return (isBackendEnabled.value) ? null : 'text-muted'; }); const recordStreamsOptions = computed(() => { return [ { text: 'MP3', value: 'mp3', }, { text: 'OGG Vorbis', value: 'ogg', }, { text: 'OGG Opus', value: 'opus', }, { text: 'AAC+ (MPEG4 HE-AAC v2)', value: 'aac' } ]; }); </script> ```
/content/code_sandbox/frontend/components/Admin/Stations/Form/StreamersForm.vue
vue
2016-04-30T21:41:23
2024-08-16T18:27:26
AzuraCast
AzuraCast/AzuraCast
2,978
1,749