Skip to content

A self-hosted media server and file management system

feat: global loading bar and minimal scrollbar (this probably has bugs)

aminnausin4c5ea79a50b3
diff --git a/package-lock.json b/package-lock.json
index bcadb165..521c86d7 100755
--- a/package-lock.json
+++ b/package-lock.json
@@ -14,6 +14,7 @@
"focus-trap": "^7.5.4",
"lodash.clonedeep": "^4.5.0",
"lodash.isequal": "^4.5.0",
+ "nprogress": "^0.2.0",
"pinia": "^3.0.1",
"puppeteer": "^24.7.2",
"ua-parser-js": "^2.0.3",
@@ -46,6 +47,7 @@
"@types/lodash.clonedeep": "^4.5.9",
"@types/lodash.isequal": "^4.5.8",
"@types/node": "^22.9.3",
+ "@types/nprogress": "^0.2.3",
"@typescript-eslint/eslint-plugin": "^8.13.0",
"@typescript-eslint/parser": "^8.13.0",
"@vitejs/plugin-vue": "^5.0.5",
@@ -1937,6 +1939,13 @@
"form-data": "^4.0.0"
}
},
+ "node_modules/@types/nprogress": {
+ "version": "0.2.3",
+ "resolved": "https://registry.npmjs.org/@types/nprogress/-/nprogress-0.2.3.tgz",
+ "integrity": "sha512-k7kRA033QNtC+gLc4VPlfnue58CM1iQLgn1IMAU8VPHGOj7oIHPp9UlhedEnD/Gl8evoCjwkZjlBORtZ3JByUA==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@types/tough-cookie": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.5.tgz",
@@ -5917,6 +5926,12 @@
"node": ">=0.10.0"
}
},
+ "node_modules/nprogress": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/nprogress/-/nprogress-0.2.0.tgz",
+ "integrity": "sha512-I19aIingLgR1fmhftnbWWO3dXc0hSxqHQHQb3H8m+K3TnEn/iSeTZZOyvKXWqQESMwuUVnatlCnZdLBZZt2VSA==",
+ "license": "MIT"
+ },
"node_modules/nth-check": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz",
diff --git a/package.json b/package.json
index 6e05204d..87004cc5 100755
--- a/package.json
+++ b/package.json
@@ -56,6 +56,7 @@
"@types/lodash.clonedeep": "^4.5.9",
"@types/lodash.isequal": "^4.5.8",
"@types/node": "^22.9.3",
+ "@types/nprogress": "^0.2.3",
"@typescript-eslint/eslint-plugin": "^8.13.0",
"@typescript-eslint/parser": "^8.13.0",
"@vitejs/plugin-vue": "^5.0.5",
@@ -95,6 +96,7 @@
"focus-trap": "^7.5.4",
"lodash.clonedeep": "^4.5.0",
"lodash.isequal": "^4.5.0",
+ "nprogress": "^0.2.0",
"pinia": "^3.0.1",
"puppeteer": "^24.7.2",
"ua-parser-js": "^2.0.3",
diff --git a/resources/js/app.ts b/resources/js/app.ts
index 86e35134..9cd51034 100644
--- a/resources/js/app.ts
+++ b/resources/js/app.ts
@@ -4,9 +4,13 @@ import { VueQueryPlugin } from '@tanstack/vue-query';
import { createPinia } from 'pinia';
import { createApp } from 'vue';
+import nProgress from 'nprogress';
import router from './router/index';
import App from './App.vue';
+import 'nprogress/nprogress.css';
+
+nProgress.configure({ showSpinner: false });
const application = createApp(App);
const pinia = createPinia();
diff --git a/resources/js/components/panels/VideoSidebar.vue b/resources/js/components/panels/VideoSidebar.vue
index 72d41264..06b1d463 100755
--- a/resources/js/components/panels/VideoSidebar.vue
+++ b/resources/js/components/panels/VideoSidebar.vue
@@ -90,7 +90,7 @@ watch(
v-if="stateRecords.length > 0"
to="/history"
:title="'View All Watch History'"
- :class="'text-sm h-6 mx-auto mt-2 mb-2 hover:!bg-white dark:!bg-primary-dark-800/70 !bg-primary-800 dark:hover:!bg-primary-dark-600 line-clamp-1 truncate !rounded-full hover:!ring-violet-400 hover:dark:!ring-violet-700 hover:ring-[0.125rem]'"
+ :class="'text-sm h-8 mx-auto mt-2 mb-2 hover:!bg-white dark:!bg-primary-dark-800/70 !bg-primary-800 dark:hover:!bg-primary-dark-600 line-clamp-1 truncate !rounded-full hover:!ring-violet-400 hover:dark:!ring-violet-700 hover:ring-[0.125rem]'"
:variant="'form'"
target=""
>
diff --git a/resources/js/components/pinesUI/DropdownMenu.vue b/resources/js/components/pinesUI/DropdownMenu.vue
index 4a400e85..327ee124 100755
--- a/resources/js/components/pinesUI/DropdownMenu.vue
+++ b/resources/js/components/pinesUI/DropdownMenu.vue
@@ -15,11 +15,11 @@ import LucideTvMinimalPlay from '~icons/lucide/tv-minimal-play';
import LucideFolderSearch from '~icons/lucide/folder-search';
import LucideFolderCheck from '~icons/lucide/folder-check';
import ProiconsTaskList from '~icons/proicons/task-list';
+import ProiconsSettings from '~icons/proicons/settings';
import LucideFolderSync from '~icons/lucide/folder-sync';
import ProiconsLibrary from '~icons/proicons/library';
import LucideUserPlus from '~icons/lucide/user-plus';
import ProiconsScript from '~icons/proicons/script';
-import LucideSettings from '~icons/lucide/settings';
import ProiconsGraph from '~icons/proicons/graph';
import LucideHistory from '~icons/lucide/history';
import LucideLogOut from '~icons/lucide/log-out';
@@ -30,7 +30,7 @@ import LucideUser from '~icons/lucide/user';
const defaults = { external: false, disabled: false };
const dropDownItems: DropdownMenuItem[][] = [
- [{ ...defaults, name: 'settings', url: '/settings', text: 'Settings', icon: LucideSettings }],
+ [{ ...defaults, name: 'settings', url: '/settings', text: 'Settings', icon: ProiconsSettings }],
[
{ ...defaults, name: 'login', url: '/login', text: 'Log in', icon: LucideLogIn },
{ ...defaults, name: 'register', url: '/register', text: 'Sign up', icon: LucideUserPlus },
@@ -47,8 +47,8 @@ const manualPosition = ref(0);
const dropDownItemsAuth = computed<DropdownMenuItem[][]>(() => {
return [
[
- { ...defaults, name: 'profile', url: '/profile', text: 'Account', icon: LucideUser, disabled: false },
- { ...defaults, name: 'settings', url: '/settings', text: 'Settings', icon: LucideSettings },
+ { ...defaults, name: 'profile', url: '/profile', text: 'Account', icon: LucideUser, disabled: false, iconStrokeWidth: 2 },
+ { ...defaults, name: 'settings', url: '/settings', text: 'Settings', icon: ProiconsSettings, iconStrokeWidth: 2 },
{ ...defaults, name: 'home', url: '/', text: 'Home', icon: LucideTvMinimalPlay },
],
[
@@ -194,65 +194,31 @@ onUnmounted(() => {
ref="dropdown"
>
<div
- v-if="userData"
class="p-1 mt-1 bg-white dark:bg-neutral-800/70 backdrop-blur-lg border rounded-md shadow-md border-neutral-200/70 dark:border-neutral-700 text-neutral-700 dark:text-neutral-100"
>
- <div class="px-2 py-1.5 text-sm font-semibold">{{ userData.email }}</div>
- <div class="h-px my-1 -mx-1 bg-neutral-200 dark:bg-neutral-500"></div>
- <section v-for="(group, groupIndex) in dropDownItemsAuth" :key="groupIndex">
+ <div class="px-2 py-1.5 text-sm font-semibold" v-if="userData">{{ userData.email }}</div>
+ <div class="h-px my-1 -mx-1 bg-neutral-200 dark:bg-neutral-500" v-if="userData"></div>
+ <section v-for="(group, groupIndex) in userData ? dropDownItemsAuth : dropDownItems" :key="groupIndex">
<div
- v-if="groupIndex !== 0 && groupIndex !== dropDownItemsAuth.length && group.some((item) => !item.hidden)"
+ v-if="groupIndex !== 0 && groupIndex !== group.length && group.some((item) => !item.hidden)"
class="h-px my-1 -mx-1 bg-neutral-200 dark:bg-neutral-500"
></div>
<DropdownItem
- v-for="(item, index) in dropDownItemsAuth[groupIndex].filter((item) => !item.hidden)"
+ v-for="(item, index) in group.filter((item) => !item.hidden)"
:key="index"
:linkData="item"
- :selected="item?.url && ($route.path === item.name || $route.path === item.url) ? true : false"
- :external="item?.external ? true : false"
- :disabled="item?.disabled ?? false"
+ :selected="$route.name === item.name || $route.path === item.name || $route.path === item.url"
+ :external="item.external"
+ :disabled="item.disabled ?? false"
@click="
() => {
$emit('toggleDropdown', false);
- if (item.action) item.action();
+ if (item.action && userData) item.action();
}
"
>
<template #icon>
- <component :is="item.icon" viewBox="0 0 24 24" stroke="currentColor" stroke-width="0.2" class="w-4 h-4 mr-2" />
- </template>
- </DropdownItem>
- </section>
- </div>
- <div
- v-else
- class="p-1 mt-1 bg-white dark:bg-neutral-800/70 backdrop-blur-lg border rounded-md shadow-md border-neutral-200/70 dark:border-neutral-700 text-neutral-700 dark:text-neutral-100"
- >
- <section v-for="(group, groupIndex) in dropDownItems" :key="groupIndex">
- <div
- v-if="groupIndex !== 0 && groupIndex !== dropDownItemsAuth.length && group.some((item) => !item.hidden)"
- class="h-px my-1 -mx-1 bg-neutral-200 dark:bg-neutral-500"
- ></div>
- <DropdownItem
- v-for="(item, index) in dropDownItems[groupIndex]"
- :key="index"
- :linkData="item"
- :selected="$route.name === item.name"
- :external="item?.external"
- >
- <template #icon>
- <component
- :is="item.icon"
- width="24"
- height="24"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- stroke-width="2"
- stroke-linecap="round"
- stroke-linejoin="round"
- class="w-4 h-4 mr-2"
- />
+ <component :is="item.icon" :class="['w-4 h-4 mr-2', item.iconStrokeWidth ? `[&>*]:stroke-[${item.iconStrokeWidth}]` : '']" />
</template>
</DropdownItem>
</section>
diff --git a/resources/js/router/index.ts b/resources/js/router/index.ts
index 45ec3760..bb378585 100644
--- a/resources/js/router/index.ts
+++ b/resources/js/router/index.ts
@@ -17,6 +17,7 @@ import VideoView from '@/views/VideoView.vue';
import ErrorView from '@/views/ErrorView.vue';
import SetupView from '@/views/SetupView.vue';
import RootView from '@/views/RootView.vue';
+import nProgress from 'nprogress';
interface RouteMeta {
title?: string;
@@ -135,7 +136,7 @@ const router = createRouter({
},
{
path: '/404',
- name: 'NotFound',
+ name: '404',
component: ErrorView,
meta: { code: 404, message: 'Not Found' },
},
@@ -191,6 +192,8 @@ const redirectGuest = async (next: NavigationGuardNext) => {
router.beforeEach(async (to, from, next) => {
const meta = to.meta as RouteMeta;
+ nProgress.start();
+
// If going to a route that isnt included in the list, set the page title to the route title
if (to?.name && ['logout', 'root', 'home'].indexOf(to.name.toString()) === -1) {
document.title = meta.title ?? toTitleCase(`${to.name?.toString()}`); // Update Page Title
@@ -221,6 +224,8 @@ router.beforeEach(async (to, from, next) => {
});
router.afterEach((to) => {
+ nProgress.done(true);
+
// Scroll to top on every spa page load
if (to?.name === 'home') return;
diff --git a/resources/js/service/api.ts b/resources/js/service/api.ts
index 315f6c15..4a8fe0d0 100644
--- a/resources/js/service/api.ts
+++ b/resources/js/service/api.ts
@@ -1,22 +1,26 @@
import { toast } from '@/service/toaster/toastService';
-import axios from 'axios';
+import nProgress from 'nprogress';
+import axios, { AxiosError } from 'axios';
+
+let progressTimeout: NodeJS.Timeout;
const handleResponse = (response: any) => {
+ clearTimeout(progressTimeout);
+ nProgress.done(true);
return response;
};
-const handleError = (error: { response: { status: number; data: { message: any } }; message: any }) => {
+const handleError = (error: AxiosError<{ message?: string }>) => {
+ clearTimeout(progressTimeout);
+ nProgress.done(true);
+
// if the server throws an error (404, 500 etc.)
console.log(error);
- // if (error.response.status === 403) {
- // //|| error.response.status === 500
- // window.location.href = `/${error.response.status}?message=${error?.response?.data?.message ?? error?.message}`;
- // return;
- // }
+ const message = error.response?.data?.message ?? error.message;
- toast('Error', { type: 'danger', description: error.response.data.message ?? error.message });
- if (error.response.status === 401 || error.response.status == 422 || error.response.status == 500 || error.response.status == 404) throw error;
+ toast('Error', { type: 'danger', description: message });
+ if (error.status === 401 || error.status == 422 || error.status == 500 || error.status == 404) throw error;
return error.response;
};
@@ -42,11 +46,19 @@ export const WEB = axios.create({
export async function getMediaUrl(path: string): Promise<string> {
if (!path) return '';
const newPath = path.replace('storage/', '');
- // console.log(newPath);
const response = await axios.get(`/signed-url/${newPath}`);
return response.data; // The signed URL
}
+API.interceptors.request.use((config) => {
+ clearTimeout(progressTimeout);
+ nProgress.done(true);
+
+ progressTimeout = setTimeout(() => nProgress.start(), 100);
+
+ return config;
+});
+
API.interceptors.response.use(handleResponse, handleError);
WEB.interceptors.response.use(handleResponse, handleError);
diff --git a/resources/js/types/types.ts b/resources/js/types/types.ts
index f928a1fc..47881a08 100644
--- a/resources/js/types/types.ts
+++ b/resources/js/types/types.ts
@@ -309,6 +309,7 @@ export interface DropdownMenuItem {
external?: boolean;
action?: () => void;
shortcut?: string;
+ iconStrokeWidth?: number;
}
export interface AppManifest {
diff --git a/resources/js/views/ErrorView.vue b/resources/js/views/ErrorView.vue
index 4a62ffa3..7c213f83 100755
--- a/resources/js/views/ErrorView.vue
+++ b/resources/js/views/ErrorView.vue
@@ -1,14 +1,12 @@
<template>
- <main class="relative flex items-top justify-center min-h-screen bg-gray-100 dark:bg-gray-900 sm:items-center sm:pt-0">
+ <main class="relative flex items-top justify-center min-h-screen sm:items-center sm:pt-0">
<div class="max-w-xl mx-auto sm:px-6 lg:px-8">
<div class="flex items-center pt-8 sm:justify-start sm:pt-0">
<div class="px-4 text-lg text-gray-400 border-r border-gray-400 tracking-wider">
{{ $route.name }}
</div>
- <div class="ml-4 text-lg text-gray-500 uppercase tracking-wider">
- {{ $route.meta.message }} : {{ $route.query?.message ?? 'No message' }}
- </div>
+ <div class="ml-4 text-lg text-gray-500 uppercase tracking-wider">{{ $route.meta.message }} : {{ $route.query?.message ?? 'No message' }}</div>
</div>
</div>
</main>
diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php
index 46956963..c66135cc 100755
--- a/resources/views/layouts/app.blade.php
+++ b/resources/views/layouts/app.blade.php
@@ -19,20 +19,24 @@
<!-- local -->
@vite('resources/css/app.css')
<style>
- html {
+ #app {
scrollbar-gutter: stable;
font-optical-sizing: auto;
}
@media (min-width: 640px) {
- html {
+ #app {
scrollbar-gutter: stable both-edges;
}
}
- html.fullscreen {
+ #app.fullscreen {
scrollbar-gutter: auto;
}
+
+ #nprogress .bar {
+ background: #9333ea !important;
+ }
</style>
</head>
@@ -42,7 +46,7 @@
data-reverb-config='@json(["key" => config("reverb.apps.apps.0.key"), "host" => config("reverb.apps.apps.0.options.host"), "port" => config("reverb.apps.apps.0.options.port")])'>
</div>
@vite('resources/js/app.ts')
- <div id='app' class="h-screen"></div>
+ <div id='app' class="h-screen overflow-auto scrollbar-minimal scrollbar-track:bg-neutral-300 scrollbar-track:dark:bg-neutral-800"></div>
{{ $slot }}
</body>