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 #61

Merged
merged 1 commit into from
Jan 15, 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/Stations/Form/BackendForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ const emit = defineEmits<FormTabEmits>();

const {enableAdvancedFeatures} = useAzuraCast();

const {v$, tabClass} = useVuelidateOnFormTab(
const {form, v$, tabClass} = useVuelidateOnFormTab(
props,
emit,
computed(() => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/Admin/Stations/Form/FrontendForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ const emit = defineEmits<FormTabEmits>();

const {enableAdvancedFeatures} = useAzuraCast();

const {v$, tabClass} = useVuelidateOnFormTab(
const {form, v$, tabClass} = useVuelidateOnFormTab(
props,
emit,
computed(() => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/Admin/Stations/Form/RequestsForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ interface StationRequestsFormProps extends FormTabProps {
const props = defineProps<StationRequestsFormProps>();
const emit = defineEmits<FormTabEmits>();

const {v$, tabClass} = useVuelidateOnFormTab(
const {form, v$, tabClass} = useVuelidateOnFormTab(
props,
emit,
{
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/Admin/Stations/Form/StreamersForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const emit = defineEmits<FormTabEmits>();

const {enableAdvancedFeatures} = useAzuraCast();

const {v$, tabClass} = useVuelidateOnFormTab(
const {form, v$, tabClass} = useVuelidateOnFormTab(
props,
emit,
computed(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ import Tab from "~/components/Common/Tab.vue";
const props = defineProps<FormTabProps>();
const emit = defineEmits<FormTabEmits>();

const {v$, tabClass} = useVuelidateOnFormTab(
const {form, v$, tabClass} = useVuelidateOnFormTab(
props,
emit,
{
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/Common/AlbumArt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {useLightbox} from "~/vendor/lightbox";
const props = withDefaults(
defineProps<{
src: string,
width: number
width?: number
}>(),
{
width: 40
Expand Down
21 changes: 7 additions & 14 deletions frontend/components/Common/Tab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,15 @@
</template>

<script setup lang="ts">
import {useTabChild} from "~/functions/tabs.ts";
import {TabChildProps, useTabChild} from "~/functions/tabs.ts";

const props = defineProps({
id: {
type: [String, Number],
default: null
},
label: {
type: String,
required: true
},
itemHeaderClass: {
type: [String, Function, Array],
default: () => null
const props = withDefaults(
defineProps<TabChildProps>(),
{
id: null,
itemHeaderClass: null,
}
});
);

const {computedId, isActive, isLazy} = useTabChild(props);
</script>
27 changes: 9 additions & 18 deletions frontend/components/Common/Tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,17 @@

<script setup lang="ts">
import {onMounted, ref} from "vue";
import {useTabParent} from "~/functions/tabs.ts";
import {TabParentProps, useTabParent} from "~/functions/tabs.ts";

const props = defineProps({
modelValue: {
type: String,
default: null
},
navTabsClass: {
type: [String, Function, Array],
default: () => 'nav-tabs'
},
contentClass: {
type: [String, Function, Array],
default: () => 'mt-3'
},
destroyOnHide: {
type: Boolean,
default: false
const props = withDefaults(
defineProps<TabParentProps>(),
{
modelValue: null,
navTabsClass: 'nav-tabs',
contentClass: 'mt-3',
destroyOnHide: false,
}
});
);

const emit = defineEmits(['update:modelValue']);

Expand Down
39 changes: 15 additions & 24 deletions frontend/components/Stations/Media.vue
Original file line number Diff line number Diff line change
Expand Up @@ -279,31 +279,22 @@ import useStationDateTimeFormatter from "~/functions/useStationDateTimeFormatter
import {ApiFileList, CustomField, FileTypes} from "~/entities/ApiInterfaces.ts";
import {DataTableTemplateRef} from "~/functions/useHasDatatable.ts";

const props = defineProps({
initialPlaylists: {
type: Array,
required: false,
default: () => []
},
customFields: {
type: Array,
required: false,
default: () => []
},
validMimeTypes: {
type: Array,
required: false,
default: () => []
},
showSftp: {
type: Boolean,
default: true
},
supportsImmediateQueue: {
type: Boolean,
required: true
const props = withDefaults(
defineProps<{
initialPlaylists?: any[], // TODO
customFields?: any[], // TODO
validMimeTypes?: string[],
showSftp?: boolean,
supportsImmediateQueue?: boolean,
}>(),
{
initialPlaylists: () => [],
customFields: () => [],
validMimeTypes: () => [],
showSftp: true,
supportsImmediateQueue: true
}
});
);

const listUrl = getStationApiUrl('/files/list');
const batchUrl = getStationApiUrl('/files/batch');
Expand Down
31 changes: 7 additions & 24 deletions frontend/components/Stations/Media/MediaToolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -220,30 +220,13 @@ import useHandleBatchResponse from "~/components/Stations/Media/useHandleBatchRe
import {useNotify} from "~/functions/useNotify.ts";
import {useDialog} from "~/functions/useDialog.ts";

const props = defineProps({
currentDirectory: {
type: String,
required: true
},
selectedItems: {
type: Object,
required: true
},
playlists: {
type: Array,
default: () => {
return [];
}
},
batchUrl: {
type: String,
required: true
},
supportsImmediateQueue: {
type: Boolean,
required: true
}
});
const props = defineProps<{
currentDirectory: string,
selectedItems: object, // TODO
playlists?: any[], // TODO
batchUrl: string,
supportsImmediateQueue: boolean
}>();

const emit = defineEmits(['relist', 'add-playlist', 'move-files', 'create-directory']);

Expand Down
24 changes: 6 additions & 18 deletions frontend/components/Stations/Media/MoveFilesModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,12 @@ import {ModalTemplateRef, useHasModal} from "~/functions/useHasModal.ts";
import useHandleBatchResponse from "~/components/Stations/Media/useHandleBatchResponse.ts";
import {useAsyncState} from "@vueuse/core";

const props = defineProps({
selectedItems: {
type: Object,
required: true
},
currentDirectory: {
type: String,
required: true
},
batchUrl: {
type: String,
required: true
},
listDirectoriesUrl: {
type: String,
required: true
}
});
const props = defineProps<{
selectedItems: object, // TODO
currentDirectory: string,
batchUrl: string,
listDirectoriesUrl: string,
}>();

const emit = defineEmits(['relist']);

Expand Down
4 changes: 2 additions & 2 deletions frontend/components/Stations/Mounts/Form/AutoDj.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const emit = defineEmits<FormTabEmits>();

const {maxBitrate} = useAzuraCastStation();

const {v$, tabClass} = useVuelidateOnFormTab(
const {form, v$, tabClass} = useVuelidateOnFormTab(
props,
emit,
{
Expand Down Expand Up @@ -97,6 +97,6 @@ const formatOptions = [
];

const formatSupportsBitrateOptions = computed(() => {
return (props.form.autodj_format !== 'flac');
return (form.value.autodj_format !== 'flac');
});
</script>
2 changes: 1 addition & 1 deletion frontend/components/Stations/Remotes/Form/AutoDj.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const emit = defineEmits<FormTabEmits>();

const {maxBitrate} = useAzuraCastStation();

const {v$, tabClass} = useVuelidateOnFormTab(
const {form, v$, tabClass} = useVuelidateOnFormTab(
props,
emit,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@

<script lang="ts">
export interface DateRange {
start: Date,
end: Date,
startDate: Date,
endDate: Date,
}
</script>

Expand Down
6 changes: 3 additions & 3 deletions frontend/components/Stations/Webhooks/Form/BasicInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ const triggerOptions = computed(() => {

const {$gettext, interpolate} = useTranslate();

const langSeconds = $gettext('%{ seconds } seconds');
const langMinutes = $gettext('%{ minutes } minutes');
const langHours = $gettext('%{ hours } hours');
const langSeconds = $gettext('%{seconds} seconds');
const langMinutes = $gettext('%{minutes} minutes');
const langHours = $gettext('%{hours} hours');

const rateLimitOptions = [
{
Expand Down
52 changes: 43 additions & 9 deletions frontend/functions/tabs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
import {InjectionKey, UnwrapNestedRefs, computed, inject, onBeforeMount, onBeforeUnmount, provide, reactive, watch} from "vue";
import {
computed,
inject,
InjectionKey,
onBeforeMount,
onBeforeUnmount,
provide,
reactive,
UnwrapNestedRefs,
watch
} from "vue";

type VueClass = string | Record<string, boolean> | VueClass[];

export interface TabChildProps {
id?: string | number,
label: string,
itemHeaderClass?: VueClass
}

export interface TabParentProps {
modelValue?: string,
navTabsClass?: VueClass,
contentClass?: VueClass,
destroyOnHide?: boolean
}

interface TabChild {
computedId: string,
Expand All @@ -16,7 +41,12 @@ interface TabParent {

const tabStateKey: InjectionKey<UnwrapNestedRefs<TabParent>> = Symbol() as InjectionKey<UnwrapNestedRefs<TabParent>>;

export function useTabParent(props) {
export function useTabParent(originalProps: TabParentProps) {
const props: TabParentProps = {
destroyOnHide: false,
...originalProps,
}

const state = reactive<TabParent>({
lazy: props.destroyOnHide,
active: null,
Expand All @@ -38,31 +68,35 @@ export function useTabParent(props) {
return state;
}

export function useTabChild(props) {
export function useTabChild(props: TabChildProps) {
const tabState = inject(tabStateKey);

const computedId = props.id ?? props.label.toLowerCase().replace(/ /g, "-");
const computedId = computed(() => {
return String(
props.id ?? props.label.toLowerCase().replace(/ /g, "-")
);
});

const isLazy = tabState.lazy;

const isActive = computed(() => {
return tabState.active === computedId;
return tabState.active === computedId.value;
});

watch(
() => ({...props}),
() => tabState.update(computedId, {
() => tabState.update(computedId.value, {
...props,
computedId: computedId
computedId: computedId.value
})
);

onBeforeMount(() => tabState.add({
...props,
computedId: computedId
computedId: computedId.value
}));

onBeforeUnmount(() => tabState.delete(computedId));
onBeforeUnmount(() => tabState.delete(computedId.value));

return {
computedId,
Expand Down
3 changes: 2 additions & 1 deletion frontend/functions/useChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export interface ChartProps<
options?: ChartConfiguration<TType, TData, TLabel> | ChartConfigurationCustomTypesPerDataset<TType, TData, TLabel>,
data?: any[],
aspectRatio?: number,
alt?: ChartAltData[]
alt?: ChartAltData[],
labels?: Array<any>
}

export const chartProps = {
Expand Down
6 changes: 4 additions & 2 deletions frontend/functions/useResettableRef.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import {MaybeRefOrGetter, Ref, ref, toValue} from "vue";
import {cloneDeep} from "lodash";

export function useResettableRef<T extends object = object>(original: MaybeRefOrGetter<T>): {
export function useResettableRef<T = any>(
original: MaybeRefOrGetter<T>
): {
record: Ref<T>,
reset(): void
} {
const record = ref<T>(cloneDeep(toValue(original)));
const record = ref(cloneDeep(toValue(original))) as Ref<T>;

const reset = () => {
record.value = cloneDeep(toValue(original));
Expand Down
Loading
Loading