Skip to content

A self-hosted media server and file management system

chore: code smells

aminnausind503c5d03608
diff --git a/resources/js/components/pinesUI/InputSelect.vue b/resources/js/components/pinesUI/InputSelect.vue
index 25115137..751b14d9 100755
--- a/resources/js/components/pinesUI/InputSelect.vue
+++ b/resources/js/components/pinesUI/InputSelect.vue
@@ -184,7 +184,7 @@ watch(
@keydown.stop="select.selectKeydown($event)"
v-cloak
>
- <ul ref="selectableItemsList" class="w-full overflow-auto max-h-56 scrollbar-thin focus:outline-none" tabindex="-1">
+ <ul ref="selectableItemsList" class="w-full overflow-auto max-h-56 scrollbar-thin focus:outline-none" tabindex="-1" role="listbox">
<template v-for="item in select.selectableItems" :key="item.value">
<li
@click="handleItemClick(item)"
@@ -200,6 +200,7 @@ watch(
}"
class="focus:rounded-md relative flex items-center h-full py-2 pl-8 cursor-pointer data-[disabled=true]:opacity-50 data-[disabled=true]:pointer-events-none"
:title="item.title"
+ role="option"
tabindex="0"
>
<svg
@@ -215,6 +216,7 @@ watch(
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
+ :tabindex="0"
>
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
diff --git a/resources/js/components/pinesUI/ToastController.vue b/resources/js/components/pinesUI/ToastController.vue
index 885d4c3b..d75f0762 100755
--- a/resources/js/components/pinesUI/ToastController.vue
+++ b/resources/js/components/pinesUI/ToastController.vue
@@ -105,26 +105,30 @@ function positionToasts() {
yBuffer += 16;
}
- messages.value.length >= props.maxVisibleToasts;
+ if (messages.value.length <= props.maxVisibleToasts) {
+ return;
+ }
let burnToast = document.getElementById(`${messages.value[props.maxVisibleToasts]?.id}`);
- if (burnToast) {
- burnToast.firstElementChild?.classList.remove('opacity-100');
- burnToast.firstElementChild?.classList.add('opacity-0');
+ if (!burnToast) {
+ return;
+ }
- if (burnTimeout.value) {
- clearTimeout(burnTimeout.value);
- }
+ burnToast.firstElementChild?.classList.remove('opacity-100');
+ burnToast.firstElementChild?.classList.add('opacity-0');
- // Burn 🔥 (remove) last toast
- burnTimeout.value = setTimeout(function () {
- messages.value.pop();
- }, 300);
+ if (burnTimeout.value) {
+ clearTimeout(burnTimeout.value);
+ }
- if (position.value.includes('bottom')) {
- toastElements[1].style.top = 'auto';
- }
+ // Burn 🔥 (remove) last toast
+ burnTimeout.value = setTimeout(function () {
+ messages.value.pop();
+ }, 300);
+
+ if (position.value.includes('bottom')) {
+ toastElements[1].style.top = 'auto';
}
} catch (error) {
console.log(error);
diff --git a/resources/js/components/video/VideoHeatmap.vue b/resources/js/components/video/VideoHeatmap.vue
index 760051b0..86e1e334 100644
--- a/resources/js/components/video/VideoHeatmap.vue
+++ b/resources/js/components/video/VideoHeatmap.vue
@@ -10,76 +10,76 @@ const { playbackHeatmap } = storeToRefs(useAppStore());
const heatMap = computed(() => {
const start = 'M 0.0,100.0 ';
- const catmullRomFitting = function (data: string | any[], alpha: number | undefined) {
+ function catmullRomFitting(data: string | any[], alpha: number | undefined) {
if (!data?.length || data.length < 5) return '';
if (alpha == 0 || alpha === undefined) {
return '';
- } else {
- let p0, p1, p2, p3, bp1, bp2, d1, d2, d3, A, B, N, M;
- let d3powA, d2powA, d3pow2A, d2pow2A, d1pow2A, d1powA;
- let d = Math.round(data[0].x) + ',' + Math.round(data[0].y) + ' ';
- let length = data.length;
- for (let i = 0; i < length - 1; i++) {
- p0 = i == 0 ? data[0] : data[i - 1];
- p1 = data[i];
- p2 = data[i + 1];
- p3 = i + 2 < length ? data[i + 2] : p2;
+ }
- d1 = Math.sqrt(Math.pow(p0.x - p1.x, 2) + Math.pow(p0.y - p1.y, 2));
- d2 = Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
- d3 = Math.sqrt(Math.pow(p2.x - p3.x, 2) + Math.pow(p2.y - p3.y, 2));
+ let p0, p1, p2, p3, bp1, bp2, d1, d2, d3, A, B, N, M;
+ let d3powA, d2powA, d3pow2A, d2pow2A, d1pow2A, d1powA;
+ let d = Math.round(data[0].x) + ',' + Math.round(data[0].y) + ' ';
+ let length = data.length;
+ for (let i = 0; i < length - 1; i++) {
+ p0 = i == 0 ? data[0] : data[i - 1];
+ p1 = data[i];
+ p2 = data[i + 1];
+ p3 = i + 2 < length ? data[i + 2] : p2;
- // Catmull-Rom to Cubic Bezier conversion matrix
+ d1 = Math.sqrt(Math.pow(p0.x - p1.x, 2) + Math.pow(p0.y - p1.y, 2));
+ d2 = Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
+ d3 = Math.sqrt(Math.pow(p2.x - p3.x, 2) + Math.pow(p2.y - p3.y, 2));
- // A = 2d1^2a + 3d1^a * d2^a + d3^2a
- // B = 2d3^2a + 3d3^a * d2^a + d2^2a
+ // Catmull-Rom to Cubic Bezier conversion matrix
- // [ 0 1 0 0 ]
- // [ -d2^2a /N A/N d1^2a /N 0 ]
- // [ 0 d3^2a /M B/M -d2^2a /M ]
- // [ 0 0 1 0 ]
+ // A = 2d1^2a + 3d1^a * d2^a + d3^2a
+ // B = 2d3^2a + 3d3^a * d2^a + d2^2a
- d3powA = Math.pow(d3, alpha);
- d3pow2A = Math.pow(d3, 2 * alpha);
- d2powA = Math.pow(d2, alpha);
- d2pow2A = Math.pow(d2, 2 * alpha);
- d1powA = Math.pow(d1, alpha);
- d1pow2A = Math.pow(d1, 2 * alpha);
+ // [ 0 1 0 0 ]
+ // [ -d2^2a /N A/N d1^2a /N 0 ]
+ // [ 0 d3^2a /M B/M -d2^2a /M ]
+ // [ 0 0 1 0 ]
- A = 2 * d1pow2A + 3 * d1powA * d2powA + d2pow2A;
- B = 2 * d3pow2A + 3 * d3powA * d2powA + d2pow2A;
- N = 3 * d1powA * (d1powA + d2powA);
- if (N > 0) {
- N = 1 / N;
- }
- M = 3 * d3powA * (d3powA + d2powA);
- if (M > 0) {
- M = 1 / M;
- }
+ d3powA = Math.pow(d3, alpha);
+ d3pow2A = Math.pow(d3, 2 * alpha);
+ d2powA = Math.pow(d2, alpha);
+ d2pow2A = Math.pow(d2, 2 * alpha);
+ d1powA = Math.pow(d1, alpha);
+ d1pow2A = Math.pow(d1, 2 * alpha);
- bp1 = {
- x: (-d2pow2A * p0.x + A * p1.x + d1pow2A * p2.x) * N,
- y: (-d2pow2A * p0.y + A * p1.y + d1pow2A * p2.y) * N,
- };
+ A = 2 * d1pow2A + 3 * d1powA * d2powA + d2pow2A;
+ B = 2 * d3pow2A + 3 * d3powA * d2powA + d2pow2A;
+ N = 3 * d1powA * (d1powA + d2powA);
+ if (N > 0) {
+ N = 1 / N;
+ }
+ M = 3 * d3powA * (d3powA + d2powA);
+ if (M > 0) {
+ M = 1 / M;
+ }
- bp2 = {
- x: (d3pow2A * p1.x + B * p2.x - d2pow2A * p3.x) * M,
- y: (d3pow2A * p1.y + B * p2.y - d2pow2A * p3.y) * M,
- };
+ bp1 = {
+ x: (-d2pow2A * p0.x + A * p1.x + d1pow2A * p2.x) * N,
+ y: (-d2pow2A * p0.y + A * p1.y + d1pow2A * p2.y) * N,
+ };
- if (bp1.x == 0 && bp1.y == 0) {
- bp1 = p1;
- }
- if (bp2.x == 0 && bp2.y == 0) {
- bp2 = p2;
- }
+ bp2 = {
+ x: (d3pow2A * p1.x + B * p2.x - d2pow2A * p3.x) * M,
+ y: (d3pow2A * p1.y + B * p2.y - d2pow2A * p3.y) * M,
+ };
- d += 'C' + bp1.x + ',' + bp1.y + ' ' + bp2.x + ',' + bp2.y + ' ' + p2.x + ',' + p2.y + ' ';
+ if (bp1.x == 0 && bp1.y == 0) {
+ bp1 = p1;
+ }
+ if (bp2.x == 0 && bp2.y == 0) {
+ bp2 = p2;
}
- return d;
+ d += 'C' + bp1.x + ',' + bp1.y + ' ' + bp2.x + ',' + bp2.y + ' ' + p2.x + ',' + p2.y + ' ';
}
- };
+
+ return d;
+ }
return (
start +
catmullRomFitting(
diff --git a/resources/js/components/video/VideoPlayer.vue b/resources/js/components/video/VideoPlayer.vue
index ff9a527d..43b350f1 100755
--- a/resources/js/components/video/VideoPlayer.vue
+++ b/resources/js/components/video/VideoPlayer.vue
@@ -353,7 +353,7 @@ const onPlayerPlay = async (override = false, recordProgress = true) => {
await player.value.play();
isLoading.value = false;
- // isPaused.value = false;
+ // Set isPaused to false?
emit('loadedData');
emit('play');
@@ -1232,7 +1232,6 @@ defineExpose({
<p v-show="isRewind" class="text-transparent pointer-events-none select-none p-1 rounded-full">{{ timeAutoSeek }}s</p>
</Transition>
</span>
- <!-- <span class="w-1/12 md:hidden"></span> -->
<span :class="`absolute w-full h-full top-0 flex flex-col items-center justify-start py-4 pointer-events-none`" style="z-index: 4">
<Transition
enter-active-class="transition ease-out duration-[1.4s] text-white bg-neutral-900/30"
@@ -1243,7 +1242,6 @@ defineExpose({
<p v-show="isChangingVolume" class="text-transparent pointer-events-none select-none px-2 py-1 rounded-full">{{ Math.round(currentVolume * 100) }}%</p>
</Transition>
</span>
- <!-- <span class="w-1/12 md:hidden"></span> -->
<span
:class="`absolute w-1/6 h-full top-0 right-0 flex flex-col items-center justify-center`"
aria-describedby="Skip Forward"
diff --git a/resources/js/composables/useMultiSelect.js b/resources/js/composables/useMultiSelect.js
index 3490bd7f..be555b57 100644
--- a/resources/js/composables/useMultiSelect.js
+++ b/resources/js/composables/useMultiSelect.js
@@ -35,7 +35,6 @@ export default function useMultiSelect({ options, defaultItems }, refs) {
activeElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
activeElement.focus({ preventScroll: false });
- return;
},
selectKeydown(event) {
if (event.keyCode >= 65 && event.keyCode <= 90) {
@@ -44,7 +43,6 @@ export default function useMultiSelect({ options, defaultItems }, refs) {
if (selectedItemBestMatch) {
if (this.selectOpen) {
this.selectableItemActive = selectedItemBestMatch;
- // let index = this.selectableItems.indexOf(this.selectableItemActive);
this.selectScrollToActiveItem(selectableItemActive.id);
} else {
// this.selectedItem = this.selectableItemActive === selectedItemBestMatch; // What does this line do there was only 1 equal
diff --git a/resources/js/composables/useSelect.js b/resources/js/composables/useSelect.js
index 3d204f91..e77c56cb 100755
--- a/resources/js/composables/useSelect.js
+++ b/resources/js/composables/useSelect.js
@@ -45,7 +45,6 @@ export default function useSelect(options, refs) {
if (!activeElement) return;
- // activeElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
activeElement.focus();
},
selectKeydown(event) {
diff --git a/resources/js/service/util.ts b/resources/js/service/util.ts
index 51a3d8c8..622dc56d 100644
--- a/resources/js/service/util.ts
+++ b/resources/js/service/util.ts
@@ -23,11 +23,11 @@ export function toTimeSpan(rawDate: Date | string, timeZoneName = ' EST') {
const timeSpan =
weeks > 0
- ? `${weeks} week${weeks > 1 ? 's' : ''} ago`
+ ? `${weeks} week${toPlural(weeks)} ago`
: days > 0
- ? `${days} day${days > 1 ? 's' : ''} ago`
+ ? `${days} day${toPlural(days)} ago`
: hours > 0
- ? `${hours} hour${hours > 1 ? 's' : ''} ago`
+ ? `${hours} hour${toPlural(hours)} ago`
: minutes > 0
? `${minutes}m ago`
: `${seconds}s ago`;
@@ -70,9 +70,9 @@ export function toFormattedDuration(rawSeconds: number = 0, leadingZero: boolean
const minutes = Math.floor((rawSeconds % 3600) / 60);
const seconds = Math.floor(rawSeconds % 60);
- const hoursText = format === 'verbose' ? ` hour${hours == 1 ? '' : 's'}` : 'h';
- const minutesText = format === 'verbose' ? ` minute${minutes == 1 ? '' : 's'}` : 'm';
- const secondsText = format === 'verbose' ? ` second${seconds == 1 ? '' : 's'}` : 's';
+ const hoursText = format === 'verbose' ? ` hour${toPlural(hours)}` : 'h';
+ const minutesText = format === 'verbose' ? ` minute${toPlural(minutes)}` : 'm';
+ const secondsText = format === 'verbose' ? ` second${toPlural(seconds)}` : 's';
if (format === 'digital') {
return `${hours > 0 ? `${formatInteger(hours)}:` : ''}${formatInteger(minutes)}:${formatInteger(seconds)}`;
@@ -250,3 +250,7 @@ export function sortObject<T>(column: keyof T, direction: SortDir = 1, dateColum
export function isAxiosError(error: unknown): error is AxiosError {
return (error as AxiosError).isAxiosError === true;
}
+
+export function toPlural(value: number): string {
+ return value != 1 ? 's' : '';
+}
diff --git a/resources/js/stores/DashboardStore.ts b/resources/js/stores/DashboardStore.ts
index 86b5de9f..8b6ac79b 100644
--- a/resources/js/stores/DashboardStore.ts
+++ b/resources/js/stores/DashboardStore.ts
@@ -90,13 +90,15 @@ export const useDashboardStore = defineStore('Dashboard', () => {
stateTasks,
stateUsers,
stateTaskStats,
+ stateLibraryId,
stateTotalLibrariesSize,
stateActiveSessions,
isLoadingLibraries,
isLoadingLibraryFolders,
- stateLibraryId,
isLoadingUsers,
isLoadingTasks,
+ isLoadingTaskStats,
+ isLoadingActiveSessions,
updateSingleTask,
updateSingleLibrary,
} as {
@@ -112,6 +114,8 @@ export const useDashboardStore = defineStore('Dashboard', () => {
stateLibraryId: Ref<number>;
isLoadingUsers: Ref<boolean>;
isLoadingTasks: Ref<boolean>;
+ isLoadingTaskStats: Ref<boolean>;
+ isLoadingActiveSessions: Ref<boolean>;
updateSingleTask: (data: TaskResource) => void;
updateSingleLibrary: (data: CategoryResource) => void;
};
diff --git a/resources/js/views/DashboardView.vue b/resources/js/views/DashboardView.vue
index b84567fa..86754210 100644
--- a/resources/js/views/DashboardView.vue
+++ b/resources/js/views/DashboardView.vue
@@ -16,14 +16,8 @@ import DashboardTasks from '@/components/dashboard/DashboardTasks.vue';
import SidebarCard from '@/components/cards/SidebarCard.vue';
import LayoutBase from '@/layouts/LayoutBase.vue';
-// import LucideChartNoAxesColumnIncreasing from '~icons/lucide/chart-no-axes-column-increasing';
-// import ProiconsAddSquareMultiple from '~icons/proicons/add-square-multiple';
-// import ProiconsBookAdd2 from '~icons/proicons/book-add-2';
import ProiconsLibrary from '~icons/proicons/library';
-// import ProiconsHistory from '~icons/proicons/history';
-// import CircumDatabase from '~icons/circum/database';
import ProiconsGraph from '~icons/proicons/graph';
-// import LucideImages from '~icons/lucide/images';
import CircumServer from '~icons/circum/server';
import LucideUsers from '~icons/lucide/users';
@@ -31,7 +25,7 @@ const { stateTaskStats, stateTotalLibrariesSize, stateLibraryId, stateActiveSess
stateTaskStats: Ref<TaskStatsResponse>;
stateTotalLibrariesSize: Ref<string>;
stateLibraryId: Ref<number>;
- stateActiveSessions: Ref<Number>;
+ stateActiveSessions: Ref<number>;
};
const { pageTitle, selectedSideBar } = storeToRefs(useAppStore());
const { cycleSideBar } = useAppStore();