Skip to content

A self-hosted media server and file management system

user list and running tasks from ui

aminnausina92fcb57484d
diff --git a/app/Actions/FetchIpAddress.php b/app/Actions/FetchIpAddress.php
new file mode 100644
index 00000000..2e6b36ca
--- /dev/null
+++ b/app/Actions/FetchIpAddress.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Actions;
+
+interface FetchesIpAddress {
+ public function __invoke(): ?string;
+}
+
+class FetchIpAddress implements FetchesIpAddress {
+ public function __invoke(): ?string {
+ if (app()->runningInConsole()) {
+ return 'console';
+ }
+
+ return request()->ip();
+ }
+}
diff --git a/app/Enums/TaskStatus.php b/app/Enums/TaskStatus.php
new file mode 100644
index 00000000..b89f715a
--- /dev/null
+++ b/app/Enums/TaskStatus.php
@@ -0,0 +1,54 @@
+<?php
+
+namespace App\Enums;
+
+enum TaskStatus: string {
+ case PENDING = 'pending';
+ case PROCESSING = 'processing';
+ case COMPLETE = 'complete';
+ case CANCELLED = 'cancelled';
+ case FAILED = 'failed';
+ case INCOMPLETE = 'incomplete';
+
+
+ public function isPending(): bool {
+ return $this === self::PENDING;
+ }
+
+ public function isProcessing(): bool {
+ return $this === self::PROCESSING;
+ }
+
+ public function isComplete(): bool {
+ return $this === self::PROCESSING;
+ }
+
+ public function isCancelled(): bool {
+ return $this === self::PROCESSING;
+ }
+
+ public function isFailed(): bool {
+ return $this === self::PROCESSING;
+ }
+
+ public function isIncomplete(): bool {
+ return $this === self::INCOMPLETE;
+ }
+
+ /**
+ * Check if a given value is a valid enum case.
+ */
+ public static function isValid(string $type): bool {
+ foreach (self::cases() as $case) {
+ if ($case->value === $type) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public static function getValues(): array {
+ return array_column(self::cases(), 'value');
+ }
+}
diff --git a/app/Http/Controllers/Api/V1/UserController.php b/app/Http/Controllers/Api/V1/UserController.php
new file mode 100644
index 00000000..0a8f1f58
--- /dev/null
+++ b/app/Http/Controllers/Api/V1/UserController.php
@@ -0,0 +1,49 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1;
+
+use App\Http\Controllers\Controller;
+use App\Http\Resources\UserResource;
+use App\Models\User;
+use App\Traits\HttpResponses;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\DB;
+
+class UserController extends Controller {
+ use HttpResponses;
+
+ /**
+ * Display a listing of the resource.
+ */
+ public function index() {
+ try {
+ if (! Auth::user() || Auth::user()->id !== 1) {
+ abort(403, 'Unauthorized action.');
+ }
+
+ return
+ UserResource::collection(
+ User::all()->sortBy('name')
+ );
+ } catch (\Throwable $th) {
+ return $this->error(null, 'Unable to get list of users. Error: ' . $th->getMessage(), 500);
+ }
+ }
+
+
+ public function SessionCount() {
+ try {
+ if (! Auth::user() || Auth::user()->id !== 1) {
+ abort(403, 'Unauthorized action.');
+ }
+
+ $count = DB::table('sessions')
+ ->whereNotNull('user_id')
+ ->count();
+
+ return $count;
+ } catch (\Throwable $th) {
+ return $this->error(null, 'Unable to get count of logged in of users. Error: ' . $th->getMessage(), 500);
+ }
+ }
+}
diff --git a/app/Http/Controllers/DirectoryController.php b/app/Http/Controllers/DirectoryController.php
index 1b788d52..2b5861d9 100755
--- a/app/Http/Controllers/DirectoryController.php
+++ b/app/Http/Controllers/DirectoryController.php
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
+use App\Http\Requests\IndexFilesRequest;
use App\Http\Resources\FolderResource;
use App\Http\Resources\SeriesResource;
use App\Http\Resources\VideoResource;
@@ -31,7 +32,7 @@ class DirectoryController extends Controller {
$dir = trim(strtolower($request?->dir ?? ''));
$folderName = trim(strtolower($request?->folderName ?? ''));
- if (isset($privateCategories[$dir]) && (! $request->user('sanctum')) || Auth::user()->id !== 1) {
+ if (isset($privateCategories[$dir]) && (! $request->user('sanctum')) || (Auth::user() && Auth::user()->id !== 1)) {
$data['message'] = 'Unauthorized';
return $this->error(null, 'Access to this folder is forbidden', 403);
@@ -61,9 +62,66 @@ class DirectoryController extends Controller {
}
}
- public function indexFiles(Request $request) {
+ public function scanFiles(Request $request, Category $category = null) {
+ try {
+ $chain = [
+ new SyncFiles,
+ new IndexFiles,
+ ];
+
+ $fileChunks = [];
+
+ if ($category) {
+ $videos = Video::whereHas('folder.category', function ($query) use ($category) {
+ $query->where('id', $category->id);
+ })
+ ->with('folder.category')
+ ->orderBy('id')
+ ->get();
+ } else {
+ $videos = Video::orderBy('id')->get();
+ }
+
+ $videos->chunk(20, function ($videos) use (&$fileChunks) {
+ $fileChunks[] = $videos;
+ });
+
+ foreach ($fileChunks as $chunk) {
+ $chain[] = new VerifyFiles($chunk);
+ }
+
+ $folderChunks = [];
+ if ($category) {
+ $folders = Folder::whereHas('category', function ($query) use ($category) {
+ $query->where('id', $category->id);
+ })
+ ->with('category')
+ ->orderBy('id')
+ ->get();
+ } else {
+ $folders = Folder::orderBy('id')->get();
+ }
+
+ $folders->chunk(20)->each(function ($chunk) use (&$folderChunks) {
+ $folderChunks[] = $chunk;
+ });
+
+ foreach ($folderChunks as $chunk) {
+ $chain[] = new VerifyFolders($chunk);
+ }
+
+ Bus::batch($chain)->dispatch();
+
+ // dump('All jobs have been dispatched: Sync, Index, Verify Files, and Verify Folders.');
+ } catch (\Throwable $th) {
+ // dump('Error: cannot process the jobs');
+ // dump($th);
+ abort(500, $th->getMessage());
+ }
+ }
+
+ public function indexFiles(Request $request, Category $category = null) {
try {
- // IndexFiles::dispatchSync();
$chain = [
new SyncFiles,
new IndexFiles,
@@ -86,12 +144,23 @@ class DirectoryController extends Controller {
}
}
- public function verifyFiles(Request $request) {
+ public function verifyFiles(Request $request, Category $category = null) {
try {
$jobs = [];
$chunks = [];
- Video::orderBy('id')->chunk(20, function ($videos) use (&$chunks) {
+ if ($category) {
+ $videos = Video::whereHas('folder.category', function ($query) use ($category) {
+ $query->where('id', $category->id);
+ })
+ ->with('folder.category')
+ ->orderBy('id')
+ ->get();
+ } else {
+ $videos = Video::orderBy('id')->get();
+ }
+
+ $videos->chunk(20, function ($videos) use (&$chunks) {
$chunks[] = $videos;
});
@@ -111,8 +180,24 @@ class DirectoryController extends Controller {
$jobs = [];
$chunks = [];
- Folder::orderBy('id')->chunk(20, function ($folders) use (&$chunks) {
- $chunks[] = $folders;
+ // Folder::orderBy('id')->chunk(20, function ($folders) use (&$chunks) {
+ // $chunks[] = $folders;
+ // });
+
+ $chunks = [];
+ if ($category) {
+ $folders = Folder::whereHas('category', function ($query) use ($category) {
+ $query->where('id', $category->id);
+ })
+ ->with('category')
+ ->orderBy('id')
+ ->get();
+ } else {
+ $folders = Folder::orderBy('id')->get();
+ }
+
+ $folders->chunk(20)->each(function ($chunk) use (&$chunks) {
+ $chunks[] = $chunk;
});
foreach ($chunks as $chunk) {
@@ -128,7 +213,7 @@ class DirectoryController extends Controller {
}
}
- public function verifyFolders(Request $request) {
+ public function verifyFolders(Request $request, Category $category = null) {
try {
$jobs = [];
$chunks = [];
diff --git a/app/Http/Middleware/UserLastActive.php b/app/Http/Middleware/UserLastActive.php
new file mode 100644
index 00000000..bc4e73a7
--- /dev/null
+++ b/app/Http/Middleware/UserLastActive.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use App\Models\User;
+use Carbon\Carbon;
+use Closure;
+use Illuminate\Support\Facades\Auth;
+
+class UserLastActive {
+ /**
+ * Handle an incoming request.
+ *
+ * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
+ */
+ public function handle($request, Closure $next) {
+ if (Auth::check()) {
+ User::where('id', Auth::user()->id)->update(['last_active' => Carbon::now()]);
+ }
+ return $next($request);
+ }
+}
diff --git a/app/Http/Requests/IndexFilesRequest.php b/app/Http/Requests/IndexFilesRequest.php
new file mode 100644
index 00000000..3d8e5218
--- /dev/null
+++ b/app/Http/Requests/IndexFilesRequest.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+use Illuminate\Support\Facades\Auth;
+
+class IndexFilesRequest extends FormRequest {
+ /**
+ * Determine if the user is authorized to make this request.
+ */
+ public function authorize(): bool {
+ return Auth::check();
+ }
+
+ /**
+ * Get the validation rules that apply to the request.
+ * Gets list of category ids to index
+ *
+ * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
+ */
+ public function rules(): array {
+ return [
+ 'categories' => 'sometimes|array',
+ 'categories.*' => 'integer|min:1'
+ ];
+ }
+}
diff --git a/app/Http/Resources/UserResource.php b/app/Http/Resources/UserResource.php
new file mode 100644
index 00000000..8f496637
--- /dev/null
+++ b/app/Http/Resources/UserResource.php
@@ -0,0 +1,23 @@
+<?php
+
+namespace App\Http\Resources;
+
+use Illuminate\Http\Request;
+use Illuminate\Http\Resources\Json\JsonResource;
+
+class UserResource extends JsonResource {
+ /**
+ * Transform the resource into an array.
+ *
+ * @return array<string, mixed>
+ */
+ public function toArray(Request $request): array {
+ return [
+ 'id' => $this->id,
+ 'name' => $this->name,
+ 'email' => $this->email,
+ 'created_at' => $this->created_at,
+ 'last_active' => $this->last_active,
+ ];
+ }
+}
diff --git a/app/Models/SubTask.php b/app/Models/SubTask.php
new file mode 100644
index 00000000..81b6bbd7
--- /dev/null
+++ b/app/Models/SubTask.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+use App\Enums\TaskStatus;
+
+class SubTask extends Model {
+ protected $fillable = [
+ 'task_id',
+ 'name',
+ 'status',
+ 'started_at',
+ 'ended_at',
+ ];
+
+ protected $casts = [
+ 'status' => TaskStatus::class,
+ ];
+
+ public function task() {
+ return $this->belongsTo(Task::class);
+ }
+}
diff --git a/app/Models/Task.php b/app/Models/Task.php
new file mode 100644
index 00000000..cc44608e
--- /dev/null
+++ b/app/Models/Task.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+use App\Enums\TaskStatus;
+use Illuminate\Database\Eloquent\Relations\HasMany;
+
+class Task extends Model {
+ protected $fillable = [
+ 'user_id',
+ 'name',
+ 'summary',
+ 'status',
+ 'sub_tasks',
+ 'sub_tasks_pending',
+ 'sub_tasks_completed',
+ 'sub_tasks_failed',
+ 'started_at',
+ 'ended_at',
+ ];
+
+ protected $casts = [
+ 'status' => TaskStatus::class,
+ ];
+
+ public function user() {
+ return $this->belongsTo(User::class);
+ }
+
+ public function sub_tasks(): HasMany {
+ return $this->hasMany(SubTask::class);
+ }
+}
diff --git a/bootstrap/app.php b/bootstrap/app.php
index 54b68c76..194466e4 100755
--- a/bootstrap/app.php
+++ b/bootstrap/app.php
@@ -20,7 +20,9 @@ return Application::configure(basePath: dirname(__DIR__))
->withMiddleware(function (Middleware $middleware) {
$middleware->statefulApi();
$middleware->append(TrustProxies::class);
- $middleware->web(append: []);
+ $middleware->web(append: [
+ \App\Http\Middleware\UserLastActive::class,
+ ]);
$middleware->api(prepend: []);
$middleware->alias([
'auth' => Authenticate::class,
diff --git a/database/migrations/2024_12_24_064559_create_edits_table.php b/database/migrations/2024_12_24_064559_create_edits_table.php
index 1b4ea21d..c2812f08 100644
--- a/database/migrations/2024_12_24_064559_create_edits_table.php
+++ b/database/migrations/2024_12_24_064559_create_edits_table.php
@@ -12,10 +12,9 @@ return new class extends Migration {
Schema::create('edits', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->onDelete('cascade');
- $table->string('entity_type', 50);
+ $table->string('entity_type');
$table->unsignedBigInteger('entity_id');
$table->json('changes');
- $table->timestamp('timestamp');
$table->timestamps();
// Indexes
diff --git a/database/migrations/2024_12_24_064632_create_activity_table.php b/database/migrations/2024_12_24_064632_create_activity_table.php
index 0a6d53ab..d6bb619f 100644
--- a/database/migrations/2024_12_24_064632_create_activity_table.php
+++ b/database/migrations/2024_12_24_064632_create_activity_table.php
@@ -11,12 +11,12 @@ return new class extends Migration {
public function up(): void {
Schema::create('activity', function (Blueprint $table) {
$table->id();
- $table->foreignId('user_id')->constrained()->onDelete('cascade');
- $table->string('activity_type', 50);
- $table->string('ip_address', 45);
- $table->timestamp('timestamp');
+ $table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
+ $table->string('ip_address', 45)->nullable()->default(null);
+ $table->string('activity_type');
+ $table->string('summary');
+ $table->timestamp('created_at');
$table->unsignedBigInteger('related_id')->nullable();
- $table->timestamps();
// Indexes
$table->index('activity_type');
diff --git a/database/migrations/2024_12_24_064717_create_server_jobs_and_sub_jobs_table.php b/database/migrations/2024_12_24_064717_create_server_jobs_and_sub_jobs_table.php
deleted file mode 100644
index e0775615..00000000
--- a/database/migrations/2024_12_24_064717_create_server_jobs_and_sub_jobs_table.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-return new class extends Migration
-{
- /**
- * Run the migrations.
- */
- public function up(): void
- {
- Schema::create('server_jobs_and_sub_jobs', function (Blueprint $table) {
- $table->id();
- $table->timestamps();
- });
- }
-
- /**
- * Reverse the migrations.
- */
- public function down(): void
- {
- Schema::dropIfExists('server_jobs_and_sub_jobs');
- }
-};
diff --git a/database/migrations/2024_12_24_064717_create_tasks_and_sub_tasks_table.php b/database/migrations/2024_12_24_064717_create_tasks_and_sub_tasks_table.php
new file mode 100644
index 00000000..8c183006
--- /dev/null
+++ b/database/migrations/2024_12_24_064717_create_tasks_and_sub_tasks_table.php
@@ -0,0 +1,47 @@
+<?php
+
+use App\Enums\TaskStatus;
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration {
+ /**
+ * Run the migrations.
+ */
+ public function up(): void {
+ Schema::create('tasks', function (Blueprint $table) {
+ $table->id();
+ $table->foreignId('user_id')->constrained()->nullOnDelete();
+ $table->string('status')->default(TaskStatus::PENDING);
+ $table->string('name')->nullable();
+ $table->string('summary')->nullable();
+ $table->unsignedSmallInteger('sub_tasks')->default(0);
+ $table->unsignedSmallInteger('sub_tasks_pending')->default(0);
+ $table->unsignedSmallInteger('sub_tasks_complete')->default(0);
+ $table->unsignedSmallInteger('sub_tasks_failed')->default(0);
+ $table->timestamp('started_at')->nullable();
+ $table->timestamp('ended_at')->nullable();
+ $table->timestamps();
+ });
+
+ Schema::create('sub_tasks', function (Blueprint $table) {
+ $table->id();
+ $table->foreignId('tasks_id')->constrained()->cascadeOnDelete();
+ $table->string('status')->default(TaskStatus::PENDING);
+ $table->string('name')->nullable();
+ $table->unsignedInteger('model_count');
+ $table->timestamp('started_at')->nullable();
+ $table->timestamp('ended_at')->nullable();
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void {
+ Schema::dropIfExists('tasks');
+ Schema::dropIfExists('sub_tasks');
+ }
+};
diff --git a/database/migrations/2024_12_27_175027_add_last_active_to_user_table.php b/database/migrations/2024_12_27_175027_add_last_active_to_user_table.php
new file mode 100644
index 00000000..566cee35
--- /dev/null
+++ b/database/migrations/2024_12_27_175027_add_last_active_to_user_table.php
@@ -0,0 +1,25 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration {
+ /**
+ * Run the migrations.
+ */
+ public function up(): void {
+ Schema::table('users', function (Blueprint $table) {
+ $table->timestamp('last_active')->nullable();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void {
+ Schema::table('users', function (Blueprint $table) {
+ $table->dropColumn('last_active');
+ });
+ }
+};
diff --git a/resources/js/components/cards/CategoryCard.vue b/resources/js/components/cards/CategoryCard.vue
index ba912f5d..5aba6351 100644
--- a/resources/js/components/cards/CategoryCard.vue
+++ b/resources/js/components/cards/CategoryCard.vue
@@ -4,7 +4,7 @@ import { type CategoryResource, type FolderResource } from '@/types/resources';
import { formatFileSize, toFormattedDate } from '@/service/util';
import { useQueryClient } from '@tanstack/vue-query';
import { updateCategory } from '@/service/mediaAPI.ts';
-import { ref, watch } from 'vue';
+import { ref, useTemplateRef, watch } from 'vue';
import { toast } from '@/service/toaster/toastService';
import Popover from '@/components/pinesUI/Popover.vue';
@@ -17,12 +17,15 @@ import ProiconsArrowSync from '~icons/proicons/arrow-sync';
import ProiconsDelete from '~icons/proicons/delete';
import ProiconsLock from '~icons/proicons/lock';
import CircumEdit from '~icons/circum/edit';
+import { startScanFilesTask } from '@/service/siteAPI';
const props = defineProps<{ data?: CategoryResource }>();
const defaultFolder = ref<FolderResource>();
const queryClient = useQueryClient();
const processing = ref(false);
+const popover = useTemplateRef('popover');
+
const handleSetDefaultFolder = async (newFolder: { value: number }) => {
if (processing.value || !props.data?.id || newFolder.value === props.data.default_folder_id) return;
@@ -43,6 +46,22 @@ const handleSetDefaultFolder = async (newFolder: { value: number }) => {
}
};
+const handleStartScan = async () => {
+ if (!props.data?.id) {
+ toast('Error', { description: 'Invalid Category ID!', type: 'danger' });
+ popover.value?.handleClose();
+ return;
+ }
+
+ try {
+ await startScanFilesTask(props.data.id);
+ toast.add('Success', { type: 'success', description: `Submitted scan Request!` });
+ popover.value?.handleClose();
+ } catch (error) {
+ toast('Failure', { type: 'danger', description: `Unable to submit scan request.` });
+ }
+};
+
watch(
() => props.data,
() => {
@@ -73,14 +92,14 @@ watch(
{{ data?.name }}
<span class="flex flex-wrap gap-2 [&>*]:h-6 text-sm">
- <ButtonText class="dark:!bg-neutral-950 hidden md:flex" :title="'Scan for Folder Changes'">
- <template #text> Scan Folders </template>
+ <ButtonText class="dark:!bg-neutral-950 hidden 2xl:flex" :title="'Scan for Folder Changes'" @click="handleStartScan">
+ <template #text> Scan </template>
<template #icon> <ProiconsArrowSync class="h-4 w-4" /></template>
</ButtonText>
- <Popover popoverClass="w-48 sm:w-64 rounded-lg" :buttonClass="'!p-1 ml-auto'">
+ <Popover popoverClass="w-48 sm:w-64 rounded-lg" :buttonClass="'!p-1 ml-auto'" ref="popover">
<template #buttonIcon>
- <ProiconsMoreVertical class="h-4 w-4 md:hidden" />
- <CircumEdit class="w-full h-full hidden md:block" />
+ <ProiconsMoreVertical class="h-4 w-4 2xl:hidden" />
+ <CircumEdit class="w-full h-full hidden 2xl:block" />
</template>
<template #content>
<div class="grid gap-4">
@@ -108,7 +127,11 @@ watch(
"
/>
</div>
- <ButtonText class="h-8 dark:!bg-neutral-950 md:hidden" :title="'Scan for Folder Changes'">
+ <ButtonText
+ class="h-8 dark:!bg-neutral-950 2xl:hidden"
+ :title="'Scan for Folder Changes'"
+ @click="handleStartScan"
+ >
<template #text> Scan Folders </template>
<template #icon> <ProiconsArrowSync class="h-4 w-4" /></template>
</ButtonText>
@@ -121,7 +144,7 @@ watch(
<template #icon> <ProiconsLock class="h-4 w-4" /></template>
</ButtonText>
<ButtonText
- class="h-8 text-red-600 dark:!bg-red-700 disabled:opacity-60"
+ class="h-8 text-rose-600 dark:!bg-rose-700 disabled:opacity-60"
:title="'Remove From Server'"
@click.stop.prevent="$emit('clickAction')"
disabled
@@ -135,7 +158,7 @@ watch(
</Popover>
</span>
</h3>
- <span class="w-full text-sm text-slate-600 dark:text-slate-400" v-if="data">
+ <span class="w-full text-sm text-neutral-500 dark:text-neutral-400" v-if="data">
<span class="flex items-center justify-between mt-auto flex-wrap">
<p class="">Folders: {{ data?.folders_count }}</p>
<p class="hidden sm:block" title="Total Size">
diff --git a/resources/js/components/cards/DashboardCard.vue b/resources/js/components/cards/DashboardCard.vue
index c97f1d9e..b0f10ecf 100644
--- a/resources/js/components/cards/DashboardCard.vue
+++ b/resources/js/components/cards/DashboardCard.vue
@@ -24,14 +24,16 @@ const props = withDefaults(
<header class="flex flex-wrap justify-between items-center gap-4 mb-3 @md:mb-6">
<div class="flex-1 basis-0 flex-grow-[10000] max-w-full">
<div class="flex overflow-hidden gap-2 items-start">
- <div class="[&>svg]:flex-shrink-0 [&>svg]:w-6 [&>svg]:h-6 [&>svg]:stroke-gray-400 [&>svg]:dark:stroke-gray-600">
+ <div
+ class="[&>svg]:flex-shrink-0 [&>svg]:w-6 [&>svg]:h-6 [&>svg]:stroke-gray-600/80 [&>svg]:dark:stroke-neutral-400/80 text-gray-400 dark:text-neutral-400/80"
+ >
<slot name="icon"></slot>
</div>
<hgroup class="flex flex-wrap items-baseline gap-x-2 overflow-hidden">
<h2 class="text-base font-bold text-gray-600 dark:text-gray-300 truncate" :title="props.title">
{{ props.name }}
</h2>
- <p v-if="props.details" class="text-gray-400 dark:text-gray-600 font-medium truncate">
+ <p v-if="props.details" class="text-gray-600/80 dark:text-neutral-400/80 font-medium truncate">
<small class="text-xs">{{ props.details }}</small>
</p>
</hgroup>
diff --git a/resources/js/components/cards/RecordCardDetails.vue b/resources/js/components/cards/RecordCardDetails.vue
index a3ff3b41..e06cebae 100755
--- a/resources/js/components/cards/RecordCardDetails.vue
+++ b/resources/js/components/cards/RecordCardDetails.vue
@@ -23,7 +23,7 @@ const videoLink = computed(() => {
<template>
<button
@click.stop.prevent="$emit('clickAction')"
- class="text-left relative flex flex-col gap-4 sm:flex-row flex-wrap rounded-xl dark:bg-primary-dark-800/70 bg-primary-800 dark:hover:bg-primary-dark-600 hover:bg-gray-200 dark:text-white shadow p-3 w-full group cursor-pointer divide-gray-300 dark:divide-neutral-400"
+ class="text-left relative flex flex-col gap-4 sm:flex-row flex-wrap rounded-xl dark:bg-primary-dark-800/70 bg-white ring-1 ring-gray-900/5 dark:hover:bg-primary-dark-600 hover:bg-primary-800 dark:text-white shadow p-3 w-full group cursor-pointer divide-gray-300 dark:divide-neutral-400"
>
<section class="flex justify-between gap-4 w-full">
<h2 class="text-xl w-full truncate" :title="props.data.relationships.file_name">
@@ -51,9 +51,9 @@ const videoLink = computed(() => {
/>
</div>
</section>
- <section class="flex flex-col sm:flex-row sm:justify-between w-full">
+ <section class="flex flex-col sm:flex-row sm:justify-between w-full text-neutral-500 dark:text-neutral-400">
<h3
- class="text-neutral-500 w-full text-wrap truncate sm:text-nowrap"
+ class="w-full text-wrap truncate sm:text-nowrap"
:title="`Watched on ${rawDate.toLocaleDateString('en-ca', {
year: 'numeric',
month: '2-digit',
@@ -65,7 +65,7 @@ const videoLink = computed(() => {
>
{{ props.data.relationships.folder?.name }} · {{ timeSpan }}
</h3>
- <h3 class="truncate sm:text-right text-neutral-500 w-full line-clamp-2">
+ <h3 class="truncate sm:text-right w-full line-clamp-2">
{{
`${rawDate.toLocaleDateString('en-ca', {
year: 'numeric',
diff --git a/resources/js/components/cards/TaskCard.vue b/resources/js/components/cards/TaskCard.vue
new file mode 100644
index 00000000..230bb7b8
--- /dev/null
+++ b/resources/js/components/cards/TaskCard.vue
@@ -0,0 +1,132 @@
+<script setup lang="ts">
+import type { UserResource } from '@/types/resources';
+
+import { toFormattedDate, toTimeSpan } 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 ProiconsMoreVertical from '~icons/proicons/more-vertical';
+import ProiconsPersonCircle from '~icons/proicons/person-circle';
+import ProiconsLockOpen from '~icons/proicons/lock-open';
+import ProiconsDelete from '~icons/proicons/delete';
+
+const props = defineProps<{ data: UserResource }>();
+</script>
+<template>
+ <div
+ class="text-left relative flex flex-col xs:flex-row xs:gap-4 xs:p-3 rounded-xl dark:bg-primary-dark-800/70 bg-white ring-1 ring-gray-900/5 dark:hover:bg-primary-dark-600 hover:bg-primary-800 dark:text-white shadow w-full group divide-gray-300 dark:divide-neutral-400"
+ >
+ <img
+ class="aspect-square h-full max-h-28 xs:max-h-16 my-auto rounded-t-xl xs:rounded-full object-cover"
+ :src="`https://ui-avatars.com/api/?name=${data.name[0]}&amp;color=7F9CF5&amp;background=random`"
+ alt="aminushki"
+ />
+ <div class="flex flex-col gap-4 flex-wrap flex-1 max-w-full max-h-full p-3 xs:p-0">
+ <section class="flex justify-between gap-2 w-full items-center">
+ <h2 class="md:text-xl truncate capitalize flex-1" :title="data.name">
+ {{ data.name }}
+ </h2>
+
+ <div class="flex justify-end gap-1 flex-1">
+ <Popover
+ popoverClass="w-48 rounded-lg "
+ :buttonComponent="ButtonCorner"
+ :button-attributes="{
+ positionClasses: 'w-7 h-7 !p-1 ml-auto sm:hidden',
+ textClasses: 'hover:text-violet-600 dark:hover:text-violet-500',
+ colourClasses: 'dark:hover:bg-neutral-800 hover:bg-gray-200',
+ label: 'Manage Permissions',
+ }"
+ >
+ <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 User</h4>
+ </div>
+
+ <div class="grid gap-2">
+ <ButtonText
+ class="h-8 dark:!bg-neutral-950 2xl:hidden"
+ :title="'Scan for Folder Changes'"
+ :to="'/profile'"
+ >
+ <template #text> View Profile </template>
+ <template #icon> <ProiconsPersonCircle class="h-4 w-4" /></template>
+ </ButtonText>
+ <ButtonText
+ class="h-8 dark:!bg-neutral-950 disabled:opacity-60"
+ :title="'Set User Access Permissions'"
+ disabled
+ >
+ <template #text> Manage Permissions </template>
+ <template #icon> <ProiconsLockOpen class="h-4 w-4" /></template>
+ </ButtonText>
+ <ButtonText
+ 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> Remove User </template>
+ <template #icon> <ProiconsDelete class="h-4 w-4" /></template>
+ </ButtonText>
+ </div>
+ </div>
+ </template>
+ </Popover>
+ <ButtonCorner
+ :positionClasses="'w-7 h-7 sm:flex hidden'"
+ :textClasses="'hover:text-violet-600 dark:hover:text-violet-500'"
+ :colourClasses="'dark:hover:bg-neutral-800 hover:bg-gray-200'"
+ :to="`/profile/${data.name}`"
+ :label="'View Profile'"
+ @click.stop.prevent="() => {}"
+ >
+ <template #icon>
+ <ProiconsPersonCircle width="20" height="20" />
+ </template>
+ </ButtonCorner>
+ <ButtonCorner
+ :positionClasses="'w-7 h-7 sm:flex hidden'"
+ :textClasses="'hover:text-violet-600 dark:hover:text-violet-500'"
+ :colourClasses="'dark:hover:bg-neutral-800 hover:bg-gray-200'"
+ :label="'Manage Permissions'"
+ @click.stop.prevent="() => {}"
+ disabled
+ >
+ <template #icon>
+ <ProiconsLockOpen width="20" height="20" />
+ </template>
+ </ButtonCorner>
+ <ButtonCorner
+ :positionClasses="'w-7 h-7 sm:flex hidden'"
+ :textClasses="'text-rose-700 hover:text-rose-600'"
+ :colourClasses="'dark:hover:bg-neutral-800 hover:bg-gray-200'"
+ :label="'Remove User'"
+ disabled
+ @click.stop.prevent="$emit('clickAction')"
+ />
+ </div>
+ </section>
+ <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 truncate sm:text-nowrap" :title="`Date joined`">
+ Date Joined:
+ {{
+ data.created_at
+ ? toFormattedDate(new Date(data.created_at), false, { year: 'numeric', month: 'short', day: 'numeric' })
+ : 'Unknown'
+ }}
+ </h3>
+ <h3 class="truncate sm:text-right w-full line-clamp-2 capitalize" v-show="data.last_active" title="Last date of activity">
+ Last Active:
+ {{ data.last_active ? toTimeSpan(new Date(data.last_active + ' UTC')) : 'Unknown' }}
+ </h3>
+ </section>
+ </div>
+ </div>
+</template>
diff --git a/resources/js/components/cards/UserCard.vue b/resources/js/components/cards/UserCard.vue
new file mode 100644
index 00000000..8004bbc3
--- /dev/null
+++ b/resources/js/components/cards/UserCard.vue
@@ -0,0 +1,128 @@
+<script setup lang="ts">
+import type { UserResource } from '@/types/resources';
+
+import { toFormattedDate, toTimeSpan } 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 ProiconsMoreVertical from '~icons/proicons/more-vertical';
+import ProiconsPersonCircle from '~icons/proicons/person-circle';
+import ProiconsLockOpen from '~icons/proicons/lock-open';
+import ProiconsDelete from '~icons/proicons/delete';
+
+const props = defineProps<{ data: UserResource }>();
+</script>
+<template>
+ <div
+ class="text-left relative flex flex-col xs:flex-row xs:gap-4 xs:p-3 rounded-xl dark:bg-primary-dark-800/70 bg-white ring-1 ring-gray-900/5 dark:hover:bg-primary-dark-600 hover:bg-primary-800 dark:text-white shadow w-full group divide-gray-300 dark:divide-neutral-400"
+ >
+ <img
+ class="aspect-square h-full max-h-28 xs:max-h-16 my-auto rounded-t-xl xs:rounded-full object-cover"
+ :src="`https://ui-avatars.com/api/?name=${data.name[0]}&amp;color=7F9CF5&amp;background=random`"
+ alt="aminushki"
+ />
+ <div class="flex flex-col gap-4 flex-wrap flex-1 max-w-full max-h-full p-3 xs:p-0">
+ <section class="flex justify-between gap-2 w-full items-center">
+ <h2 class="md:text-xl truncate capitalize flex-1" :title="data.name">
+ {{ data.name }}
+ </h2>
+
+ <div class="flex justify-end gap-1 flex-1">
+ <Popover
+ popoverClass="w-48 rounded-lg "
+ :buttonComponent="ButtonCorner"
+ :button-attributes="{
+ positionClasses: 'w-7 h-7 !p-1 ml-auto sm:hidden',
+ textClasses: 'hover:text-violet-600 dark:hover:text-violet-500',
+ colourClasses: 'dark:hover:bg-neutral-800 hover:bg-gray-200',
+ label: 'Manage Permissions',
+ }"
+ >
+ <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 User</h4>
+ </div>
+
+ <div class="grid gap-2">
+ <ButtonText class="h-8 dark:!bg-neutral-950" :title="'Scan for Folder Changes'" :to="'/profile'">
+ <template #text> View Profile </template>
+ <template #icon> <ProiconsPersonCircle class="h-4 w-4" /></template>
+ </ButtonText>
+ <ButtonText
+ class="h-8 dark:!bg-neutral-950 disabled:opacity-60"
+ :title="'Set User Access Permissions'"
+ disabled
+ >
+ <template #text> Manage Permissions </template>
+ <template #icon> <ProiconsLockOpen class="h-4 w-4" /></template>
+ </ButtonText>
+ <ButtonText
+ 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> Remove User </template>
+ <template #icon> <ProiconsDelete class="h-4 w-4" /></template>
+ </ButtonText>
+ </div>
+ </div>
+ </template>
+ </Popover>
+ <ButtonCorner
+ :positionClasses="'w-7 h-7 sm:flex hidden'"
+ :textClasses="'hover:text-violet-600 dark:hover:text-violet-500'"
+ :colourClasses="'dark:hover:bg-neutral-800 hover:bg-gray-200'"
+ :to="`/profile/${data.name}`"
+ :label="'View Profile'"
+ @click.stop.prevent="() => {}"
+ >
+ <template #icon>
+ <ProiconsPersonCircle width="20" height="20" />
+ </template>
+ </ButtonCorner>
+ <ButtonCorner
+ :positionClasses="'w-7 h-7 sm:flex hidden'"
+ :textClasses="'hover:text-violet-600 dark:hover:text-violet-500'"
+ :colourClasses="'dark:hover:bg-neutral-800 hover:bg-gray-200'"
+ :label="'Manage Permissions'"
+ @click.stop.prevent="() => {}"
+ disabled
+ >
+ <template #icon>
+ <ProiconsLockOpen width="20" height="20" />
+ </template>
+ </ButtonCorner>
+ <ButtonCorner
+ :positionClasses="'w-7 h-7 sm:flex hidden'"
+ :textClasses="'text-rose-700 hover:text-rose-600'"
+ :colourClasses="'dark:hover:bg-neutral-800 hover:bg-gray-200'"
+ :label="'Remove User'"
+ disabled
+ @click.stop.prevent="$emit('clickAction')"
+ />
+ </div>
+ </section>
+ <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 truncate sm:text-nowrap" :title="`Date joined`">
+ Date Joined:
+ {{
+ data.created_at
+ ? toFormattedDate(new Date(data.created_at), false, { year: 'numeric', month: 'short', day: 'numeric' })
+ : 'Unknown'
+ }}
+ </h3>
+ <h3 class="truncate sm:text-right w-full line-clamp-2 capitalize" v-show="data.last_active" title="Last date of activity">
+ Last Active:
+ {{ data.last_active ? toTimeSpan(new Date(data.last_active + ' UTC')) : 'Unknown' }}
+ </h3>
+ </section>
+ </div>
+ </div>
+</template>
diff --git a/resources/js/components/dashboard/DashboardActivity.vue b/resources/js/components/dashboard/DashboardActivity.vue
new file mode 100644
index 00000000..5a4b8b21
--- /dev/null
+++ b/resources/js/components/dashboard/DashboardActivity.vue
@@ -0,0 +1,111 @@
+<script setup lang="ts">
+import type { CategoryResource } from '@/types/resources';
+
+import { computed, onMounted, ref, watch } from 'vue';
+import { toast } from '@/service/toaster/toastService';
+
+import CategoryCard from '@/components/cards/CategoryCard.vue';
+import ButtonText from '@/components/inputs/ButtonText.vue';
+import ModalBase from '@/components/pinesUI/ModalBase.vue';
+import TableBase from '@/components/table/TableBase.vue';
+import useModal from '@/composables/useModal';
+
+import ProiconsArrowSync from '~icons/proicons/arrow-sync';
+import ProiconsAdd from '~icons/proicons/add';
+
+// const { data: rawCategories, isLoading } = useGetCategories();
+const categories = ref<CategoryResource[]>([]);
+const searchQuery = ref('');
+const sortingOptions = ref([
+ {
+ title: 'Title',
+ value: 'name',
+ disabled: false,
+ },
+ {
+ title: 'Date',
+ value: 'created_at',
+ disabled: false,
+ },
+]);
+
+const filteredCategories = computed(() => {
+ let tempList = searchQuery.value
+ ? categories.value.filter((category: CategoryResource) => {
+ {
+ try {
+ let strRepresentation = [category.name, category.folders_count, category.folders[0]?.name ?? '', category.created_at]
+ .join(' ')
+ .toLowerCase();
+ return strRepresentation.includes(searchQuery.value.toLowerCase());
+ } catch (error) {
+ console.log(error);
+ return false;
+ }
+ }
+ })
+ : categories.value;
+ return tempList;
+});
+
+const handleSort = async (column = 'date', dir = 1) => {
+ let tempList = categories.value.sort((categoryA: CategoryResource, categoryB: CategoryResource) => {
+ if (column === 'created_at') {
+ let dateA = new Date(categoryA?.created_at ?? '');
+ let dateB = new Date(categoryB?.created_at ?? '');
+ return (dateB.getTime() - dateA.getTime()) * dir;
+ }
+ return `${categoryB[column as keyof CategoryResource]}`?.localeCompare(`${categoryA[column as keyof CategoryResource]}`) * dir;
+ });
+ categories.value = tempList;
+ return tempList;
+};
+
+const handleSearch = (query: string) => {
+ searchQuery.value = query;
+};
+
+// watch(rawCategories, (v) => {
+// categories.value = v.data ?? [];
+// });
+
+// onMounted(() => {
+// if (rawCategories.value?.data) categories.value = rawCategories.value.data;
+// });
+</script>
+
+<template>
+ <section id="tasks" class="flex gap-8 flex-col">
+ <div class="flex items-center gap-2 justify-between flex-wrap">
+ <p class="uppercase">Running: {{ categories?.length }}</p>
+ <div class="flex flex-wrap items-center gap-2 [&>*]:h-8">
+ <ButtonText
+ title="Start New Task"
+ @click="toast.add('Success', { type: 'success', description: 'Submitted Scan Request!', life: 3000 })"
+ disabled
+ >
+ <template #text>New Task</template>
+ <template #icon><ProiconsAdd /></template>
+ </ButtonText>
+ <ButtonText
+ @click="toast.add('Success', { type: 'success', description: 'Submitted File Indexing Request!', life: 3000 })"
+ disabled
+ >
+ <template #text>Run File Scan</template>
+ <template #icon><ProiconsArrowSync /></template>
+ </ButtonText>
+ </div>
+ </div>
+ <TableBase
+ :use-grid="'grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 2xl:grid-cols-4 3xl:grid-cols-5 gap-3'"
+ :use-pagination="true"
+ :data="[...filteredCategories]"
+ :row="CategoryCard"
+ :click-action="() => {}"
+ :loading="false"
+ :sort-action="handleSort"
+ :sorting-options="sortingOptions"
+ @search="handleSearch"
+ />
+ </section>
+</template>
diff --git a/resources/js/components/dashboard/DashboardAnalytics.vue b/resources/js/components/dashboard/DashboardAnalytics.vue
index ef9d1cc1..a4124cb7 100644
--- a/resources/js/components/dashboard/DashboardAnalytics.vue
+++ b/resources/js/components/dashboard/DashboardAnalytics.vue
@@ -76,7 +76,7 @@ watch(
:details="`past ${periodForHumans(period)}`"
>
<template #icon>
- <LucideChartNoAxesCombined class="w-6 h-6 text-gray-400 dark:text-gray-600" />
+ <LucideChartNoAxesCombined class="w-6 h-6" />
</template>
<template #slot>
<span v-for="(stat, index) in stats?.changes" :key="index" class="flex gap-2 capitalize items-center flex-wrap">
@@ -84,7 +84,7 @@ watch(
<span>
<h3 class="text-lg">{{ stat.count ?? 0 }}</h3>
</span>
- <h4 :class="`text-sm ${stat.change >= 0 ? 'text-green-700 dark:text-green-600' : 'text-red-500'} ml-auto`">
+ <h4 :class="`text-sm ${stat.change >= 0 ? 'text-green-700 dark:text-green-600' : 'text-rose-500'} ml-auto`">
{{ `${stat.change === 0 ? 'no change' : `${stat.change >= 0 ? '+' : '-'}${stat.change}`}` }}
</h4>
</span>
diff --git a/resources/js/components/dashboard/DashboardLibraries.vue b/resources/js/components/dashboard/DashboardLibraries.vue
index 6958b806..75752340 100644
--- a/resources/js/components/dashboard/DashboardLibraries.vue
+++ b/resources/js/components/dashboard/DashboardLibraries.vue
@@ -13,13 +13,31 @@ import useModal from '@/composables/useModal';
import ProiconsArrowSync from '~icons/proicons/arrow-sync';
import ProiconsAdd from '~icons/proicons/add';
+import { startIndexFilesTask } from '@/service/siteAPI';
const cachedID = ref<null | number>(null);
const confirmModal = useModal({ title: 'Delete Category?', submitText: 'Confim' });
-const searchQuery = ref('');
const { data: rawCategories, isLoading } = useGetCategories();
const categories = ref<CategoryResource[]>([]);
+const searchQuery = ref('');
+const sortingOptions = ref([
+ {
+ title: 'Title',
+ value: 'name',
+ disabled: false,
+ },
+ {
+ title: 'Date',
+ value: 'created_at',
+ disabled: false,
+ },
+ {
+ title: 'Folders',
+ value: 'folders_count',
+ disabled: false,
+ },
+]);
const filteredCategories = computed(() => {
let tempList = searchQuery.value
@@ -53,24 +71,6 @@ const submitDelete = async () => {
}
};
-const sortingOptions = ref([
- {
- title: 'Title',
- value: 'name',
- disabled: false,
- },
- {
- title: 'Date',
- value: 'created_at',
- disabled: false,
- },
- {
- title: 'Folders',
- value: 'folders_count',
- disabled: false,
- },
-]);
-
const handleSort = async (column = 'date', dir = 1) => {
let tempList = categories.value.sort((categoryA: CategoryResource, categoryB: CategoryResource) => {
if (column === 'created_at') {
@@ -88,6 +88,16 @@ const handleSearch = (query: string) => {
searchQuery.value = query;
};
+const handleStartScan = async () => {
+ try {
+ const result = await startIndexFilesTask();
+
+ toast.add('Success', { type: 'success', description: `Submitted scan Request!` });
+ } catch (error) {
+ toast('Failure', { type: 'danger', description: `Unable to submit scan request.` });
+ }
+};
+
watch(rawCategories, (v) => {
categories.value = v.data ?? [];
});
@@ -99,8 +109,7 @@ onMounted(() => {
<template>
<section id="content-libraries" class="flex gap-8 flex-col">
<div class="flex items-center gap-2 justify-between flex-wrap">
- <p class="uppercase">Installed: {{ categories?.length }}</p>
- <div class="flex flex-wrap items-center gap-2 [&>*]:h-8">
+ <div class="flex flex-wrap items-center gap-2 [&>*]:h-fit [&>*]:xs:h-8">
<ButtonText
title="Add New Library"
@click="toast.add('Success', { type: 'success', description: 'Submitted Scan Request!', life: 3000 })"
@@ -109,11 +118,12 @@ onMounted(() => {
<template #text>New Library</template>
<template #icon><ProiconsAdd /></template>
</ButtonText>
- <ButtonText @click="toast.add('Success', { type: 'success', description: 'Submitted Scan Request!', life: 3000 })" disabled>
- <template #text>Run Full Scan</template>
+ <ButtonText @click="handleStartScan">
+ <template #text>Scan For Changes</template>
<template #icon><ProiconsArrowSync /></template>
</ButtonText>
</div>
+ <p class="capitalize text-sm">Count: {{ categories?.length }}</p>
</div>
<TableBase
:use-grid="'grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 2xl:grid-cols-4 3xl:grid-cols-5 gap-3'"
diff --git a/resources/js/components/dashboard/DashboardTasks.vue b/resources/js/components/dashboard/DashboardTasks.vue
new file mode 100644
index 00000000..e1f00f17
--- /dev/null
+++ b/resources/js/components/dashboard/DashboardTasks.vue
@@ -0,0 +1,221 @@
+<script setup lang="ts">
+import type { UserResource } from '@/types/resources';
+
+import { getActiveSessions, getUsers, startIndexFilesTask, startSyncFilesTask, startVerifyFilesTask } from '@/service/siteAPI';
+import { computed, onMounted, ref, useTemplateRef } from 'vue';
+import { toast } from '@/service/toaster/toastService';
+
+import ButtonText from '@/components/inputs/ButtonText.vue';
+import ModalBase from '@/components/pinesUI/ModalBase.vue';
+import TableBase from '@/components/table/TableBase.vue';
+import useModal from '@/composables/useModal';
+
+import UserCard from '../cards/UserCard.vue';
+import Popover from '../pinesUI/Popover.vue';
+
+import ProiconsArrowSync from '~icons/proicons/arrow-sync';
+import ProiconsAdd from '~icons/proicons/add';
+
+import LucideFolderSync from '~icons/lucide/folder-sync';
+import LucideFolderSearch from '~icons/lucide/folder-search';
+import LucideFolderCheck from '~icons/lucide/folder-check';
+import LucideFolderTree from '~icons/lucide/folder-tree';
+
+const confirmModal = useModal({ title: 'Remove User?', submitText: 'Confim' });
+
+const searchQuery = ref('');
+const sortingOptions = ref([
+ {
+ title: 'Username',
+ value: 'name',
+ disabled: false,
+ },
+ {
+ title: 'Date Joined',
+ value: 'created_at',
+ disabled: false,
+ },
+ {
+ title: 'Last Active',
+ value: 'last_active',
+ disabled: false,
+ },
+]);
+
+const activeSessions = ref(0);
+const users = ref<UserResource[]>([]);
+const cachedID = ref<number | null>(null);
+
+const taskPopover = useTemplateRef('taskPopover');
+
+const filteredUsers = computed(() => {
+ let tempList = searchQuery.value
+ ? users.value.filter((user: UserResource) => {
+ {
+ try {
+ let strRepresentation = [user.name, user.email, user.created_at].join(' ').toLowerCase();
+ return strRepresentation.includes(searchQuery.value.toLowerCase());
+ } catch (error) {
+ console.log(error);
+ return false;
+ }
+ }
+ })
+ : users.value;
+ return tempList;
+});
+
+const handleSort = async (column = 'date', dir = 1) => {
+ let tempList = users.value.sort((userA: UserResource, userB: UserResource) => {
+ if (column === 'created_at' || column === 'last_active') {
+ let dateA = new Date(userA?.[column] ?? '');
+ let dateB = new Date(userB?.[column] ?? '');
+ return (dateB.getTime() - dateA.getTime()) * dir;
+ }
+ return `${userB[column as keyof UserResource]}`?.localeCompare(`${userA[column as keyof UserResource]}`) * dir;
+ });
+ users.value = tempList;
+ return tempList;
+};
+
+const handleSearch = (query: string) => {
+ searchQuery.value = query;
+};
+
+const handleDelete = (id: number) => {
+ cachedID.value = id;
+ confirmModal.toggleModal(true);
+};
+
+const submitDelete = async () => {
+ if (cachedID.value) {
+ // let request = await deleteRecord(cachedID.value);
+ let request = false;
+ if (request) toast.add('Success', { type: 'success', description: 'User deleted successfully!', life: 3000 });
+ else toast.add('Error', { type: 'warning', description: 'Unable to delete user. Please try again.', life: 3000 });
+ }
+};
+
+const loadData = async () => {
+ const { data: rawActiveSessions } = await getActiveSessions();
+ activeSessions.value = parseInt(rawActiveSessions) ?? 0;
+
+ const { data: rawUsers } = await getUsers();
+
+ users.value = rawUsers?.data?.length > 0 ? rawUsers.data : [];
+};
+
+const handleStartTask = async (job: 'index' | 'sync' | 'verify') => {
+ try {
+ const result =
+ job === 'index' ? await startIndexFilesTask() : job === 'sync' ? await startSyncFilesTask() : await startVerifyFilesTask();
+
+ toast.add('Success', { type: 'success', description: `Submitted ${job} Request!` });
+ } catch (error) {
+ toast('Failure', { type: 'danger', description: `Unable to submit ${job} request.` });
+ }
+
+ taskPopover.value?.handleClose();
+};
+
+onMounted(() => {
+ loadData();
+});
+</script>
+
+<template>
+ <section id="tasks" class="flex gap-8 flex-col">
+ <div class="flex items-start gap-2 justify-between flex-wrap">
+ <div class="flex flex-wrap items-center gap-2 [&>*]:h-fit [&>*]:xs:h-8">
+ <Popover popoverClass="w-52 rounded-lg " :button-attributes="{ title: 'Start New Task' }" ref="taskPopover">
+ <template #buttonText>New Task</template>
+ <template #buttonIcon>
+ <ProiconsAdd />
+ </template>
+ <template #content>
+ <div class="grid gap-4">
+ <div class="space-y-2">
+ <h4 class="font-medium leading-none">Start Server Task</h4>
+ </div>
+
+ <div class="grid gap-2">
+ <ButtonText
+ class="h-8 dark:!bg-neutral-950"
+ :title="'Scan for Folder Changes'"
+ @click="handleStartTask('index')"
+ >
+ <template #text> Index Files </template>
+ <template #icon> <LucideFolderSearch class="-order-1 h-4 w-4" /></template>
+ </ButtonText>
+ <ButtonText
+ class="h-8 dark:!bg-neutral-950"
+ :title="'Sync Folder With Database'"
+ @click="handleStartTask('sync')"
+ >
+ <template #text> Sync Files </template>
+ <template #icon> <LucideFolderSync class="-order-1 h-4 w-4" /></template>
+ </ButtonText>
+ <ButtonText
+ class="h-8 dark:!bg-neutral-950 disabled:opacity-60"
+ :title="'Scan for New Metadata'"
+ @click="handleStartTask('verify')"
+ >
+ <template #text> Verify Metadata </template>
+ <template #icon> <LucideFolderCheck class="-order-1 h-4 w-4" /></template>
+ </ButtonText>
+
+ <ButtonText
+ class="h-8 text-rose-600 dark:!bg-rose-700 disabled:opacity-60"
+ :title="'Scan and Index All Files For Metadata'"
+ @click.stop.prevent="$emit('clickAction')"
+ disabled
+ >
+ <template #text> Scan All Files </template>
+ <template #icon> <LucideFolderTree class="-order-1 h-4 w-4" /></template>
+ </ButtonText>
+ </div>
+ </div>
+ </template>
+ </Popover>
+ <ButtonText @click="toast.add('Success', { type: 'success', description: 'Submitted Scan Request!', life: 3000 })" disabled>
+ <template #text>Run Full Scan</template>
+ <template #icon><ProiconsArrowSync /></template>
+ </ButtonText>
+ <ButtonText
+ @click="
+ () => {
+ loadData().then(() => {
+ toast.add('Success', { type: 'success', description: 'Data Refreshed!', life: 3000 });
+ });
+ }
+ "
+ >
+ <template #text>Refresh</template>
+ <template #icon><ProiconsArrowSync /></template>
+ </ButtonText>
+ </div>
+ <div class="capitalize text-sm font-medium text-neutral-600 dark:text-neutral-300 flex flex-col gap-1 w-fit text-end">
+ <p class="w-fit">Running Tasks: {{ activeSessions }}</p>
+ <p class="w-fit">Failed Tasks: {{ users.length }}</p>
+ </div>
+ </div>
+ <TableBase
+ :use-pagination="true"
+ :data="[...filteredUsers]"
+ :row="UserCard"
+ :loading="false"
+ :clickAction="handleDelete"
+ :sort-action="handleSort"
+ :sorting-options="sortingOptions"
+ :table-styles="'gap-4 xs:gap-2'"
+ @search="handleSearch"
+ />
+ </section>
+ <ModalBase :modalData="confirmModal" :action="submitDelete">
+ <template #content>
+ <div class="relative w-auto pb-8">
+ <p>Are you sure you want to remove this user?</p>
+ </div>
+ </template>
+ </ModalBase>
+</template>
diff --git a/resources/js/components/dashboard/DashboardUsers.vue b/resources/js/components/dashboard/DashboardUsers.vue
new file mode 100644
index 00000000..ed6730ae
--- /dev/null
+++ b/resources/js/components/dashboard/DashboardUsers.vue
@@ -0,0 +1,153 @@
+<script setup lang="ts">
+import type { UserResource } from '@/types/resources';
+
+import { getActiveSessions, getUsers } from '@/service/siteAPI';
+import { computed, onMounted, ref } from 'vue';
+import { toast } from '@/service/toaster/toastService';
+
+import ButtonText from '@/components/inputs/ButtonText.vue';
+import ModalBase from '@/components/pinesUI/ModalBase.vue';
+import TableBase from '@/components/table/TableBase.vue';
+import UserCard from '@/components/cards/UserCard.vue';
+import useModal from '@/composables/useModal';
+
+import ProiconsArrowSync from '~icons/proicons/arrow-sync';
+import ProiconsAdd from '~icons/proicons/add';
+
+const confirmModal = useModal({ title: 'Remove User?', submitText: 'Confim' });
+
+const searchQuery = ref('');
+const sortingOptions = ref([
+ {
+ title: 'Username',
+ value: 'name',
+ disabled: false,
+ },
+ {
+ title: 'Date Joined',
+ value: 'created_at',
+ disabled: false,
+ },
+ {
+ title: 'Last Active',
+ value: 'last_active',
+ disabled: false,
+ },
+]);
+
+const activeSessions = ref(0);
+const users = ref<UserResource[]>([]);
+const cachedID = ref<number | null>(null);
+
+const filteredUsers = computed(() => {
+ let tempList = searchQuery.value
+ ? users.value.filter((user: UserResource) => {
+ {
+ try {
+ let strRepresentation = [user.name, user.email, user.created_at].join(' ').toLowerCase();
+ return strRepresentation.includes(searchQuery.value.toLowerCase());
+ } catch (error) {
+ console.log(error);
+ return false;
+ }
+ }
+ })
+ : users.value;
+ return tempList;
+});
+
+const handleSort = async (column = 'date', dir = 1) => {
+ let tempList = users.value.sort((userA: UserResource, userB: UserResource) => {
+ if (column === 'created_at' || column === 'last_active') {
+ let dateA = new Date(userA?.[column] ?? '');
+ let dateB = new Date(userB?.[column] ?? '');
+ return (dateB.getTime() - dateA.getTime()) * dir;
+ }
+ return `${userB[column as keyof UserResource]}`?.localeCompare(`${userA[column as keyof UserResource]}`) * dir;
+ });
+ users.value = tempList;
+ return tempList;
+};
+
+const handleSearch = (query: string) => {
+ searchQuery.value = query;
+};
+
+const handleDelete = (id: number) => {
+ cachedID.value = id;
+ confirmModal.toggleModal(true);
+};
+
+const submitDelete = async () => {
+ if (cachedID.value) {
+ // let request = await deleteRecord(cachedID.value);
+ let request = false;
+ if (request) toast.add('Success', { type: 'success', description: 'User deleted successfully!', life: 3000 });
+ else toast.add('Error', { type: 'warning', description: 'Unable to delete user. Please try again.', life: 3000 });
+ }
+};
+
+const loadData = async () => {
+ const { data: rawActiveSessions } = await getActiveSessions();
+ activeSessions.value = parseInt(rawActiveSessions) ?? 0;
+
+ const { data: rawUsers } = await getUsers();
+
+ users.value = rawUsers?.data?.length > 0 ? rawUsers.data : [];
+};
+
+onMounted(() => {
+ loadData();
+});
+</script>
+
+<template>
+ <section id="tasks" class="flex gap-8 flex-col">
+ <div class="flex items-start gap-2 justify-between flex-wrap">
+ <div class="flex flex-wrap items-center gap-2 [&>*]:h-fit [&>*]:xs:h-8">
+ <ButtonText
+ title="Create new user"
+ @click="toast.add('Success', { type: 'success', description: 'User Created!', life: 3000 })"
+ disabled
+ >
+ <template #text>New User</template>
+ <template #icon><ProiconsAdd /></template>
+ </ButtonText>
+ <ButtonText
+ @click="
+ () => {
+ loadData().then(() => {
+ toast.add('Success', { type: 'success', description: 'Data Refreshed!', life: 3000 });
+ });
+ }
+ "
+ >
+ <template #text>Refresh</template>
+ <template #icon><ProiconsArrowSync /></template>
+ </ButtonText>
+ </div>
+ <div class="capitalize text-sm font-medium text-neutral-600 dark:text-neutral-300 flex flex-col gap-1 w-fit text-end">
+ <p class="w-fit">Active Users: {{ users.length }}</p>
+ <p class="w-fit">Active Users: {{ activeSessions }}</p>
+ </div>
+ </div>
+ <TableBase
+ :use-pagination="true"
+ :data="[...filteredUsers]"
+ :row="UserCard"
+ :loading="false"
+ :clickAction="handleDelete"
+ :sort-action="handleSort"
+ :sorting-options="sortingOptions"
+ :table-styles="'gap-4 xs:gap-2'"
+ @search="handleSearch"
+ />
+ </section>
+ <ModalBase :modalData="confirmModal" :action="submitDelete">
+ <template #content>
+ <div class="relative w-auto pb-8">
+ <p>Are you sure you want to remove this user?</p>
+ </div>
+ </template>
+ </ModalBase>
+</template>
diff --git a/resources/js/components/forms/EditFolder.vue b/resources/js/components/forms/EditFolder.vue
index 6346e637..5344a18d 100644
--- a/resources/js/components/forms/EditFolder.vue
+++ b/resources/js/components/forms/EditFolder.vue
@@ -137,7 +137,7 @@ const handleSubmit = async () => {
<DatePicker v-else-if="field.type === 'date'" v-model="form.fields[field.name]" :field="field" :tabindex="index + 1" />
<FormInputNumber v-else-if="field.type === 'number'" v-model="form.fields[field.name]" :field="field" :tabindex="index + 1" />
<FormInput v-else v-model="form.fields[field.name]" :field="field" :tabindex="index + 1" />
- <ul class="text-sm text-red-600 dark:text-red-400">
+ <ul class="text-sm text-rose-600 dark:text-rose-400">
<li v-for="(item, index) in form.errors[field.name]" :key="index">{{ item }}</li>
</ul>
</div>
diff --git a/resources/js/components/forms/EditVideo.vue b/resources/js/components/forms/EditVideo.vue
index d273c65a..d08108a4 100755
--- a/resources/js/components/forms/EditVideo.vue
+++ b/resources/js/components/forms/EditVideo.vue
@@ -153,7 +153,7 @@ watch(tagsQuery, () => {
@removeAction="handleRemoveTag"
/>
<FormInput v-else v-model="form.fields[field.name]" :field="field" />
- <ul class="text-sm text-red-600 dark:text-red-400">
+ <ul class="text-sm text-rose-600 dark:text-rose-400">
<li v-for="(item, index) in form.errors[field.name]" :key="index">{{ item }}</li>
</ul>
</div>
diff --git a/resources/js/components/inputs/ButtonCorner.vue b/resources/js/components/inputs/ButtonCorner.vue
index e6863876..1bdc5ca7 100755
--- a/resources/js/components/inputs/ButtonCorner.vue
+++ b/resources/js/components/inputs/ButtonCorner.vue
@@ -1,17 +1,18 @@
-<script setup>
+<script setup lang="ts">
import IconDelete from '@/components/icons/IconDelete.vue';
-const props = defineProps(['positionClasses', 'colourClasses', 'textClasses', 'to', 'label']);
+const props = defineProps(['positionClasses', 'colourClasses', 'textClasses', 'to', 'label', 'disabled']);
</script>
<template>
<router-link
- v-if="props?.to"
- :aria-label="props?.label ?? 'Link'"
- :title="props?.label ?? 'Link'"
- :to="props?.to ?? '/'"
- class="flex items-center justify-center rounded-full"
- :class="`${props?.positionClasses ?? 'absolute top-0 right-0 w-8 h-8 mt-5 mr-5'} ${props?.colourClasses ?? 'hover:bg-gray-50 hover:dark:bg-gray-700'} ${props?.textClasses ?? 'text-gray-600 dark:text-gray-400 hover:text-gray-800 hover:dark:text-gray-200'}`"
+ v-if="to"
+ :aria-label="label ?? 'Link'"
+ :title="label ?? 'Link'"
+ :to="to ?? '/'"
+ class="flex items-center justify-center rounded-full aria-disabled:cursor-not-allowed aria-disabled:hover:ring-neutral-200 aria-disabled:hover:dark:ring-neutral-700 aria-disabled:opacity-60"
+ :class="`${positionClasses ?? ' absolute top-0 right-0 w-8 h-8 mt-5 mr-5'} ${props?.colourClasses ?? 'hover:bg-gray-50 hover:dark:bg-gray-700'} ${props?.textClasses ?? 'text-gray-600 dark:text-gray-400 hover:text-gray-800 hover:dark:text-gray-200'}`"
+ :aria-disabled="disabled"
>
<slot name="icon">
<IconDelete />
@@ -21,8 +22,10 @@ const props = defineProps(['positionClasses', 'colourClasses', 'textClasses', 't
v-else
:aria-label="props?.label ?? 'Close Modal'"
:title="props?.label ?? 'Close Modal'"
- class="flex items-center justify-center rounded-full"
+ class="flex items-center justify-center rounded-full disabled:cursor-not-allowed disabled:hover:ring-neutral-200 disabled:hover:dark:ring-neutral-700 disabled:opacity-60"
:class="`${props?.positionClasses ?? 'absolute top-0 right-0 w-8 h-8 mt-5 mr-5'} ${props?.colourClasses ?? 'hover:bg-gray-50 hover:dark:bg-gray-700'} ${props?.textClasses ?? 'text-gray-600 dark:text-gray-400 hover:text-gray-800 hover:dark:text-gray-200'}`"
+ :disabled="disabled"
+ type="button"
>
<slot name="icon">
<IconDelete />
diff --git a/resources/js/components/inputs/ButtonText.vue b/resources/js/components/inputs/ButtonText.vue
index 945cacf3..594a770a 100755
--- a/resources/js/components/inputs/ButtonText.vue
+++ b/resources/js/components/inputs/ButtonText.vue
@@ -1,9 +1,26 @@
<script setup lang="ts">
-const props = defineProps(['class', 'type', 'disabled', 'title']);
+const props = defineProps(['class', 'type', 'disabled', 'title', 'to']);
</script>
<template>
+ <router-link
+ v-if="to"
+ :to="to"
+ :class="`p-2 flex items-center justify-center h-10 max-h-full gap-2
+ shadow-sm rounded-md cursor-pointer focus:outline-none
+ ring-1 ring-neutral-200 dark:ring-neutral-700 hocus:ring-[0.125rem]
+ focus:ring-indigo-400 dark:focus:ring-indigo-500 hover:ring-violet-400 hover:dark:ring-violet-700
+ text-gray-900 dark:text-neutral-100 bg-white dark:bg-primary-dark-800
+ ${props.class} aria-disabled:cursor-not-allowed aria-disabled:hover:ring-neutral-200 aria-disabled:hover:dark:ring-neutral-700 aria-disabled:ring-1 aria-disabled:opacity-60`"
+ :type="props.type"
+ :title="props.title ?? 'Button'"
+ :aria-disabled="disabled"
+ >
+ <slot name="text"> </slot>
+ <slot name="icon"> </slot>
+ </router-link>
<button
+ v-else
:class="`p-2 flex items-center justify-center h-10 max-h-full gap-2
shadow-sm rounded-md cursor-pointer focus:outline-none
ring-1 ring-neutral-200 dark:ring-neutral-700 hocus:ring-[0.125rem]
diff --git a/resources/js/components/pinesUI/Popover.vue b/resources/js/components/pinesUI/Popover.vue
index b26a9c27..63f69d6f 100644
--- a/resources/js/components/pinesUI/Popover.vue
+++ b/resources/js/components/pinesUI/Popover.vue
@@ -1,11 +1,23 @@
<script setup lang="ts">
import { OnClickOutside } from '@vueuse/components';
import { UseFocusTrap } from '@vueuse/integrations/useFocusTrap/component';
-import { nextTick, onMounted, ref, useTemplateRef, watch } from 'vue';
-
-import ButtonText from '../inputs/ButtonText.vue';
-
-const props = defineProps<{ buttonClass?: string; popoverClass?: string }>();
+import { nextTick, onMounted, ref, useTemplateRef, watch, type Component, type ComponentPublicInstance } from 'vue';
+
+import ButtonText from '@/components/inputs/ButtonText.vue';
+
+const props = withDefaults(
+ defineProps<{
+ disabled?: boolean;
+ buttonClass?: string;
+ popoverClass?: string;
+ buttonComponent?: Component;
+ buttonAttributes?: { [key: string]: any };
+ }>(),
+ {
+ disabled: false,
+ buttonComponent: ButtonText,
+ },
+);
const popoverOpen = ref(false);
const popoverArrow = ref(true);
@@ -15,7 +27,7 @@ const popoverHeight = ref(0);
const popoverOffset = ref(8);
const popover = useTemplateRef('popover');
-const popoverButton = useTemplateRef('popoverButton');
+const popoverButton = useTemplateRef<ComponentPublicInstance>('popoverButton');
const popoverInner = ref<null | HTMLElement>(null);
const popoverArrowRef = useTemplateRef('popoverArrowRef');
@@ -69,6 +81,12 @@ const adjustPopoverPosition = () => {
}
};
+const handleClose = () => {
+ popoverOpen.value = false;
+};
+
+defineExpose({ handleClose });
+
watch(
() => popoverOpen.value,
async (value) => {
@@ -93,7 +111,17 @@ onMounted(() => {
</script>
<template>
<div class="relative flex">
- <ButtonText ref="popoverButton" :class="buttonClass" @click="popoverOpen = true">
+ <component
+ :is="buttonComponent"
+ ref="popoverButton"
+ :class="buttonClass"
+ @click="popoverOpen = true"
+ v-bind="buttonAttributes"
+ :disabled="disabled"
+ >
+ <template #text>
+ <slot name="buttonText"> </slot>
+ </template>
<template #icon>
<slot name="buttonIcon">
<svg class="w-4 h-4" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -106,7 +134,7 @@ onMounted(() => {
</svg>
</slot>
</template>
- </ButtonText>
+ </component>
<Transition
enter-active-class="ease-out duration-150"
enter-from-class="scale-[0.8] opacity-60"
diff --git a/resources/js/components/pinesUI/ToastController.vue b/resources/js/components/pinesUI/ToastController.vue
index 15874282..99de082b 100755
--- a/resources/js/components/pinesUI/ToastController.vue
+++ b/resources/js/components/pinesUI/ToastController.vue
@@ -8,7 +8,7 @@ import { ToastState } from '@/service/toaster/toastService';
import ToastNotification from '@/components/pinesUI/ToastNotification.vue';
// Visible toasts amount
-const VISIBLE_TOASTS_AMOUNT = 6;
+const VISIBLE_TOASTS_AMOUNT = 3;
// Viewport padding
const VIEWPORT_OFFSET = '24px';
@@ -40,6 +40,7 @@ const toastsHovered = ref(false);
const expanded = ref(props.layout === 'expanded' ? true : false);
const paddingBetweenToasts = ref(props.paddingBetweenToasts);
const heightRecalculateTimeout = ref<null | number>(null);
+const burnTimeout = ref<null | number>(null);
// function UniqueComponentId(prefix = 'pv_id_') {
// return prefix + Math.random().toString(16).slice(2);
@@ -133,14 +134,20 @@ function positionToasts() {
yBuffer += 16;
}
+ messages.value.length >= props.maxVisibleToasts;
+
let burnToast = document.getElementById(`${messages.value[props.maxVisibleToasts]?.id}`);
if (burnToast) {
burnToast.firstElementChild?.classList.remove('opacity-100');
burnToast.firstElementChild?.classList.add('opacity-0');
+ if (burnTimeout.value) {
+ clearTimeout(burnTimeout.value);
+ }
+
// Burn 🔥 (remove) last toast
- setTimeout(function () {
+ burnTimeout.value = setTimeout(function () {
messages.value.pop();
}, 300);
diff --git a/resources/js/components/pinesUI/ToastNotification.vue b/resources/js/components/pinesUI/ToastNotification.vue
index b1817f56..73522b9d 100755
--- a/resources/js/components/pinesUI/ToastNotification.vue
+++ b/resources/js/components/pinesUI/ToastNotification.vue
@@ -95,7 +95,7 @@ onBeforeUnmount(() => {
'text-green-500': props.type == 'success',
'text-blue-500': props.type == 'info',
'text-orange-400': props.type == 'warning',
- 'text-red-500': props.type == 'danger',
+ 'text-rose-500': props.type == 'danger',
'dark:text-neutral-100 text-gray-800': props.type == 'default',
}"
>
diff --git a/resources/js/components/pulseCards/PulseServers.vue b/resources/js/components/pulseCards/PulseServers.vue
index 3f23469b..ec0cf2f5 100644
--- a/resources/js/components/pulseCards/PulseServers.vue
+++ b/resources/js/components/pulseCards/PulseServers.vue
@@ -272,7 +272,7 @@ watch(
<div v-if="servers[server]?.recently_reported" class="w-5 flex justify-center mr-1">
<div class="h-1 w-1 bg-green-500 rounded-full animate-pulse"></div>
</div>
- <IconSignalSlash v-else class="w-5 h-5 stroke-red-500 mr-1" />
+ <IconSignalSlash v-else class="w-5 h-5 stroke-rose-500 mr-1" />
</div>
<div
:id="`${server}-name`"
diff --git a/resources/js/components/table/TableBase.vue b/resources/js/components/table/TableBase.vue
index ef155d44..2e9268a1 100755
--- a/resources/js/components/table/TableBase.vue
+++ b/resources/js/components/table/TableBase.vue
@@ -31,6 +31,7 @@ const props = withDefaults(
itemsPerPage?: number;
searchQuery?: any;
selectedID?: any;
+ tableStyles?: string;
}>(),
{
useToolbar: true,
@@ -95,7 +96,7 @@ watch(props.data, tableData.handlePageReset, { immediate: true });
</ButtonIcon>
</span>
</section>
- <tbody :class="`${useGrid ? useGrid : 'flex w-full flex-wrap gap-2'}`">
+ <tbody :class="`${useGrid ? useGrid : `flex w-full flex-wrap gap-2 ${tableStyles}`}`">
<div
v-if="loading || tableData.filteredPage.length === 0"
class="col-span-full flex items-center justify-center text-center text-lg text-gray-500 dark:text-gray-400 uppercase tracking-wider w-full gap-2"
diff --git a/resources/js/components/video/VideoAmbientPlayer.vue b/resources/js/components/video/VideoAmbientPlayer.vue
index 51fee157..7b30b611 100755
--- a/resources/js/components/video/VideoAmbientPlayer.vue
+++ b/resources/js/components/video/VideoAmbientPlayer.vue
@@ -79,7 +79,7 @@ watch(player, (newVal) => {
<section class="w-full h-fit relative" ref="container">
<!-- <span
v-show="!lightMode && ambientMode"
- class="snap-y absolute -left-[1%] -top-[1%] gap-6 pt-2 flex w-[102%] h-[102%] z-10 rounded-2xl px-6 bg-red-400 pointer-events-none"
+ class="snap-y absolute -left-[1%] -top-[1%] gap-6 pt-2 flex w-[102%] h-[102%] z-10 rounded-2xl px-6 bg-rose-400 pointer-events-none"
ref="canvasContainer"
> -->
<canvas
diff --git a/resources/js/composables/useForm.ts b/resources/js/composables/useForm.ts
index 0c3d3e97..64d7ec02 100644
--- a/resources/js/composables/useForm.ts
+++ b/resources/js/composables/useForm.ts
@@ -6,28 +6,27 @@ import cloneDeep from 'lodash.clonedeep';
import isEqual from 'lodash.isequal';
interface FormHooks {
- onBefore?: () => Promise<void>;
- onSuccess?: (response: any) => Promise<void>;
- onError?: (error: any) => Promise<void>;
- onFinish?: () => Promise<void>;
+ onBefore?: () => any;
+ onSuccess?: (response: any) => any;
+ onError?: (error: any) => any;
+ onFinish?: () => any;
}
interface FormState {
- fields: { [key: string]: string };
- field?: any;
+ fields: { [key: string]: string | boolean };
errors: { [key: string]: string };
dirty: boolean;
hasErrors: boolean;
processing: boolean;
wasSuccessful: boolean;
recentlySuccessful: boolean;
- submit: (submitFn: (fields: { [key: string]: string }) => Promise<any>, hooks?: FormHooks) => Promise<void>;
+ submit: (submitFn: (fields: { [key: string]: string | boolean }) => Promise<any>, hooks?: FormHooks) => Promise<void>;
reset: (...fields: string[]) => void;
clearErrors: (...fields: string[]) => void;
setErrors: (errors: { [key: string]: string }) => void;
}
-export default function useForm(fields: { [key: string]: string }) {
+export default function useForm(fields: { [key: string]: string | boolean }) {
let defaults = fields;
let recentlySuccessfulTimeoutId: number;
const form = reactive<FormState>({
@@ -39,7 +38,7 @@ export default function useForm(fields: { [key: string]: string }) {
wasSuccessful: false,
recentlySuccessful: false,
- async submit(submitFn: (fields: { [key: string]: string }) => any, hooks = {}) {
+ async submit(submitFn: (fields: { [key: string]: string | boolean }) => any, hooks = {}) {
if (this.processing) return;
const _hooks = {
diff --git a/resources/js/router/index.js b/resources/js/router/index.js
index b3caba84..5f4cfaa6 100755
--- a/resources/js/router/index.js
+++ b/resources/js/router/index.js
@@ -69,7 +69,7 @@ const router = createRouter({
component: HistoryView,
},
{
- path: '/profile',
+ path: '/profile/:username?',
name: 'profile',
meta: { protected: true },
component: ProfileView,
diff --git a/resources/js/service/siteAPI.ts b/resources/js/service/siteAPI.ts
index d658805f..2e71119c 100644
--- a/resources/js/service/siteAPI.ts
+++ b/resources/js/service/siteAPI.ts
@@ -14,3 +14,27 @@ export function getSiteAnalytics(period?: string) {
export function getPulse(req?: { type?: string; period?: string }) {
return API.get(`/pulse${req?.type ? `/${req?.type}` : ''}${req?.period ? `?period=${req?.period}` : ''}`);
}
+
+export function getUsers() {
+ return API.get('/users');
+}
+
+export function getActiveSessions() {
+ return API.get('/active-sessions');
+}
+
+export function startIndexFilesTask(category?: number) {
+ return API.post(`/tasks/index/${category ?? ''}`);
+}
+
+export function startSyncFilesTask() {
+ return API.post(`/tasks/sync`);
+}
+
+export function startVerifyFilesTask(category?: number) {
+ return API.post(`/tasks/verify/${category ?? ''}`);
+}
+
+export function startScanFilesTask(category?: number) {
+ return API.post(`/tasks/scan/${category ?? ''}`);
+}
diff --git a/resources/js/service/util.ts b/resources/js/service/util.ts
index 60c9963a..327999db 100644
--- a/resources/js/service/util.ts
+++ b/resources/js/service/util.ts
@@ -32,11 +32,20 @@ export function toTimeSpan(rawDate: Date | string) {
return timeSpan;
}
-export function toFormattedDate(rawDate: Date) {
- return rawDate
- .toLocaleString([], { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', hour12: true })
- .toLocaleUpperCase()
- .replaceAll('.', '');
+export function toFormattedDate(
+ rawDate: Date,
+ toUpperCase: boolean = true,
+ format: Intl.DateTimeFormatOptions = {
+ year: 'numeric',
+ month: '2-digit',
+ day: '2-digit',
+ hour: '2-digit',
+ minute: '2-digit',
+ hour12: true,
+ },
+) {
+ let result = rawDate.toLocaleString(['en-CA'], format).replaceAll('.', '');
+ return toUpperCase ? result.toLocaleUpperCase() : result;
}
export function toFormattedDuration(rawSeconds: number = 0) {
diff --git a/resources/js/types/resources.ts b/resources/js/types/resources.ts
index 3ac6dde0..885f3bc5 100644
--- a/resources/js/types/resources.ts
+++ b/resources/js/types/resources.ts
@@ -1,5 +1,13 @@
import type { Category, Folder, Metadata, User } from './model';
+export interface UserResource {
+ id: number;
+ name: string;
+ email: string;
+ last_active: string;
+ created_at: string;
+}
+
export interface CategoryResource {
id: number;
name: string;
diff --git a/resources/js/views/DashboardView.vue b/resources/js/views/DashboardView.vue
index 66404647..8789991c 100644
--- a/resources/js/views/DashboardView.vue
+++ b/resources/js/views/DashboardView.vue
@@ -19,6 +19,9 @@ import ProiconsGraph from '~icons/proicons/graph';
import LucideImages from '~icons/lucide/images';
import CircumServer from '~icons/circum/server';
import LucideUsers from '~icons/lucide/users';
+import DashboardActivity from '@/components/dashboard/DashboardActivity.vue';
+import DashboardUsers from '@/components/dashboard/DashboardUsers.vue';
+import DashboardTasks from '@/components/dashboard/DashboardTasks.vue';
const dashboardTabs: {
name: string;
@@ -52,7 +55,7 @@ const dashboardTabs: {
icon: LucideUsers,
},
{
- name: 'jobs',
+ name: 'tasks',
description: '',
info: { value: 'Currently Running: 2' },
icon: CircumServer,
@@ -90,6 +93,9 @@ watch(
<section id="content-dashboard" class="min-h-[80vh]">
<DashboardAnalytics v-if="dashboardTab?.name == 'overview'" />
<DashboardLibraries v-if="dashboardTab?.name == 'libraries'" />
+ <DashboardActivity v-if="dashboardTab?.name == 'activity'" />
+ <DashboardUsers v-if="dashboardTab?.name == 'users'" />
+ <DashboardTasks v-if="dashboardTab?.name == 'tasks'" />
</section>
</template>
<template v-slot:leftSidebar>
diff --git a/resources/js/views/LoginView.vue b/resources/js/views/LoginView.vue
index b53bec1e..95c68258 100755
--- a/resources/js/views/LoginView.vue
+++ b/resources/js/views/LoginView.vue
@@ -37,7 +37,7 @@ const handleLogin = async () => {
userData.value = response.data.data.user;
router.push(route.query.redirect ? route.query.redirect.toString() : '/');
},
- onError: () => form.reset('password'),
+ onError: (errors: any) => form.reset('password'),
},
);
};
@@ -74,7 +74,7 @@ const handleLogin = async () => {
</div>
<div class="flex w-full justify-end">
- <ul class="text-sm text-red-600 dark:text-red-400">
+ <ul class="text-sm text-rose-600 dark:text-rose-400">
<li v-for="(error, index) in form.errors" :key="index">{{ error }}</li>
</ul>
</div>
diff --git a/resources/js/views/RegisterView.vue b/resources/js/views/RegisterView.vue
index abc36e29..9ccab647 100755
--- a/resources/js/views/RegisterView.vue
+++ b/resources/js/views/RegisterView.vue
@@ -60,7 +60,7 @@ const handleRegister = async () => {
<div v-for="(field, index) in fields" :key="index">
<FormInputLabel :field="field" />
<FormInput v-model="form.fields[field.name]" :field="field" />
- <ul class="text-sm text-red-600 dark:text-red-400">
+ <ul class="text-sm text-rose-600 dark:text-rose-400">
<li v-for="(item, index) in form.errors[field.name]" :key="index">{{ item }}</li>
</ul>
</div>
diff --git a/routes/api.php b/routes/api.php
index f4d83611..a703b11d 100755
--- a/routes/api.php
+++ b/routes/api.php
@@ -10,6 +10,7 @@ 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\TagController;
+use App\Http\Controllers\Api\V1\UserController;
use App\Http\Controllers\Api\V1\VideoController;
use App\Http\Controllers\DirectoryController;
use Illuminate\Http\Request;
@@ -25,6 +26,9 @@ Route::get('/user', function (Request $request) {
Route::group(['middleware' => ['auth:sanctum']], function () {
Route::get('/auth', [AuthController::class, 'authenticate']); // New
Route::delete('/logout', [AuthController::class, 'destroy']); // New
+
+ Route::get('/active-sessions', [UserController::class, 'SessionCount']);
+
Route::resource('/records', RecordController::class)->only(['index', 'store', 'destroy']);
Route::resource('/profile', ProfileController::class)->only(['show', 'store', 'update']);
Route::resource('/series', SeriesController::class)->only(['index', 'store', 'update']);
@@ -32,6 +36,14 @@ Route::group(['middleware' => ['auth:sanctum']], function () {
Route::resource('/tags', TagController::class)->only(['index', 'store']);
Route::resource('/analytics', AnalyticsController::class)->only(['index']);
Route::resource('/categories', CategoryController::class)->only(['index', 'update']);
+ Route::resource('/users', UserController::class)->only(['index']);
+
+ Route::prefix('tasks')->group(function () {
+ Route::post('/sync', [DirectoryController::class, 'syncFiles']);
+ Route::post('/index/{category?}', [DirectoryController::class, 'indexFiles']);
+ Route::post('/verify/{category?}', [DirectoryController::class, 'verifyFiles']);
+ Route::post('/scan/{category?}', [DirectoryController::class, 'scanFiles']);
+ });
});
Route::prefix('pulse')->group(function () {