Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from AzuraCast:main #69

Merged
merged 3 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/components/Admin/Backups/ConfigureModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</div>

<div
v-if="v$.backup_enabled.$model"
v-if="form.backup_enabled"
class="row g-3"
>
<form-group-field
Expand Down
49 changes: 30 additions & 19 deletions frontend/components/Admin/StorageLocations/EditModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ import {
ModalFormTemplateRef,
useBaseEditModal
} from "~/functions/useBaseEditModal";
import {computed, ref} from "vue";
import {computed, nextTick, ref, watch} 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";
import mergeExisting from "~/functions/mergeExisting.ts";

interface StorageLocationsEditModalProps extends BaseEditModalProps {
type: string
Expand All @@ -60,6 +61,7 @@ const {
isEditMode,
form,
v$,
resetForm,
clearContents,
create,
edit,
Expand All @@ -69,27 +71,21 @@ const {
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,
adapter: {},
},
{
adapter: 'local',
},
{
populateForm: (data, formRef) => {
formRef.value.adapter = data.adapter;

nextTick(() => {
resetForm();
formRef.value = mergeExisting(formRef.value, data);
});
},
getSubmittableFormData: (formRef, isEditModeRef) => {
if (isEditModeRef.value) {
return formRef.value;
Expand All @@ -103,6 +99,21 @@ const {
}
);

watch(
() => form.value.adapter,
() => {
if (!isEditMode.value) {
const originalForm = form.value;

nextTick(() => {
resetForm();
form.value = mergeExisting(form.value, originalForm);
});
}

}
)

const {$gettext} = useTranslate();

const langTitle = computed(() => {
Expand Down
5 changes: 5 additions & 0 deletions frontend/components/Admin/StorageLocations/Form/Dropbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ const {form, v$, tabClass} = useVuelidateOnFormTab(
dropboxAppSecret: {},
dropboxAuthToken: {required},
},
{
dropboxAppKey: null,
dropboxAppSecret: null,
dropboxAuthToken: null,
}
);

const baseAuthUrl = 'https://www.dropbox.com/oauth2/authorize';
Expand Down
9 changes: 9 additions & 0 deletions frontend/components/Admin/StorageLocations/Form/S3.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ const {v$, tabClass} = useVuelidateOnFormTab(
s3Bucket: {required},
s3Endpoint: {required},
s3UsePathStyle: {}
},
{
s3CredentialKey: null,
s3CredentialSecret: null,
s3Region: null,
s3Version: 'latest',
s3Bucket: null,
s3Endpoint: null,
s3UsePathStyle: false,
}
);
</script>
8 changes: 8 additions & 0 deletions frontend/components/Admin/StorageLocations/Form/Sftp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ const {v$, tabClass} = useVuelidateOnFormTab(
sftpPassword: {},
sftpPrivateKey: {},
sftpPrivateKeyPassPhrase: {}
},
{
sftpHost: null,
sftpPort: '22',
sftpUsername: null,
sftpPassword: null,
sftpPrivateKey: null,
sftpPrivateKeyPassPhrase: null,
}
);
</script>
17 changes: 14 additions & 3 deletions frontend/components/Common/CodemirrorTextarea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

<script setup lang="ts">
import CodeMirror from "vue-codemirror6";
import {useVModel} from "@vueuse/core";
import {computed} from "vue";
import {css} from "@codemirror/lang-css";
import {javascript} from "@codemirror/lang-javascript";
Expand All @@ -18,15 +17,27 @@ import {liquidsoap} from "codemirror-lang-liquidsoap";
import useTheme from "~/functions/theme";

const props = defineProps<{
modelValue: string | null,
modelValue?: string | number | null,
mode: string
}>();

const emit = defineEmits<{
(e: 'update:modelValue', modelValue: string | null): void
}>();

const textValue = useVModel(props, 'modelValue', emit);
const textValue = computed({
get() {
const value = props.modelValue ?? null;
if (value === null) {
return "";
}

return String(value);
},
set(newValue) {
emit('update:modelValue', newValue);
}
});

const lang = computed(() => {
switch (props.mode) {
Expand Down
15 changes: 13 additions & 2 deletions frontend/components/Public/WebDJ/PlaylistPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ const onFileSelected = (e: Event) => {
const eventTarget = e.target as HTMLInputElement;

forEach(eventTarget.files, (file) => {
// @ts-expect-error Weird custom function from taglib. Don't worry about it.
file.readTaglibMetadata((data) => {
files.value.push({
file: file,
Expand All @@ -283,7 +284,12 @@ const onFileSelected = (e: Event) => {
});
}

const selectFile = (options = {}) => {
interface PlayOptions {
isAutoPlay?: boolean,
fileIndex?: number
}

const selectFile = (options: PlayOptions = {}) => {
if (files.value.length === 0) {
return;
}
Expand Down Expand Up @@ -313,7 +319,12 @@ const selectFile = (options = {}) => {
return files.value[fileIndex.value];
};

const play = (options = {}) => {
const play = (initialOptions: PlayOptions = {}) => {
const options = {
isAutoPlay: false,
...initialOptions,
};

const file = selectFile(options);

if (!file) {
Expand Down
6 changes: 5 additions & 1 deletion frontend/components/Public/WebDJ/useWebDjSource.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import {useInjectWebDjNode} from "~/components/Public/WebDJ/useWebDjNode";

interface StreamAudioSourceWithStop extends MediaStreamAudioSourceNode {
stop?(): void
}

export function useWebDjSource() {
const {context} = useInjectWebDjNode();

Expand Down Expand Up @@ -50,7 +54,7 @@ export function useWebDjSource() {
deviceId: audioDeviceId
}
}).then((stream) => {
const source = context.value.createMediaStreamSource(stream);
const source: StreamAudioSourceWithStop = context.value.createMediaStreamSource(stream);
source.stop = () => {
const ref = stream.getAudioTracks();
return (ref !== null)
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/Stations/Media/EditModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const {
reset();
},
populateForm: (data, form) => {
record.value = mergeExisting(record.value, data);
record.value = mergeExisting(record.value, data as typeof record.value);

const newForm = mergeExisting(form.value, data);
newForm.playlists = map(data.playlists, 'id');
Expand Down
4 changes: 3 additions & 1 deletion frontend/components/Stations/Mounts/EditModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ const {
props,
emit,
$modal,
{},
{
intro_file: {}
},
{
intro_file: null
},
Expand Down
4 changes: 3 additions & 1 deletion frontend/components/Stations/Playlists/EditModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ const {
props,
emit,
$modal,
{},
{
schedule_items: {}
},
{
schedule_items: []
},
Expand Down
7 changes: 5 additions & 2 deletions frontend/components/Stations/Podcasts/EpisodeEditModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ const {
props,
emit,
$modal,
{},
{
artwork_file: {},
media_file: {}
},
{
artwork_file: null,
media_file: null
Expand All @@ -102,7 +105,7 @@ const {
reset();
},
populateForm: (data, formRef) => {
record.value = mergeExisting(record.value, data);
record.value = mergeExisting(record.value, data as typeof record.value);
formRef.value = mergeExisting(formRef.value, data);
},
},
Expand Down
4 changes: 3 additions & 1 deletion frontend/components/Stations/Podcasts/PodcastEditModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ const {
props,
emit,
$modal,
{},
{
artwork_file: {},
},
{
artwork_file: null
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ const {v$, tabClass} = useVuelidateOnFormTab(
public_custom_html: {}
},
},
{
() => ({
branding_config: {
public_custom_html: ''
}
}
})
);
</script>
7 changes: 5 additions & 2 deletions frontend/components/Stations/Streamers/EditModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ const {
props,
emit,
$modal,
{},
{
schedule_items: {},
artwork_file: {},
},
{
schedule_items: [],
artwork_file: null
Expand All @@ -87,7 +90,7 @@ const {
reset();
},
populateForm: (data, formRef) => {
record.value = data;
record.value = mergeExisting(record.value, data);
formRef.value = mergeExisting(formRef.value, data);
},
},
Expand Down
22 changes: 14 additions & 8 deletions frontend/components/Stations/Webhooks/EditModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import GetMeRadio from "~/components/Stations/Webhooks/Form/GetMeRadio.vue";
import RadioReg from "~/components/Stations/Webhooks/Form/RadioReg.vue";
import GroupMe from "~/components/Stations/Webhooks/Form/GroupMe.vue";
import Bluesky from "~/components/Stations/Webhooks/Form/Bluesky.vue";
import mergeExisting from "~/functions/mergeExisting.ts";

interface WebhookEditModalProps extends BaseEditModalProps {
nowPlayingUrl: string,
Expand Down Expand Up @@ -118,16 +119,21 @@ const {
props,
emit,
$modal,
{},
{},
{
type: {}
},
{
type: null
},
{
populateForm: (data, formRef) => {
type.value = data.type;
formRef.value = {
name: data.name,
triggers: data.triggers,
config: data.config
};

// Wait for type-specific components to mount.
nextTick(() => {
resetForm();
formRef.value = mergeExisting(formRef.value, data);
});
},
getSubmittableFormData(formRef, isEditModeRef) {
const formData = formRef.value;
Expand Down Expand Up @@ -156,7 +162,7 @@ const clearContents = () => {
originalClearContents();
};

const setType = (newType) => {
const setType = (newType: WebhookType) => {
type.value = newType;
nextTick(resetForm);
};
Expand Down
1 change: 1 addition & 0 deletions frontend/components/Stations/Webhooks/Form/BasicInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
:description="$gettext('This web hook will only run when the selected event(s) occur on this specific station.')"
/>

<!-- @vue-expect-error Vuelidate mistyping -->
<form-group-select
id="form_config_rate_limit"
class="col-md-5"
Expand Down
4 changes: 2 additions & 2 deletions frontend/components/Stations/Webhooks/Form/Bluesky.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ const {form, v$, tabClass} = useVuelidateOnFormTab(
app_password: {required}
}
},
{
() => ({
config: {
handle: '',
app_password: ''
}
}
})
);
</script>
Loading
Loading