Skip to content

Commit

Permalink
More TS bugfixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
BusterNeece committed Jan 16, 2025
1 parent b006df1 commit 08ebd32
Show file tree
Hide file tree
Showing 25 changed files with 81 additions and 50 deletions.
2 changes: 1 addition & 1 deletion frontend/components/Admin/Stations/Form/ProfileForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const emit = defineEmits<FormTabEmits>();
const {enableAdvancedFeatures} = useAzuraCast();
const {v$, tabClass} = useVuelidateOnFormTab(
const {form, v$, tabClass} = useVuelidateOnFormTab(
props,
emit,
computed(() => {
Expand Down
5 changes: 3 additions & 2 deletions frontend/components/Admin/Users.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ import useConfirmAndDelete from "~/functions/useConfirmAndDelete";
import CardPage from "~/components/Common/CardPage.vue";
import {getApiUrl} from "~/router";
import AddButton from "~/components/Common/AddButton.vue";
import {ComponentExposed} from "vue-component-type-helpers";
const props = defineProps<{
roles: object, // TODO
roles: Record<number, string>,
}>();
const listUrl = getApiUrl('/admin/users');
Expand All @@ -105,7 +106,7 @@ const fields: DataTableField[] = [
const $datatable = ref<DataTableTemplateRef>(null);
const {relist} = useHasDatatable($datatable);
const $editModal = ref<InstanceType<EditModal> | null>(null);
const $editModal = ref<ComponentExposed<typeof EditModal> | null>(null);
const {doCreate, doEdit} = useHasEditModal($editModal);
const {doDelete} = useConfirmAndDelete(
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/Admin/Users/EditModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {useTranslate} from "~/vendor/gettext";
import ModalForm from "~/components/Common/ModalForm.vue";
interface UsersEditModalProps extends BaseEditModalProps {
roles: object
roles: Record<number, string>
}
const props = defineProps<UsersEditModalProps>();
Expand Down
6 changes: 3 additions & 3 deletions frontend/components/Admin/menu.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {useTranslate} from "~/vendor/gettext.ts";
import {GlobalPermission, userAllowed} from "~/acl.ts";
import filterMenu, {MenuCategory, ReactiveMenu} from "~/functions/filterMenu.ts";
import filterMenu, {MenuCategory} from "~/functions/filterMenu.ts";
import {computed, reactive} from "vue";
import {IconGroups, IconRadio, IconRouter} from "~/components/Common/icons.ts";

export function useAdminMenu(): ReactiveMenu {
export function useAdminMenu(): MenuCategory[] {
const {$gettext} = useTranslate();

const menu: ReactiveMenu = reactive<Array<MenuCategory>>([
const menu: MenuCategory[] = reactive([
{
key: 'maintenance',
label: computed(() => $gettext('System Maintenance')),
Expand Down
4 changes: 2 additions & 2 deletions frontend/components/Common/Charts/ChartAltValues.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
</template>

<script setup lang="ts">
import ChartAltValues from "~/components/Common/Charts/ChartAltValues.vue";
import {ChartAltData} from "~/functions/useChart.ts";
const props = defineProps<{
alt: ChartAltValues[]
alt: ChartAltData[]
}>();
</script>
8 changes: 2 additions & 6 deletions frontend/components/Common/DateRangeDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface DateRange {
const props = defineProps<{
options?: Partial<VueDatePickerProps>,
modelValue: DateRange
modelValue?: DateRange
}>();
const emit = defineEmits(['update:modelValue']);
Expand Down Expand Up @@ -69,11 +69,7 @@ const dateRange = computed({
const {$gettext} = useTranslate();
const ranges = computed(() => {
let nowTz = DateTime.now();
if (props.options?.timezone) {
nowTz = nowTz.setZone(props.options.timezone);
}
const nowTz = DateTime.now().setZone(props.options?.timezone ?? "UTC");
const nowAtMidnightDate = nowTz.endOf('day').toJSDate();
return [
Expand Down
10 changes: 5 additions & 5 deletions frontend/components/Form/useFormField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ export function useFormField<T = ModelFormField>(

const model: WritableComputedRef<T, T> = computed({
get() {
return (field !== undefined)
? field.$model
return (props.field !== undefined)
? props.field.$model
: props.modelValue;
},
set(newValue) {
if (field !== undefined) {
field.$model = newValue;
if (props.field !== undefined) {
props.field.$model = newValue;
} else {
emit('update:modelValue', newValue);
}
Expand All @@ -66,7 +66,7 @@ export function useFormField<T = ModelFormField>(

const isRequired = computed(() => {
if (props.required) {
return required;
return props.required;
}

return (props.field !== undefined)
Expand Down
5 changes: 3 additions & 2 deletions frontend/components/Public/FullPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ 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 {ref, shallowRef} from "vue";
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.vue";
import {PlayerProps} from "~/components/Public/Player.vue";
import {ApiNowPlayingSongHistory} from "~/entities/ApiInterfaces.ts";
interface FullPlayerProps extends PlayerProps, RequestsProps {
stationName: string,
Expand All @@ -86,7 +87,7 @@ const props = withDefaults(
}
);
const history = ref({});
const history = shallowRef<ApiNowPlayingSongHistory[]>([]);
const onNowPlayingUpdate = (newNowPlaying) => {
history.value = newNowPlaying?.song_history;
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/Public/History.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ const props = withDefaults(
const {np} = useNowPlaying(props);
const history = computed(() => {
return np.value.song_history ?? {};
return np.value.song_history ?? [];
});
</script>
10 changes: 8 additions & 2 deletions frontend/components/Public/OnDemand.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,21 @@ import AlbumArt from "~/components/Common/AlbumArt.vue";
import {IconDownload} from "~/components/Common/icons";
import FullHeightCard from "~/components/Public/FullHeightCard.vue";
interface OnDemandCustomField {
display_key: string,
key: string,
label: string,
}
const props = withDefaults(
defineProps<{
listUrl: string,
stationName: string,
customFields?: object,
customFields?: OnDemandCustomField[],
showDownloadButton?: boolean
}>(),
{
customFields: () => ({}),
customFields: () => ([]),
showDownloadButton: false,
}
);
Expand Down
7 changes: 5 additions & 2 deletions frontend/components/Public/Player.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ import usePlayerVolume from "~/functions/usePlayerVolume";
import {usePlayerStore} from "~/functions/usePlayerStore.ts";
import {useEventListener} from "@vueuse/core";
import useShowVolume from "~/functions/useShowVolume.ts";
import {ApiNowPlaying} from "~/entities/ApiInterfaces.ts";
defineOptions({
inheritAttrs: false
Expand All @@ -174,7 +175,9 @@ const props = withDefaults(
}
);
const emit = defineEmits(['np_updated']);
const emit = defineEmits<{
(e: 'np_updated', np: ApiNowPlaying)
}>();
const {
np,
Expand Down Expand Up @@ -274,7 +277,7 @@ onMounted(() => {
document.dispatchEvent(new CustomEvent("player-ready"));
});
const onNowPlayingUpdated = (np_new) => {
const onNowPlayingUpdated = (np_new: ApiNowPlaying) => {
emit('np_updated', np_new);
// Set a "default" current stream if none exists.
Expand Down
5 changes: 3 additions & 2 deletions frontend/components/Public/Podcasts/Podcast.vue
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ import useStationDateTimeFormatter from "~/functions/useStationDateTimeFormatter
import PodcastCommon from "./PodcastCommon.vue";
import GridLayout from "~/components/Common/GridLayout.vue";
import {usePodcastGroupLayout} from "~/components/Public/Podcasts/usePodcastGroupLayout.ts";
import {ApiPodcast, ApiPodcastEpisode} from "~/entities/ApiInterfaces.ts";
const {groupLayout} = usePodcastGroupLayout();
Expand All @@ -191,15 +192,15 @@ const {params} = useRoute();
const podcastUrl = getStationApiUrl(`/public/podcast/${params.podcast_id}`);
const {axios} = useAxios();
const {state: podcast, isLoading} = useRefreshableAsyncState(
const {state: podcast, isLoading} = useRefreshableAsyncState<ApiPodcast>(
() => axios.get(podcastUrl.value).then((r) => r.data),
{},
);
const episodesUrl = getStationApiUrl(`/public/podcast/${params.podcast_id}/episodes`);
const {$gettext} = useTranslate();
const fields: DataTableField[] = [
const fields: DataTableField<ApiPodcastEpisode>[] = [
{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},
Expand Down
3 changes: 2 additions & 1 deletion frontend/components/Public/Podcasts/PodcastList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,15 @@ 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";
import {ApiPodcast} from "~/entities/ApiInterfaces.ts";
const {groupLayout} = usePodcastGroupLayout();
const apiUrl = getStationApiUrl('/public/podcasts');
const {$gettext} = useTranslate();
const fields: DataTableField[] = [
const fields: DataTableField<ApiPodcast>[] = [
{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'}
Expand Down
3 changes: 2 additions & 1 deletion frontend/components/Stations/Media/Form/CustomFields.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
<script setup lang="ts">
import FormGroupField from "~/components/Form/FormGroupField.vue";
import {VuelidateObject} from "~/functions/useVuelidateOnForm.ts";
import {CustomField} from "~/entities/ApiInterfaces.ts";
const props = defineProps<{
form: VuelidateObject,
customFields: object, // TODO
customFields: CustomField[],
}>();
</script>
2 changes: 1 addition & 1 deletion frontend/components/Stations/Media/MoveFilesModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const fields: DataTableField[] = [
const langHeader = computed(() => {
return $gettext(
'Move %{num} File(s) to',
{num: props.selectedItems.all.length}
{num: String(props.selectedItems.all.length)}
);
});
Expand Down
3 changes: 2 additions & 1 deletion frontend/components/Stations/Media/NewDirectoryModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {useTranslate} from "~/vendor/gettext";
import Modal from "~/components/Common/Modal.vue";
import InvisibleSubmitButton from "~/components/Common/InvisibleSubmitButton.vue";
import {ModalTemplateRef, useHasModal} from "~/functions/useHasModal.ts";
import {ComponentExposed} from "vue-component-type-helpers";
const props = defineProps<{
currentDirectory: string,
Expand All @@ -72,7 +73,7 @@ const onHidden = () => {
resetForm();
}
const $field = ref<InstanceType<typeof FormGroupField> | null>(null);
const $field = ref<ComponentExposed<typeof FormGroupField> | null>(null);
const onShown = () => {
nextTick(() => {
Expand Down
3 changes: 2 additions & 1 deletion frontend/components/Stations/Media/RenameModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {useAxios} from "~/vendor/axios";
import Modal from "~/components/Common/Modal.vue";
import InvisibleSubmitButton from "~/components/Common/InvisibleSubmitButton.vue";
import {ModalTemplateRef, useHasModal} from "~/functions/useHasModal.ts";
import {ComponentExposed} from "vue-component-type-helpers";
const props = defineProps<{
renameUrl: string
Expand Down Expand Up @@ -74,7 +75,7 @@ const open = (filePath: string): void => {
show();
}
const $field = ref<InstanceType<typeof FormGroupField> | null>(null);
const $field = ref<ComponentExposed<typeof FormGroupField> | null>(null);
const onShown = () => {
nextTick(() => {
Expand Down
11 changes: 10 additions & 1 deletion frontend/components/Stations/Playlists/Form/ScheduleRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,18 @@ import FormGroupMultiCheck from "~/components/Form/FormGroupMultiCheck.vue";
import TimeZone from "~/components/Stations/Common/TimeZone.vue";
import {IconRemove} from "~/components/Common/icons";
interface PlaylistScheduleRow {
start_time: number,
end_time: number,
start_date: string,
end_date: string,
days: number[],
loop_once: boolean,
}
const props = defineProps<{
index: number,
row: object
row: PlaylistScheduleRow
}>();
const emit = defineEmits(['remove']);
Expand Down
3 changes: 2 additions & 1 deletion frontend/components/Stations/Profile/HeaderPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ import Icon from '~/components/Common/Icon.vue';
import PlayButton from "~/components/Common/PlayButton.vue";
import {StationPermission, userAllowedForStation} from "~/acl";
import {IconEdit} from "~/components/Common/icons";
import {ApiNowPlayingStation} from "~/entities/ApiInterfaces.ts";
defineOptions({
inheritAttrs: false
});
interface ProfileHeaderPanelProps extends ProfileHeaderPanelParentProps {
station: object
station: ApiNowPlayingStation
}
const props = defineProps<ProfileHeaderPanelProps>();
Expand Down
3 changes: 2 additions & 1 deletion frontend/components/Stations/Profile/UpdateMetadataModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import InvisibleSubmitButton from "~/components/Common/InvisibleSubmitButton.vue
import {ModalTemplateRef, useHasModal} from "~/functions/useHasModal.ts";
import {getStationApiUrl} from "~/router.ts";
import InfoCard from "~/components/Common/InfoCard.vue";
import {ComponentExposed} from "vue-component-type-helpers";
const updateMetadataUrl = getStationApiUrl('/nowplaying/update');
Expand All @@ -87,7 +88,7 @@ const onHidden = () => {
resetForm();
}
const $field = ref<InstanceType<typeof FormGroupField> | null>(null);
const $field = ref<ComponentExposed<typeof FormGroupField> | null>(null);
const onShown = () => {
nextTick(() => {
Expand Down
4 changes: 2 additions & 2 deletions frontend/components/Stations/Reports/Listeners/MapPoint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<script setup lang="ts">
import {inject, onUnmounted, ref, ShallowRef, watch} from 'vue';
import {LatLngTuple, Map, marker} from 'leaflet';
import {LatLngTuple, Map, marker, Popup} from 'leaflet';
const props = defineProps<{
position: LatLngTuple
Expand All @@ -18,7 +18,7 @@ const map = $map.value;
const mapMarker = marker(props.position);
mapMarker.addTo(map);
const popup = new L.Popup();
const popup = new Popup();
const $content = ref<HTMLDivElement | null>(null);
watch(
Expand Down
10 changes: 9 additions & 1 deletion frontend/components/Stations/Streamers/Form/ScheduleRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,17 @@ import FormGroupMultiCheck from "~/components/Form/FormGroupMultiCheck.vue";
import TimeZone from "~/components/Stations/Common/TimeZone.vue";
import {IconRemove} from "~/components/Common/icons";
interface PlaylistScheduleRow {
start_time: number,
end_time: number,
start_date: string,
end_date: string,
days: number[],
}
const props = defineProps<{
index: number,
row: object,
row: PlaylistScheduleRow,
}>();
const emit = defineEmits(['remove']);
Expand Down
Loading

0 comments on commit 08ebd32

Please sign in to comment.