Skip to content

A self-hosted media server and file management system

ui optimise

aminnausinfba0c54a8424
diff --git a/app/Http/Controllers/Api/V1/SubTaskController.php b/app/Http/Controllers/Api/V1/SubTaskController.php
index e526bd0f..522a9250 100644
--- a/app/Http/Controllers/Api/V1/SubTaskController.php
+++ b/app/Http/Controllers/Api/V1/SubTaskController.php
@@ -3,11 +3,16 @@
namespace App\Http\Controllers\Api\V1;
use App\Http\Controllers\Controller;
+use App\Http\Resources\SubTasksResource;
use App\Models\SubTask;
+use App\Models\Task;
+use App\Traits\HttpResponses;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class SubTaskController extends Controller {
+ use HttpResponses;
+
/**
* Display a listing of the resource.
*/
@@ -32,8 +37,19 @@ class SubTaskController extends Controller {
/**
* Display the specified resource.
*/
- public function show(string $id) {
- //
+ public function show(Request $request, Task $task) {
+ try {
+ if (! Auth::user() || Auth::user()->id !== 1) {
+ abort(403, 'Unauthorized action.');
+ }
+
+ return
+ SubTasksResource::collection(
+ SubTask::where('task_id', $task->id)->get()->sortBy('id')
+ );
+ } catch (\Throwable $th) {
+ return $this->error(null, 'Unable to get related subtasks. Error: ' . $th->getMessage(), 500);
+ }
}
/**
diff --git a/app/Http/Controllers/Api/V1/TasksController.php b/app/Http/Controllers/Api/V1/TasksController.php
index 5d76859f..9b345462 100644
--- a/app/Http/Controllers/Api/V1/TasksController.php
+++ b/app/Http/Controllers/Api/V1/TasksController.php
@@ -25,7 +25,7 @@ class TasksController extends Controller {
return
TasksResource::collection(
- Task::all()->sortBy('id')
+ Task::all()->sortByDesc('created_at')
);
} catch (\Throwable $th) {
return $this->error(null, 'Unable to get list of tasks. Error: ' . $th->getMessage(), 500);
diff --git a/app/Http/Controllers/DirectoryController.php b/app/Http/Controllers/DirectoryController.php
index 044bb7be..863d2728 100755
--- a/app/Http/Controllers/DirectoryController.php
+++ b/app/Http/Controllers/DirectoryController.php
@@ -3,7 +3,6 @@
namespace App\Http\Controllers;
use App\Enums\TaskStatus;
-use App\Http\Requests\IndexFilesRequest;
use App\Http\Resources\FolderResource;
use App\Http\Resources\SeriesResource;
use App\Http\Resources\VideoResource;
@@ -71,8 +70,8 @@ class DirectoryController extends Controller {
$description = "Scans for file changes and loads metadata from all Libraries.";
if (isset($category)) {
- $name .= " from the Library $category->name";
- $description = "Scans for file changes and loads metadata from the specified Library $category->name";
+ $name .= " from the Library \"$category->name\"";
+ $description = "Scans for file changes and loads metadata from the specified Library \"$category->name\"";
}
try {
@@ -169,8 +168,8 @@ class DirectoryController extends Controller {
$description = "Verifies folder and video metadata for all Libraries.";
if (isset($category)) {
- $name .= " for Library $category->name";
- $description = "Verifies folder and video metadata for the specified Library $category->name";
+ $name .= " for Library \"$category->name\"";
+ $description = "Verifies folder and video metadata for the specified Library \"$category->name\"";
}
try {
@@ -215,45 +214,64 @@ class DirectoryController extends Controller {
}
public function verifyFolders(Request $request, Category $category = null) {
+ $name = "Verify Folders";
+ $description = "Verifies folder metadata for all Libraries.";
+
+ if (isset($category)) {
+ $name .= " for Library \"$category->name\"";
+ $description = "Verifies folder metadata for the specified Library \"$category->name\"";
+ }
+
try {
- $jobs = [];
- $chunks = [];
+ $userId = $request->user() ? $request->user()->id : null;
+ $task = $this->setupTask($userId, $name, $description);
+
+ $chain = [];
+
+ $folderQuery = Folder::orderBy('id');
+
+ if ($category) {
- Folder::orderBy('id')->chunk(20, function ($folders) use (&$chunks) {
- $chunks[] = $folders;
- });
- foreach ($chunks as $chunk) {
- $jobs[] = new VerifyFolders($chunk, 0);
- // break;
+ $folderQuery = $folderQuery->whereHas('category', function ($query) use ($category) {
+ $query->where('id', $category->id);
+ })->with('category');
}
- Bus::batch($jobs)->dispatch();
- dump('verifyFolders : This job has no web output. Check queue listener console for updates.');
+ $folders = $folderQuery->get();
+
+ $folders->chunk(20)->each(function ($chunk) use (&$chain, $task) {
+ $chain[] = new VerifyFolders($chunk, $task->id);
+ });
+
+ $batch = $this->setupBatch($chain, $task);
+ $task->update(['batch_id' => $batch->id, 'sub_tasks_total' => count($chain)]);
+ return response()->json(['task_id' => $task->id, 'message' => 'Async Task "VERIFY FOLDERS" was started.']);
} catch (\Throwable $th) {
- dump('Error cannot verify folder series data');
- dump($th);
+ if ($task) $task->update(['status' => TaskStatus::FAILED, 'ended_at' => now(),]);
+ return response()->json(['error' => 'Error cannot verify folders', 'details' => $th->getMessage()], 500);
+ // dump('Error cannot verify file metadata');
+ // dump($th);
}
}
public function cleanPaths(Request $request) {
$name = "Clean Paths";
$description = "Cleans file and folder paths for all Libraries.";
- $chain = [];
try {
$userId = $request->user() ? $request->user()->id : null;
$task = $this->setupTask($userId, $name, $description);
- Video::orderBy('id')->chunk(20, function ($videos) use (&$chain) {
- $chain[] = new CleanFolderPaths($videos);
- });
+ $chain = [];
- Folder::orderBy('id')->chunk(20, function ($folders) use (&$chain) {
- $chain[] = new CleanFolderPaths($folders);
+ Video::orderBy('id')->chunk(20)->each(function ($chunk) use (&$chain, $task) {
+ $chain[] = new CleanVideoPaths($chunk, $task->id);
});
- $chain[] = new SyncFiles($task->id);
+ Folder::orderBy('id')->chunk(20)->each(function ($chunk) use (&$chain, $task) {
+ $chain[] = new CleanFolderPaths($chunk, $task->id);
+ });
$batch = $this->setupBatch($chain, $task);
$task->update(['batch_id' => $batch->id, 'sub_tasks_total' => count($chain)]);
@@ -277,7 +295,7 @@ class DirectoryController extends Controller {
]);
}
- public static function setupBatch($chain, $task) {
+ public static function setupBatch($chain, Task $task) {
return Bus::batch($chain)->progress(function (Batch $batch) use ($task) {
$task->refresh();
$task->update([
@@ -317,46 +335,6 @@ class DirectoryController extends Controller {
'status' => TaskStatus::PROCESSING,
'started_at' => now(),
]);
- })->dispatch();
- }
-
- function setupBatch2($chain, $task) {
- return Bus::batch($chain)->then(function (Batch $batch) use ($task) {
- // $status = $batch->cancelled() ? TaskStatus::CANCELLED : ($batch->processedJobs() !== $task->sub_tasks_total ? TaskStatus::INCOMPLETE : TaskStatus::COMPLETED);
-
- // $task->update([
- // 'status' => $status,
- // 'sub_tasks_pending' => $batch->pendingJobs,
- // 'sub_tasks_complete' => $batch->processedJobs(),
- // 'sub_tasks_failed' => $batch->failedJobs,
- // 'ended_at' => now(),
- // ]);
- })->progress(function (Batch $batch) use ($task) {
- $task->update([
- 'sub_tasks_pending' => $batch->pendingJobs,
- 'sub_tasks_complete' => $batch->processedJobs(),
- 'sub_tasks_failed' => $batch->failedJobs,
- ]);
- })->catch(function (Batch $batch, \Throwable $e) use ($task) {
- $task->update([
- 'status' => TaskStatus::FAILED,
- ]);
- // Log the error for debugging
- Log::error('Batch failed', ['task_id' => $task->id, 'error' => $e->getMessage()]);
- })->finally(function (Batch $batch) use ($task) {
- $status = $task->status !== TaskStatus::PROCESSING ? $task->status : ($batch->cancelled() ? TaskStatus::CANCELLED : ($batch->processedJobs() !== $task->sub_tasks_total ? TaskStatus::INCOMPLETE : TaskStatus::COMPLETED));
-
- $task->update([
- 'status' => $status,
- 'sub_tasks_pending' => $batch->pendingJobs,
- 'sub_tasks_failed' => $batch->failedJobs,
- 'ended_at' => now(),
- ]);
- })->before(function (Batch $batch) use ($task) {
- $task->update([
- 'status' => TaskStatus::PROCESSING,
- 'started_at' => now(),
- ]);
- })->dispatch();
+ })->name($task->name)->dispatch();
}
}
diff --git a/app/Jobs/CleanFolderPaths.php b/app/Jobs/CleanFolderPaths.php
index 0c7dd640..31441295 100644
--- a/app/Jobs/CleanFolderPaths.php
+++ b/app/Jobs/CleanFolderPaths.php
@@ -2,43 +2,70 @@
namespace App\Jobs;
+use App\Enums\TaskStatus;
use App\Models\Folder;
+use App\Models\SubTask;
use Illuminate\Bus\Batchable;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
+use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
class CleanFolderPaths implements ShouldQueue {
use Batchable, Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+ protected $taskId;
+ protected $subTaskId;
+
/**
* Create a new job instance.
*/
- public function __construct(public $folders) {
+ public function __construct(public $folders, $taskId) {
//
+ $subTask = SubTask::create(['task_id' => $taskId, 'status' => TaskStatus::PENDING, 'name' => 'Sync Files']); //
+ $this->taskId = $taskId;
+ $this->subTaskId = $subTask->id;
}
/**
* Execute the job.
*/
public function handle(): void {
- if ($this->batch()->cancelled()) {
+ if ($this->batch() && $this->batch()->cancelled()) {
// Determine if the batch has been cancelled...
+ SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::CANCELLED, 'summary' => 'Parent Task was Cancelled']);
return;
}
- if (count($this->folders) == 0) {
- dump('Folder Data Lost');
+ DB::table('tasks')->where('id', $this->taskId)->decrement('sub_tasks_pending');
+ SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::PROCESSING, 'started_at' => now()]);
- return;
+ try {
+ $summary = $this->cleanFolderPaths();
+ 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,
+ ]);
+ } catch (\Throwable $th) {
+ 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()]);
+ }
+ }
+
+ private function cleanFolderPaths() {
+ if (count($this->folders) == 0) {
+ throw new \Exception('Folder Data Lost');
}
$transactions = [];
$error = false;
- foreach ($this->folders as $folder) {
+ foreach ($this->folders as $index => $folder) {
try {
$stored = [];
$changes = [];
@@ -54,15 +81,19 @@ class CleanFolderPaths implements ShouldQueue {
if (count($changes) > 0) {
array_push($transactions, [...$stored, ...$changes]);
}
+
+ SubTask::where('id', $this->subTaskId)->update(['progress' => (int) (($index + 1) / count($this->folders) * 100)]);
} catch (\Throwable $th) {
- dump('Error cannot clean file path ' . $th->getMessage() . ' Cancelling ' . count($transactions) . ' updates');
$error = true;
- break;
+ $errorMessage = 'Error cannot clean folder path ' . $th->getMessage() . ' Cancelling ' . count($transactions) . ' updates';
+ dump($errorMessage);
+
+ throw new \Exception($errorMessage);
}
}
if (count($transactions) == 0 || $error == true) {
- return;
+ return 'No Changes Found';
}
Folder::upsert($transactions, 'id', ['path']);
@@ -76,5 +107,7 @@ class CleanFolderPaths implements ShouldQueue {
'data' => $transactions,
];
Storage::put('dataCache.json', json_encode($dataCache, JSON_UNESCAPED_SLASHES));
+
+ return $msg;
}
}
diff --git a/app/Jobs/CleanVideoPaths.php b/app/Jobs/CleanVideoPaths.php
index 8868c7f5..afb9ebb5 100644
--- a/app/Jobs/CleanVideoPaths.php
+++ b/app/Jobs/CleanVideoPaths.php
@@ -2,6 +2,8 @@
namespace App\Jobs;
+use App\Enums\TaskStatus;
+use App\Models\SubTask;
use App\Models\Video;
use Illuminate\Bus\Batchable;
use Illuminate\Bus\Queueable;
@@ -9,36 +11,61 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
+use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
class CleanVideoPaths implements ShouldQueue {
use Batchable, Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+ protected $taskId;
+ protected $subTaskId;
+
/**
* Create a new job instance.
*/
- public function __construct(public $videos) {
+ public function __construct(public $videos, $taskId) {
//
+ $subTask = SubTask::create(['task_id' => $taskId, 'status' => TaskStatus::PENDING, 'name' => 'Sync Files']); //
+ $this->taskId = $taskId;
+ $this->subTaskId = $subTask->id;
}
/**
* Execute the job.
*/
public function handle(): void {
- if ($this->batch()->cancelled()) {
+ if ($this->batch() && $this->batch()->cancelled()) {
// Determine if the batch has been cancelled...
+ SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::CANCELLED, 'summary' => 'Parent Task was Cancelled']);
return;
}
- if (count($this->videos) == 0) {
- dump('Video Data Lost');
+ DB::table('tasks')->where('id', $this->taskId)->decrement('sub_tasks_pending');
+ SubTask::where('id', $this->subTaskId)->update(['status' => TaskStatus::PROCESSING, 'started_at' => now()]);
- return;
+ try {
+ $summary = $this->cleanVideoPaths();
+ 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,
+ ]);
+ } catch (\Throwable $th) {
+ 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()]);
+ }
+ }
+
+ private function cleanVideoPaths() {
+ if (count($this->videos) == 0) {
+ throw new \Exception('Video Data Lost');
}
$transactions = [];
$error = false;
- foreach ($this->videos as $video) {
+ foreach ($this->videos as $index => $video) {
try {
$stored = [];
$changes = [];
@@ -54,16 +81,20 @@ class CleanVideoPaths implements ShouldQueue {
if (count($changes) > 0) {
array_push($transactions, [...$stored, ...$changes]);
}
+
+ SubTask::where('id', $this->subTaskId)->update(['progress' => (int) (($index + 1) / count($this->videos) * 100)]);
} catch (\Throwable $th) {
- dump('Error cannot clean file path ' . $th->getMessage() . ' Cancelling ' . count($transactions) . ' updates');
$error = true;
- break;
+ $errorMessage = 'Error cannot clean file path ' . $th->getMessage() . ' Cancelling ' . count($transactions) . ' updates';
+ dump($errorMessage);
+
+ throw new \Exception($errorMessage);
}
}
-
if (count($transactions) == 0 || $error == true) {
- return;
+ return 'No Changes Found';
}
+
Video::upsert($transactions, 'id', ['path']);
$msg = 'Updated ' . count($transactions) . ' video path(s) from id ' . ($transactions[0]['id']) . ' to ' . ($transactions[count($transactions) - 1]['id']);
@@ -76,5 +107,7 @@ class CleanVideoPaths implements ShouldQueue {
'data' => $transactions,
];
Storage::put('dataCache.json', json_encode($dataCache, JSON_UNESCAPED_SLASHES));
+
+ return $msg;
}
}
diff --git a/resources/css/app.css b/resources/css/app.css
index 8580c944..a7da045f 100755
--- a/resources/css/app.css
+++ b/resources/css/app.css
@@ -31,4 +31,8 @@
box-shadow: 0 0 0px 1000px #8a8274c7 inset;
background-color: #645c4cc7;
} */
+
+ [v-cloak] {
+ display: none;
+ }
}
diff --git a/resources/js/components/cards/HoverCard.vue b/resources/js/components/cards/HoverCard.vue
new file mode 100644
index 00000000..b36ad809
--- /dev/null
+++ b/resources/js/components/cards/HoverCard.vue
@@ -0,0 +1,87 @@
+<script setup lang="ts">
+import { ref } from 'vue';
+import ProiconsCommentExclamation from '~icons/proicons/comment-exclamation';
+
+const props = withDefaults(
+ defineProps<{
+ content?: string;
+ positionClasses?: string;
+ }>(),
+ {
+ positionClasses: 'z-30 left-20 bottom-10',
+ },
+);
+
+const hoverCardHovered = ref<boolean>(false);
+const hoverCardDelay = ref<number>(600);
+const hoverCardLeaveDelay = ref<number>(500);
+const hoverCardTimout = ref<number | null>(null);
+const hoverCardLeaveTimeout = ref<number | null>(null);
+const tooltipStyles = ref<Record<string, string>>({});
+
+const init = ref(false);
+
+const hoverCardEnter = (event: MouseEvent) => {
+ if (props.content === '') return;
+
+ if (hoverCardLeaveTimeout.value) clearTimeout(hoverCardLeaveTimeout.value);
+
+ if (hoverCardHovered.value) return;
+
+ if (hoverCardTimout.value) clearTimeout(hoverCardTimout.value);
+
+ if (!init.value) init.value = true; // Loads into Dom after hover for the first time
+
+ hoverCardTimout.value = setTimeout(() => {
+ hoverCardHovered.value = true;
+ updateTooltipPosition(event);
+ }, hoverCardDelay.value);
+};
+
+const hoverCardLeave = () => {
+ if (props.content === '') return;
+ if (hoverCardTimout.value) clearTimeout(hoverCardTimout.value);
+
+ if (!hoverCardHovered.value) return;
+ if (hoverCardLeaveTimeout.value) clearTimeout(hoverCardLeaveTimeout.value);
+
+ hoverCardLeaveTimeout.value = setTimeout(() => {
+ hoverCardHovered.value = false;
+ }, hoverCardLeaveDelay.value);
+};
+
+const updateTooltipPosition = (event: MouseEvent) => {
+ const rect = (event.target as HTMLElement).getBoundingClientRect();
+ tooltipStyles.value = { left: `${rect.left + window.scrollX}px`, top: `${rect.bottom + window.scrollY}px` };
+};
+//relative
+</script>
+
+<template>
+ <div class="" @mouseover="hoverCardEnter" @mouseleave="hoverCardLeave">
+ <slot name="trigger">
+ <a href="#_" class="hover:underline">@thedevdojo</a>
+ </slot>
+ <Teleport to="body" v-if="init">
+ <Transition enter-from-class="opacity-0" enter-to-class="opacity-100" leave-from-class="opacity-100" leave-to-class="opacity-0">
+ <div
+ @mouseover="hoverCardEnter"
+ @mouseleave="hoverCardLeave"
+ v-show="hoverCardHovered"
+ v-cloak
+ :class="`flex ${positionClasses} absolute overflow-auto transition-opacity ease-in-out duration-200 md:max-w-xl text-sm p-3 h-fit bg-white dark:odd:bg-primary-dark-600/70 dark:bg-neutral-800/70 backdrop-blur-lg border dark:border-none rounded-md shadow-md border-neutral-200/70 gap-2 items-center`"
+ :style="tooltipStyles"
+ >
+ <slot name="icon">
+ <ProiconsCommentExclamation class="h-4 w-4 shrink-0" />
+ </slot>
+ <slot name="content">
+ <p class="text-pretty h-fit w-full break-words whitespace-pre-wrap">
+ {{ content }}
+ </p>
+ </slot>
+ </div>
+ </Transition>
+ </Teleport>
+ </div>
+</template>
diff --git a/resources/js/components/cards/SubTaskCard.vue b/resources/js/components/cards/SubTaskCard.vue
index a1daa6e4..840f4105 100644
--- a/resources/js/components/cards/SubTaskCard.vue
+++ b/resources/js/components/cards/SubTaskCard.vue
@@ -1,51 +1,42 @@
<script setup lang="ts">
import type { SubTaskResource } from '@/types/resources';
-import type { TaskStatus } from '@/types/types';
-import { toFormattedDate, toFormattedDuration, toTimeSpan, within24Hrs } from '@/service/util';
-import { ref } from 'vue';
+import { toFormattedDate, toFormattedDuration, within24Hrs } from '@/service/util';
import ButtonCorner from '@/components/inputs/ButtonCorner.vue';
-import ButtonText from '@/components/inputs/ButtonText.vue';
-import Popover from '@/components/pinesUI/Popover.vue';
+import HoverCard from '@/components/cards/HoverCard.vue';
import ChipTag from '@/components/labels/ChipTag.vue';
-import ProiconsCommentExclamation from '~icons/proicons/comment-exclamation';
-import ProiconsMoreVertical from '~icons/proicons/more-vertical';
import PulseDoughnutChart from '../charts/PulseDoughnutChart.vue';
-import ProiconsChevronDown from '~icons/proicons/chevron-down';
-import ProiconsArrowSync from '~icons/proicons/arrow-sync';
import ProiconsDelete from '~icons/proicons/delete';
-import SubTaskCard from './SubTaskCard.vue';
-import ButtonIcon from '../inputs/ButtonIcon.vue';
import ProiconsArrowReply from '~icons/proicons/arrow-reply';
const props = defineProps<{ data: SubTaskResource }>();
</script>
<template>
- <span class="flex text-left rounded-xl ring-1 ring-gray-900/5 dark:text-white shadow w-full divide-gray-300 dark:divide-neutral-400">
+ <span class="flex text-left rounded-xl dark:text-white w-full">
<section
- class="flex ring-1 ring-inset ring-purple-700 rounded-xl shadow-sm w-full bg-white dark:bg-primary-dark-800/70 dark:hover:bg-primary-dark-600 hover:bg-primary-800 p-3 gap-4 items-center flex-1"
+ class="flex ring-1 ring-inset ring-gray-900/5 hover:ring-purple-700 rounded-md shadow-sm w-full bg-white dark:bg-primary-dark-800/70 dark:hover:bg-primary-dark-600 hover:bg-primary-800 p-3 gap-4 items-center flex-1"
>
<div class="relative group flex flex-col gap-1 flex-1">
- <div class="flex gap-x-4 gap-y-2 items-center">
- <h2 class="truncate capitalize group" :title="data.name">
- {{ data.name }}
- </h2>
- <p v-if="data.summary" class="truncate text-neutral-500 dark:text-neutral-400 max-w-64 hidden md:block">
- {{ data.summary }}
- </p>
- <div
- v-if="(data.summary?.length ?? 0) > 0"
- class="flex z-30 left-20 bottom-10 absolute opacity-0 group-hover:opacity-100 transition-opacity ease-in-out duration-500 md:max-w-72 text-sm p-3 bg-white dark:odd:bg-primary-dark-600/70 dark:bg-neutral-800/70 backdrop-blur-lg border dark:border-none rounded-md shadow-md border-neutral-200/70 gap-2 items-center"
+ <HoverCard :content="data.summary ?? ''" class="flex gap-x-4 gap-y-2 items-center">
+ <template #trigger>
+ <h2 class="truncate capitalize group" :title="data.name">{{ data.name }}</h2>
+ <p v-if="data.summary" class="truncate text-neutral-500 dark:text-neutral-400 max-w-64 hidden md:block">
+ {{ data.summary }}
+ </p>
+ </template>
+ </HoverCard>
+ <div class="flex gap-x-8 gap-y-2 p">
+ <h4
+ class="text-xs text-neutral-500 dark:text-neutral-400 truncate line-clamp-1 capitalize"
+ :title="
+ `Created: ${data.created_at}\n` +
+ (data.started_at ? `Started: ${data.started_at} UTC\n` : '') +
+ (data.ended_at ? `Finished: ${data.ended_at} UTC\n` : '')
+ "
>
- <ProiconsCommentExclamation class="h-4 w-4" />
- <p class="text-wrap">{{ data.summary }}</p>
- </div>
- </div>
- <div class="flex gap-x-8 gap-y-2 overflow-clip">
- <h4 class="text-xs text-neutral-500 dark:text-neutral-400 truncate line-clamp-1 capitalize" title="">
{{
data.ended_at !== null
? `Finished: ${toFormattedDate(new Date(data.ended_at + ' UTC'), true, within24Hrs(data.ended_at + ' UTC') ? { hour: '2-digit', minute: '2-digit' } : undefined)}`
@@ -58,7 +49,7 @@ const props = defineProps<{ data: SubTaskResource }>();
class="text-xs text-neutral-500 dark:text-neutral-400 truncate line-clamp-1 capitalize w-20 hidden sm:block"
title="Duration"
>
- Duration: {{ toFormattedDuration(data.duration) }}
+ Duration: {{ toFormattedDuration(data.duration, false) }}
</h4>
</div>
</div>
@@ -130,45 +121,6 @@ const props = defineProps<{ data: SubTaskResource }>();
<template #text> Remove </template>
<template #icon> <ProiconsDelete class="h-4 w-4" /></template>
</ButtonCorner>
- <!-- <Popover
- popoverClass="!w-40 rounded-lg "
- :buttonComponent="ButtonCorner"
- :button-attributes="{
- positionClasses: 'w-7 h-7 !p-1 ml-auto',
- textClasses: 'hover:text-violet-600 dark:hover:text-violet-500',
- colourClasses: 'dark:hover:bg-neutral-900 hover:bg-gray-100 hover:shadow-md',
- label: 'Manage Permissions',
- }"
- @click.stop="() => {}"
- >
- <template #buttonIcon>
- <ProiconsMoreVertical class="h-4 w-4" />
- </template>
- <template #content>
- <div class="grid gap-4">
- <div class="space-y-2">
- <h4 class="font-medium leading-none">Manage Task</h4>
- </div>
-
- <div class="grid gap-2">
- <ButtonText class="h-8 dark:!bg-neutral-950" :title="'Scan for Folder Changes'" :to="'/profile'">
- <template #text> Run Again </template>
- <template #icon> <ProiconsArrowSync class="h-4 w-4" /></template>
- </ButtonText>
- <ButtonText
- v-if="data.status_key >= 0 && data.status_key <= 1"
- class="h-8 text-rose-600 dark:!bg-rose-700 disabled:opacity-60"
- :title="'Remove User From Server'"
- @click.stop.prevent="$emit('clickAction')"
- disabled
- >
- <template #text> Cancel </template>
- <template #icon> <ProiconsDelete class="h-4 w-4" /></template>
- </ButtonText>
- </div>
- </div>
- </template>
- </Popover> -->
</div>
</section>
<ProiconsArrowReply class="-scale-y-100 h-6 w-6 mx-2 my-auto shrink-0" />
diff --git a/resources/js/components/cards/TaskCard.vue b/resources/js/components/cards/TaskCard.vue
index fe5c6f70..c677e88a 100644
--- a/resources/js/components/cards/TaskCard.vue
+++ b/resources/js/components/cards/TaskCard.vue
@@ -1,26 +1,42 @@
<script setup lang="ts">
-import type { TaskResource } from '@/types/resources';
+import { type SubTaskResource, type TaskResource } from '@/types/resources';
-import { toFormattedDate, toFormattedDuration, toTimeSpan, within24Hrs } from '@/service/util';
+import { toFormattedDate, toFormattedDuration, within24Hrs } from '@/service/util';
+import { getSubTasks } from '@/service/siteAPI';
import { ref } from 'vue';
+import PulseDoughnutChart from '@/components/charts/PulseDoughnutChart.vue';
import ButtonCorner from '@/components/inputs/ButtonCorner.vue';
+import SubTaskCard from '@/components/cards/SubTaskCard.vue';
+import ButtonIcon from '@/components/inputs/ButtonIcon.vue';
import ButtonText from '@/components/inputs/ButtonText.vue';
+import HoverCard from '@/components/cards/HoverCard.vue';
import Popover from '@/components/pinesUI/Popover.vue';
import ChipTag from '@/components/labels/ChipTag.vue';
-import ProiconsCommentExclamation from '~icons/proicons/comment-exclamation';
import ProiconsMoreVertical from '~icons/proicons/more-vertical';
-import PulseDoughnutChart from '../charts/PulseDoughnutChart.vue';
import ProiconsChevronDown from '~icons/proicons/chevron-down';
import ProiconsArrowSync from '~icons/proicons/arrow-sync';
import ProiconsDelete from '~icons/proicons/delete';
-import SubTaskCard from './SubTaskCard.vue';
-import ButtonIcon from '../inputs/ButtonIcon.vue';
-
-const props = defineProps<{ data: TaskResource }>();
+import TableBase from '../table/TableBase.vue';
+const props = defineProps<{ data: TaskResource; isScreenSmall?: boolean }>();
+const subTasks = ref<SubTaskResource[]>([]);
+const subTasksFetched = ref(false);
const expanded = ref(false);
+
+const toggleExpanded = async () => {
+ if (!subTasksFetched.value && !expanded.value) await loadSubTasks();
+ expanded.value = !expanded.value;
+};
+
+const loadSubTasks = async () => {
+ const { data } = await getSubTasks(props.data.id);
+
+ if (Array.isArray(data?.data)) subTasks.value = data.data;
+
+ subTasksFetched.value = true;
+};
</script>
<template>
<div
@@ -30,25 +46,15 @@ const expanded = ref(false);
class="bg-white dark:bg-primary-dark-800/70 dark:hover:bg-primary-dark-600 hover:bg-primary-800 p-3 rounded-xl ring-1 ring-gray-900/5 flex gap-4 w-full items-center flex-wrap"
>
<div class="flex flex-col gap-2 sm:gap-1 flex-1 relative">
- <div class="flex gap-x-4 gap-y-2 items-center">
- <h2 class="truncate capitalize group" :title="data.name">
- {{ data.name }}
- <div
- v-if="(data.description?.length ?? 0) > 0"
- class="flex z-30 left-20 bottom-10 absolute opacity-0 group-hover:opacity-100 transition-opacity ease-in-out duration-500 md:max-w-72 text-sm p-3 bg-white dark:odd:bg-primary-dark-600/70 dark:bg-neutral-800/70 backdrop-blur-lg border dark:border-none rounded-md shadow-md border-neutral-200/70 gap-2 items-center"
- >
- <ProiconsCommentExclamation class="h-4 w-4" />
- <p class="text-wrap">{{ data.description }}</p>
- </div>
- </h2>
- <p
- v-if="data.summary"
- class="flex justify-end gap-1 flex-1 line-clamp-3 sm:line-clamp-1 text-wrap text-ellipsis sm:text-nowrap text-neutral-500 dark:text-neutral-400"
- >
- {{ data.summary }}
- </p>
- </div>
- <div class="flex justify-between md:grid grid-cols-3 flex-1 w-full md:w-fit gap-4 md:gap-1 flex-wrap">
+ <HoverCard :content="data.description ?? ''" class="flex gap-x-4 gap-y-2 items-center">
+ <template #trigger>
+ <h2 class="truncate capitalize group" :title="data.name">{{ data.name }}</h2>
+ <p v-if="data.summary" class="truncate text-neutral-500 dark:text-neutral-400 max-w-64 hidden md:block">
+ {{ data.summary }}
+ </p>
+ </template>
+ </HoverCard>
+ <div class="flex md:grid md:grid-cols-3 xl:grid-cols-5 flex-1 w-full gap-1 gap-x-4 flex-wrap">
<div class="flex gap-1 h-fit">
<img
class="aspect-square h-4 my-auto rounded-t-xl xs:rounded-full object-cover"
@@ -60,8 +66,15 @@ const expanded = ref(false);
</h4>
</div>
- <span class="flex gap-1 flex-1">
- <h4 class="text-xs text-neutral-500 dark:text-neutral-400 truncate line-clamp-1 capitalize" title="Time">
+ <span class="flex gap-1 w-full flex-wrap md:flex-nowrap col-span-2">
+ <h4
+ class="text-xs text-neutral-500 dark:text-neutral-400 xs:truncate capitalize flex-auto xs:flex-1 md:flex-auto break-words"
+ :title="
+ `Created: ${data.created_at}\n` +
+ (data.started_at ? `Started: ${data.started_at} UTC\n` : '') +
+ (data.ended_at ? `Finished: ${data.ended_at} UTC\n` : '')
+ "
+ >
{{
data.ended_at
? `Finished: ${toFormattedDate(new Date(data.ended_at + ' UTC'), true, within24Hrs(data.ended_at + ' UTC') ? { hour: '2-digit', minute: '2-digit' } : undefined)}`
@@ -70,13 +83,15 @@ const expanded = ref(false);
: `Created: ${toFormattedDate(new Date(data.created_at), true, within24Hrs(data.created_at) ? { hour: '2-digit', minute: '2-digit' } : undefined)}`
}}
</h4>
-
- <h4 class="text-xs text-neutral-500 dark:text-neutral-400 truncate line-clamp-1 capitalize" title="Time">
- {{ toFormattedDuration(data.duration) }}
+ <h4 class="text-xs text-neutral-500 dark:text-neutral-400 truncate capitalize md:ml-auto" title="Time">
+ Duration:
+ </h4>
+ <h4 class="text-xs text-neutral-500 dark:text-neutral-400 capitalize md:me-auto" title="Time">
+ {{ toFormattedDuration(data.duration, false) }}
</h4>
</span>
- <span class="flex gap-x-4">
+ <span :class="`grid xs:grid-cols-2 col-span-3 md:col-span-2 gap-x-4`">
<h4
class="text-xs text-neutral-500 dark:text-neutral-400 truncate line-clamp-1 capitalize w-20"
title="Pending Tasks"
@@ -103,7 +118,9 @@ const expanded = ref(false);
<div class="flex items-center gap-2 w-full md:w-fit">
<PulseDoughnutChart
- class="!h-8 !w-8 md:!hidden"
+ v-if="isScreenSmall ?? false"
+ v-cloak
+ class="!h-8 !w-8 sm:!hidden"
:chart-options="{
borderWidth: 0,
plugins: {
@@ -127,10 +144,10 @@ const expanded = ref(false);
],
}"
/>
- <p class="w-full text-left md:!hidden text-xs">
+ <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) }}%
</p>
- <div class="px-2 text-xs hidden md:flex flex-col gap-1 h-fit min-w-32 flex-1">
+ <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
</p>
@@ -186,7 +203,12 @@ const expanded = ref(false);
</div>
<div class="grid gap-2">
- <ButtonText class="h-8 dark:!bg-neutral-950" :title="'Scan for Folder Changes'" :to="'/profile'">
+ <ButtonText
+ class="h-8 dark:!bg-neutral-950"
+ :title="'Scan for Folder Changes'"
+ :to="'/profile'"
+ disabled
+ >
<template #text> Run Again </template>
<template #icon> <ProiconsArrowSync class="h-4 w-4" /></template>
</ButtonText>
@@ -217,7 +239,7 @@ const expanded = ref(false);
<ButtonIcon
variant="ghost"
:class="`hover:shadow-md rounded-xl transition-transform duration-200 ease-in-out p-1 w-fit h-fit dark:hover:bg-neutral-900 hover:bg-gray-100 ${expanded ? 'rotate-180' : 'rotate-0'}`"
- @click="expanded = !expanded"
+ @click="toggleExpanded"
:title="`${expanded ? 'Hide Sub Tasks' : 'Show Sub Tasks'}`"
>
<template #icon>
@@ -226,31 +248,35 @@ const expanded = ref(false);
</ButtonIcon>
</div>
</div>
- <!-- <section class="flex flex-col sm:flex-row sm:justify-between w-full text-sm text-neutral-500 dark:text-neutral-400">
- <h3 class="w-full text-wrap line-clamp-2" :title="`Description`">
- {{ data.summary ?? 'This task has no summary.' }}
- </h3>
- <span>
- <h3 class="truncate sm:text-right w-full line-clamp-1 capitalize" title="Time Started">
- Started:
- {{ data.created_at ? toFormattedDate(new Date(data.created_at)) : 'Unknown' }}
- </h3>
- <h3 class="truncate sm:text-right w-full line-clamp-1 capitalize" title="Time Started">Duration: 23m</h3>
- </span>
- </section> -->
</section>
<section
- :class="`flex flex-col gap-1 transition-all duration-300 ease-in-out ${expanded ? `py-1 h-fit` : 'overflow-hidden '}`"
- :style="`height: ${expanded ? `${Math.max(52, (data?.sub_tasks?.length ?? 0) * (68 + 4))}px` : '0px'};`"
+ :class="`scrollbar-hide flex flex-col gap-1 transition-all duration-300 ease-in-out rounded-xl px-1 ${expanded ? `py-1 max-h-[800px] overflow-y-auto` : 'overflow-hidden max-h-0'}`"
>
- <SubTaskCard v-for="subTask in data.sub_tasks" :key="subTask.id" :data="subTask" />
<div
- v-if="(data.sub_tasks?.length ?? 0) == 0"
+ v-if="(subTasks.length ?? 0) == 0"
class="col-span-full flex items-center justify-center text-center text-gray-500 dark:text-gray-400 uppercase tracking-wider w-full gap-2 text-sm my-auto"
>
{{ 'No Sub Tasks Found' }}
</div>
+ <SubTaskCard
+ v-if="subTasks.length <= 8"
+ v-for="subTask in subTasks.slice(0, Math.min(subTasks.length, 8))"
+ :key="subTask.id"
+ :data="subTask"
+ />
+ <TableBase
+ v-else
+ :class="'p-1'"
+ :pagination-class="'pe-10 -mt-2 text-sm'"
+ :use-pagination="true"
+ :data="subTasks"
+ :row="SubTaskCard"
+ :loading="false"
+ :table-styles="'gap-4 xs:gap-2'"
+ :use-toolbar="false"
+ :items-per-page="8"
+ />
</section>
</div>
</template>
diff --git a/resources/js/components/dashboard/DashboardTasks.vue b/resources/js/components/dashboard/DashboardTasks.vue
index bbcc57b2..6552ca99 100644
--- a/resources/js/components/dashboard/DashboardTasks.vue
+++ b/resources/js/components/dashboard/DashboardTasks.vue
@@ -4,7 +4,7 @@ import type { TaskResource } from '@/types/resources';
import { getTasks, getTaskStats, startIndexFilesTask, startSyncFilesTask, startVerifyFilesTask } from '@/service/siteAPI';
-import { computed, onMounted, ref, useTemplateRef } from 'vue';
+import { computed, onMounted, onUnmounted, ref, useTemplateRef } from 'vue';
import { toast } from '@/service/toaster/toastService';
import ButtonText from '@/components/inputs/ButtonText.vue';
@@ -62,10 +62,11 @@ const sortingOptions = ref([
},
]);
-const taskStats = ref<TaskStatsResponse>();
-const tasks = ref<TaskResource[]>([]);
+const isScreenSmall = ref(false);
const cachedID = ref<number | null>(null);
+const taskStats = ref<TaskStatsResponse>();
+const tasks = ref<TaskResource[]>([]);
const taskPopover = useTemplateRef('taskPopover');
@@ -100,6 +101,8 @@ const handleSort = async (column = 'date', dir = 1) => {
return `${valueA}`?.localeCompare(`${valueB}`) * dir;
});
tasks.value = tempList;
+ console.log('sort done');
+
return tempList;
};
@@ -142,9 +145,19 @@ const handleStartTask = async (job: 'index' | 'sync' | 'verify') => {
taskPopover.value?.handleClose();
};
+const updateScreenSize = () => {
+ isScreenSmall.value = window.innerWidth < 640;
+};
+
onMounted(() => {
+ updateScreenSize();
+ window.addEventListener('resize', updateScreenSize);
loadData();
});
+
+onUnmounted(() => {
+ window.removeEventListener('resize', updateScreenSize);
+});
</script>
<template>
@@ -227,6 +240,7 @@ onMounted(() => {
:use-pagination="true"
:data="[...filteredTasks]"
:row="TaskCard"
+ :row-attributes="{ isScreenSmall }"
:loading="false"
:clickAction="handleDelete"
:sort-action="handleSort"
diff --git a/resources/js/components/pinesUI/HoverCard.vue b/resources/js/components/pinesUI/HoverCard.vue
index dfc2bd22..b65c8bca 100644
--- a/resources/js/components/pinesUI/HoverCard.vue
+++ b/resources/js/components/pinesUI/HoverCard.vue
@@ -1,54 +1,66 @@
-<script setup>
+<script setup lang="ts">
import { reactive } from 'vue';
-const data = reactive({
+const data = reactive<{
+ hoverCardHovered: boolean;
+ hoverCardDelay: number;
+ hoverCardLeaveDelay: number;
+ hoverCardTimout: number | null;
+ hoverCardLeaveTimeout: number | null;
+ tooltipStyles: Record<string, string>;
+}>({
hoverCardHovered: false,
hoverCardDelay: 600,
hoverCardLeaveDelay: 500,
hoverCardTimout: null,
hoverCardLeaveTimeout: null,
+ tooltipStyles: {},
});
-const hoverCardEnter = () => {
- clearTimeout(data.hoverCardLeaveTimeout);
+const hoverCardEnter = (event: MouseEvent) => {
+ if (data.hoverCardLeaveTimeout) clearTimeout(data.hoverCardLeaveTimeout);
if (data.hoverCardHovered) return;
- clearTimeout(data.hoverCardTimout);
+ if (data.hoverCardTimout) clearTimeout(data.hoverCardTimout);
data.hoverCardTimout = setTimeout(() => {
data.hoverCardHovered = true;
+ updateTooltipPosition(event);
}, data.hoverCardDelay);
};
const hoverCardLeave = () => {
- clearTimeout(data.hoverCardTimout);
+ if (data.hoverCardTimout) clearTimeout(data.hoverCardTimout);
if (!data.hoverCardHovered) return;
- clearTimeout(data.hoverCardLeaveTimeout);
+ if (data.hoverCardLeaveTimeout) clearTimeout(data.hoverCardLeaveTimeout);
data.hoverCardLeaveTimeout = setTimeout(() => {
data.hoverCardHovered = false;
}, data.hoverCardLeaveDelay);
};
+
+const updateTooltipPosition = (event: MouseEvent) => {
+ const rect = (event.target as HTMLElement).getBoundingClientRect();
+ console.log(event.target);
+ data.tooltipStyles = { left: `${rect.left + window.scrollX}px`, top: `${rect.bottom + window.scrollY}px` };
+};
</script>
<template>
- <div class="relative" @mouseover="hoverCardEnter()" @mouseleave="hoverCardLeave()">
- <slot name="content">Hover Over ME</slot>
+ <div class="relative" @mouseover="hoverCardEnter" @mouseleave="hoverCardLeave">
+ <slot name="trigger">
+ <a href="#_" class="hover:underline">@thedevdojo</a>
+ </slot>
- <Transition
- :enter-active-class="`transition ease-out duration-300`"
- enter-from-class="translate-y-6"
- enter-to-class="translate-y-0"
- :leave-active-class="`transition ease-in duration-300`"
- leave-from-class="translate-y-0"
- leave-to-class="translate-y-6"
- >
- <div v-show="data.hoverCardHovered" class="absolute top-0 max-w-lg z-30 left-1/2" v-cloak>
+ <Teleport to="body">
+ <Transition enter-from-class="opacity-0" enter-to-class="opacity-100" leave-from-class="opacity-100" leave-to-class="opacity-0">
<div
v-show="data.hoverCardHovered"
- class="w-[full] h-auto bg-white space-x-3 p-5 flex items-start rounded-md shadow-sm border border-neutral-200/70"
+ :style="data.tooltipStyles"
+ :class="`absolute w-[365px] max-w-[100vw] md:max-w-lg z-30 transition-all duration-300 ease-in-out -translate-x-1/2 translate-y-3 left-1/2 h-auto bg-white space-x-3 p-5 flex items-start rounded-md shadow-sm border border-neutral-200/70`"
+ v-cloak
>
- <slot name="hover-content">
+ <slot name="content">
<img src="https://cdn.devdojo.com/users/June2022/devdojo.jpg" alt="devdojo image" class="rounded-full w-14 h-14" />
<div class="relative">
<p class="mb-1 font-bold">@thedevdojo</p>
@@ -75,7 +87,7 @@ const hoverCardLeave = () => {
</div>
</slot>
</div>
- </div>
- </Transition>
+ </Transition>
+ </Teleport>
</div>
</template>
diff --git a/resources/js/components/pinesUI/Popover.vue b/resources/js/components/pinesUI/Popover.vue
index 3aa99bb5..822ea429 100644
--- a/resources/js/components/pinesUI/Popover.vue
+++ b/resources/js/components/pinesUI/Popover.vue
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { OnClickOutside } from '@vueuse/components';
import { UseFocusTrap } from '@vueuse/integrations/useFocusTrap/component';
-import { nextTick, onMounted, ref, useTemplateRef, watch, type Component, type ComponentPublicInstance } from 'vue';
+import { nextTick, onMounted, onUnmounted, ref, useTemplateRef, watch, type Component, type ComponentPublicInstance } from 'vue';
import ButtonText from '@/components/inputs/ButtonText.vue';
@@ -31,6 +31,8 @@ const popoverButton = useTemplateRef<ComponentPublicInstance>('popoverButton');
const popoverInner = ref<null | HTMLElement>(null);
const popoverArrowRef = useTemplateRef('popoverArrowRef');
+const resizeTimeout = ref<null | number>(null);
+
async function popoverHeightCalculate() {
if (!popover.value) return;
popover.value.$el.classList.add('invisible');
@@ -71,10 +73,9 @@ const adjustPopoverPosition = () => {
adjustment = viewportWidth - popoverRect.right - margin;
} else if (viewportWidth > popoverRect.width + margin * 2 && popoverRect.left <= margin) {
adjustment = margin * 2;
- console.log(adjustment);
+ // console.log(adjustment);
} else {
- console.log(viewportWidth, popoverRect.width + margin * 2, popoverRect.left);
-
+ // console.log(viewportWidth, popoverRect.width + margin * 2, popoverRect.left);
return;
}
@@ -103,14 +104,19 @@ watch(
);
onMounted(() => {
- window.addEventListener('resize', function () {
- popoverPositionCalculate();
- });
+ window.addEventListener('resize', popoverPositionCalculate);
setTimeout(function () {
popoverHeightCalculate();
}, 100);
});
+
+onUnmounted(() => {
+ window.removeEventListener('resize', popoverPositionCalculate);
+ if (resizeTimeout.value) {
+ clearTimeout(resizeTimeout.value);
+ }
+});
</script>
<template>
<div class="relative flex">
@@ -232,9 +238,3 @@ onMounted(() => {
</Transition>
</div>
</template>
-
-<style scoped>
-[v-cloak] {
- display: none;
-}
-</style>
diff --git a/resources/js/components/table/TableBase.vue b/resources/js/components/table/TableBase.vue
index f35f070d..33be7814 100755
--- a/resources/js/components/table/TableBase.vue
+++ b/resources/js/components/table/TableBase.vue
@@ -19,6 +19,7 @@ const props = withDefaults(
useGrid?: string;
data: any[];
row: Component;
+ rowAttributes?: { [key: string]: any };
loading?: boolean;
clickAction?: any;
otherAction?: any;
@@ -33,6 +34,7 @@ const props = withDefaults(
selectedID?: any;
tableStyles?: string;
startAscending?: boolean;
+ paginationClass?: string;
}>(),
{
useToolbar: true,
@@ -58,7 +60,7 @@ const handleSortChange = (sortKey?: { title?: string; value?: string; disabled?:
watch(props.data, tableData.handlePageReset, { immediate: true });
onMounted(() => {
- props.sortAction(lastSortKey.value, props.startAscending ? 1 : -1);
+ if (props.useToolbar && props.sortAction) props.sortAction(lastSortKey.value, props.startAscending ? 1 : -1);
});
</script>
@@ -119,6 +121,7 @@ onMounted(() => {
:data="row"
:index="index"
:currentID="props.selectedID ?? null"
+ v-bind="rowAttributes"
@clickAction="props.clickAction(row?.id)"
@otherAction="$emit('otherAction', $event)"
></component>
@@ -126,6 +129,7 @@ onMounted(() => {
<!-- <hr class="p-0" /> -->
<TablePagination
v-if="usePagination"
+ :class="paginationClass"
:listLength="props.data?.length ?? 0"
:itemsPerPage="tableData.fields.itemsPerPage"
:currentPage="tableData.fields.currentPage"
diff --git a/resources/js/service/siteAPI.ts b/resources/js/service/siteAPI.ts
index dd6b4159..b60e52b1 100644
--- a/resources/js/service/siteAPI.ts
+++ b/resources/js/service/siteAPI.ts
@@ -27,6 +27,10 @@ export function getTasks() {
return API.get('/tasks');
}
+export function getSubTasks(taskId: number) {
+ return API.post(`/sub-tasks/${taskId}`);
+}
+
export function getTaskStats() {
return API.get('/tasks/stats');
}
diff --git a/resources/js/service/util.ts b/resources/js/service/util.ts
index 9ac25745..6952b05c 100644
--- a/resources/js/service/util.ts
+++ b/resources/js/service/util.ts
@@ -60,13 +60,13 @@ export function toFormattedDate(
return toUpperCase ? result.toLocaleUpperCase() : result;
}
-export function toFormattedDuration(rawSeconds: number = 0) {
+export function toFormattedDuration(rawSeconds: number = 0, leadingZero: boolean = true) {
if (isNaN(parseInt(rawSeconds?.toString() ?? '0'))) return null;
const hours = Math.floor(rawSeconds / 3600);
const minutes = Math.floor((rawSeconds % 3600) / 60);
const seconds = Math.floor(rawSeconds % 60);
- const duration = `${hours > 0 ? `${hours}h ` : ''}${minutes > 0 ? `${minutes}m ` : ''}${`${formatInteger(seconds)}s`}`;
+ const duration = `${hours > 0 ? `${hours}h ` : ''}${minutes > 0 ? `${minutes}m ` : ''}${`${leadingZero ? formatInteger(seconds) : `${seconds}`}s`}`;
return duration;
}
diff --git a/routes/api.php b/routes/api.php
index 27b8ab35..16810b0a 100755
--- a/routes/api.php
+++ b/routes/api.php
@@ -9,6 +9,7 @@ use App\Http\Controllers\Api\V1\PlaybackController;
use App\Http\Controllers\Api\V1\ProfileController;
use App\Http\Controllers\Api\V1\RecordController;
use App\Http\Controllers\Api\V1\SeriesController;
+use App\Http\Controllers\Api\V1\SubTaskController;
use App\Http\Controllers\Api\V1\TagController;
use App\Http\Controllers\Api\V1\TasksController;
use App\Http\Controllers\Api\V1\UserController;
@@ -38,14 +39,19 @@ Route::group(['middleware' => ['auth:sanctum']], function () {
Route::resource('/analytics', AnalyticsController::class)->only(['index']);
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::post('/sub-tasks/{task}', [SubTaskController::class, 'show']);
Route::prefix('tasks')->group(function () {
- Route::resource('/', TasksController::class)->only(['index']);
+ 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']);
Route::post('/verify/{category?}', [DirectoryController::class, 'verifyFiles']);
+ Route::post('/verify-folders/{category?}', [DirectoryController::class, 'verifyFolders']);
Route::post('/scan/{category?}', [DirectoryController::class, 'scanFiles']);
+ Route::post('/clean', [DirectoryController::class, 'cleanPaths']);
});
});