Skip to content

A self-hosted media server and file management system

duration and music player bg

aminnausind6ade49ee0a9
diff --git a/app/Http/Resources/TasksResource.php b/app/Http/Resources/TasksResource.php
index dbc09223..8634311d 100644
--- a/app/Http/Resources/TasksResource.php
+++ b/app/Http/Resources/TasksResource.php
@@ -34,7 +34,7 @@ class TasksResource extends JsonResource {
'name' => $this->name,
'description' => $this->description,
'summary' => $this->summary,
- 'sub_tasks' => SubTasksResource::collection($this->sub_tasks),
+ 'sub_tasks' => [],
'sub_tasks_total' => $this->sub_tasks_total,
'sub_tasks_pending' => $this->sub_tasks_pending,
'sub_tasks_complete' => $this->sub_tasks_complete,
diff --git a/app/Jobs/CleanFolderPaths.php b/app/Jobs/CleanFolderPaths.php
index 31441295..57bff06c 100644
--- a/app/Jobs/CleanFolderPaths.php
+++ b/app/Jobs/CleanFolderPaths.php
@@ -19,7 +19,7 @@ class CleanFolderPaths implements ShouldQueue {
protected $taskId;
protected $subTaskId;
-
+ protected $startedAt;
/**
* Create a new job instance.
*/
@@ -40,21 +40,27 @@ class CleanFolderPaths implements ShouldQueue {
return;
}
+ $this->startedAt = now();
DB::table('tasks')->where('id', $this->taskId)->decrement('sub_tasks_pending');
- SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::PROCESSING, 'started_at' => now()]);
+ SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::PROCESSING, 'started_at' => $this->startedAt]);
try {
$summary = $this->cleanFolderPaths();
+ $endedAt = now();
+ $duration = (int) $this->startedAt->diffInSeconds($endedAt);
DB::table('tasks')->where('id', $this->taskId)->increment('sub_tasks_complete');
SubTask::where('id', $this->subTaskId)->update([
'status' => TaskStatus::COMPLETED,
'summary' => $summary,
- 'ended_at' => now(),
'progress' => 100,
+ 'ended_at' => $endedAt,
+ 'duration' => $duration
]);
} catch (\Throwable $th) {
+ $endedAt = now();
+ $duration = (int) $this->startedAt->diffInSeconds($endedAt);
DB::table('tasks')->where('id', $this->taskId)->increment('sub_tasks_failed');
- SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::FAILED, 'summary' => "Error: " . $th->getMessage(), 'ended_at' => now()]);
+ SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::FAILED, 'summary' => "Error: " . $th->getMessage(), 'ended_at' => $endedAt, 'duration' => $duration]);
}
}
diff --git a/app/Jobs/CleanVideoPaths.php b/app/Jobs/CleanVideoPaths.php
index afb9ebb5..65ec3963 100644
--- a/app/Jobs/CleanVideoPaths.php
+++ b/app/Jobs/CleanVideoPaths.php
@@ -19,7 +19,7 @@ class CleanVideoPaths implements ShouldQueue {
protected $taskId;
protected $subTaskId;
-
+ protected $startedAt;
/**
* Create a new job instance.
*/
@@ -40,21 +40,27 @@ class CleanVideoPaths implements ShouldQueue {
return;
}
+ $this->startedAt = now();
DB::table('tasks')->where('id', $this->taskId)->decrement('sub_tasks_pending');
- SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::PROCESSING, 'started_at' => now()]);
+ SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::PROCESSING, 'started_at' => $this->startedAt]);
try {
$summary = $this->cleanVideoPaths();
+ $endedAt = now();
+ $duration = (int) $this->startedAt->diffInSeconds($endedAt);
DB::table('tasks')->where('id', $this->taskId)->increment('sub_tasks_complete');
SubTask::where('id', $this->subTaskId)->update([
'status' => TaskStatus::COMPLETED,
'summary' => $summary,
- 'ended_at' => now(),
'progress' => 100,
+ 'ended_at' => $endedAt,
+ 'duration' => $duration
]);
} catch (\Throwable $th) {
+ $endedAt = now();
+ $duration = (int) $this->startedAt->diffInSeconds($endedAt);
DB::table('tasks')->where('id', $this->taskId)->increment('sub_tasks_failed');
- SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::FAILED, 'summary' => "Error: " . $th->getMessage(), 'ended_at' => now()]);
+ SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::FAILED, 'summary' => "Error: " . $th->getMessage(), 'ended_at' => $endedAt, 'duration' => $duration]);
}
}
diff --git a/app/Jobs/EmbedUidInMetadata.php b/app/Jobs/EmbedUidInMetadata.php
index e5b37a55..33dddc4d 100644
--- a/app/Jobs/EmbedUidInMetadata.php
+++ b/app/Jobs/EmbedUidInMetadata.php
@@ -23,7 +23,7 @@ class EmbedUidInMetadata implements ShouldQueue {
protected $taskId;
protected $subTaskId;
-
+ protected $startedAt;
/**
* Create a new job instance.
*
@@ -48,21 +48,27 @@ class EmbedUidInMetadata implements ShouldQueue {
* @return void
*/
public function handle() {
+ $this->startedAt = now();
DB::table('tasks')->where('id', $this->taskId)->decrement('sub_tasks_pending');
- SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::PROCESSING, 'started_at' => now(), 'summary' => "Adding uuid to $this->filePath"]);
+ SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::PROCESSING, 'started_at' => $this->startedAt, 'summary' => "Adding uuid to $this->filePath"]);
try {
$summary = $this->handleEmbed();
+ $endedAt = now();
+ $duration = (int) $this->startedAt->diffInSeconds($endedAt);
DB::table('tasks')->where('id', $this->taskId)->increment('sub_tasks_complete');
SubTask::where('id', $this->subTaskId)->update([
'status' => TaskStatus::COMPLETED,
'summary' => $summary,
- 'ended_at' => now(),
'progress' => 100,
+ 'ended_at' => $endedAt,
+ 'duration' => $duration
]);
} catch (\Throwable $th) {
+ $endedAt = now();
+ $duration = (int) $this->startedAt->diffInSeconds($endedAt);
DB::table('tasks')->where('id', $this->taskId)->increment('sub_tasks_failed');
- SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::FAILED, 'summary' => "Error: " . $th->getMessage(), 'ended_at' => now()]);
+ SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::FAILED, 'summary' => "Error: " . $th->getMessage(), 'ended_at' => $endedAt, 'duration' => $duration]);
}
}
diff --git a/app/Jobs/IndexFiles.php b/app/Jobs/IndexFiles.php
index 9c3b3ceb..f1dc2c62 100755
--- a/app/Jobs/IndexFiles.php
+++ b/app/Jobs/IndexFiles.php
@@ -30,7 +30,7 @@ class IndexFiles implements ShouldBeUnique, ShouldQueue {
protected $taskId;
protected $subTaskId;
-
+ protected $startedAt;
/**
* Create a new job instance.
*/
@@ -52,22 +52,27 @@ class IndexFiles implements ShouldBeUnique, ShouldQueue {
dump('Starting Index Files');
-
+ $this->startedAt = now();
DB::table('tasks')->where('id', $this->taskId)->decrement('sub_tasks_pending');
- SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::PROCESSING, 'started_at' => now(), 'summary' => 'Starting Index Files']);
+ SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::PROCESSING, 'started_at' => $this->startedAt, 'summary' => 'Starting Index Files']);
try {
$summary = $this->generateData();
+ $endedAt = now();
+ $duration = (int) $this->startedAt->diffInSeconds($endedAt);
DB::table('tasks')->where('id', $this->taskId)->increment('sub_tasks_complete');
SubTask::where('id', $this->subTaskId)->update([
'status' => TaskStatus::COMPLETED,
'summary' => $summary,
- 'ended_at' => now(),
'progress' => 100,
+ 'ended_at' => $endedAt,
+ 'duration' => $duration
]);
} catch (\Throwable $th) {
+ $endedAt = now();
+ $duration = (int) $this->startedAt->diffInSeconds($endedAt);
DB::table('tasks')->where('id', $this->taskId)->increment('sub_tasks_failed');
- SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::FAILED, 'summary' => "Error: " . $th->getMessage(), 'ended_at' => now()]);
+ SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::FAILED, 'summary' => "Error: " . $th->getMessage(), 'ended_at' => $endedAt, 'duration' => $duration]);
}
}
diff --git a/app/Jobs/SyncFiles.php b/app/Jobs/SyncFiles.php
index 7dcd3654..334128c2 100755
--- a/app/Jobs/SyncFiles.php
+++ b/app/Jobs/SyncFiles.php
@@ -22,7 +22,7 @@ class SyncFiles implements ShouldBeUnique, ShouldQueue {
protected $taskId;
protected $subTaskId;
-
+ protected $startedAt;
/**
* Create a new job instance.
*/
@@ -43,16 +43,21 @@ class SyncFiles implements ShouldBeUnique, ShouldQueue {
return;
}
+ $this->startedAt = now();
DB::table('tasks')->where('id', $this->taskId)->decrement('sub_tasks_pending');
- SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::PROCESSING, 'started_at' => now()]);
+ SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::PROCESSING, 'started_at' => $this->startedAt]);
try {
$this->syncCache();
+ $endedAt = now();
+ $duration = (int) $this->startedAt->diffInSeconds($endedAt);
DB::table('tasks')->where('id', $this->taskId)->increment('sub_tasks_complete');
- SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::COMPLETED, 'summary' => '', 'ended_at' => now(), 'progress' => 100]);
+ SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::COMPLETED, 'summary' => '', 'ended_at' => $endedAt, 'duration' => $duration, 'progress' => 100]);
} catch (\Throwable $th) {
+ $endedAt = now();
+ $duration = (int) $this->startedAt->diffInSeconds($endedAt);
DB::table('tasks')->where('id', $this->taskId)->increment('sub_tasks_failed');
- SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::FAILED, 'summary' => "Error: " . $th->getMessage(), 'ended_at' => now()]);
+ SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::FAILED, 'summary' => "Error: " . $th->getMessage(), 'ended_at' => $endedAt, 'duration' => $duration]);
//throw $th;
}
}
diff --git a/app/Jobs/VerifyFiles.php b/app/Jobs/VerifyFiles.php
index 567cde51..257841f6 100755
--- a/app/Jobs/VerifyFiles.php
+++ b/app/Jobs/VerifyFiles.php
@@ -25,7 +25,7 @@ class VerifyFiles implements ShouldQueue {
protected $taskId;
protected $subTaskId;
-
+ protected $startedAt;
/**
* Create a new job instance.
*/
@@ -62,21 +62,27 @@ class VerifyFiles implements ShouldQueue {
return;
}
+ $this->startedAt = now();
DB::table('tasks')->where('id', $this->taskId)->decrement('sub_tasks_pending');
- SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::PROCESSING, 'started_at' => now()]);
+ SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::PROCESSING, 'started_at' => $this->startedAt]);
try {
$summary = $this->verifyFiles();
+ $endedAt = now();
+ $duration = (int) $this->startedAt->diffInSeconds($endedAt);
DB::table('tasks')->where('id', $this->taskId)->increment('sub_tasks_complete');
SubTask::where('id', $this->subTaskId)->update([
'status' => TaskStatus::COMPLETED,
'summary' => $summary,
- 'ended_at' => now(),
'progress' => 100,
+ 'ended_at' => $endedAt,
+ 'duration' => $duration
]);
} catch (\Throwable $th) {
+ $endedAt = now();
+ $duration = (int) $this->startedAt->diffInSeconds($endedAt);
DB::table('tasks')->where('id', $this->taskId)->increment('sub_tasks_failed');
- SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::FAILED, 'summary' => "Error: " . $th->getMessage(), 'ended_at' => now()]);
+ SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::FAILED, 'summary' => "Error: " . $th->getMessage(), 'ended_at' => $endedAt, 'duration' => $duration]);
}
}
diff --git a/app/Jobs/VerifyFolders.php b/app/Jobs/VerifyFolders.php
index 3b11d9d2..d31ade41 100644
--- a/app/Jobs/VerifyFolders.php
+++ b/app/Jobs/VerifyFolders.php
@@ -19,7 +19,7 @@ class VerifyFolders implements ShouldQueue {
protected $taskId;
protected $subTaskId;
-
+ protected $startedAt;
/**
* Create a new job instance.
@@ -40,21 +40,27 @@ class VerifyFolders implements ShouldQueue {
return;
}
+ $this->startedAt = now();
DB::table('tasks')->where('id', $this->taskId)->decrement('sub_tasks_pending');
- SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::PROCESSING, 'started_at' => now()]);
+ SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::PROCESSING, 'started_at' => $this->startedAt]);
try {
$summary = $this->VerifyFolders();
+ $endedAt = now();
+ $duration = (int) $this->startedAt->diffInSeconds($endedAt);
DB::table('tasks')->where('id', $this->taskId)->increment('sub_tasks_complete');
SubTask::where('id', $this->subTaskId)->update([
'status' => TaskStatus::COMPLETED,
'summary' => $summary,
- 'ended_at' => now(),
'progress' => 100,
+ 'ended_at' => $endedAt,
+ 'duration' => $duration
]);
} catch (\Throwable $th) {
+ $endedAt = now();
+ $duration = (int) $this->startedAt->diffInSeconds($endedAt);
DB::table('tasks')->where('id', $this->taskId)->increment('sub_tasks_failed');
- SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::FAILED, 'summary' => "Error: " . $th->getMessage(), 'ended_at' => now()]);
+ SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::FAILED, 'summary' => "Error: " . $th->getMessage(), 'ended_at' => $endedAt, 'duration' => $duration]);
}
}
diff --git a/app/Models/SubTask.php b/app/Models/SubTask.php
index c95fb35e..bcc2cbcd 100644
--- a/app/Models/SubTask.php
+++ b/app/Models/SubTask.php
@@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Enums\TaskStatus;
+use Illuminate\Support\Facades\Log;
class SubTask extends Model {
protected $fillable = [
@@ -24,12 +25,13 @@ class SubTask extends Model {
protected static function boot() {
parent::boot();
- static::updated(function ($subTask) {
- $subTask->updateDuration();
- });
+ // static::updated(function ($subTask) {
+ // $subTask->updateDuration();
+ // });
}
public function updateDuration() {
+
if (!isset($this->started_at)) {
$this->duration = 0;
$this->save;
@@ -37,7 +39,7 @@ class SubTask extends Model {
}
$time = now();
- $this->duration = (int) $time->diffInSeconds($this->started_at);
+ $this->duration = (int) $this->started_at->diffInSeconds($time);
$this->save();
}
diff --git a/resources/js/components/cards/SubTaskCard.vue b/resources/js/components/cards/SubTaskCard.vue
index 4038e1ae..23f78962 100644
--- a/resources/js/components/cards/SubTaskCard.vue
+++ b/resources/js/components/cards/SubTaskCard.vue
@@ -86,9 +86,9 @@ const props = defineProps<{ data: SubTaskResource; isScreenSmall?: boolean }>();
datasets: [
{
data: [
- 100 - data.progress,
- data.status === 'processing' || data.status === 'completed' ? data.progress : 0,
- data.status === 'failed' ? data.progress : 0,
+ Math.max(100 - data.progress, 0),
+ data.status === 'processing' || data.status === 'completed' ? Math.min(data.progress, 0) : 0,
+ data.status === 'failed' ? Math.min(data.progress, 0) : 0,
],
backgroundColor: ['#f59e0b', '#9333ea', '#be123c'],
hoverBackgroundColor: ['#f59e0b', '#9333ea', '#e11d48'],
@@ -96,7 +96,7 @@ const props = defineProps<{ data: SubTaskResource; isScreenSmall?: boolean }>();
],
}"
/>
- <p class="text-left lg:!hidden text-xs">{{ data.progress }}%</p>
+ <p class="text-left lg:!hidden text-xs">{{ Math.min(data.progress, 0) }}%</p>
<ChipTag
:class="`h-6 shadow-sm`"
diff --git a/resources/js/components/cards/TaskCard.vue b/resources/js/components/cards/TaskCard.vue
index d1bd4102..45e55762 100644
--- a/resources/js/components/cards/TaskCard.vue
+++ b/resources/js/components/cards/TaskCard.vue
@@ -144,7 +144,11 @@ const handleClick = (cancel: boolean = false) => {
labels: ['Pending', 'Completed', 'Failed'],
datasets: [
{
- data: [data.sub_tasks_pending, data.sub_tasks_complete, data.sub_tasks_failed],
+ data: [
+ Math.max(data.sub_tasks_pending - data.sub_tasks_failed, 0),
+ Math.max(data.sub_tasks_complete, 0),
+ data.sub_tasks_failed,
+ ],
backgroundColor: ['#f59e0b', '#9333ea', '#be123c'],
hoverBackgroundColor: ['#f59e0b', '#9333ea', '#e11d48'],
},
@@ -152,20 +156,21 @@ const handleClick = (cancel: boolean = false) => {
}"
/>
<p class="w-full text-left sm:!hidden text-xs">
- {{ Math.ceil((data.sub_tasks_complete / (data.sub_tasks_total ? data.sub_tasks_total : 1)) * 100) }}%
+ {{ Math.ceil((Math.max(data.sub_tasks_complete, 0) / (data.sub_tasks_total ? data.sub_tasks_total : 1)) * 100) }}%
</p>
- <div class="px-2 text-xs hidden sm:flex flex-col gap-1 h-fit min-w-20 flex-1">
- <p class="w-full text-left pe-8">
- {{ Math.ceil((data.sub_tasks_complete / (data.sub_tasks_total ? data.sub_tasks_total : 1)) * 100) }}% Processed
+ <div class="px-2 text-xs hidden sm:flex flex-col gap-1 h-fit min-w-32 flex-1">
+ <p class="w-full text-left">
+ {{ Math.ceil((Math.max(data.sub_tasks_complete, 0) / (data.sub_tasks_total ? data.sub_tasks_total : 1)) * 100) }}%
+ Processed
</p>
<div class="rounded-full h-1 w-full bg-primary-dark-900 flex overflow-clip">
<div
:class="`h-1 bg-purple-600 rounded-full`"
- :style="`width: ${(data.sub_tasks_complete / (data.sub_tasks_total ? data.sub_tasks_total : 1)) * 100}%;`"
+ :style="`width: ${(Math.max(data.sub_tasks_complete, 0) / (data.sub_tasks_total ? data.sub_tasks_total : 1)) * 100}%;`"
></div>
<div
:class="`h-1 bg-amber-500 rounded-full`"
- :style="`width: ${(data.sub_tasks_pending / (data.sub_tasks_total ? data.sub_tasks_total : 1)) * 100}%;`"
+ :style="`width: ${(Math.max(data.sub_tasks_pending - data.sub_tasks_failed, 0) / (data.sub_tasks_total ? data.sub_tasks_total : 1)) * 100}%;`"
></div>
<div
:class="`h-1 bg-rose-600 rounded-full`"
@@ -174,21 +179,23 @@ const handleClick = (cancel: boolean = false) => {
</div>
</div>
<div class="flex gap-1 items-center ml-auto">
- <ChipTag
- :class="`h-6 shadow-sm`"
- :colour="`!text-white ${
- data.status === 'pending'
- ? 'bg-[#e4e4e4] dark:bg-white !text-neutral-900'
- : data.status === 'processing'
- ? 'bg-purple-600 dark:bg-purple-700'
- : data.status === 'completed'
- ? 'bg-[#660099] '
- : data.status === 'incomplete' || data.status === 'cancelled'
- ? 'bg-amber-500 !text-neutral-900 '
- : 'bg-rose-600 dark:bg-rose-700 '
- }`"
- :label="data.status"
- />
+ <span class="w-24 flex items-center justify-end">
+ <ChipTag
+ :class="`h-6 shadow-sm`"
+ :colour="`!text-white ${
+ data.status === 'pending'
+ ? 'bg-[#e4e4e4] dark:bg-white !text-neutral-900'
+ : data.status === 'processing'
+ ? 'bg-purple-600 dark:bg-purple-700'
+ : data.status === 'completed'
+ ? 'bg-[#660099] '
+ : data.status === 'incomplete' || data.status === 'cancelled'
+ ? 'bg-amber-500 !text-neutral-900 '
+ : 'bg-rose-600 dark:bg-rose-700 '
+ }`"
+ :label="data.status"
+ />
+ </span>
<Popover
ref="popover"
popoverClass="!w-40 rounded-lg "
diff --git a/resources/js/components/dashboard/DashboardTasks.vue b/resources/js/components/dashboard/DashboardTasks.vue
index 7b8860ab..87e9c5e3 100644
--- a/resources/js/components/dashboard/DashboardTasks.vue
+++ b/resources/js/components/dashboard/DashboardTasks.vue
@@ -2,7 +2,15 @@
import type { TaskStatsResponse } from '@/types/types';
import type { TaskResource } from '@/types/resources';
-import { getTasks, getTaskStats, startIndexFilesTask, startSyncFilesTask, startVerifyFilesTask } from '@/service/siteAPI';
+import {
+ cancelTask,
+ deleteTask,
+ getTasks,
+ getTaskStats,
+ startIndexFilesTask,
+ startSyncFilesTask,
+ startVerifyFilesTask,
+} from '@/service/siteAPI';
import { computed, onMounted, onUnmounted, ref, useTemplateRef } from 'vue';
import { toast } from '@/service/toaster/toastService';
@@ -116,21 +124,21 @@ const handleDelete = (id: number, cancel: boolean = false) => {
};
const submitCancel = async () => {
- if (cachedID.value) {
- // let request = await deleteRecord(cachedID.value);
- let request = false;
- if (request) toast.add('Success', { type: 'success', description: 'Task cancelled successfully!', life: 3000 });
- else toast.add('Error', { type: 'warning', description: 'Unable to cancel task. Please try again.', life: 3000 });
- }
+ if (!cachedID.value) return;
+ let request = await cancelTask(cachedID.value);
+ if (request) {
+ toast.add('Success', { type: 'success', description: 'Task cancelled successfully!', life: 3000 });
+ loadData();
+ } else toast.add('Error', { type: 'warning', description: 'Unable to cancel task. Please try again.', life: 3000 });
};
const submitDelete = async () => {
- if (cachedID.value) {
- // let request = await deleteRecord(cachedID.value);
- let request = false;
- if (request) toast.add('Success', { type: 'success', description: 'Task deleted successfully!', life: 3000 });
- else toast.add('Error', { type: 'warning', description: 'Unable to delete task. Please try again.', life: 3000 });
- }
+ if (!cachedID.value) return;
+ let request = await deleteTask(cachedID.value);
+ if (request) {
+ toast.add('Success', { type: 'success', description: 'Task deleted successfully!', life: 3000 });
+ loadData();
+ } else toast.add('Error', { type: 'warning', description: 'Unable to delete task. Please try again.', life: 3000 });
};
const loadData = async () => {
diff --git a/resources/js/components/video/VideoAmbientPlayer.vue b/resources/js/components/video/VideoAmbientPlayer.vue
index 3c63a6c7..a9dc6c81 100755
--- a/resources/js/components/video/VideoAmbientPlayer.vue
+++ b/resources/js/components/video/VideoAmbientPlayer.vue
@@ -88,7 +88,7 @@ watch(player, (newVal) => {
width="10"
height="6"
aria-hidden="true"
- class="absolute z-10 opacity-100 blur-lg"
+ class="absolute z-10 opacity-100 blur-lg pointer-events-none"
ref="canvas"
>
Canvas
diff --git a/resources/js/components/video/VideoPlayer.vue b/resources/js/components/video/VideoPlayer.vue
index 965e3331..5bea929a 100755
--- a/resources/js/components/video/VideoPlayer.vue
+++ b/resources/js/components/video/VideoPlayer.vue
@@ -266,6 +266,7 @@ onMounted(() => {
// console.count('loop restart');
// this.play();
// });
+ console.log(stateFolder.value.series?.thumbnail_url);
});
onUnmounted(() => {
@@ -275,16 +276,31 @@ onUnmounted(() => {
<template>
<div class="relative group rounded-xl overflow-clip">
+ <div
+ v-if="stateVideo.path?.endsWith('.mp3')"
+ class="absolute top-0 left-0 w-full h-full blur"
+ :style="`background: transparent url('${
+ stateVideo?.metadata?.poster_url ??
+ stateFolder.series?.thumbnail_url ??
+ 'https://m.media-amazon.com/images/M/MV5BMjVjZGU5ZTktYTZiNC00N2Q1LThiZjMtMDVmZDljN2I3ZWIwXkEyXkFqcGdeQXVyMTUzMTg2ODkz._V1_.jpg'
+ }') 50% 50% / cover no-repeat`"
+ ></div>
<video
id="vid-source"
width="100%"
controls
- preload="none"
type="video/mp4"
- :src="stateVideo?.path ? `../${stateVideo?.path}` : ''"
- :class="`focus:outline-none flex object-cover ${stateVideo?.path ? '' : 'aspect-video'}`"
- :poster="stateVideo?.metadata?.poster_url ?? stateFolder.series?.thumbnail_url ?? ''"
ref="player"
+ style="z-index: 3"
+ :src="stateVideo?.path ? `../${stateVideo?.path}` : ''"
+ :class="`relative focus:outline-none flex object-contain ${stateVideo?.path ? (stateVideo.path.endsWith('.mp3') ? 'max-h-[60vh]' : '') : 'aspect-video'}`"
+ :poster="
+ stateVideo?.path?.endsWith('.mp3')
+ ? (stateVideo?.metadata?.poster_url ??
+ stateFolder.series?.thumbnail_url ??
+ 'https://m.media-amazon.com/images/M/MV5BMjVjZGU5ZTktYTZiNC00N2Q1LThiZjMtMDVmZDljN2I3ZWIwXkEyXkFqcGdeQXVyMTUzMTg2ODkz._V1_.jpg')
+ : ''
+ "
@play="onPlayerPlay"
@pause="onPlayerPause"
@ended="onPlayerEnded"
@@ -301,7 +317,8 @@ onUnmounted(() => {
<track kind="captions" />
</video>
<section
- :class="`absolute ${stateVideo.path?.endsWith('.mp3') ? 'bottom-[52px] rounded-sm overflow-clip' : 'bottom-6'} w-[94.95%] m-auto left-0 right-0 opacity-0 group-hover:opacity-65 transition-opacity duration-75 h-5 pointer-events-none`"
+ style="z-index: 4"
+ :class="`absolute ${stateVideo.path?.endsWith('.mp3') ? 'bottom-[52px] z-20 rounded-sm overflow-clip' : 'bottom-6'} w-[94.95%] m-auto left-0 right-0 opacity-0 group-hover:opacity-65 transition-opacity duration-75 h-5 pointer-events-none`"
v-show="playbackHeatmap"
>
<svg class="ytp-heat-map-svg fill-indigo-200/20 h-full w-full" preserveAspectRatio="none" viewBox="0 0 1000 100">
@@ -341,8 +358,8 @@ onUnmounted(() => {
}
}
-video {
- object-fit: cover; /*to cover all the box*/
- /* background: transparent url('') 50% 50% / cover no-repeat; */
-}
+/* video {
+ object-fit: cover;
+ background: transparent url('') 50% 50% / cover no-repeat;
+} */
</style>
diff --git a/resources/js/service/siteAPI.ts b/resources/js/service/siteAPI.ts
index b60e52b1..a374fca9 100644
--- a/resources/js/service/siteAPI.ts
+++ b/resources/js/service/siteAPI.ts
@@ -54,3 +54,15 @@ export function startVerifyFilesTask(category?: number) {
export function startScanFilesTask(category?: number) {
return API.post(`/tasks/scan/${category ?? ''}`);
}
+
+export function deleteTask(taskId: number) {
+ return API.delete(`/tasks/${taskId}`);
+}
+
+export function cancelTask(taskId: number) {
+ return API.post(`/tasks/cancel/${taskId}`);
+}
+
+export function deleteSubTask(taskId: number) {
+ return API.delete(`/sub-tasks/${taskId}`);
+}
diff --git a/resources/js/stores/ContentStore.js b/resources/js/stores/ContentStore.js
index 8a19cc5e..707b802e 100755
--- a/resources/js/stores/ContentStore.js
+++ b/resources/js/stores/ContentStore.js
@@ -6,6 +6,7 @@ import { useRoute } from 'vue-router';
import recordsAPI from '@/service/recordsAPI';
import mediaAPI from '@/service/mediaAPI.ts';
+import { toast } from '@/service/toaster/toastService';
export const useContentStore = defineStore('Content', () => {
const AuthStore = useAuthStore();
@@ -90,7 +91,7 @@ export const useContentStore = defineStore('Content', () => {
return video.id === id;
});
}
- if (!result) toast.add({ type: 'danger', title: 'Invalid Video', description: 'Selected video cannot be found...' });
+ if (!result) toast.add('Invalid Video', { type: 'danger', description: 'Selected video cannot be found...' });
else {
stateVideo.value = result;
document.title = `${stateFolder.value.name} · ${stateVideo.value?.title ?? stateVideo.value?.name}`;
@@ -133,7 +134,7 @@ export const useContentStore = defineStore('Content', () => {
// statefolder (list of videos) = folder => /api/folders/8?videos=true
if (error || !response?.success) {
- toast.add({ type: 'danger', title: 'Error', description: response?.message ?? 'Unable to load data.' });
+ toast.add('Error', { type: 'danger', description: response?.message ?? 'Unable to load data.' });
pageTitle.value = 'Folder not Found';
console.log(error ?? response?.message);
return false;
@@ -146,7 +147,7 @@ export const useContentStore = defineStore('Content', () => {
pageTitle.value = stateFolder.value.name;
if (!stateFolder.value.id) {
- toast.add({ type: 'danger', title: 'Invalid folder', description: `The folder '${stateFolder.value.name}' does not exist.` });
+ toast.add('Invalid folder', { type: 'danger', description: `The folder '${stateFolder.value.name}' does not exist.` });
return false;
}
@@ -169,14 +170,14 @@ export const useContentStore = defineStore('Content', () => {
});
if (!nextFolder?.id) {
- toast.add({ type: 'danger', title: 'Invalid folder', description: `The folder '${nextFolderName}' does not exist.` });
+ toast.add('Invalid folder', { type: 'danger', description: `The folder '${nextFolderName}' does not exist.` });
return;
}
const { data, error } = await mediaAPI.getFolder(nextFolder.id); // get videos with given folder id (list of videos organised by folder id)
if (error) {
- toast.add({ type: 'danger', title: 'Invalid folder', description: `The folder '${nextFolderName}' does not exist.` });
+ toast.add('Invalid folder', { type: 'danger', description: `The folder '${nextFolderName}' does not exist.` });
pageTitle.value = 'Folder not Found';
console.log(error ?? data?.message);
return Promise.reject(false);
diff --git a/routes/api.php b/routes/api.php
index 16810b0a..94badcb4 100755
--- a/routes/api.php
+++ b/routes/api.php
@@ -40,11 +40,11 @@ Route::group(['middleware' => ['auth:sanctum']], function () {
Route::resource('/categories', CategoryController::class)->only(['index', 'update']);
Route::resource('/users', UserController::class)->only(['index', 'destroy']);
Route::resource('/sub-tasks', SubTaskController::class)->only(['show', 'destroy']);
+ Route::resource('/tasks', TasksController::class)->only(['index', 'destroy']);
Route::post('/sub-tasks/{task}', [SubTaskController::class, 'show']);
Route::prefix('tasks')->group(function () {
- Route::resource('/', TasksController::class)->only(['index', 'destroy']);
Route::get('/stats', [TasksController::class, 'stats']);
Route::post('/sync', [DirectoryController::class, 'syncFiles']);
Route::post('/index/{category?}', [DirectoryController::class, 'indexFiles']);