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

Merged
merged 2 commits into from
Feb 8, 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
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default defineConfigWithVueTs(
varsIgnorePattern: "^_",
}],

"@typescript-eslint/no-redundant-type-constituents": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/prefer-promise-reject-errors": "off",
"@typescript-eslint/no-unsafe-enum-comparison": "off",
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/Admin/Backups.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const settingsLoading = ref(false);

const blankSettings = {
backupEnabled: false,
backupLastRun: null,
backupLastRun: 0,
backupLastOutput: '',
};

Expand Down
2 changes: 1 addition & 1 deletion frontend/components/Admin/Debug/TaskOutput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const getBadgeLabel = (logLevel: keyof typeof badgeLabels) => {
return get(badgeLabels, logLevel, badgeLabels[100]);
};

const dump = (value) => {
const dump = (value: any) => {
return JSON.stringify(value);
}
</script>
31 changes: 2 additions & 29 deletions frontend/components/Admin/Index/NetworkStatsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,14 @@
{{ $gettext('Received') }}
</h5>

<network-stats-table
:fields="getNetworkInterfaceTableFields(netInterface.received)"
:data="getNetworkInterfaceTableItems(netInterface.received)"
/>
<network-stats-table :row="netInterface.received"/>
</div>
<div class="col">
<h5 class="mb-1 text-center">
{{ $gettext('Transmitted') }}
</h5>

<network-stats-table
:fields="getNetworkInterfaceTableFields(netInterface.transmitted)"
:data="getNetworkInterfaceTableItems(netInterface.transmitted)"
/>
<network-stats-table :row="netInterface.transmitted"/>
</div>
</div>
</tab>
Expand All @@ -44,31 +38,10 @@
<script setup lang="ts">
import Tab from "~/components/Common/Tab.vue";
import Tabs from "~/components/Common/Tabs.vue";
import {isObject} from "lodash";
import NetworkStatsTable from "~/components/Admin/Index/NetworkStatsTable.vue";
import {AdminStats} from "~/components/Admin/Index.vue";

defineProps<{
stats: AdminStats
}>();

const getNetworkInterfaceTableFields = (interfaceData: object) => Object.keys(interfaceData);

const getNetworkInterfaceTableItems = (interfaceData: object) => {
const item = {};

Object.entries(interfaceData).forEach((data) => {
const key = data[0];
let value: any = data[1];

if (isObject(value) && "readable" in value) {
// eslint-disable-next-line @typescript-eslint/no-base-to-string,@typescript-eslint/restrict-plus-operands
value = value.readable + '/s';
}

item[key] = value;
});

return [item];
};
</script>
29 changes: 25 additions & 4 deletions frontend/components/Admin/Index/NetworkStatsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,31 @@
</template>

<script setup lang="ts">
import {get} from "lodash";
import {get, isObject, mapValues} from "lodash";
import {computed} from "vue";

defineProps<{
fields: string[],
data: Record<string, any>,
const props = defineProps<{
row: object,
}>();

const fields = computed<string[]>(() => {
return Object.keys(props.row);
});

interface HasReadable {
readable: string
}

const data = computed(() => {
const items = mapValues(
props.row,
(value: HasReadable | string) => {
return (isObject(value) && value.readable)
? value.readable + '/s'
: value;
}
);

return [items];
});
</script>
3 changes: 2 additions & 1 deletion frontend/components/Admin/Permissions/Form/GlobalForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {useVuelidateOnFormTab} from "~/functions/useVuelidateOnFormTab.ts";
import {SimpleFormOptionInput} from "~/functions/objectToFormOptions.ts";
import {Permission} from "~/components/Admin/Permissions/EditModal.vue";
import {required} from "@vuelidate/validators";
import {DeepPartial} from "utility-types";

defineProps<{
globalPermissions: SimpleFormOptionInput,
Expand All @@ -44,7 +45,7 @@ const {v$} = useVuelidateOnFormTab(
'global': {},
}
},
() => ({
(): DeepPartial<Permission> => ({
'name': '',
'permissions': {
'global': [],
Expand Down
12 changes: 4 additions & 8 deletions frontend/components/Admin/Stations/Form/AdminForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ import {useAzuraCast} from "~/vendor/azuracast";
import Tab from "~/components/Common/Tab.vue";
import {getApiUrl} from "~/router";
import {GenericForm} from "~/entities/Forms.ts";
import {SimpleFormOptionInput} from "~/functions/objectToFormOptions.ts";
import {omit} from "lodash";

const props = defineProps<{
isEditMode: boolean,
Expand Down Expand Up @@ -157,18 +159,12 @@ const storageLocationOptions = reactive({
podcasts_storage_location: {}
});

const filterLocations = (group) => {
const filterLocations = (group: SimpleFormOptionInput): SimpleFormOptionInput => {
if (!props.isEditMode) {
return group;
}

const newGroup = {};
for (const oldKey in group) {
if (oldKey !== "") {
newGroup[oldKey] = group[oldKey];
}
}
return newGroup;
return omit(group, [""]);
}

const {axios} = useAxios();
Expand Down
9 changes: 5 additions & 4 deletions frontend/components/Admin/StorageLocations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ import useConfirmAndDelete from "~/functions/useConfirmAndDelete";
import CardPage from "~/components/Common/CardPage.vue";
import {getApiUrl} from "~/router";
import AddButton from "~/components/Common/AddButton.vue";
import {ApiAdminStorageLocation} from "~/entities/ApiInterfaces.ts";

const activeType = ref('station_media');

Expand All @@ -124,7 +125,7 @@ const listUrlForType = computed(() => {

const {$gettext} = useTranslate();

const fields: DataTableField[] = [
const fields: DataTableField<ApiAdminStorageLocation>[] = [
{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},
Expand Down Expand Up @@ -156,12 +157,12 @@ const {relist} = useHasDatatable($dataTable);
const $editModal = useTemplateRef('$editModal');
const {doCreate, doEdit} = useHasEditModal($editModal);

const setType = (type) => {
const setType = (type: string) => {
activeType.value = type;
void nextTick(relist);
};

const getAdapterName = (adapter) => {
const getAdapterName = (adapter: string) => {
switch (adapter) {
case 'local':
return $gettext('Local');
Expand All @@ -177,7 +178,7 @@ const getAdapterName = (adapter) => {
}
};

const getSpaceUsed = (item) => {
const getSpaceUsed = (item: ApiAdminStorageLocation) => {
return (item.storageAvailable)
? item.storageUsed + ' / ' + item.storageAvailable
: item.storageUsed;
Expand Down
1 change: 0 additions & 1 deletion frontend/components/Common/Charts/HourChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ useChart<'bar'>(
{
type: 'bar',
options: {
aspectRatio: props.aspectRatio,
scales: {
x: {
title: {
Expand Down
5 changes: 1 addition & 4 deletions frontend/components/Common/Charts/PieChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ useChart<'pie'>(
props,
$canvas,
{
type: 'pie',
options: {
aspectRatio: props.aspectRatio,
}
type: 'pie'
}
);
</script>
1 change: 0 additions & 1 deletion frontend/components/Common/Charts/TimeSeriesChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ useChart<'line'>(
computed(() => ({
type: 'line',
options: {
aspectRatio: props.aspectRatio ?? 2,
datasets: {
line: {
spanGaps: true,
Expand Down
26 changes: 13 additions & 13 deletions frontend/components/Common/DataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,13 @@ const slots = defineSlots<{
'empty'?: () => any,
}>()

const emit = defineEmits([
'refresh-clicked',
'refreshed',
'row-selected',
'filtered',
'data-loaded'
]);
const emit = defineEmits<{
(e: 'refresh-clicked', event: MouseEvent): void,
(e: 'refreshed'): void,
(e: 'row-selected', rows: Row[]): void,
(e: 'filtered', newPhrase: string): void,
(e: 'data-loaded', data: Row[]): void,
}>();

const selectedRows = shallowRef<Row[]>([]);

Expand Down Expand Up @@ -407,7 +407,7 @@ type RowField = DataTableField<Row>
type RowFields = RowField[]

const allFields = computed<RowFields>(() => {
return map(props.fields, (field: RowField) => {
return map(props.fields, (field: RowField): RowField => {
return {
isRowHeader: false,
sortable: false,
Expand Down Expand Up @@ -497,7 +497,7 @@ const visibleFields = computed<DataTableField<Row>[]>(() => {
});
});

const getPerPageLabel = (num): string => {
const getPerPageLabel = (num: number): string => {
return (num === 0) ? 'All' : num.toString();
};

Expand Down Expand Up @@ -640,7 +640,7 @@ const refresh = () => {
}
};

const onPageChange = (p) => {
const onPageChange = (p: number) => {
currentPage.value = p;
refresh();
}
Expand All @@ -650,7 +650,7 @@ const relist = () => {
refresh();
};

const onClickRefresh = (e) => {
const onClickRefresh = (e: MouseEvent) => {
emit('refresh-clicked', e);

if (e.shiftKey) {
Expand All @@ -666,7 +666,7 @@ const navigate = () => {
relist();
};

const setFilter = (newTerm) => {
const setFilter = (newTerm: string) => {
searchPhrase.value = newTerm;
};

Expand Down Expand Up @@ -741,7 +741,7 @@ const checkRow = (row: Row) => {
}

const checkAll = () => {
const newSelectedRows = [];
const newSelectedRows: Row[] = [];

if (!isAllChecked.value) {
forEach(visibleItems.value, (currentRow) => {
Expand Down
51 changes: 33 additions & 18 deletions frontend/components/Common/FlowUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,10 @@ import {useTranslate} from "~/vendor/gettext";
import {IconUpload} from "~/components/Common/icons";
import {useEventListener} from "@vueuse/core";

const props = withDefaults(
defineProps<{
targetUrl: string,
allowMultiple?: boolean,
directoryMode?: boolean,
validMimeTypes?: string[],
flowConfiguration?: object,
}>(),
{
allowMultiple: false,
directoryMode: false,
validMimeTypes: () => ['*'],
flowConfiguration: () => ({}),
}
);
export interface UploadResponseBody {
originalFilename: string,
uploadedPath: string
}

interface FlowFile {
uniqueIdentifier: string,
Expand All @@ -106,7 +95,27 @@ interface OriginalFlowFile {
progress(): number
}

const emit = defineEmits(['complete', 'success', 'error']);
const props = withDefaults(
defineProps<{
targetUrl: string,
allowMultiple?: boolean,
directoryMode?: boolean,
validMimeTypes?: string[],
flowConfiguration?: object,
}>(),
{
allowMultiple: false,
directoryMode: false,
validMimeTypes: () => ['*'],
flowConfiguration: () => ({}),
}
);

const emit = defineEmits<{
(e: 'complete'): void,
(e: 'success', file: OriginalFlowFile, message: UploadResponseBody | null): void,
(e: 'error', file: OriginalFlowFile, message: string | null): void,
}>();

let flow: Flow | null = null;

Expand Down Expand Up @@ -208,10 +217,16 @@ onMounted(() => {
files.get(file).progressPercent = toInteger(file.progress() * 100);
});

flow.on('fileSuccess', (file: OriginalFlowFile, message) => {
flow.on('fileSuccess', (file: OriginalFlowFile, message: string) => {
files.get(file).isCompleted = true;

const messageJson = JSON.parse(message);
let messageJson: UploadResponseBody | null;
try {
messageJson = JSON.parse(message) as UploadResponseBody;
} catch {
messageJson = null;
}

emit('success', file, messageJson);
});

Expand Down
Loading