Skip to content

A self-hosted media server and file management system

add category management functionality and lots of UI

aminnausin02b807e3f571
diff --git a/app/Http/Controllers/Api/V1/AnalyticsController.php b/app/Http/Controllers/Api/V1/AnalyticsController.php
index 245ef9f1..10e86e3d 100644
--- a/app/Http/Controllers/Api/V1/AnalyticsController.php
+++ b/app/Http/Controllers/Api/V1/AnalyticsController.php
@@ -2,7 +2,6 @@
namespace App\Http\Controllers\Api\V1;
-use Carbon\Carbon;
use App\Http\Controllers\Controller;
use App\Models\Category;
use App\Models\Folder;
@@ -11,6 +10,7 @@ use App\Models\Tag;
use App\Models\User;
use App\Models\Video;
use App\Traits\HasPeriod;
+use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
@@ -54,7 +54,7 @@ class AnalyticsController extends Controller {
'count' => $currentCount,
'change' => $currentCount - $previousCounts[$key],
'change_pct' => round($changePercentage, 2),
- 'prev' => $previousCount
+ 'prev' => $previousCount,
];
}
diff --git a/app/Http/Controllers/Api/V1/CategoryController.php b/app/Http/Controllers/Api/V1/CategoryController.php
index e11f81af..7bf720d1 100755
--- a/app/Http/Controllers/Api/V1/CategoryController.php
+++ b/app/Http/Controllers/Api/V1/CategoryController.php
@@ -3,8 +3,10 @@
namespace App\Http\Controllers\Api\V1;
use App\Http\Controllers\Controller;
+use App\Http\Requests\CategoryUpdateRequest;
use App\Http\Resources\CategoryResource;
use App\Models\Category;
+use App\Models\Folder;
use App\Traits\HttpResponses;
use Illuminate\Support\Facades\Auth;
@@ -40,4 +42,27 @@ class CategoryController extends Controller {
public function show(Category $category) {
return new CategoryResource($category);
}
+
+ /**
+ * Update the specified resource in storage.
+ *
+ * @param int $category_id
+ */
+ public function update(CategoryUpdateRequest $request, Category $category) {
+ try {
+ $validated = $request->validated();
+
+ $folder = Folder::where('id', $validated['default_folder_id'])->first();
+ if (! $folder || $folder->category_id != $category->id) {
+ return $this->error($category, 'Folder cannot be assigned to category!', 500);
+ }
+
+ $validated['editor_id'] = Auth::id();
+ $category->update($validated);
+
+ return $this->success($validated);
+ } catch (\Throwable $th) {
+ return $this->error($request, 'Unable to edit category. Error: ' . $th->getMessage(), 500);
+ }
+ }
}
diff --git a/app/Http/Controllers/DirectoryController.php b/app/Http/Controllers/DirectoryController.php
index c469ff12..1b788d52 100755
--- a/app/Http/Controllers/DirectoryController.php
+++ b/app/Http/Controllers/DirectoryController.php
@@ -2,7 +2,6 @@
namespace App\Http\Controllers;
-use App\Http\Requests\VideoCollectionRequest;
use App\Http\Resources\FolderResource;
use App\Http\Resources\SeriesResource;
use App\Http\Resources\VideoResource;
@@ -16,41 +15,13 @@ use App\Models\Category;
use App\Models\Folder;
use App\Models\Video;
use App\Traits\HttpResponses;
-use ErrorException;
use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Bus;
class DirectoryController extends Controller {
use HttpResponses;
- public function showDirectory(Request $request) {
- // aim -> return directory and folder id where exists so folder controller is usable
- $privateCategories = ['legacy' => 1];
-
- if (isset($privateCategories[strtolower($request->dir)]) && ! $request->user('sanctum')) {
- $data['message'] = 'Unauthorized';
-
- return view('error', $data);
- }
- $dirRaw = Category::select('id')->firstWhere('name', 'ilike', '%' . $request->dir . '%');
-
- if (isset($dirRaw->id)) {
- $data['dir'] = ['id' => $dirRaw->id, 'name' => $request->dir];
- if (isset($request->folder_name)) {
- $data['folder'] = ['id' => null, 'name' => $request->folder_name];
- } else {
- $folderRaw = Folder::select('id', 'name')->firstWhere('category_id', $data['dir']['id']);
- $data['folder'] = ['id' => $folderRaw->id, 'name' => $folderRaw->name];
- }
- } else {
- $data['dir'] = ['id' => null, 'name' => $request->dir];
- $data['folder'] = ['id' => null, 'name' => null];
- }
-
- // dump($data);
- return view('home', $data);
- }
-
public function showDirectoryAPI(Request $request) {
// All this does is convert url to ids and names
// IDEALLY it should also load data to prevent requiring more api requests
@@ -60,25 +31,25 @@ class DirectoryController extends Controller {
$dir = trim(strtolower($request?->dir ?? ''));
$folderName = trim(strtolower($request?->folderName ?? ''));
- if (isset($privateCategories[$dir]) && ! $request->user('sanctum')) {
+ if (isset($privateCategories[$dir]) && (! $request->user('sanctum')) || Auth::user()->id !== 1) {
$data['message'] = 'Unauthorized';
return $this->error(null, 'Access to this folder is forbidden', 403);
}
- $dirRaw = Category::select('id')->firstWhere('name', 'ilike', '%' . $dir . '%');
+ $dirRaw = Category::select('id', 'default_folder_id')->firstWhere('name', 'ilike', '%' . $dir . '%');
$data = ['dir' => ['id' => null, 'name' => $dir, 'folders' => null], 'folder' => ['id' => null, 'name' => $folderName ?? null, 'videos' => null]]; // Default null values
if (! isset($dirRaw->id)) { // Cannot find category so return default nulls
- return $this->error(['categoryName' => $dir], 'Cannot find specified category', 200);
+ return $this->error(['categoryName' => $dir], 'Cannot find specified category', 404);
}
$folderList = Folder::where('category_id', $dirRaw->id)->withCount(['videos']); // Folders in category
$data['dir'] = ['id' => $dirRaw->id, 'name' => $dir, 'folders' => FolderResource::collection($folderList->get())]; // Full category data
- $folderRaw = isset($request->folderName) ? $folderList->firstWhere('name', 'ilike', '%' . $folderName . '%') : $folderList->first(); // Folder in request ? search by name else select first in category
+ $folderRaw = isset($request->folderName) ? $folderList->firstWhere('name', 'ilike', '%' . $folderName . '%') : (isset($dirRaw->default_folder_id) ? $folderList->firstWhere('id', $dirRaw->default_folder_id) : $folderList->first()); // Folder in request ? search by name else select first in category
if (! isset($folderRaw->id)) { // no folder found
- return $this->error(['categoryName' => $dir, 'folderName' => $folderName], 'Cannot find folder in specified category', 200);
+ return $this->error(['categoryName' => $dir, 'folderName' => $folderName], 'Cannot find folder in specified category', 404);
}
$videoList = VideoResource::collection(Video::where('folder_id', $folderRaw->id)->get());
@@ -90,50 +61,6 @@ class DirectoryController extends Controller {
}
}
- public function getDirectory(Request $request) {
- try {
- $default = 'tv';
- $dir = isset($request->dir) ? $request->dir : $default;
-
- $category_id = Category::select('id')->firstWhere('name', $dir)->id;
- $folders = Folder::select('id', 'name')->where('category_id', $category_id)->get();
- $firstFolder_id = $folders->first()->id;
-
- $videos = Video::select('name', 'path', 'date')->where('folder_id', $firstFolder_id)->get();
- dump(json_encode(['success' => true, 'result' => ['folders' => $folders->toArray(), 'videos' => $videos->toArray()], 'error' => ''], JSON_UNESCAPED_SLASHES));
- //return json_encode(array("success"=>true, "result"=>array("folders"=>$folders->toArray(),"videos"=>$videos->toArray()), "error"=>""), JSON_UNESCAPED_SLASHES);
- } catch (\Throwable $th) {
- //throw $th;
- return json_encode(['success' => false, 'result' => ['folders' => [], 'videos' => []], 'error' => $th->getMessage()], JSON_UNESCAPED_SLASHES);
- }
- }
-
- public function getDirectoryContents(Request $request) {
- try {
- $default = 'tv';
- $dir = isset($request->dir) ? $request->dir : $default;
-
- $category_id = Category::select('id')->firstWhere('name', $dir)->id;
- $folders = Folder::select('id', 'name')->where('category_id', $category_id)->get();
-
- return json_encode(['success' => true, 'result' => $folders->toArray(), 'error' => ''], JSON_UNESCAPED_SLASHES);
- } catch (\Throwable $th) {
- return json_encode(['success' => false, 'result' => [], 'error' => $th->getMessage()], JSON_UNESCAPED_SLASHES);
- }
- }
-
- public function getFolderContents(VideoCollectionRequest $request) {
- try {
- $folder_id = isset($request->folder_id) ? $request->folder_id : throw new ErrorException('No folder id or invalid folder name provided. Cannot generate videos.');
-
- $videos = Video::select('id', 'name', 'path', 'date')->where('folder_id', $folder_id)->get();
-
- return json_encode(['success' => true, 'result' => $videos->toArray(), 'error' => ''], JSON_UNESCAPED_SLASHES);
- } catch (\Throwable $th) {
- return json_encode(['success' => false, 'result' => [], 'error' => $th->getMessage()], JSON_UNESCAPED_SLASHES);
- }
- }
-
public function indexFiles(Request $request) {
try {
// IndexFiles::dispatchSync();
diff --git a/app/Http/Requests/CategoryUpdateRequest.php b/app/Http/Requests/CategoryUpdateRequest.php
new file mode 100644
index 00000000..a06e127b
--- /dev/null
+++ b/app/Http/Requests/CategoryUpdateRequest.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+use Illuminate\Support\Facades\Auth;
+
+class CategoryUpdateRequest extends FormRequest {
+ /**
+ * Determine if the user is authorized to make this request.
+ */
+ public function authorize(): bool {
+ return Auth::check() && Auth::user()->id === 1;
+ }
+
+ /**
+ * Get the validation rules that apply to the request.
+ * Gets category and potentially folder id from query strings
+ *
+ * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
+ */
+ public function rules(): array {
+ return [
+ 'default_folder_id' => 'integer|required',
+ ];
+ }
+}
diff --git a/app/Http/Resources/CategoryResource.php b/app/Http/Resources/CategoryResource.php
index b19bfd30..e9202f6a 100755
--- a/app/Http/Resources/CategoryResource.php
+++ b/app/Http/Resources/CategoryResource.php
@@ -15,6 +15,7 @@ class CategoryResource extends JsonResource {
return [
'id' => (string) $this->id,
'name' => $this->name,
+ 'default_folder_id' => $this->default_folder_id,
'folders_count' => $this->folders_count ?? 0,
'folders' => FolderResource::collection($this->folders),
'created_at' => $this->created_at,
diff --git a/app/Http/Resources/Pulse/RequestsResource.php b/app/Http/Resources/Pulse/RequestsResource.php
index 2b9c6d88..23fed0f3 100644
--- a/app/Http/Resources/Pulse/RequestsResource.php
+++ b/app/Http/Resources/Pulse/RequestsResource.php
@@ -1,6 +1,5 @@
<?php
-
namespace App\Http\Resources\Pulse;
use Illuminate\Http\Request;
@@ -9,7 +8,7 @@ use PauloHortelan\RequestsGraphPulse\Recorders\RequestsGraphRecorder;
class RequestsResource extends PulseResource {
public function toArray(Request $request): array {
- [$requests, $time, $runAt] = $this->remember(fn() => $this->graph(
+ [$requests, $time, $runAt] = $this->remember(fn () => $this->graph(
[
'informational',
'successful',
diff --git a/app/Http/Resources/Pulse/ScheduleResource.php b/app/Http/Resources/Pulse/ScheduleResource.php
index 4e04f04e..8e9ce560 100644
--- a/app/Http/Resources/Pulse/ScheduleResource.php
+++ b/app/Http/Resources/Pulse/ScheduleResource.php
@@ -1,14 +1,7 @@
<?php
-
namespace App\Http\Resources\Pulse;
-use Carbon\CarbonImmutable;
-use Carbon\CarbonInterval;
-use Illuminate\Http\Request;
-
-use function Safe\preg_replace;
-
use Closure;
use Cron\CronExpression;
use DateTimeZone;
@@ -17,23 +10,23 @@ use Illuminate\Console\Scheduling\CallbackEvent;
use Illuminate\Console\Scheduling\Event;
use Illuminate\Console\Scheduling\Schedule as IlluminateSchedule;
use Illuminate\Contracts\Console\Kernel as ConsoleKernel;
-use Illuminate\Contracts\View\View;
+use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
-use Laravel\Pulse\Livewire\Card;
-use Livewire\Attributes\Lazy;
use ReflectionClass;
use ReflectionFunction;
+use function Safe\preg_replace;
+
class ScheduleResource extends PulseResource {
public int|string|null $ignoreAfter = null;
- public function toArray(Request $request,): array {
+ public function toArray(Request $request): array {
[$events, $time, $runAt] = $this->remember(function (ConsoleKernel $kernel, IlluminateSchedule $schedule) {
$kernel->bootstrap();
$timezone = new DateTimeZone(config('app.timezone')); // @phpstan-ignore-line
$events = collect($schedule->events())
- ->map(fn(Event $event): array => [
+ ->map(fn (Event $event): array => [
'command' => $this->getCommand($event),
'expression' => $this->getExpression($event),
'next_due' => $this->getNextDueDateForEvent($event, $timezone)
diff --git a/app/Models/Category.php b/app/Models/Category.php
index e2eee8ca..5bbe5cae 100755
--- a/app/Models/Category.php
+++ b/app/Models/Category.php
@@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Category extends Model {
@@ -11,12 +12,16 @@ class Category extends Model {
public $timestamps = false;
- protected $fillable = ['name', 'media_content'];
+ protected $fillable = ['name', 'default_folder_id', 'editor_id'];
public function folders(): HasMany {
return $this->hasMany(Folder::class);
}
+ public function editor(): BelongsTo {
+ return $this->belongsTo(User::class);
+ }
+
protected static function boot() {
parent::boot(); // Automatic withCount
static::addGlobalScope('foldersCount', function ($builder) {
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index b8f3619e..ba2f7b2a 100755
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -21,7 +21,7 @@ class AppServiceProvider extends ServiceProvider {
*/
public function boot(): void {
//
- Pulse::user(fn($user) => [
+ Pulse::user(fn ($user) => [
'name' => $user->name,
'extra' => $user->email,
]);
diff --git a/app/Traits/HasPeriod.php b/app/Traits/HasPeriod.php
index f598e911..f27e1dce 100644
--- a/app/Traits/HasPeriod.php
+++ b/app/Traits/HasPeriod.php
@@ -16,7 +16,7 @@ trait HasPeriod {
* The period as an Interval instance.
*/
public function periodAsInterval(): CarbonInterval {
- if (!$this->period || !preg_match('/(\d+)_(hours?|days?|weeks?|months?|years?)/', $this->period, $matches)) {
+ if (! $this->period || ! preg_match('/(\d+)_(hours?|days?|weeks?|months?|years?)/', $this->period, $matches)) {
return CarbonInterval::hours(24);
}
// Extract the value and unit from the period string
diff --git a/config/pulse-api.php b/config/pulse-api.php
index 29832a41..30f47b2d 100644
--- a/config/pulse-api.php
+++ b/config/pulse-api.php
@@ -71,7 +71,7 @@ return [
'resources' => PulseAPI::getDefaultResources()->merge([
// Add your custom resources
- 'requests' => RequestsResource::class
+ 'requests' => RequestsResource::class,
// 'schedule' => ScheduleResource::class,
// PulseResourcesEnum::SERVERS->value => ServersResource::class,
// PulseResourcesEnum::USAGE->value => UsageResource::class,
diff --git a/database/migrations/2024_12_26_024652_add_default_folder_to_category.php b/database/migrations/2024_12_26_024652_add_default_folder_to_category.php
new file mode 100644
index 00000000..e9e77ca0
--- /dev/null
+++ b/database/migrations/2024_12_26_024652_add_default_folder_to_category.php
@@ -0,0 +1,35 @@
+<?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('categories', function (Blueprint $table) {
+ $table->unsignedBigInteger('default_folder_id')->nullable()->unique();
+ $table->unsignedBigInteger('editor_id')->nullable();
+ $table->foreign('default_folder_id')
+ ->references('id')
+ ->on('folders')
+ ->nullOnDelete();
+ $table->foreign('editor_id')
+ ->references('id')
+ ->on('users')
+ ->nullOnDelete();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void {
+ Schema::table('categories', function (Blueprint $table) {
+ $table->dropColumn('default_folder_id');
+ $table->dropColumn('editor_id');
+ });
+ }
+};
diff --git a/package-lock.json b/package-lock.json
index 7d54281e..05583b0b 100755
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,6 +9,7 @@
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/forms": "^0.5.7",
"@tanstack/vue-query": "^5.59.20",
+ "@types/lodash": "^4.17.13",
"@vueuse/components": "^10.11.0",
"@vueuse/core": "^10.11.0",
"@vueuse/integrations": "^11.0.0",
@@ -33,7 +34,10 @@
"@iconify-json/mdi-light": "^1.2.1",
"@iconify-json/ph": "^1.1.13",
"@iconify-json/proicons": "^1.2.9",
+ "@iconify-json/svg-spinners": "^1.2.2",
"@tsconfig/node22": "^22.0.0",
+ "@types/lodash.clonedeep": "^4.5.9",
+ "@types/lodash.isequal": "^4.5.8",
"@types/node": "^22.9.3",
"@typescript-eslint/eslint-plugin": "^8.13.0",
"@typescript-eslint/parser": "^8.13.0",
@@ -935,6 +939,16 @@
"@iconify/types": "*"
}
},
+ "node_modules/@iconify-json/svg-spinners": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/@iconify-json/svg-spinners/-/svg-spinners-1.2.2.tgz",
+ "integrity": "sha512-DIErwfBWWzLfmAG2oQnbUOSqZhDxlXvr8941itMCrxQoMB0Hiv8Ww6Bln/zIgxwjDvSem2dKJtap+yKKwsB/2A==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@iconify/types": "*"
+ }
+ },
"node_modules/@iconify/types": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@iconify/types/-/types-2.0.0.tgz",
@@ -1491,6 +1505,32 @@
"integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
"license": "MIT"
},
+ "node_modules/@types/lodash": {
+ "version": "4.17.13",
+ "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.13.tgz",
+ "integrity": "sha512-lfx+dftrEZcdBPczf9d0Qv0x+j/rfNCMuC6OcfXmO8gkfeNAY88PgKUbvG56whcN23gc27yenwF6oJZXGFpYxg==",
+ "license": "MIT"
+ },
+ "node_modules/@types/lodash.clonedeep": {
+ "version": "4.5.9",
+ "resolved": "https://registry.npmjs.org/@types/lodash.clonedeep/-/lodash.clonedeep-4.5.9.tgz",
+ "integrity": "sha512-19429mWC+FyaAhOLzsS8kZUsI+/GmBAQ0HFiCPsKGU+7pBXOQWhyrY6xNNDwUSX8SMZMJvuFVMF9O5dQOlQK9Q==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/lodash": "*"
+ }
+ },
+ "node_modules/@types/lodash.isequal": {
+ "version": "4.5.8",
+ "resolved": "https://registry.npmjs.org/@types/lodash.isequal/-/lodash.isequal-4.5.8.tgz",
+ "integrity": "sha512-uput6pg4E/tj2LGxCZo9+y27JNyB2OZuuI/T5F+ylVDYuqICLG2/ktjxx0v6GvVntAf8TvEzeQLcV0ffRirXuA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/lodash": "*"
+ }
+ },
"node_modules/@types/node": {
"version": "22.10.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.1.tgz",
diff --git a/package.json b/package.json
index 7d5fe579..dc85beb9 100755
--- a/package.json
+++ b/package.json
@@ -30,7 +30,10 @@
"@iconify-json/mdi-light": "^1.2.1",
"@iconify-json/ph": "^1.1.13",
"@iconify-json/proicons": "^1.2.9",
+ "@iconify-json/svg-spinners": "^1.2.2",
"@tsconfig/node22": "^22.0.0",
+ "@types/lodash.clonedeep": "^4.5.9",
+ "@types/lodash.isequal": "^4.5.8",
"@types/node": "^22.9.3",
"@typescript-eslint/eslint-plugin": "^8.13.0",
"@typescript-eslint/parser": "^8.13.0",
@@ -58,6 +61,7 @@
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/forms": "^0.5.7",
"@tanstack/vue-query": "^5.59.20",
+ "@types/lodash": "^4.17.13",
"@vueuse/components": "^10.11.0",
"@vueuse/core": "^10.11.0",
"@vueuse/integrations": "^11.0.0",
diff --git a/resources/js/components/cards/CategoryCard.vue b/resources/js/components/cards/CategoryCard.vue
index 2d9a157b..ba912f5d 100644
--- a/resources/js/components/cards/CategoryCard.vue
+++ b/resources/js/components/cards/CategoryCard.vue
@@ -1,43 +1,161 @@
<script setup lang="ts">
-import type { CategoryResource } from '@/types/resources';
+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 { toast } from '@/service/toaster/toastService';
+
+import Popover from '@/components/pinesUI/Popover.vue';
+import ButtonText from '@/components/inputs/ButtonText.vue';
+import FormInputLabel from '@/components/labels/FormInputLabel.vue';
+import InputSelect from '@/components/pinesUI/InputSelect.vue';
+
+import ProiconsMoreVertical from '~icons/proicons/more-vertical';
+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 { toFormattedDate } from '@/service/util';
-import ButtonCorner from '../inputs/ButtonCorner.vue';
-import ButtonIcon from '@/components/inputs/ButtonIcon.vue';
const props = defineProps<{ data?: CategoryResource }>();
+const defaultFolder = ref<FolderResource>();
+const queryClient = useQueryClient();
+const processing = ref(false);
+
+const handleSetDefaultFolder = async (newFolder: { value: number }) => {
+ if (processing.value || !props.data?.id || newFolder.value === props.data.default_folder_id) return;
+
+ try {
+ processing.value = true;
+
+ await updateCategory(props.data.id, { default_folder_id: newFolder.value });
+ toast('Default Folder Updated', { type: 'success' });
+
+ await queryClient.invalidateQueries({
+ queryKey: ['categories'],
+ });
+
+ processing.value = false;
+ } catch (error) {
+ console.log(error);
+ toast('Update Failed', { type: 'danger' });
+ }
+};
+
+watch(
+ () => props.data,
+ () => {
+ if (!props.data?.folders || props.data.folders.length < 1) return;
+
+ defaultFolder.value = props.data.default_folder_id
+ ? props.data.folders.find((folder) => folder.id === props.data?.default_folder_id)
+ : props.data.folders[0];
+ },
+ { immediate: true },
+);
</script>
<template>
- <div class="flex gap-2 p-4 overflow-clip rounded-xl shadow-lg dark:bg-primary-dark-800/70 bg-white ring-1 ring-gray-900/5 w-full">
- <div class="h-28 object-cover rounded-md shadow-md aspect-2/3 mb-auto relative group">
- <img
- id="folder-thumbnail"
- class="h-28 object-cover rounded-md aspect-2/3 ring-1 ring-gray-900/5"
- :src="
- data?.folders[0]?.series?.thumbnail_url ??
- 'https://m.media-amazon.com/images/M/MV5BMjVjZGU5ZTktYTZiNC00N2Q1LThiZjMtMDVmZDljN2I3ZWIwXkEyXkFqcGdeQXVyMTUzMTg2ODkz._V1_.jpg'
- "
- alt="Folder Cover Art"
- />
- </div>
- <section class="flex flex-1 h-full flex-col">
- <h3 class="capitalize text-lg flex items-start justify-between">
+ <div class="flex flex-col rounded-xl shadow-lg dark:bg-primary-dark-800/70 bg-white ring-1 ring-gray-900/5 w-full">
+ <img
+ id="folder-thumbnail"
+ class="w-full h-40 object-cover rounded-t-md shadow-md mb-auto relative group ring-1 ring-gray-900/5"
+ :src="
+ defaultFolder?.series?.thumbnail_url ??
+ 'https://m.media-amazon.com/images/M/MV5BMjVjZGU5ZTktYTZiNC00N2Q1LThiZjMtMDVmZDljN2I3ZWIwXkEyXkFqcGdeQXVyMTUzMTg2ODkz._V1_.jpg'
+ "
+ alt="Folder Cover Art"
+ loading="lazy"
+ />
+ <section class="flex flex-1 h-full flex-col p-4 gap-2">
+ <h3 class="capitalize text-lg flex items-start justify-between flex-wrap">
{{ data?.name }}
- <ButtonIcon class="!w-6 !h-6 !p-1 !static">
- <template #icon>
- <CircumEdit class="w-full h-full" />
- </template>
- </ButtonIcon>
+
+ <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>
+ <template #icon> <ProiconsArrowSync class="h-4 w-4" /></template>
+ </ButtonText>
+ <Popover popoverClass="w-48 sm:w-64 rounded-lg" :buttonClass="'!p-1 ml-auto'">
+ <template #buttonIcon>
+ <ProiconsMoreVertical class="h-4 w-4 md:hidden" />
+ <CircumEdit class="w-full h-full hidden md:block" />
+ </template>
+ <template #content>
+ <div class="grid gap-4">
+ <div class="space-y-2">
+ <h4 class="font-medium leading-none">Manage Library</h4>
+ <p class="text-sm text-muted-foreground">Set Library Properties.</p>
+ </div>
+
+ <div class="grid gap-2">
+ <div class="w-full flex flex-col gap-1">
+ <FormInputLabel :field="{ text: 'Default Folder', name: 'Default Folder' }" class="font-normal" />
+ <InputSelect
+ id="default_folder"
+ root-class="flex-1 rounded-l-none capitalize !w-full !whitespace-nowrap col-span-2"
+ class="h-8"
+ :placeholder="'Select Default Folder'"
+ :default-item="data?.folders.findIndex((folder) => folder.id == defaultFolder?.id) ?? 0"
+ :disabled="processing"
+ title="Select Default Folder"
+ @selectItem="handleSetDefaultFolder"
+ :options="
+ data?.folders.map((folder) => {
+ return { title: folder.name, value: folder.id };
+ })
+ "
+ />
+ </div>
+ <ButtonText class="h-8 dark:!bg-neutral-950 md:hidden" :title="'Scan for Folder Changes'">
+ <template #text> Scan Folders </template>
+ <template #icon> <ProiconsArrowSync 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 Access </template>
+ <template #icon> <ProiconsLock class="h-4 w-4" /></template>
+ </ButtonText>
+ <ButtonText
+ class="h-8 text-red-600 dark:!bg-red-700 disabled:opacity-60"
+ :title="'Remove From Server'"
+ @click.stop.prevent="$emit('clickAction')"
+ disabled
+ >
+ <template #text> Remove Library </template>
+ <template #icon> <ProiconsDelete class="h-4 w-4" /></template>
+ </ButtonText>
+ </div>
+ </div>
+ </template>
+ </Popover>
+ </span>
</h3>
- <span class="flex items-center justify-between gap-2 text-sm mt-auto" v-if="data?.folders[0]">
- <p class="text-slate-400">First Folder: {{ data.folders[0].name }}</p>
- <p class="text-slate-400">Videos: {{ data.folders[0].file_count }}</p>
- </span>
- <span class="flex items-center justify-between gap-2 text-sm">
- <p class="text-slate-400">Folders: {{ data?.folders_count }}</p>
- <p class="text-slate-400">Added: {{ data?.created_at ? toFormattedDate(new Date(data?.created_at + ' EST')) : 'N/A' }}</p>
+ <span class="w-full text-sm text-slate-600 dark:text-slate-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">
+ {{ formatFileSize(data.folders.reduce((total, folder) => total + Number(folder.total_size), 0)) }}
+ </p>
+ </span>
+ <span class="flex items-center justify-between gap-x-2 flex-wrap">
+ <p class="">{{ defaultFolder ? `Default: ${defaultFolder.name}` : 'No Default Folder' }}</p>
+ <p class="hidden sm:block" title="Date Added">
+ {{ data?.created_at ? toFormattedDate(new Date(data?.created_at + ' EST')) : 'N/A' }}
+ </p>
+ </span>
+ <span class="sm:hidden flex items-center justify-between gap-x-2 flex-wrap mt-2">
+ <p class="" title="Date Added">
+ {{ data?.created_at ? toFormattedDate(new Date(data?.created_at + ' EST')) : 'N/A' }}
+ </p>
+ <p class="" title="Total Size">
+ {{ formatFileSize(data.folders.reduce((total, folder) => total + Number(folder.total_size), 0)) }}
+ </p>
+ </span>
</span>
</section>
</div>
diff --git a/resources/js/components/cards/CategoryCardList.vue b/resources/js/components/cards/CategoryCardList.vue
new file mode 100644
index 00000000..2d9a157b
--- /dev/null
+++ b/resources/js/components/cards/CategoryCardList.vue
@@ -0,0 +1,44 @@
+<script setup lang="ts">
+import type { CategoryResource } from '@/types/resources';
+
+import CircumEdit from '~icons/circum/edit';
+import { toFormattedDate } from '@/service/util';
+import ButtonCorner from '../inputs/ButtonCorner.vue';
+import ButtonIcon from '@/components/inputs/ButtonIcon.vue';
+
+const props = defineProps<{ data?: CategoryResource }>();
+</script>
+
+<template>
+ <div class="flex gap-2 p-4 overflow-clip rounded-xl shadow-lg dark:bg-primary-dark-800/70 bg-white ring-1 ring-gray-900/5 w-full">
+ <div class="h-28 object-cover rounded-md shadow-md aspect-2/3 mb-auto relative group">
+ <img
+ id="folder-thumbnail"
+ class="h-28 object-cover rounded-md aspect-2/3 ring-1 ring-gray-900/5"
+ :src="
+ data?.folders[0]?.series?.thumbnail_url ??
+ 'https://m.media-amazon.com/images/M/MV5BMjVjZGU5ZTktYTZiNC00N2Q1LThiZjMtMDVmZDljN2I3ZWIwXkEyXkFqcGdeQXVyMTUzMTg2ODkz._V1_.jpg'
+ "
+ alt="Folder Cover Art"
+ />
+ </div>
+ <section class="flex flex-1 h-full flex-col">
+ <h3 class="capitalize text-lg flex items-start justify-between">
+ {{ data?.name }}
+ <ButtonIcon class="!w-6 !h-6 !p-1 !static">
+ <template #icon>
+ <CircumEdit class="w-full h-full" />
+ </template>
+ </ButtonIcon>
+ </h3>
+ <span class="flex items-center justify-between gap-2 text-sm mt-auto" v-if="data?.folders[0]">
+ <p class="text-slate-400">First Folder: {{ data.folders[0].name }}</p>
+ <p class="text-slate-400">Videos: {{ data.folders[0].file_count }}</p>
+ </span>
+ <span class="flex items-center justify-between gap-2 text-sm">
+ <p class="text-slate-400">Folders: {{ data?.folders_count }}</p>
+ <p class="text-slate-400">Added: {{ data?.created_at ? toFormattedDate(new Date(data?.created_at + ' EST')) : 'N/A' }}</p>
+ </span>
+ </section>
+ </div>
+</template>
diff --git a/resources/js/components/cards/FolderCard.vue b/resources/js/components/cards/FolderCard.vue
index 1d5e9107..3dfc706c 100755
--- a/resources/js/components/cards/FolderCard.vue
+++ b/resources/js/components/cards/FolderCard.vue
@@ -1,6 +1,6 @@
<script setup lang="ts">
import type { FolderResource } from '@/types/resources';
-import { formatFileSize } from '@/composables/useMetaData';
+import { formatFileSize } from '@/service/util';
import { RouterLink } from 'vue-router';
import { ref } from 'vue';
diff --git a/resources/js/components/cards/RecordCard.vue b/resources/js/components/cards/RecordCard.vue
index f705c650..5f35b454 100755
--- a/resources/js/components/cards/RecordCard.vue
+++ b/resources/js/components/cards/RecordCard.vue
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { toFormattedDate, toTimeSpan } from '../../service/util';
import { type RecordResource } from '@/types/resources';
-import { formatFileSize } from '@/composables/useMetaData';
+import { formatFileSize } from '@/service/util';
import { computed } from 'vue';
import ButtonCorner from '../inputs/ButtonCorner.vue';
diff --git a/resources/js/components/charts/PulseDoughnutChart.vue b/resources/js/components/charts/PulseDoughnutChart.vue
index 3db16052..60b037f6 100644
--- a/resources/js/components/charts/PulseDoughnutChart.vue
+++ b/resources/js/components/charts/PulseDoughnutChart.vue
@@ -1,5 +1,4 @@
<script setup lang="ts">
-import type { ChartData, ChartOptions } from 'chart.js';
import { Doughnut } from 'vue-chartjs';
const props = defineProps<{
diff --git a/resources/js/components/dashboard/DashboardAnalytics.vue b/resources/js/components/dashboard/DashboardAnalytics.vue
index 50232d31..ef9d1cc1 100644
--- a/resources/js/components/dashboard/DashboardAnalytics.vue
+++ b/resources/js/components/dashboard/DashboardAnalytics.vue
@@ -44,11 +44,11 @@ watch(
<section class="flex flex-wrap gap-4 flex-col">
<section class="flex justify-between flex-wrap gap-2">
<div class="flex items-center gap-2 flex-wrap [&>*]:h-8">
- <ButtonText @click="toast.add('Success', { type: 'success', description: 'Submitted Scan Request!', life: 3000 })">
+ <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="toast.add('Success', { type: 'success', description: 'Submitted Scan Request!', life: 3000 })">
+ <ButtonText @click="toast.add('Success', { type: 'success', description: 'Submitted Scan Request!', life: 3000 })" disabled>
<template #text>New Task</template>
<template #icon><ProiconsAdd /></template>
</ButtonText>
diff --git a/resources/js/components/dashboard/DashboardLibraries.vue b/resources/js/components/dashboard/DashboardLibraries.vue
index 1fc63b09..6958b806 100644
--- a/resources/js/components/dashboard/DashboardLibraries.vue
+++ b/resources/js/components/dashboard/DashboardLibraries.vue
@@ -1,24 +1,24 @@
<script setup lang="ts">
-import { computed, onMounted, ref } from 'vue';
-import { getCategories } from '@/service/mediaAPI';
+import type { CategoryResource } from '@/types/resources';
+
+import { computed, onMounted, ref, watch } from 'vue';
+import { useGetCategories } from '@/service/queries';
+import { toast } from '@/service/toaster/toastService';
-import RecordCardDetails from '@/components/cards/RecordCardDetails.vue';
+import CategoryCard from '@/components/cards/CategoryCard.vue';
import ButtonText from '@/components/inputs/ButtonText.vue';
-import ButtonIcon from '@/components/inputs/ButtonIcon.vue';
import ModalBase from '@/components/pinesUI/ModalBase.vue';
import TableBase from '@/components/table/TableBase.vue';
import useModal from '@/composables/useModal';
-const loading = ref(false);
+import ProiconsArrowSync from '~icons/proicons/arrow-sync';
+import ProiconsAdd from '~icons/proicons/add';
+
const cachedID = ref<null | number>(null);
const confirmModal = useModal({ title: 'Delete Category?', submitText: 'Confim' });
const searchQuery = ref('');
-import type { CategoryResource } from '@/types/resources';
-
-import ProiconsAddCircle from '~icons/proicons/add-circle';
-import CategoryCard from '../cards/CategoryCard.vue';
-
+const { data: rawCategories, isLoading } = useGetCategories();
const categories = ref<CategoryResource[]>([]);
const filteredCategories = computed(() => {
@@ -72,7 +72,7 @@ const sortingOptions = ref([
]);
const handleSort = async (column = 'date', dir = 1) => {
- let tempList = categories.value.sort((categoryA, categoryB) => {
+ 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 ?? '');
@@ -88,40 +88,49 @@ const handleSearch = (query: string) => {
searchQuery.value = query;
};
-onMounted(async () => {
- const { data: rawCategories } = await getCategories();
+watch(rawCategories, (v) => {
+ categories.value = v.data ?? [];
+});
- categories.value = rawCategories?.data;
+onMounted(() => {
+ if (rawCategories.value?.data) categories.value = rawCategories.value.data;
});
</script>
<template>
- <section id="content-libraries" class="flex gap-2 flex-col">
- <span class="flex items-center justify-between">
- <ButtonText title="Add New Category">
- <template #text>
- <div class="flex justify-between items-center gap-2">
- <p class="text-nowrap">Add New Category</p>
- <ProiconsAddCircle height="24" width="24" />
- </div>
- </template>
- </ButtonText>
- <p class="text-slate-400 uppercase">Categories: {{ categories.length }}</p>
- </span>
+ <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">
+ <ButtonText
+ title="Add New Library"
+ @click="toast.add('Success', { type: 'success', description: 'Submitted Scan Request!', life: 3000 })"
+ disabled
+ >
+ <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>
+ <template #icon><ProiconsArrowSync /></template>
+ </ButtonText>
+ </div>
+ </div>
<TableBase
- :data="filteredCategories"
+ :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"
- :clickAction="handleDelete"
- :loading="loading"
- :useToolbar="true"
- :sortAction="handleSort"
- :sortingOptions="sortingOptions"
+ :click-action="handleDelete"
+ :loading="isLoading"
+ :sort-action="handleSort"
+ :sorting-options="sortingOptions"
@search="handleSearch"
/>
</section>
<ModalBase :modalData="confirmModal" :action="submitDelete">
<template #content>
<div class="relative w-auto pb-8">
- <p>Are you sure you want to delete this record?</p>
+ <p>Are you sure you want to delete this Library?</p>
</div>
</template>
</ModalBase>
diff --git a/resources/js/components/inputs/ButtonText.vue b/resources/js/components/inputs/ButtonText.vue
index 6c43c806..945cacf3 100755
--- a/resources/js/components/inputs/ButtonText.vue
+++ b/resources/js/components/inputs/ButtonText.vue
@@ -1,4 +1,4 @@
-<script setup>
+<script setup lang="ts">
const props = defineProps(['class', 'type', 'disabled', 'title']);
</script>
@@ -9,7 +9,7 @@ const props = defineProps(['class', 'type', 'disabled', 'title']);
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} disabled:cursor-not-allowed disabled:hover:ring-neutral-200 disabled:hover:dark:ring-neutral-700 disabled:ring-1`"
+ ${props.class} disabled:cursor-not-allowed disabled:hover:ring-neutral-200 disabled:hover:dark:ring-neutral-700 disabled:ring-1 disabled:opacity-60`"
:type="props.type"
:disabled="props.disabled"
:title="props.title ?? 'Button'"
diff --git a/resources/js/components/labels/FormInputLabel.vue b/resources/js/components/labels/FormInputLabel.vue
index 70574a98..3886e0f4 100755
--- a/resources/js/components/labels/FormInputLabel.vue
+++ b/resources/js/components/labels/FormInputLabel.vue
@@ -1,12 +1,11 @@
-<script setup>
-const { field, textSize } = defineProps(['field', 'textSize']);
+<script setup lang="ts">
+const props = defineProps(['field', 'textSize', 'class']);
</script>
<template>
<label
- class="block font-medium text-gray-700 dark:text-neutral-200"
:for="field?.name"
- :class="{ textSize: textSize, 'text-sm': !textSize }"
+ :class="`block font-medium text-gray-700 dark:text-neutral-200 ${props.class} ${textSize ? textSize : 'text-sm'}`"
>
{{ field?.text }}
</label>
diff --git a/resources/js/components/panels/NavBar.vue b/resources/js/components/panels/NavBar.vue
index f3c47b5e..73aedb46 100755
--- a/resources/js/components/panels/NavBar.vue
+++ b/resources/js/components/panels/NavBar.vue
@@ -74,11 +74,6 @@ watch(userData, handleAuthEvent, { immediate: false });
class="flex flex-wrap sm:flex-nowrap sm:max-w-sm items-center gap-1 sm:shrink-0 justify-end sm:justify-normal sm:w-auto ml-auto"
>
<section id="navbar-video" class="flex items-center gap-1 text-slate-900 antialiased">
- <NavLink v-if="$route.name != 'home'" :label="'home'" :URL="'/'" :class="`ring-1 ring-gray-900/5`">
- <template #icon>
- <CircumMonitor height="24" width="24" />
- </template>
- </NavLink>
<NavButton v-if="username" @click="cycleSideBar('notifications')" :label="'notifications'" class="hidden">
<template #icon>
<CircumInboxIn height="24" width="24" />
@@ -117,6 +112,11 @@ watch(userData, handleAuthEvent, { immediate: false });
<MaterialSymbolsLightMenu height="26" width="26" />
</template>
</NavButton>
+ <NavLink v-if="$route.name != 'home'" :label="'home'" :URL="'/'" :class="`ring-1 ring-gray-900/5`">
+ <template #icon>
+ <CircumMonitor height="24" width="24" />
+ </template>
+ </NavLink>
</section>
<ToggleLightMode />
</span>
diff --git a/resources/js/components/pinesUI/InputSelect.vue b/resources/js/components/pinesUI/InputSelect.vue
index 48bb8a1c..2ac0cf81 100755
--- a/resources/js/components/pinesUI/InputSelect.vue
+++ b/resources/js/components/pinesUI/InputSelect.vue
@@ -1,62 +1,65 @@
-<script setup>
-import useSelect from '../../composables/useSelect';
+<script setup lang="ts">
+import useSelect from '@/composables/useSelect';
import { onMounted, ref, watch } from 'vue';
import { OnClickOutside } from '@vueuse/components';
-const props = defineProps({
- class: {
- type: String,
- default: '',
- },
- placeholder: {
- type: String,
- default: 'Select Item',
- },
- defaultItem: {
- type: Number,
- default: null,
- },
- options: {
- type: Array,
- default: () => {
- return [
- {
- title: 'Title',
- value: 'title',
- disabled: false,
- },
- {
- title: 'Date Uploaded',
- value: 'date',
- disabled: false,
- },
- {
- title: 'Date released',
- value: 'date_released',
- disabled: false,
- },
- {
- title: 'Episode',
- value: 'episode',
- disabled: true,
- },
- {
- title: 'Season',
- value: 'season',
- disabled: true,
- },
- ];
- },
+interface SelectItem {
+ title: string;
+ value: any;
+ key?: any;
+ disabled?: boolean;
+}
+
+const props = withDefaults(
+ defineProps<{
+ class?: string;
+ rootClass?: string;
+ placeholder?: string;
+ defaultItem?: number | null;
+ options?: SelectItem[];
+ disabled?: boolean;
+ }>(),
+ {
+ class: '',
+ rootClass: '',
+ defaultItem: null,
+ options: () => [
+ {
+ title: 'Title',
+ value: 'title',
+ disabled: false,
+ },
+ {
+ title: 'Date Uploaded',
+ value: 'date',
+ disabled: false,
+ },
+ {
+ title: 'Date released',
+ value: 'date_released',
+ disabled: false,
+ },
+ {
+ title: 'Episode',
+ value: 'episode',
+ disabled: true,
+ },
+ {
+ title: 'Season',
+ value: 'season',
+ disabled: true,
+ },
+ ],
},
-});
+);
const emit = defineEmits(['selectItem']);
-const selectButton = ref(null);
+const selectButton = ref<HTMLElement | null>(null);
const selectableItemsList = ref(null);
const select = useSelect(props.options, { selectableItemsList, selectButton });
-const handleItemClick = (item, setFocus = true) => {
+const handleItemClick = (item: any, setFocus = true) => {
select.selectedItem = item;
select.toggleSelect(false);
if (setFocus) selectButton.value?.focus();
@@ -64,6 +67,8 @@ const handleItemClick = (item, setFocus = true) => {
};
onMounted(() => {
+ if (props.disabled) return;
+
if (props.defaultItem != undefined && props.defaultItem < props.options.length && props.defaultItem >= 0) {
handleItemClick(props.options[props.defaultItem], false);
}
@@ -85,105 +90,123 @@ watch(
);
</script>
<template>
- <div
+ <OnClickOutside
+ @trigger="select.toggleSelect(false)"
@keydown.esc="
- if (select.selectOpen) {
- select.toggleSelect(false);
+ (event: Event) => {
+ if (select.selectOpen) {
+ select.toggleSelect(false);
+ event.stopPropagation();
+ }
}
"
@keydown.down="
- if (select.selectOpen) {
- select.selectableItemActiveNext();
- } else {
- select.toggleSelect(true);
+ (event: Event) => {
+ if (select.selectOpen) {
+ select.selectableItemActiveNext();
+ } else {
+ select.toggleSelect(true);
+ }
+ event.preventDefault();
}
- event.preventDefault();
"
@keydown.up="
- if (select.selectOpen) {
- select.selectableItemActivePrevious();
- } else {
- select.toggleSelect(true);
+ (event: Event) => {
+ if (select.selectOpen) {
+ select.selectableItemActivePrevious();
+ } else {
+ select.toggleSelect(true);
+ }
+ event.preventDefault();
}
- event.preventDefault();
"
@keydown.enter="
+ //@ts-ignore
select.selectedItem = select.selectableItemActive;
select.toggleSelect(false);
"
@keydown="select.selectKeydown($event)"
- class="relative"
+ :class="`relative ${rootClass}`"
>
- <OnClickOutside @trigger="select.toggleSelect(false)">
- <button
- ref="selectButton"
- @click="select.toggleSelect()"
- :class="`${select.selectOpen && 'hocus:ring-0'} relative h-10 flex items-center justify-between w-full py-2 pl-3 pr-10 text-left rounded-md shadow-sm cursor-pointer text-sm border-none focus:outline-none ring-inset ring-1 ring-neutral-200 dark:ring-neutral-700 hocus:ring-[0.125rem] hover:ring-violet-400 hover:dark:ring-violet-700 focus:ring-indigo-400 dark:focus:ring-indigo-500 text-gray-900 dark:text-neutral-100 bg-white dark:bg-neutral-800 ${props.class}`"
- >
- <span class="truncate">{{ select.selectedItem ? select.selectedItem.title : placeholder }}</span>
- <span class="absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none">
+ <button
+ ref="selectButton"
+ @click="select.toggleSelect()"
+ :class="`${select.selectOpen && 'hocus:ring-0'} relative h-10 flex items-center justify-between w-full py-2 pl-3 pr-10 text-left rounded-md shadow-sm cursor-pointer text-sm border-none focus:outline-none ring-inset ring-1 ring-neutral-200 dark:ring-neutral-700 hocus:ring-[0.125rem] hover:ring-violet-400 hover:dark:ring-violet-700 focus:ring-indigo-400 dark:focus:ring-indigo-500 text-gray-900 dark:text-neutral-100 bg-white dark:bg-neutral-800 ${props.class}`"
+ :disabled="disabled"
+ >
+ <span class="truncate"
+ >{{
+ //@ts-ignore
+ select.selectedItem ? select.selectedItem.title : placeholder
+ }}
+ </span>
+ <span class="absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none">
+ <slot name="selectButtonIcon">
<svg
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 20 20"
- fill="currentColor"
- aria-hidden="true"
- class="w-5 h-5 text-gray-400"
- >
- <path
- fill-rule="evenodd"
- d="M10 3a.75.75 0 01.55.24l3.25 3.5a.75.75 0 11-1.1 1.02L10 4.852 7.3 7.76a.75.75 0 01-1.1-1.02l3.25-3.5A.75.75 0 0110 3zm-3.76 9.2a.75.75 0 011.06.04l2.7 2.908 2.7-2.908a.75.75 0 111.1 1.02l-3.25 3.5a.75.75 0 01-1.1 0l-3.25-3.5a.75.75 0 01.04-1.06z"
- clip-rule="evenodd"
- ></path>
- </svg>
- </span>
- </button>
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 20 20"
+ fill="currentColor"
+ aria-hidden="true"
+ class="w-5 h-5 text-gray-400"
+ >
+ <path
+ fill-rule="evenodd"
+ d="M10 3a.75.75 0 01.55.24l3.25 3.5a.75.75 0 11-1.1 1.02L10 4.852 7.3 7.76a.75.75 0 01-1.1-1.02l3.25-3.5A.75.75 0 0110 3zm-3.76 9.2a.75.75 0 011.06.04l2.7 2.908 2.7-2.908a.75.75 0 111.1 1.02l-3.25 3.5a.75.75 0 01-1.1 0l-3.25-3.5a.75.75 0 01.04-1.06z"
+ clip-rule="evenodd"
+ ></path>
+ </svg>
+ </slot>
+ </span>
+ </button>
- <Transition
- enter-active-class="transition ease-out duration-50"
- enter-from-class="opacity-0 -translate-y-1"
- enter-to-class="opacity-100"
+ <Transition
+ enter-active-class="transition ease-out duration-50"
+ enter-from-class="opacity-0 -translate-y-1"
+ enter-to-class="opacity-100"
+ >
+ <ul
+ v-show="select.selectOpen"
+ ref="selectableItemsList"
+ :class="{
+ 'bottom-0 mb-10': select.selectDropdownPosition == 'top',
+ 'top-0 mt-10': select.selectDropdownPosition == 'bottom',
+ }"
+ class="z-30 absolute w-full mt-1 overflow-auto text-sm rounded-md shadow-md max-h-56 focus:outline-none ring-1 ring-opacity-5 ring-black dark:ring-neutral-700 bg-white dark:bg-neutral-800/70 backdrop-blur-lg"
+ v-cloak
>
- <ul
- v-show="select.selectOpen"
- ref="selectableItemsList"
- :class="{
- 'bottom-0 mb-10': select.selectDropdownPosition == 'top',
- 'top-0 mt-10': select.selectDropdownPosition == 'bottom',
- }"
- class="z-30 absolute w-full mt-1 overflow-auto text-sm rounded-md shadow-md max-h-56 focus:outline-none ring-1 ring-opacity-5 ring-black dark:ring-neutral-700 bg-white dark:bg-neutral-800/70 backdrop-blur-lg"
- v-cloak
- >
- <template v-for="item in select.selectableItems" :key="item.value">
- <li
- @click="handleItemClick(item)"
- :id="item.value + '-' + select.selectId"
- :data-disabled="item.disabled ? item.disabled : ''"
- :class="{
- 'bg-neutral-100 dark:bg-neutral-900/70 text-gray-900 dark:text-neutral-100':
- select.selectableItemIsActive(item),
- 'text-gray-700 dark:text-neutral-300': !select.selectableItemIsActive(item),
- }"
- @mousemove="select.selectableItemActive = item"
- class="relative flex items-center h-full py-2 pl-8 cursor-pointer select-none data-[disabled=true]:opacity-50 data-[disabled=true]:pointer-events-none"
+ <template v-for="item in select.selectableItems" :key="item.value">
+ <li
+ @click="handleItemClick(item)"
+ :id="item.value + '-' + select.selectId"
+ :data-disabled="item.disabled ? item.disabled : ''"
+ :class="{
+ 'bg-neutral-100 dark:bg-neutral-900/70 text-gray-900 dark:text-neutral-100':
+ select.selectableItemIsActive(item),
+ 'text-gray-700 dark:text-neutral-300': !select.selectableItemIsActive(item),
+ }"
+ @mousemove="select.selectableItemActive = item"
+ class="relative flex items-center h-full py-2 pl-8 cursor-pointer select-none data-[disabled=true]:opacity-50 data-[disabled=true]:pointer-events-none"
+ >
+ <svg
+ v-if="
+ //@ts-ignore
+ select.selectedItem.value == item.value
+ "
+ class="absolute left-0 w-4 h-4 ml-2 stroke-current text-neutral-400"
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ stroke-width="2"
+ stroke-linecap="round"
+ stroke-linejoin="round"
>
- <svg
- v-if="select.selectedItem.value == item.value"
- class="absolute left-0 w-4 h-4 ml-2 stroke-current text-neutral-400"
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- stroke-width="2"
- stroke-linecap="round"
- stroke-linejoin="round"
- >
- <polyline points="20 6 9 17 4 12"></polyline>
- </svg>
- <span class="block font-medium truncate">{{ item.title }}</span>
- </li>
- </template>
- </ul>
- </Transition>
- </OnClickOutside>
- </div>
+ <polyline points="20 6 9 17 4 12"></polyline>
+ </svg>
+ <span class="block font-medium truncate">{{ item.title }}</span>
+ </li>
+ </template>
+ </ul>
+ </Transition>
+ </OnClickOutside>
</template>
diff --git a/resources/js/components/pinesUI/ModalBase.vue b/resources/js/components/pinesUI/ModalBase.vue
index 60534888..53d4bce7 100755
--- a/resources/js/components/pinesUI/ModalBase.vue
+++ b/resources/js/components/pinesUI/ModalBase.vue
@@ -71,7 +71,7 @@ watch(
<OnClickOutside
@trigger="modalData.toggleModal(false)"
@keydown.esc="modalData.toggleModal(false)"
- class="m-auto w-full p-6 bg-white dark:bg-neutral-800/90 backdrop-blur-lg border shadow-lg border-neutral-200 dark:border-neutral-700 sm:max-w-lg rounded-md sm:rounded-lg"
+ class="drop-shadow-md m-auto w-full p-6 bg-white dark:bg-neutral-800/90 backdrop-blur-lg border shadow-lg border-neutral-200 dark:border-neutral-700 sm:max-w-lg rounded-md sm:rounded-lg"
tabindex="-1"
>
<div class="flex items-center justify-between pb-3">
diff --git a/resources/js/components/pinesUI/Popover.vue b/resources/js/components/pinesUI/Popover.vue
new file mode 100644
index 00000000..b26a9c27
--- /dev/null
+++ b/resources/js/components/pinesUI/Popover.vue
@@ -0,0 +1,209 @@
+<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 }>();
+
+const popoverOpen = ref(false);
+const popoverArrow = ref(true);
+const popoverPosition = ref<'top' | 'bottom'>('bottom');
+const popoverAdjustment = ref('');
+const popoverHeight = ref(0);
+const popoverOffset = ref(8);
+
+const popover = useTemplateRef('popover');
+const popoverButton = useTemplateRef('popoverButton');
+const popoverInner = ref<null | HTMLElement>(null);
+const popoverArrowRef = useTemplateRef('popoverArrowRef');
+
+async function popoverHeightCalculate() {
+ if (!popover.value) return;
+ popover.value.$el.classList.add('invisible');
+ popoverOpen.value = true;
+
+ await nextTick();
+ popoverHeight.value = popover.value.$el.offsetHeight;
+ popoverOpen.value = false;
+ popover.value.$el.classList.remove('invisible');
+ popoverInner.value?.setAttribute('x-transition', '');
+ popoverPositionCalculate();
+}
+
+function popoverPositionCalculate() {
+ if (!popoverButton.value) return;
+
+ popoverPosition.value =
+ window.innerHeight <
+ popoverButton.value.$el.getBoundingClientRect().top +
+ popoverButton.value.$el.offsetHeight +
+ popoverOffset.value +
+ popoverHeight.value
+ ? 'top'
+ : 'bottom';
+}
+
+const adjustPopoverPosition = () => {
+ if (!popover.value || !popoverButton.value) return;
+ const margin = 40;
+ let adjustment = 0;
+
+ const popoverRect = popover.value.$el.getBoundingClientRect();
+ const viewportWidth = window.innerWidth;
+
+ // console.log(viewportWidth - popoverRect.right - margin);
+
+ if (viewportWidth > popoverRect.width + margin * 2 && viewportWidth - popoverRect.right - margin < 0) {
+ adjustment = viewportWidth - popoverRect.right - margin;
+ } else if (viewportWidth > popoverRect.width + margin * 2 && popoverRect.left < 0) {
+ adjustment = margin;
+ } else {
+ return;
+ }
+
+ popover.value.$el.style = `left: ${adjustment}px;`;
+ if (popoverArrowRef.value) {
+ popoverArrowRef.value.style.left = `${popoverRect.width - margin / 2 + popoverArrowRef.value.offsetWidth / 2}px`;
+ }
+};
+
+watch(
+ () => popoverOpen.value,
+ async (value) => {
+ if (value) {
+ await nextTick();
+ popoverPositionCalculate();
+ adjustPopoverPosition();
+ document.getElementById('width')?.focus();
+ }
+ },
+);
+
+onMounted(() => {
+ window.addEventListener('resize', function () {
+ popoverPositionCalculate();
+ });
+
+ setTimeout(function () {
+ popoverHeightCalculate();
+ }, 100);
+});
+</script>
+<template>
+ <div class="relative flex">
+ <ButtonText ref="popoverButton" :class="buttonClass" @click="popoverOpen = true">
+ <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">
+ <path
+ d="M5.5 3C4.67157 3 4 3.67157 4 4.5C4 5.32843 4.67157 6 5.5 6C6.32843 6 7 5.32843 7 4.5C7 3.67157 6.32843 3 5.5 3ZM3 5C3.01671 5 3.03323 4.99918 3.04952 4.99758C3.28022 6.1399 4.28967 7 5.5 7C6.71033 7 7.71978 6.1399 7.95048 4.99758C7.96677 4.99918 7.98329 5 8 5H13.5C13.7761 5 14 4.77614 14 4.5C14 4.22386 13.7761 4 13.5 4H8C7.98329 4 7.96677 4.00082 7.95048 4.00242C7.71978 2.86009 6.71033 2 5.5 2C4.28967 2 3.28022 2.86009 3.04952 4.00242C3.03323 4.00082 3.01671 4 3 4H1.5C1.22386 4 1 4.22386 1 4.5C1 4.77614 1.22386 5 1.5 5H3ZM11.9505 10.9976C11.7198 12.1399 10.7103 13 9.5 13C8.28967 13 7.28022 12.1399 7.04952 10.9976C7.03323 10.9992 7.01671 11 7 11H1.5C1.22386 11 1 10.7761 1 10.5C1 10.2239 1.22386 10 1.5 10H7C7.01671 10 7.03323 10.0008 7.04952 10.0024C7.28022 8.8601 8.28967 8 9.5 8C10.7103 8 11.7198 8.8601 11.9505 10.0024C11.9668 10.0008 11.9833 10 12 10H13.5C13.7761 10 14 10.2239 14 10.5C14 10.7761 13.7761 11 13.5 11H12C11.9833 11 11.9668 10.9992 11.9505 10.9976ZM8 10.5C8 9.67157 8.67157 9 9.5 9C10.3284 9 11 9.67157 11 10.5C11 11.3284 10.3284 12 9.5 12C8.67157 12 8 11.3284 8 10.5Z"
+ fill="currentColor"
+ fill-rule="evenodd"
+ clip-rule="evenodd"
+ ></path>
+ </svg>
+ </slot>
+ </template>
+ </ButtonText>
+ <Transition
+ enter-active-class="ease-out duration-150"
+ enter-from-class="scale-[0.8] opacity-60"
+ enter-to-class="scale-100 opacity-100"
+ leave-active-class="ease-in-out duration-100"
+ leave-from-class="scale-100 opacity-100"
+ leave-to-class="scale-[0.1] opacity-50"
+ >
+ <UseFocusTrap
+ v-if="popoverOpen"
+ :class="`z-50 absolute w-[300px] max-w-lg p-4 bg-white dark:bg-neutral-800/90 backdrop-blur-sm border border-neutral-200/70 dark:border-neutral-700/10 rounded-md shadow-sm ${popoverClass} -translate-x-1/2 ${popoverAdjustment ? '' : 'left-1/2'} ${popoverPosition === 'bottom' ? 'top-0 mt-8' : 'bottom-0 mb-8'}`"
+ ref="popover"
+ >
+ <OnClickOutside
+ @trigger.stop="
+ (e: any) => {
+ popoverOpen = false;
+ }
+ "
+ @keydown.esc="popoverOpen = false"
+ tabindex="-1"
+ v-show="popoverOpen"
+ v-cloak
+ :class="`w-full`"
+ >
+ <div
+ v-show="popoverArrow && popoverPosition == 'bottom'"
+ ref="popoverArrowRef"
+ :class="`absolute inline-block w-5 overflow-hidden -translate-x-2 left-1/2 ${popoverPosition === 'bottom' ? 'top-0 mt-px -translate-y-2.5' : 'bottom-0 mb-px translate-y-2.5'}`"
+ >
+ <div
+ :class="`w-2.5 h-2.5 transform bg-white dark:bg-neutral-800/90 border-l border-neutral-200/70 dark:border-neutral-700/10 rounded-sm ${popoverPosition === 'bottom' ? 'origin-bottom-left rotate-45 border-t' : 'origin-top-left -rotate-45 border-b'} `"
+ ></div>
+ </div>
+ <slot name="content">
+ <div class="grid gap-4">
+ <div class="space-y-2">
+ {{ popoverAdjustment }}
+ <h4 class="font-medium leading-none">Dimensions</h4>
+ <p class="text-sm text-muted-foreground">Set the dimensions for the layer.</p>
+ </div>
+ <div class="grid gap-2">
+ <div class="grid items-center grid-cols-3 gap-4">
+ <label
+ class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
+ for="width"
+ >Width</label
+ ><input
+ class="flex w-full h-8 col-span-2 px-3 py-2 text-sm bg-transparent border rounded-md border-input ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
+ id="width"
+ value="100%"
+ />
+ </div>
+ <div class="grid items-center grid-cols-3 gap-4">
+ <label
+ class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
+ for="maxWidth"
+ >Max. width</label
+ ><input
+ class="flex w-full h-8 col-span-2 px-3 py-2 text-sm bg-transparent border rounded-md border-input ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
+ id="maxWidth"
+ value="300px"
+ />
+ </div>
+ <div class="grid items-center grid-cols-3 gap-4">
+ <label
+ class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
+ for="height"
+ >Height</label
+ ><input
+ class="flex w-full h-8 col-span-2 px-3 py-2 text-sm bg-transparent border rounded-md border-input ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
+ id="height"
+ value="25px"
+ />
+ </div>
+ <div class="grid items-center grid-cols-3 gap-4">
+ <label
+ class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
+ for="maxHeight"
+ >Max. height</label
+ ><input
+ class="flex w-full h-8 col-span-2 px-3 py-2 text-sm bg-transparent border rounded-md border-input ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
+ id="maxHeight"
+ value="none"
+ />
+ </div>
+ </div>
+ </div>
+ </slot>
+ </OnClickOutside>
+ </UseFocusTrap>
+ </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 be6e38bd..ef155d44 100755
--- a/resources/js/components/table/TableBase.vue
+++ b/resources/js/components/table/TableBase.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import { ref, watch } from 'vue';
+import { ref, watch, type Component } from 'vue';
import TextInputLabelled from '@/components/inputs/TextInputLabelled.vue';
import TablePagination from '@/components/table/TablePagination.vue';
@@ -10,20 +10,35 @@ import useTable from '@/composables/useTable.ts';
import PhSortDescendingLight from '~icons/ph/sort-descending-light';
import PhSortAscendingLight from '~icons/ph/sort-ascending-light';
+import SvgSpinners90RingWithBg from '~icons/svg-spinners/90-ring-with-bg';
-const props = defineProps([
- 'useToolbar',
- 'data',
- 'row',
- 'clickAction',
- 'otherAction',
- 'loading',
- 'sortAction',
- 'sortingOptions',
- 'itemsPerPage',
- 'searchQuery',
- 'selectedID',
-]);
+const props = withDefaults(
+ defineProps<{
+ useToolbar?: boolean;
+ usePagination?: boolean;
+ useGrid?: string;
+ data: any[];
+ row: Component;
+ loading?: boolean;
+ clickAction?: any;
+ otherAction?: any;
+ sortAction?: any;
+ sortingOptions?: {
+ title: string;
+ value: string;
+ disabled: boolean;
+ }[];
+ itemsPerPage?: number;
+ searchQuery?: any;
+ selectedID?: any;
+ }>(),
+ {
+ useToolbar: true,
+ usePagination: true,
+ itemsPerPage: 12,
+ selectedID: null,
+ },
+);
const tableData = useTable(props);
const sortAscending = ref(true);
const lastSortKey = ref('');
@@ -41,11 +56,8 @@ watch(props.data, tableData.handlePageReset, { immediate: true });
</script>
<template>
- <div v-if="props.loading" class="text-center text-lg text-gray-500 dark:text-gray-400 uppercase tracking-wider w-full py-16">
- Loading...
- </div>
<!-- [&>*:not(:first-child)]:pt-4 -->
- <table v-else class="flex flex-col gap-4">
+ <table class="flex flex-col gap-4">
<section v-if="props.useToolbar" class="flex justify-center sm:justify-between flex-col sm:flex-row gap-2">
<TextInputLabelled
v-model="tableData.fields.searchQuery"
@@ -83,12 +95,13 @@ watch(props.data, tableData.handlePageReset, { immediate: true });
</ButtonIcon>
</span>
</section>
- <tbody class="flex w-full flex-wrap gap-2">
+ <tbody :class="`${useGrid ? useGrid : 'flex w-full flex-wrap gap-2'}`">
<div
- v-if="tableData.filteredPage.length === 0 && !props.loading"
- class="text-center text-lg text-gray-500 dark:text-gray-400 uppercase tracking-wider w-full"
+ 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"
>
- No Results
+ <p>{{ loading ? '...Loading' : 'No Results' }}</p>
+ <SvgSpinners90RingWithBg v-show="loading" />
</div>
<component
v-else
@@ -104,6 +117,7 @@ watch(props.data, tableData.handlePageReset, { immediate: true });
</tbody>
<!-- <hr class="p-0" /> -->
<TablePagination
+ v-if="usePagination"
:listLength="props.data?.length ?? 0"
:itemsPerPage="tableData.fields.itemsPerPage"
:currentPage="tableData.fields.currentPage"
diff --git a/resources/js/components/table/TablePaginationButton.vue b/resources/js/components/table/TablePaginationButton.vue
index 7d7ab610..9371a943 100755
--- a/resources/js/components/table/TablePaginationButton.vue
+++ b/resources/js/components/table/TablePaginationButton.vue
@@ -3,7 +3,7 @@ const props = defineProps(['currentPage', 'pageNumber', 'text', 'underline', 'st
</script>
<template>
- <li :class="{ hidden: props.currentPage !== props.pageNumber && !props.text && !props.sticky }" class="h-full md:block">
+ <li :class="{ hidden: props.currentPage !== props.pageNumber && !props.text && !props.sticky }" class="h-full md:block z-0">
<button
class="relative inline-flex items-center h-full px-3 group hover:text-neutral-900 hover:dark:text-neutral-50 disabled:dark:text-neutral-500 disabled:text-neutral-300"
:class="{ 'text-neutral-900 dark:text-neutral-50 bg-gray-50 dark:bg-neutral-900': props.currentPage === props.pageNumber }"
diff --git a/resources/js/composables/useForm.ts b/resources/js/composables/useForm.ts
new file mode 100644
index 00000000..0c3d3e97
--- /dev/null
+++ b/resources/js/composables/useForm.ts
@@ -0,0 +1,134 @@
+import type { FormField } from '@/types/types';
+
+import { reactive, watch } from 'vue';
+
+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>;
+}
+
+interface FormState {
+ fields: { [key: string]: string };
+ field?: any;
+ 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>;
+ reset: (...fields: string[]) => void;
+ clearErrors: (...fields: string[]) => void;
+ setErrors: (errors: { [key: string]: string }) => void;
+}
+
+export default function useForm(fields: { [key: string]: string }) {
+ let defaults = fields;
+ let recentlySuccessfulTimeoutId: number;
+ const form = reactive<FormState>({
+ fields: cloneDeep(fields),
+ errors: {},
+ dirty: false,
+ hasErrors: false,
+ processing: false,
+ wasSuccessful: false,
+ recentlySuccessful: false,
+
+ async submit(submitFn: (fields: { [key: string]: string }) => any, hooks = {}) {
+ if (this.processing) return;
+
+ const _hooks = {
+ onBefore: async () => {
+ this.processing = true;
+ this.wasSuccessful = false;
+ this.recentlySuccessful = false;
+ clearTimeout(recentlySuccessfulTimeoutId);
+
+ if (hooks.onBefore) await hooks.onBefore();
+ },
+ onSuccess: async (response: any) => {
+ this.clearErrors();
+ this.wasSuccessful = true;
+ this.recentlySuccessful = true;
+
+ recentlySuccessfulTimeoutId = setTimeout(() => {
+ this.recentlySuccessful = false;
+ }, 2000);
+
+ if (hooks.onSuccess) await hooks.onSuccess(response);
+
+ defaults = cloneDeep(this.fields);
+ },
+ onError: async (error: any) => {
+ this.hasErrors = true;
+
+ if (error?.response?.status === 422 || error?.response?.status === 401) {
+ this.clearErrors();
+ this.setErrors({
+ message: error?.response?.data.message,
+ ...error?.response?.data?.errors,
+ });
+ }
+
+ if (hooks.onError) await hooks.onError(error);
+ },
+ onFinish: async () => {
+ this.processing = false;
+
+ if (hooks.onFinish) await hooks.onFinish();
+ },
+ };
+
+ await _hooks.onBefore();
+
+ try {
+ const response = await submitFn(this.fields);
+ await _hooks.onSuccess(response);
+ } catch (error) {
+ await _hooks.onError(error);
+ } finally {
+ await _hooks.onFinish();
+ }
+ },
+ reset(...fields) {
+ const clonedDefaults = cloneDeep(defaults);
+
+ if (fields.length === 0) {
+ this.fields = clonedDefaults;
+ } else {
+ fields.forEach((field) => {
+ if (clonedDefaults[field] !== undefined) {
+ this.fields[field] = clonedDefaults[field];
+ }
+ });
+ }
+ },
+ clearErrors(...fields: string[]) {
+ if (fields.length === 0) {
+ this.errors = {};
+ } else {
+ fields.forEach((field) => delete this.errors[field]);
+ }
+
+ this.hasErrors = Object.keys(this.errors).length > 0;
+ },
+ setErrors(errors: { [key: string]: string }) {
+ this.errors = { ...this.errors, ...errors };
+ this.hasErrors = Object.keys(this.errors).length > 0;
+ },
+ });
+
+ watch(
+ () => form.fields,
+ () => {
+ form.dirty = !isEqual(form.fields, defaults);
+ },
+ { immediate: true, deep: true },
+ );
+ return form;
+}
diff --git a/resources/js/composables/useMetaData.js b/resources/js/composables/useMetaData.js
index 5312c843..66738d79 100755
--- a/resources/js/composables/useMetaData.js
+++ b/resources/js/composables/useMetaData.js
@@ -1,4 +1,4 @@
-import { toFormattedDuration } from '@/service/util';
+import { formatFileSize, toFormattedDuration } from '@/service/util';
import { useRoute } from 'vue-router';
import { reactive } from 'vue';
@@ -26,21 +26,3 @@ export default function useMetaData(data) {
},
});
}
-
-export function formatFileSize(size, space = true) {
- if (isNaN(size) || size < 0) {
- return 'Invalid size';
- }
-
- const units = ['B', 'KB', 'MB', 'GB', 'TB'];
- let unitIndex = 0;
-
- while (size >= 1024 && unitIndex < units.length - 1) {
- size /= 1024;
- unitIndex++;
- }
-
- // 2 decimal places
- const formattedSize = Math.round(size * 100) / 100;
- return `${formattedSize}${space ? ' ' : ''}${units[unitIndex]}`;
-}
diff --git a/resources/js/composables/useMultiSelect.js b/resources/js/composables/useMultiSelect.js
index 78322fe7..730edc42 100644
--- a/resources/js/composables/useMultiSelect.js
+++ b/resources/js/composables/useMultiSelect.js
@@ -91,7 +91,7 @@ export default function useMultiSelect({ options, defaultItems }, refs) {
selectPositionUpdate() {
if (!this.selectButton || !this.selectableItemsList) return;
let selectDropdownBottomPos =
- this.selectButton.getBoundingClientRect().top +
+ this.selectButton?.getBoundingClientRect().top +
this.selectButton.offsetHeight +
parseInt(window.getComputedStyle(this.selectableItemsList).maxHeight);
if (window.innerHeight < selectDropdownBottomPos) {
diff --git a/resources/js/composables/useSelect.js b/resources/js/composables/useSelect.js
index 4ec95dea..dda7dcfc 100755
--- a/resources/js/composables/useSelect.js
+++ b/resources/js/composables/useSelect.js
@@ -87,7 +87,7 @@ export default function useSelect(options, refs) {
},
selectPositionUpdate() {
let selectDropdownBottomPos =
- this.selectButton.getBoundingClientRect().top +
+ this.selectButton?.getBoundingClientRect().top +
this.selectButton.offsetHeight +
parseInt(window.getComputedStyle(this.selectableItemsList).maxHeight);
if (window.innerHeight < selectDropdownBottomPos) {
diff --git a/resources/js/layouts/LayoutBase.vue b/resources/js/layouts/LayoutBase.vue
index fc3ed6ce..3534eb15 100755
--- a/resources/js/layouts/LayoutBase.vue
+++ b/resources/js/layouts/LayoutBase.vue
@@ -21,25 +21,25 @@ const scrollBody = ref(null);
<!-- overflow-y-hidden -->
<!-- class="flex p-6 gap-6 flex-wrap lg:flex-nowrap snap-y bg-primary-950 dark:bg-primary-dark-950 dark:text-[#e2e0e2] font-sans text-gray-900 antialiased" -->
<main
- class="grid grid-cols-1 lg:grid-cols-6 p-6 gap-6 snap-y bg-primary-950 dark:bg-primary-dark-950 dark:text-[#e2e0e2] font-sans text-gray-900 antialiased"
+ class="grid grid-cols-1 lg:grid-cols-6 p-6 gap-6 snap-y bg-primary-950 dark:bg-primary-dark-950 dark:text-[#e2e0e2] font-sans text-gray-900 antialiased overflow-x-clip"
>
<section
id="left-card"
- :class="`col-span-1 h-fit order-2 lg:order-1 bg-primary-900 dark:bg-primary-dark-900 dark:text-[#e2e0e2] shadow-xl rounded-2xl space-y-2 scroll-mt-6 z-20 ring-gray-900/5 ${selectedSideBar && sideBarTarget === 'left-card' ? 'ring-1' : 'invisible'}`"
+ :class="`col-span-1 h-fit order-2 lg:order-1 bg-primary-900 dark:bg-primary-dark-900 dark:text-[#e2e0e2] shadow-xl rounded-2xl space-y-2 scroll-mt-6 ring-gray-900/5 ${selectedSideBar && sideBarTarget === 'left-card' ? 'ring-1' : 'hidden lg:block lg:invisible'}`"
>
<slot name="leftSidebar"></slot>
</section>
<!-- class="bg-primary-900 dark:bg-primary-dark-900 dark:text-[#e2e0e2] shadow-xl p-6 pt-3 rounded-2xl w-full h-fit flex flex-col gap-3 z-20 ring-1 ring-gray-900/5" -->
<section
id="content-card"
- class="col-span-full lg:col-span-4 flex-grow order-1 lg:order-2 bg-primary-900 dark:bg-primary-dark-900 dark:text-[#e2e0e2] shadow-xl p-6 pt-3 rounded-2xl w-full h-fit flex flex-col gap-3 z-20 ring-1 ring-gray-900/5"
+ class="col-span-full lg:col-span-4 flex-grow order-1 lg:order-2 bg-primary-900 dark:bg-primary-dark-900 dark:text-[#e2e0e2] shadow-xl p-6 pt-3 rounded-2xl w-full h-fit flex flex-col gap-3 ring-1 ring-gray-900/5"
>
<NavBar class="z-20" />
<slot name="content" class="relative z-0"></slot>
</section>
<section
id="list-card"
- :class="`col-span-1 h-fit order-3 bg-primary-900 dark:bg-primary-dark-900 dark:text-[#e2e0e2] shadow-xl rounded-2xl space-y-2 scroll-mt-6 z-20 ring-1 ring-gray-900/5 ${selectedSideBar && sideBarTarget === 'list-card' ? 'ring-1' : 'hidden'}`"
+ :class="`col-span-1 h-fit order-3 bg-primary-900 dark:bg-primary-dark-900 dark:text-[#e2e0e2] shadow-xl rounded-2xl space-y-2 scroll-mt-6 ring-1 ring-gray-900/5 ${selectedSideBar && sideBarTarget === 'list-card' ? 'ring-1' : 'hidden'}`"
>
<!-- w-full h-fit lg:w-1/6 lg:max-w-72 sm:min-w-32 shrink-0 -->
<!-- class="bg-primary-900 dark:bg-primary-dark-900 dark:text-[#e2e0e2] shadow-xl p-3 rounded-2xl w-full h-fit lg:w-1/6 lg:max-w-72 sm:min-w-32 shrink-0 space-y-2 scroll-mt-6 z-20 ring-1 ring-gray-900/5" -->
diff --git a/resources/js/service/mediaAPI.ts b/resources/js/service/mediaAPI.ts
index 266b1388..2fa58c48 100644
--- a/resources/js/service/mediaAPI.ts
+++ b/resources/js/service/mediaAPI.ts
@@ -52,3 +52,7 @@ export default {
export function getCategories() {
return API.get(`/categories`);
}
+
+export function updateCategory(id: number, data: { default_folder_id: number }) {
+ return API.patch(`/categories/${id}`, data);
+}
diff --git a/resources/js/service/mutations.ts b/resources/js/service/mutations.ts
index eb544cfe..0f8cbd71 100644
--- a/resources/js/service/mutations.ts
+++ b/resources/js/service/mutations.ts
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
-import { useMutation, useQueryClient } from '@tanstack/vue-query';
+import { useMutation, useQueryClient, type UseMutationReturnType } from '@tanstack/vue-query';
import { API } from './api';
-import mediaAPI from './mediaAPI';
+import mediaAPI, { updateCategory } from './mediaAPI';
export const UseCreatePlayback = () => {
const queryClient = useQueryClient();
diff --git a/resources/js/service/queries.ts b/resources/js/service/queries.ts
index 729150a5..20a784b1 100644
--- a/resources/js/service/queries.ts
+++ b/resources/js/service/queries.ts
@@ -4,7 +4,8 @@ import type { Ref } from 'vue';
import { getSiteAnalytics, getPulse } from '@/service/siteAPI.ts';
import { useQuery } from '@tanstack/vue-query';
-import mediaAPI from '@/service/mediaAPI.ts';
+import mediaAPI, { getCategories } from '@/service/mediaAPI.ts';
+import type { CategoryResource } from '@/types/resources';
export const useGetVideoTags = () => {
return useQuery({
@@ -47,6 +48,16 @@ export const useGetSiteAnalytics = (period: Ref<string>) => {
});
};
+export const useGetCategories = () => {
+ return useQuery<{ data: CategoryResource[] }>({
+ queryKey: ['categories'],
+ queryFn: async () => {
+ const { data: response } = await getCategories();
+ return response;
+ },
+ });
+};
+
// export const useGetChatRoomMessagesQuery = (chat_id: number | null) => {
// return useInfiniteQuery({
// queryKey: ['chatroom-messages', chat_id],
diff --git a/resources/js/service/util.ts b/resources/js/service/util.ts
index e13fc3a4..60c9963a 100644
--- a/resources/js/service/util.ts
+++ b/resources/js/service/util.ts
@@ -100,3 +100,21 @@ export function getScreenSize(): 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'default' {
if (width >= 640) return 'sm';
return 'default';
}
+
+export function formatFileSize(size: number, space = true) {
+ if (isNaN(size) || size < 0) {
+ return 'Invalid size';
+ }
+
+ const units = ['B', 'KB', 'MB', 'GB', 'TB'];
+ let unitIndex = 0;
+
+ while (size >= 1024 && unitIndex < units.length - 1) {
+ size /= 1024;
+ unitIndex++;
+ }
+
+ // 2 decimal places
+ const formattedSize = Math.round(size * 100) / 100;
+ return `${formattedSize}${space ? ' ' : ''}${units[unitIndex]}`;
+}
diff --git a/resources/js/types/resources.ts b/resources/js/types/resources.ts
index 1e82f56d..3ac6dde0 100644
--- a/resources/js/types/resources.ts
+++ b/resources/js/types/resources.ts
@@ -3,8 +3,9 @@ import type { Category, Folder, Metadata, User } from './model';
export interface CategoryResource {
id: number;
name: string;
- folders_count: number;
folders: FolderResource[];
+ folders_count: number;
+ default_folder_id?: number;
created_at?: string;
last_scan: number;
}
diff --git a/resources/js/types/types.ts b/resources/js/types/types.ts
index ffd7405d..647fca2f 100644
--- a/resources/js/types/types.ts
+++ b/resources/js/types/types.ts
@@ -99,12 +99,6 @@ export interface PulseRquestsResponse {
[key: string]: { [key: string]: string | null };
}
-// queued: { [key: string]: string | null };
-// processing: { [key: string]: string | null };
-// processed: { [key: string]: string | null };
-// released: { [key: string]: string | null };
-// failed: { [key: string]: string | null };
-
export interface PulseUsageResponse {
key: number;
user: {
@@ -123,8 +117,12 @@ export interface SiteAnalyticsResponse {
prev: number;
}
-export interface ChartData {
- labels: string[];
+export interface FormField {
+ name: string;
+ text: string;
+ type?: 'text' | 'url' | 'textArea' | 'date' | 'number' | 'multi' | 'select';
+ value?: any;
+ subtext?: string;
+ default?: any;
+ class?: string;
}
-
-export interface ChartOptions {}
diff --git a/resources/js/views/DashboardView.vue b/resources/js/views/DashboardView.vue
index b1caadaa..66404647 100644
--- a/resources/js/views/DashboardView.vue
+++ b/resources/js/views/DashboardView.vue
@@ -9,23 +9,54 @@ import DashboardLibraries from '@/components/dashboard/DashboardLibraries.vue';
import SidebarCard from '@/components/cards/SidebarCard.vue';
import LayoutBase from '@/layouts/LayoutBase.vue';
-import LucideImages from '~icons/lucide/images';
import LucideChartNoAxesColumnIncreasing from '~icons/lucide/chart-no-axes-column-increasing';
-import CircumDatabase from '~icons/circum/database';
-import CircumServer from '~icons/circum/server';
-import ProiconsLibrary from '~icons/proicons/library';
-import ProiconsBookAdd2 from '~icons/proicons/book-add-2';
import ProiconsAddSquareMultiple from '~icons/proicons/add-square-multiple';
-import LucideUsers from '~icons/lucide/users';
+import ProiconsBookAdd2 from '~icons/proicons/book-add-2';
+import ProiconsLibrary from '~icons/proicons/library';
import ProiconsHistory from '~icons/proicons/history';
+import CircumDatabase from '~icons/circum/database';
import ProiconsGraph from '~icons/proicons/graph';
+import LucideImages from '~icons/lucide/images';
+import CircumServer from '~icons/circum/server';
+import LucideUsers from '~icons/lucide/users';
-const dashboardTabs: { name: string; title?: string; icon?: Component }[] = [
- { name: 'overview', title: 'Analytics', icon: ProiconsGraph },
- { name: 'libraries', icon: ProiconsLibrary },
- { name: 'activity', icon: ProiconsHistory },
- { name: 'users', icon: LucideUsers },
- { name: 'jobs', icon: CircumServer },
+const dashboardTabs: {
+ name: string;
+ title?: string;
+ description?: string;
+ info?: { value: string; icon?: Component };
+ icon?: Component;
+}[] = [
+ {
+ name: 'overview',
+ title: 'Analytics',
+ description: 'Website Overview',
+ icon: ProiconsGraph,
+ },
+ {
+ name: 'libraries',
+ description: '',
+ info: { value: 'Total Size: 60GB' },
+ icon: ProiconsLibrary,
+ },
+ {
+ name: 'activity',
+ description: '',
+ info: { value: 'Logged Events: 686' },
+ icon: ProiconsHistory,
+ },
+ {
+ name: 'users',
+ description: '',
+ info: { value: 'Logged In: 4' },
+ icon: LucideUsers,
+ },
+ {
+ name: 'jobs',
+ description: '',
+ info: { value: 'Currently Running: 2' },
+ icon: CircumServer,
+ },
];
const dashboardTab = ref<{ name: string; title?: string; icon?: any }>();
@@ -82,28 +113,19 @@ watch(
<template #header>
<h2 class="w-full flex-1" :title="tab.title ?? tab.name">{{ tab.title ?? tab.name }}</h2>
<component v-if="tab.icon" :is="tab.icon" class="ml-auto w-6 h-6" />
- <!-- <ButtonCorner
- :positionClasses="'w-7 h-7'"
- :textClasses="'hover:text-violet-600 dark:hover:text-violet-500'"
- :colourClasses="'dark:hover:bg-neutral-800 hover:bg-gray-300'"
- :label="'Share'"
- @click.stop.prevent="$emit('clickAction', link)"
- >
- <template #icon>
- <CircumShare1 width="20" height="20" />
- </template>
- </ButtonCorner> -->
- <!-- <ButtonCorner
- :positionClasses="'w-7 h-7'"
- :textClasses="`${true ? 'text-violet-600' : 'hover:text-violet-600'} dark:hover:text-violet-500`"
- :colourClasses="'dark:hover:bg-neutral-800 hover:bg-gray-300'"
- :to="''"
- :label="'Open Folder'"
- >
- <template #icon>
- <CircumFolderOn width="20" height="20" />
- </template>
- </ButtonCorner> -->
+ </template>
+ <template #body>
+ <h3
+ v-if="tab.description"
+ title="Description"
+ class="text-neutral-500 w-full text-wrap truncate sm:text-nowrap flex-1"
+ >
+ {{ tab.description }}
+ </h3>
+ <h3 v-if="tab.info" title="Information" class="truncate text-nowrap sm:text-right text-neutral-500 w-fit">
+ <!-- some other folder statistic or data like number of seasons or if its popular or something -->
+ {{ tab.info.value }}
+ </h3>
</template>
</SidebarCard>
</section>
diff --git a/routes/api.php b/routes/api.php
index 1cb2b71e..f4d83611 100755
--- a/routes/api.php
+++ b/routes/api.php
@@ -31,7 +31,7 @@ Route::group(['middleware' => ['auth:sanctum']], function () {
Route::resource('/metadata', MetadataController::class)->only(['show', 'store', 'update']);
Route::resource('/tags', TagController::class)->only(['index', 'store']);
Route::resource('/analytics', AnalyticsController::class)->only(['index']);
- Route::resource('/categories', CategoryController::class)->only(['index']);
+ Route::resource('/categories', CategoryController::class)->only(['index', 'update']);
});
Route::prefix('pulse')->group(function () {
@@ -41,8 +41,8 @@ Route::prefix('pulse')->group(function () {
// public
-Route::post('/login', [AuthController::class, 'login']); // Deprecate
-Route::post('/register', [AuthController::class, 'register']); // Deprecate
+Route::post('/login', [AuthController::class, 'login']); // Deprecate?
+Route::post('/register', [AuthController::class, 'register']); // Deprecate?
Route::patch('/videos/watch/{video}', [VideoController::class, 'watch']);
Route::get('/folders', [FolderController::class, 'getFrom']);
Route::get('/videos', [VideoController::class, 'getFrom']);
diff --git a/tailwind.config.js b/tailwind.config.js
index d02e7264..0e9ac3f8 100755
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -1,6 +1,5 @@
import defaultTheme from 'tailwindcss/defaultTheme';
-
const plugin = require('tailwindcss/plugin');
/** @type {import('tailwindcss').Config} */
@@ -75,7 +74,7 @@ export default {
},
screens: {
xs: '320px',
- '3xl': '1600px',
+ '3xl': '2000px',
},
},
},
@@ -91,11 +90,11 @@ export default {
plugin(function ({ addVariant }) {
addVariant('hocus', ['&:hover', '&:focus']);
}),
-
+
require('@tailwindcss/forms'),
-
+
require('@tailwindcss/aspect-ratio'),
-
+
require('tailwind-scrollbar-hide'),
],
};