A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
it works
aminnausin7bad94ab2ad7
diff --git a/app/Events/TaskEnded.php b/app/Events/TaskEnded.phpindex 21e4e133..9641aab8 100644--- a/app/Events/TaskEnded.php+++ b/app/Events/TaskEnded.php@@ -2,6 +2,7 @@namespace App\Events;+use App\Http\Resources\TasksResource;use App\Models\Task;use Illuminate\Broadcasting\Channel;use Illuminate\Broadcasting\InteractsWithSockets;@@ -15,6 +16,7 @@ use Illuminate\Queue\SerializesModels;class TaskEnded implements ShouldBroadcast {use Dispatchable, InteractsWithSockets, SerializesModels;+ public TasksResource $resource;/*** Create a new event instance.*/@@ -28,16 +30,13 @@ class TaskEnded implements ShouldBroadcast {* @return array<int, \Illuminate\Broadcasting\Channel>*/public function broadcastOn(): array {- // $task = Task::where('id', $this->taskId)->first();- // dump("hhhhh{$this->task->userId}");try {+ $this->resource = new TasksResource($this->task);// code...return [- new PrivateChannel("tasks.{$this->task->userId}"),- new Channel('dashboard'),+ new PrivateChannel("tasks.{$this->task->user_id}"),];} catch (\Throwable $th) {- // throw $th;dump($th->getMessage());}}diff --git a/config/broadcasting.php b/config/broadcasting.phpindex 7ad80114..5446f2ec 100644--- a/config/broadcasting.php+++ b/config/broadcasting.php@@ -43,6 +43,7 @@ return [],'client_options' => [// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html+ 'verify' => env('APP_ENV') === 'local' ? false : true,],],diff --git a/resources/js/layouts/LayoutBase.vue b/resources/js/layouts/LayoutBase.vueindex c79a1dde..a332265a 100755--- a/resources/js/layouts/LayoutBase.vue+++ b/resources/js/layouts/LayoutBase.vue@@ -2,7 +2,7 @@import { useAppStore } from '@/stores/AppStore';import { storeToRefs } from 'pinia';import { toast } from '@/service/toaster/toastService';-import { onMounted, ref, watch } from 'vue';+import { onBeforeUnmount, onMounted, ref, watch } from 'vue';import NavBar from '@/components/panels/NavBar.vue';import { useAuthStore } from '@/stores/AuthStore';@@ -15,27 +15,15 @@ const { selectedSideBar, sideBarTarget, scrollLock } = storeToRefs(appStore);const scrollBody = ref(null);const userInit = ref(false);-onMounted(() => {- window.Echo.channel(`dashboard`).listen('TaskEnded', (event: any) => {- console.log(event, 'dash');-- // toast('Hi2');- });-});-function handleEvent() {// @ts-ignoreif (!userData.value?.id || userInit.value) return;userInit.value = true;// @ts-ignore- console.log('window.echo', `tasks.${userData.value.id}`);- toast('hi');- // @ts-ignorewindow.Echo.private(`tasks.${userData.value.id}`).listen('TaskEnded', (event: any) => {- console.log('window.echo2');console.log(event);- toast('Hi');+ toast.add(`"${event?.task?.name}" ${event?.resource?.status}`, { type: event?.task?.status > 0 ? 'success' : 'danger' });});}@@ -45,6 +33,15 @@ watch(handleEvent();},);++onMounted(() => {+ handleEvent();+});+onBeforeUnmount(() => {+ if (userData.value?.id) {+ window.Echo.leave(`tasks.${userData.value.id}`);+ }+});</script><template>diff --git a/routes/channels.php b/routes/channels.phpindex d478d5f6..5c240c2f 100644--- a/routes/channels.php+++ b/routes/channels.php@@ -3,15 +3,8 @@use Illuminate\Support\Facades\Broadcast;Broadcast::channel('tasks.{id}', function ($user, $id) {- dump('dam');-return (int) $user->id === (int) $id;});-Broadcast::channel('management.{id}', function ($user, $id) {- dump('dam');-- return (int) $user->id === (int) $id;+Broadcast::channel('dashboard', function () {});--Broadcast::channel('dashboard', function () {});