Implements first stage library management system

This commit is contained in:
BinaryAlley committed 2024-11-03 19:43:46 +02:00
1 parent 5e0f94cd82
commit 36352ea9e8
291 files changed
+3733 -1384

No files matched your search

@@ -0,0 +1,130 @@
@*
/library/manage/item/{id:guid}
*@
@using Lumina.Presentation.Web.Common.Models.Libraries
@{
var id = Context.Request.RouteValues["id"] as string;
}
@model LibraryModel
@await Component.InvokeAsync("FileSystemBrowser")
<div class="enlightenment-panel shadow-effect p-2 mx-auto panel w-50 mb-10" style="min-width: 320px; margin-top: 1rem;">
<div class="shine-effect"></div>
<form asp-controller="LibraryManagement" asp-action="EditLibrary" method="post" id="add-media-library-form">
@Html.AntiForgeryToken()
<input type="hidden" asp-for="Id" value="@id" />
<div class="form-row">
<h1 class="text-light-two w-100 text-center pt-0 pb-0 engraved-title">@(id is not null ? "Edit" : "Add New") Library</h1>
</div>
<div class="form-container">
<h3 class="text-light-two">General Information</h3>
<!-- Title -->
<div class="form-row">
<div class="form-label">
<label asp-for="Title">Title</label>
<span class="mandatory-field">*</span>:
</div>
<div class="form-field">
<input asp-for="Title" class="enlightenment-input" />
</div>
<small class="form-label text-disabled form-description">DescriptionTitle</small>
</div>
<!-- Library Type -->
<div class="form-row">
<div class="form-label">
<label asp-for="LibraryType">Library Type</label>
<span class="mandatory-field">*</span>:
</div>
<div class="form-field">
<div class="enlightenment-combobox inline-block w-100">
<div class="shine-effect" style="top: 1px;"></div>
<input type="checkbox" class="enlightenment-toggle-checkbox" id="library-type" />
<label class="enlightenment-toggle" for="library-type">
<span class="enlightenment-selected-text">@Model.LibraryType</span>
</label>
<div class="enlightenment-dropdown">
<div class="shine-effect" style="top: -4px;"></div>
<!-- Dropdown options remain the same -->
<div class="enlightenment-option first-option disabled">Book</div>
<div class="enlightenment-option" data-value="Book">Book</div>
<!-- ... rest of the options ... -->
</div>
</div>
</div>
<small class="form-label text-disabled form-description">DescriptionLibraryType</small>
</div>
<!-- Directories -->
<div class="form-row mt-10">
<div class="form-label">
<label asp-for="Paths">Directories</label>
<span class="mandatory-field">*</span>:
<img src="~/images/ui/add-directory.svg" alt="Add directory" id="add-media-directory" title="Add directory" class="add-form-table-row-icon ml-5" />
</div>
</div>
<div class="form-row">
<div class="form-table w-100">
@for (int i = 0; i < Model.Paths.Count; i++)
{
<div class="form-table-row">
<span title="@Model.Paths[i]">@Model.Paths[i]</span>
<img src="~/images/ui/delete.svg" alt="Remove" title="Remove" class="remove-form-table-row-icon" />
</div>
}
</div>
<small class="form-label text-disabled form-description">DescriptionDirectories</small>
</div>
<div class="form-row">
<button type="submit" class="confirm-button w-100px">Save</button>
</div>
</div>
</form>
</div>
@section Scripts {
<script type="text/javascript" defer>
document.getElementById('add-media-directory').addEventListener('click', function () {
showFileSystemBrowserDialogAsync('C:\\Users\\', true, false, addNewPaths); // TODO: take path and include hidden elements from settings
});
function addNewPaths(selectedPaths) {
// get the form table where the new paths will be added
const formTable = document.querySelector('.form-table');
// process the selected paths
const paths = selectedPaths.slice(1, -1).split('","');
// add each path as a new row
paths.forEach(path => {
// check if path already exists
const existingPath = formTable.querySelector(`span[title="${path}"]`);
if (!existingPath) {
formTable.insertAdjacentHTML('beforeend', `
<div class="form-table-row">
<span title="${path}">${path}</span>
<img src="/images/ui/delete.svg" alt="Remove" title="Remove" class="remove-form-table-row-icon" onclick="this.closest('.form-table-row').remove();" />
</div>
`);
}
});
}
document.getElementById('add-media-library-form').addEventListener('submit', async (event) => {
event.preventDefault();
const form = event.target;
const formData = {
Id: form.querySelector('[name="Id"]').value || null,
Title: form.querySelector('[name="Title"]').value,
LibraryType: form.querySelector('.enlightenment-selected-text').textContent,
Paths: Array.from(form.querySelectorAll('.form-table-row span'))
.map(span => span.textContent)
};
const result = await callApiPostAsync('/library/manage/item', formData);
if (result) {
// Optional: Handle successful response
// For example, redirect after success
// window.location.href = '/library/manage';
}
});
</script>
}
@@ -1 +1,2 @@
<p>All books</p><a href="books/E6B599D6-3819-4FAB-B988-8F027072CF7B" class="nav-link">one</a>
@@ -5,14 +5,10 @@
@using Lumina.Presentation.Web.Common.Exceptions
@using Lumina.Presentation.Web.Common.Models.FileSystemManagement
@using Lumina.Presentation.Web.Common.Models.UI
@using Lumina.Presentation.Web.Common.Services
@using Microsoft.AspNetCore.Components
@using System.Text.Json
@using System.Text
@inject IApiHttpClient _apiHttpClient
@inject INotificationService _notificationService
<div id="file-system-browser-dialog" class="container-background above-modal">
<div id="file-system-browser-content">
<div id="file-system-browser-header">
@@ -309,9 +305,9 @@
<div id="navigator-navigation-controls-container">
<!--Navigation-->
<div id="navigator-history">
<img src="images/ui/back.svg" id="navigator-navigate-back" class="navigation-icon" alt="Back" title="Back" />
<img src="images/ui/forward.svg" id="navigator-navigate-forward" class="navigation-icon" alt="Forward" title="Forward" />
<img src="images/ui/up.svg" id="navigator-navigate-up" class="navigation-icon" alt="Up One Level" title="Up One Level" />
<img src="~/images/ui/back.svg" id="navigator-navigate-back" class="navigation-icon" alt="Back" title="Back" />
<img src="~/images/ui/forward.svg" id="navigator-navigate-forward" class="navigation-icon" alt="Forward" title="Forward" />
<img src="~/images/ui/up.svg" id="navigator-navigate-up" class="navigation-icon" alt="Up One Level" title="Up One Level" />
</div>
<!--Toggle Tree View-->
<svg id="navigator-toggle-tree-view-button" class="navigator-icon" width="30" height="30" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xlink="http://www.w3.org/1999/xlink">
@@ -469,16 +465,16 @@
</div>
</div>
<button id="navigator-edit-path-button" class="navigator-edit-path-button abort-button f-16" style="height:28px; width:35px;">
<img src="images/ui/edit.svg" id="navigator-edit-icon" alt="Edit Path" title="Edit Path" />
<img src="~/images/ui/edit.svg" id="navigator-edit-icon" alt="Edit Path" title="Edit Path" />
</button>
<button id="navigator-navigate-button" class="navigator-navigate-button confirm-button f-16" style="height:28px; width:35px;">
<img src="images/ui/check.svg" id="navigator-navigate-icon" alt="Navigate" title="Navigate" />
<img src="~/images/ui/check.svg" id="navigator-navigate-icon" alt="Navigate" title="Navigate" />
</button>
<button class="file-system-browser-content-new-directory abort-button f-16" style="height:28px; width:35px;">
<img src="images/ui/new-directory.svg" id="navigator-new-directory-icon" alt="New Directory" title="New Directory" />
<img src="~/images/ui/new-directory.svg" id="navigator-new-directory-icon" alt="New Directory" title="New Directory" />
</button>
<button class="file-system-browser-content-favorite-directory abort-button f-16" style="height:28px; width:35px;">
<img src="images/ui/favorite-star.svg" class="navigation-icon favorite-unselected" alt="Favorite directory" title="Favorite directory" />
<img src="~/images/ui/favorite-star.svg" class="navigation-icon favorite-unselected" alt="Favorite directory" title="Favorite directory" />
</button>
</div>
<!--End File System Navigator-->
@@ -23,9 +23,10 @@
<main role="main">
<article>
@RenderBody()
<div id="modal-background-article"></div>
</article>
</main>
<!--Audio player-->
<!--Audio player-->
<div class="audio-player-container">
<video controls
preload="auto"
@@ -37,7 +38,7 @@
</div>
</div>
<!--Modal grid background-->
<div id="modal-background"></div>
<div id="modal-background-menu"></div>
<script defer src="~/js/notifications.js" asp-append-version="true"></script>
<script defer src="~/js/site.js" asp-append-version="true"></script>
@@ -1,48 +0,0 @@
/* Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */
a.navbar-brand {
white-space: normal;
text-align: center;
word-break: break-all;
}
a {
color: #0077cc;
}
.btn-primary {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.border-top {
border-top: 1px solid #e5e5e5;
}
.border-bottom {
border-bottom: 1px solid #e5e5e5;
}
.box-shadow {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}
button.accept-policy {
font-size: 1rem;
line-height: inherit;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px;
}