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

@@ -3,7 +3,6 @@ using FluentValidation;
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.Exceptions;
using Lumina.Presentation.Web.Common.Filters;
using Lumina.Presentation.Web.Common.Services;
using Microsoft.Extensions.DependencyInjection;
using Polly;
using Polly.CircuitBreaker;
@@ -62,7 +61,6 @@ public static class PresentationWebLayerServices
.AddPolicyHandler(retryPolicy)
.AddPolicyHandler(circuitBreakerPolicy);
services.AddScoped<INotificationService, NotificationService>();
services.AddScoped<ApiExceptionFilter>();
return services;
@@ -1,9 +1,9 @@
namespace Lumina.Presentation.Web.Common.Enums.BookLibrary;
namespace Lumina.Presentation.Web.Common.Enums.BookLibrary;
/// <summary>
/// Enumeration for the types of written content libraries.
/// </summary>
public enum WrittenContentType
public enum WrittenContentType // TODO: to be removed?
{
/// <summary>
/// A printed or written literary work.
@@ -35,6 +35,11 @@ public enum WrittenContentType
/// </summary>
Magazine,
/// <summary>
/// Periodical publication containing news.
/// </summary>
Newspaper,
/// <summary>
/// A style of Japanese comic books and graphic novels.
/// </summary>
@@ -59,4 +64,4 @@ public enum WrittenContentType
/// A script for a film, television program, or other visual media.
/// </summary>
Screenplay,
}
}
@@ -1,4 +1,4 @@
namespace Lumina.Presentation.Web.Common.Enums.Library;
namespace Lumina.Presentation.Web.Common.Enums.Library;
/// <summary>
/// Enumeration for the types of libraries.
@@ -6,27 +6,182 @@
public enum LibraryType
{
/// <summary>
/// Content that is written, such as books, articles, or other written works.
/// Traditional printed books in physical format.
/// </summary>
WrittenContent,
Book,
/// <summary>
/// Content that is video, such as movies, TV shows, or other video works.
/// Digital books in electronic format (e.g., PDF, EPUB, MOBI).
/// </summary>
VideoContent,
EBook,
/// <summary>
/// Content that is audio, such as podcasts, radio shows, or other audio works.
/// Comic books in digital or physical format.
/// </summary>
AudioContent,
ComicBook,
/// <summary>
/// Content that is visual, such as images, paintings, or other visual works.
/// Periodical publications containing articles and illustrations.
/// </summary>
VisualContent,
Magazine,
/// <summary>
/// Content that is miscellaneous, such as lyrics, movie posters, or other miscellaneous works.
/// Periodical publication containing news.
/// </summary>
MiscellaneousContent,
}
Newspaper,
/// <summary>
/// Japanese-style comics and graphic novels.
/// </summary>
Manga,
/// <summary>
/// Extended comic-format narratives, typically containing a complete story.
/// </summary>
GraphicNovel,
/// <summary>
/// Scholarly articles and research papers.
/// </summary>
AcademicPaper,
/// <summary>
/// Musical notation and scores.
/// </summary>
SheetMusic,
/// <summary>
/// Television series and episodic content.
/// </summary>
TvShow,
/// <summary>
/// Feature-length films and motion pictures.
/// </summary>
Movie,
/// <summary>
/// Non-fiction films presenting factual information.
/// </summary>
Documentary,
/// <summary>
/// Japanese animation series and films.
/// </summary>
Anime,
/// <summary>
/// Recorded live music performances and concerts.
/// </summary>
ConcertVideo,
/// <summary>
/// Educational and instructional videos.
/// </summary>
TutorialVideo,
/// <summary>
/// Personally recorded videos and family footage.
/// </summary>
HomeVideo,
/// <summary>
/// Videos sourced from YouTube platform.
/// </summary>
YouTubeVideo,
/// <summary>
/// Professional or amateur music video productions.
/// </summary>
MusicVideo,
/// <summary>
/// Videos recorded during live performances or events.
/// </summary>
LiveRecordingVideo,
/// <summary>
/// Recorded conversations and Q&A sessions in video format.
/// </summary>
InterviewVideo,
/// <summary>
/// Videos of musical performances covering other artists' work.
/// </summary>
CoverSongVideo,
/// <summary>
/// Video format podcasts and episodic content.
/// </summary>
PodcastVideo,
/// <summary>
/// Audio recordings of musical content.
/// </summary>
Music,
/// <summary>
/// Narrated books in audio format.
/// </summary>
Audiobook,
/// <summary>
/// Audio recordings from live performances or events.
/// </summary>
LiveRecordingAudio,
/// <summary>
/// Recorded conversations and Q&A sessions in audio format.
/// </summary>
InterviewAudio,
/// <summary>
/// Audio recordings of musical performances covering other artists' work.
/// </summary>
CoverSongAudio,
/// <summary>
/// Modified or reinterpreted versions of original musical recordings.
/// </summary>
Remix,
/// <summary>
/// Audio clips used for sound design and production.
/// </summary>
SoundEffect,
/// <summary>
/// Audio format podcasts and episodic content.
/// </summary>
PodcastAudio,
/// <summary>
/// Digital images and photographs.
/// </summary>
Photo,
/// <summary>
/// Curated sequences of media items.
/// </summary>
Playlist,
/// <summary>
/// Grouped sets of related media items.
/// </summary>
Collection,
/// <summary>
/// Text files containing dialogue translations for video content.
/// </summary>
Subtitles,
/// <summary>
/// Text files containing words and timing for musical content.
/// </summary>
Lyrics,
/// <summary>
/// A collection of media that does not fit into any other category.
/// </summary>
Other
}
@@ -0,0 +1,16 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Models.Common;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Represents a book.
/// </summary>
[DebuggerDisplay("{Title}")]
public class BooksModel
{
}
@@ -0,0 +1,33 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Represents a preview of important properties of a book.
/// </summary>
[DebuggerDisplay("{Title}")]
public class LightBookModel
{
/// <summary>
/// Gets the Id of the media item.
/// </summary>
public required Guid Id { get; init; }
/// <summary>
/// Gets the title of the media item.
/// </summary>
public required string Title { get; init; }
/// <summary>
/// Gets the optional release year (either re-release year, if available, or original release year, if known) of the media item.
/// </summary>
public int? ReleaseYear { get; init; }
/// <summary>
/// Gets the optional path of the image representing the cover of this book.
/// </summary>
public string? CoverPath { get; init; }
}
@@ -1,22 +0,0 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Notifications;
using Lumina.Presentation.Web.Common.Models.Common;
using System;
#endregion
namespace Lumina.Presentation.Web.Common.Services;
/// <summary>
/// Interface for the service for showing notifications.
/// </summary>
public interface INotificationService
{
event Action<NotificationModel>? OnNotification;
/// <summary>
/// Shows a notification.
/// </summary>
/// <param name="message">The message of the notification.</param>
/// <param name="type">The type of the notification.</param>
void Show(string message, NotificationType type);
}
@@ -1,25 +0,0 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Notifications;
using Lumina.Presentation.Web.Common.Models.Common;
using System;
#endregion
namespace Lumina.Presentation.Web.Common.Services;
/// <summary>
/// Service for showing notifications.
/// </summary>
public class NotificationService : INotificationService
{
public event Action<NotificationModel>? OnNotification;
/// <summary>
/// Shows a notification.
/// </summary>
/// <param name="message">The message of the notification.</param>
/// <param name="type">The type of the notification.</param>
public void Show(string message, NotificationType type)
{
OnNotification?.Invoke(new NotificationModel { Message = message, Type = type, Id = Guid.NewGuid() });
}
}
@@ -0,0 +1,50 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.Enums.Library;
using Lumina.Presentation.Web.Common.Models.Libraries;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Formatters;
using System;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Web.Controllers.Library.Management;
[Route("/library/manage/")]
public class LibraryManagementController : Controller
{
private readonly IApiHttpClient _apiHttpClient;
public LibraryManagementController(IApiHttpClient apiHttpClient)
{
_apiHttpClient = apiHttpClient;
}
[HttpGet("")]
public IActionResult Index()
{
return View("/Views/Library/Management/Index.cshtml");
}
[HttpGet("item/{id?}")]
public IActionResult EditLibrary(Guid? id = null)
{
LibraryModel libraryModel = new()
{
Id = id,
LibraryType = LibraryType.Book,
Paths = ["a", "b", "c"],
Title = ""
};
return View("/Views/Library/Management/Item.cshtml", libraryModel);
}
[HttpPost("item")]
public async Task<IActionResult> SaveLibraryAsync([FromBody] LibraryModel model)
{
LibraryModel response = model.Id.HasValue
? await _apiHttpClient.PutAsync<LibraryModel, LibraryModel>($"libraries/{model.Id}", model)
: await _apiHttpClient.PostAsync<LibraryModel, LibraryModel>("libraries", model);
return Json(new { success = true });
}
}
@@ -0,0 +1,5 @@
namespace Lumina.Presentation.Web.Renderers.Library.WrittenContentLibrary.BookLibrary.Books;
public class BooksTemplateRenderer
{
}
@@ -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;
}
@@ -10,6 +10,16 @@
display: none;
}
.enlightenment-toggle-checkbox:checked + .enlightenment-toggle + .enlightenment-dropdown {
display: block;
}
.enlightenment-toggle-checkbox:checked + .enlightenment-toggle .enlightenment-arrow {
background-size: 9px 11px;
background-position: 3px -2px;
transform: rotate(90deg);
}
.enlightenment-toggle {
display: flex;
align-items: center;
@@ -44,6 +54,21 @@
background-size: 12px 6px, 3px auto, 100%;
}
.enlightenment-arrow {
display: inline-block;
width: 12px;
height: 9px;
background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%22545%20-32.5%2027.5%2065%22%3E%3Cpath%20fill%3D%22%23FFF%22%20d%3D%22M568.254,-7.43524%20568.159,-7.34277%20567.977,-7.52246%20546.559,-28.9417%20525.484,-28.9417%20549.787,-4.63446%20557.439,3.01532%20557.619,3.19629%20550.067,10.7549%20525.758,35.0583%20546.834,35.0583%20568.254,13.6429%20578.792,3.10254%20568.254,-7.43524z%22%2F%3E%3C%2Fsvg%3E');
background-size: 10px 9px;
background-repeat: no-repeat;
background-position: 3px -0px;
transition: transform 0.3s ease;
}
.enlightenment-toggle-checkbox:checked + .enlightenment-toggle .enlightenment-arrow {
transform: rotate(90deg);
}
.enlightenment-selected-text {
flex: 1;
text-align: right;
@@ -66,15 +91,9 @@
border-right: #202020 1px solid;
padding: 3px;
z-index: 999;
max-height: none;
overflow-y: auto;
}
.enlightenment-dropdown > .shine-effect:first-child {
top: -4px;
}
.enlightenment-item {
.enlightenment-option {
display: block;
border-left: 1px solid #232323;
border-right: 1px solid #777777;
@@ -88,32 +107,30 @@
cursor: pointer;
}
.enlightenment-item.first-item {
.enlightenment-option.first-option {
border-top: 1px solid #232323;
margin-top: -1px;
}
.enlightenment-item.last-item {
.enlightenment-option.last-option {
border-bottom: 1px solid #777777;
}
.enlightenment-item.disabled {
color: #AAAAAA;
.enlightenment-option.disabled {
color: #AAAAAA; /* Gray color */
}
.enlightenment-item:hover {
.enlightenment-option:hover {
background-image: none;
background: linear-gradient(to bottom, #505050, #464646, #404040, #363636);
color: #1D8AF9;
box-shadow: inset 1px 0 0 0 #777777, inset -1px 0 0 0 #232323, inset 0 1px 0 0 #989898, inset 0 -1px 0 0 #151515;
box-shadow: inset 1px 0 0 0 #777777, /* left */
inset -1px 0 0 0 #232323, /* right */
inset 0 1px 0 0 #989898, /* top */
inset 0 -1px 0 0 #151515; /* bottom */
}
.enlightenment-combobox.open .enlightenment-dropdown {
display: block;
}
.enlightenment-combobox > .shine-effect:first-child {
top: 1px;
opacity: 0;
transition: opacity 0.5s;
}
@@ -1,6 +1,6 @@
#file-system-browser-dialog {
display: none;
position: absolute;
position: fixed;
top: 12.5%;
bottom: 12.5%;
left: 8%;
@@ -893,10 +893,6 @@ div[id^="file-system-browser-file-system-explorer"]:not([id*="container"]) {
overflow-y: auto;
}
.navigator-dropdown.opened {
display: block;
}
.navigator-option {
display: block;
border-left: 1px solid #232323;
@@ -923,7 +919,7 @@ div[id^="file-system-browser-file-system-explorer"]:not([id*="container"]) {
}
.navigator-option.disabled {
color: #AAAAAA; /* Gray color */
color: #AAAAAA;
}
.navigator-option:hover {
@@ -1013,8 +1009,8 @@ div[id^="file-system-browser-file-system-explorer"]:not([id*="container"]) {
@media screen and (max-width: 768px) {
#file-system-browser-dialog {
top: 0;
bottom: 0;
top: 65px;
bottom: 50px;
left: 0;
right: 0;
}
@@ -29,7 +29,7 @@
width: 46px;
height: 46px;
display: none;
z-index: 2;
z-index: 999;
padding: 5px 0;
margin: 0px;
font-family: 'Cabin', Sans-serif;
@@ -185,6 +185,7 @@
position: fixed;
top: 0px;
left: 0px;
max-height: 22px;
width: 100%;
z-index: 900;
}
@@ -21,7 +21,7 @@
border-right: 1px solid #000 !important;
border-bottom: 1px solid #000 !important;
box-shadow: 5px 5px 5px var(--shadow-color);
animation: fadeIn 0.3s, fadeOut 0.3s 4.7s;
animation: fadeIn 0.3s, fadeOut 0.3s 9.7s; /* animation for notifications fade out effect */
flex-direction: column;
flex-wrap: nowrap;
align-items: stretch;
@@ -60,7 +60,7 @@
flex-shrink: 0; /* prevent button from shrinking */
}
.shine-effect {
.notification-shine-effect {
background: linear-gradient(to right, transparent, #fff, transparent);
width: 100%;
top: -1px;
@@ -7,7 +7,10 @@
--border-color-dark: #000000;
--border-color-dialog: #1E90FF;
--shadow-color: #000000;
--highlight-color: #383838AA;
--text-foreground: #6DCBFE;
--light-row-background: #28292B;
--dark-row-background: #191E21;
}
html,
@@ -45,9 +48,9 @@ body {
background-color: #222;
min-width: 100%;
min-height: 100%;
height: 100%;
height: 100%;
position: relative;
display: flex;
display: flex;
flex-direction: column;
}
@@ -65,7 +68,7 @@ main {
}
main.audio-player-full-height {
bottom: calc(100% - 20px); /* full height minus menu height */
bottom: calc(100% - 22px); /* full height minus menu height */
}
.audio-player-container {
@@ -76,15 +79,27 @@ main {
transition: height 1s ease;
}
.audio-player-container.not-shown {
.audio-player-container.not-shown {
height: 0px;
}
.audio-player-container.full-height {
height: calc(100% - 20px); /* full height minus menu height */
height: calc(100% - 22px); /* full height minus menu height */
}
#modal-background {
#modal-background-menu {
display: none;
z-index: 998;
position: absolute;
top: 0px;
left: 0px;
min-width: 100%;
min-height: 22px;
background-color: #000000;
opacity: 0.6;
}
#modal-background-article {
display: none;
z-index: 998;
position: absolute;
@@ -171,6 +186,135 @@ main {
.no-underline {
text-decoration: none;
}
.form-container {
display: flex;
flex-direction: column;
gap: 0.2rem;
}
.form-row {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
align-items: center;
gap: 0.5rem;
}
.form-row-align-start {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
align-items: center;
gap: 0.5rem;
}
.form-label {
flex: 2 0 27%;
min-width: 200px;
display: flex;
align-items: center;
}
.form-field {
flex: 0 0 70%;
min-width: 0;
}
.form-field input[type="text"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field input[type="datetime"],
.form-field input[type="datetime-local"],
.form-field textarea,
.form-field input[type="password"] {
width: 100%;
}
.form-table {
max-height: 150px;
overflow-y: auto;
}
.form-table > div:nth-child(even) {
background-color: var(--dark-row-background);
}
.form-table > div:nth-child(odd) {
background-color: var(--light-row-background);
}
.form-description {
margin-left: 25px;
}
/*
.text-center {
display: flex;
justify-content: center;
width: 100%;
}
*/
.invalid-feedback {
flex: 0 0 100%;
}
.mandatory-field {
color: red;
}
.engraved-title {
margin: 0px;
font-size: 3rem;
background-color: var(--shadow-color);
background-clip: text;
-webkit-background-clip: text;
color: transparent;
text-shadow: var(--highlight-color) 2px 2px 2px;
}
.engraved-panel {
background-color: #00000033;
border-radius: 5px;
min-height: 70px;
padding: 10px;
-webkit-box-shadow: 0 0 7px 0px var(--shadow-color) inset;
-moz-box-shadow: 0 0 7px 0px var(--shadow-color) inset;
box-shadow: 0 0 7px 0px var(--shadow-color) inset;
flex: 0 0 70%;
}
.form-table-row {
padding: 3px 8px;
gap: 8px;
width: 100%;
display: flex;
align-items: center;
/*justify-content: space-between;*/
border-top: 1px solid var(--border-color-light);
border-left: 1px solid var(--border-color-light);
border-bottom: 1px solid var(--border-color-dark);
border-right: 1px solid var(--border-color-dark);
}
.form-table-row span {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
flex: 1;
min-width: 0;
}
.remove-form-table-row-icon {
width: 15px;
flex-shrink: 0;
cursor: pointer;
}
.add-form-table-row-icon {
width: 15px;
cursor: pointer;
}
/* Margins */
.mt-0 {
margin-top: 0px;
@@ -1281,5 +1425,4 @@ main {
/* For desktop: */
@media only screen and (min-width: 768px) {
}
@@ -52,5 +52,5 @@
}
textarea {
resize: none;
resize: vertical;
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg fill="#4AA747" width="800px" height="800px" viewBox="0 0 1920 1920" xmlns="http://www.w3.org/2000/svg">
<path d="m764.386 112.941 225.882 338.824H225.882v112.94H1920v1072.942c0 93.402-76.01 169.412-169.412 169.412H169.412C76.009 1807.059 0 1731.049 0 1637.647V112.941h764.386ZM1040 858.846H880v240H640v160h240v240h160v-240h240v-160h-240v-240Z" fill-rule="evenodd"/>
</svg>

After

Width:  |  Height:  |  Size: 501 B

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg fill="#4AA747" width="800px" height="800px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M5.755,20.283,4,8H20L18.245,20.283A2,2,0,0,1,16.265,22H7.735A2,2,0,0,1,5.755,20.283ZM21,4H16V3a1,1,0,0,0-1-1H9A1,1,0,0,0,8,3V4H3A1,1,0,0,0,3,6H21a1,1,0,0,0,0-2Z"/></svg>

After

Width:  |  Height:  |  Size: 402 B

@@ -7,6 +7,8 @@ const modalBackgroundArticle = document.getElementById('modal-background-article
const fileSystemBrowserDialog = document.getElementById('file-system-browser-dialog');
const fileSystemBrowserTreeview = document.getElementById('file-system-browser-treeview');
const pathSegmentsContainer = document.getElementById('navigator-path-segments');
const article = document.querySelector('article');
const menubar = document.getElementsByClassName('menubar')[0];
const fileSystemTreeViewContainer = document.getElementById('file-system-browser-file-system-treeview-container');
const fileSystemExplorerContainer = document.getElementById('file-system-browser-file-system-explorer-container');
@@ -47,6 +49,7 @@ const btnExtraLargeIconsView = document.getElementById('navigator-extra-large-ic
const btnFileSystemBrowserEditPath = document.getElementById('navigator-edit-path-button');
const btnFileSystemBrowserSubmitPath = document.getElementById('navigator-navigate-button');
const btnFileSystemBrowserConfirm = document.getElementById('file-system-browser-confirm-button');
const btnFileSystemBrowserCancel = document.getElementById('file-system-browser-cancel-button');
const selectedFileSystemElementsInput = document.getElementById('file-system-browser-selected-element');
@@ -178,15 +181,12 @@ async function initFileSystemBrowser(serverBasePathValue, clientBasePathValue, i
addHorizontalScrolling(addressBar);
//switchViewMode('list', null, true);
switchViewMode(viewModeValue, viewModeValue === 'list' ? null : iconSizeValue, true);
// TODO: to be removed:
//showFileSystemBrowserDialogAsync(initialPath, true);
}
/**
* Shows the file system browser dialog.
*/
async function showFileSystemBrowserDialogAsync(path, showHiddenElementsValue, includeFilesValue) {
async function showFileSystemBrowserDialogAsync(path, showHiddenElementsValue, includeFilesValue, onConfirmCallback) {
if (path !== undefined && path !== null) {
showHiddenElements = showHiddenElementsValue;
includeFiles = includeFilesValue;
@@ -200,6 +200,15 @@ async function showFileSystemBrowserDialogAsync(path, showHiddenElementsValue, i
await toggleFileSystemTreeViewAsync(false);
await toggleShowFileSystemElementsThumbnailsAsync(false);
await navigateToPathAsync(path, false, false);
// add click handler for confirm button
btnFileSystemBrowserConfirm.onclick = function () {
const selectedPaths = selectedFileSystemElementsInput.value;
if (onConfirmCallback && typeof onConfirmCallback === 'function')
onConfirmCallback(selectedPaths);
// hide dialog
hideFileSystemBrowserDialog();
};
btnFileSystemBrowserCancel.onclick = hideFileSystemBrowserDialog;
} else
notificationService.Show("Path cannot be null!", NotificationType.ERROR); // TODO: should ask error message from server when translation is implemented
}
@@ -208,9 +217,9 @@ async function showFileSystemBrowserDialogAsync(path, showHiddenElementsValue, i
* Hides the file system browser dialog.
*/
function hideFileSystemBrowserDialog() {
modalBackgroundMenu.style.display = 'block';
modalBackgroundArticle.style.display = 'block';
fileSystemBrowserDialog.style.display = 'block';
modalBackgroundMenu.style.display = 'none';
modalBackgroundArticle.style.display = 'none';
fileSystemBrowserDialog.style.display = 'none';
}
/**
@@ -724,21 +733,15 @@ async function fetchFileSystemFilesAsync(path, callback) {
* @param {string} itemType - Type of item being processed ('File' or 'Directory').
*/
async function fetchJsonDataAsync(url, callback, itemType) {
// initiate the fetch request from the API
const response = await fetch(url);
// parse the JSON response
const result = await response.json();
// verify the response was successful
if (!result.success)
throw new Error('Failed to fetch data from server');
// process each item in the response.data array
for (let item of result.data) {
// manually specify the type to the parsed object
item.itemType = itemType;
// call the provided callback function with the processed item
callback(item);
const response = await callApiGetAsync(url);
if (response !== undefined) {
// process each item in the response.data array
for (let item of response) {
// manually specify the type to the parsed object
item.itemType = itemType;
// call the provided callback function with the processed item
callback(item);
}
}
}
@@ -1079,16 +1082,16 @@ function startSelection(e) {
document.body.style.overflowY = 'hidden'; // needed in order to not put a vertical scrollbar on the document, while in vertical layout selection
document.documentElement.style.overflowY = 'hidden';
selectionStartPosition.x = e.pageX + fileSystemExplorer.scrollLeft;
selectionStartPosition.y = e.pageY + fileSystemExplorerContainer.scrollTop; // not a mistake - in vertical mode, this is the overflow container!
selectionStartPosition.y = (e.pageY - parseInt(window.getComputedStyle(menubar).height)) + fileSystemExplorerContainer.scrollTop; // not a mistake - in vertical mode, this is the overflow container!
// place the selection rectangle at the clicked location (relative to the whole page, and taking into account scroll offset), with 0 size
visibleSelectionRectangle.style.left = e.pageX + 'px';
visibleSelectionRectangle.style.top = e.pageY + 'px';
visibleSelectionRectangle.style.top = (e.pageY - parseInt(window.getComputedStyle(menubar).height)) + 'px';
visibleSelectionRectangle.style.width = '0px';
visibleSelectionRectangle.style.height = '0px';
visibleSelectionRectangle.style.visibility = 'visible';
selectionRectangle.style.left = e.pageX + 'px';
selectionRectangle.style.top = e.pageY + 'px';
selectionRectangle.style.top = (e.pageY - parseInt(window.getComputedStyle(menubar).height)) + 'px';
selectionRectangle.style.width = '0px';
selectionRectangle.style.height = '0px';
}
@@ -1101,7 +1104,7 @@ function updateSelection(e) {
if (!isSelecting)
return;
currentMousePosition.x = e.pageX;
currentMousePosition.y = e.pageY;
currentMousePosition.y = e.pageY - parseInt(window.getComputedStyle(menubar).height);
handleSelection();
}
@@ -1192,10 +1195,10 @@ function handleSelection() {
if (right > containerRect.right)
visibleSelectionRectangle.style.width = (containerRect.right - left) + 'px';
if (top < containerRect.top) {
const difference = containerRect.top - top;
if (top < containerRect.top - parseInt(window.getComputedStyle(menubar).height)) {
const difference = containerRect.top - top - parseInt(window.getComputedStyle(menubar).height);
visibleSelectionRectangle.style.height = (parseFloat(visibleSelectionRectangle.style.height) - difference) + 'px';
visibleSelectionRectangle.style.top = containerRect.top + 'px';
visibleSelectionRectangle.style.top = (containerRect.top - parseInt(window.getComputedStyle(menubar).height)) + 'px';
}
if (bottom > containerRect.bottom)
visibleSelectionRectangle.style.height = (containerRect.bottom - top) + 'px';
@@ -62,8 +62,8 @@ class NotificationService {
else
console.log(message);
// set a timeout to remove the notification after 5 seconds
setTimeout(() => this.removeNotification(notification.id), 5000);
// set a timeout to remove the notification after 10 seconds (fading out effect is handled in notification.css)
setTimeout(() => this.removeNotification(notification.id), 10000);
}
/**
@@ -75,9 +75,8 @@ class NotificationService {
if (index !== -1) {
this.notifications.splice(index, 1);
const element = document.getElementById(`notification-${id}`);
if (element) {
if (element)
element.remove();
}
}
}
@@ -93,7 +92,7 @@ class NotificationService {
notificationElement.id = `notification-${notification.id}`;
notificationElement.className = `notification ${notification.type}`;
notificationElement.innerHTML = `
<div class="shine-effect"></div>
<div class="notification-shine-effect"></div>
<div class="notification-body">
<span class="notification-message">${notification.message}</span>
<button class="close-button" onclick="notificationService.removeNotification('${notification.id}')">×</button>
@@ -38,6 +38,55 @@ async function callApiGetAsync(url) {
}
}
/**
* Performs a POST request to the specified API endpoint.
* @param {string} url - The API endpoint URL.
* @param {Object} data - The data to send in the request body.
* @param {Object} [options] - Additional options for the request.
* @param {boolean} [options.useAntiForgery=true] - Whether to include anti-forgery token.
* @param {Object} [options.headers] - Additional headers to include.
* @returns {Promise<any>} The response data if successful, undefined otherwise.
*/
async function callApiPostAsync(url, data, options = {}) {
const defaultOptions = {
useAntiForgery: true,
headers: {}
};
const finalOptions = { ...defaultOptions, ...options };
try {
// prepare headers
const headers = {
'Content-Type': 'application/json',
...finalOptions.headers
};
// add anti-forgery token if enabled
if (finalOptions.useAntiForgery) {
const token = document.querySelector('input[name="__RequestVerificationToken"]')?.value;
if (token)
headers['X-CSRF-TOKEN'] = token;
}
// make the request
const response = await fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(data)
});
if (!response.ok)
throw new Error(`HTTP error! status: ${response.status}`);
const jsonResponse = await response.json();
if (jsonResponse.success) {
if (jsonResponse.message)
notificationService.show(jsonResponse.message, NotificationType.SUCCESS);
return jsonResponse.data;
}
else
notificationService.show(jsonResponse.errorMessage, NotificationType.ERROR);
} catch (error) {
console.error('Error:', error);
notificationService.show(error, NotificationType.ERROR);
}
}
//+======================================================================================+
//| Website navigation |
//+======================================================================================+
@@ -338,6 +387,12 @@ function getElementOffset(id) {
};
}
document.querySelectorAll('.remove-form-table-row-icon').forEach(icon => {
icon.addEventListener('click', function () {
this.parentElement.remove();
});
});
/**
* Toggles the visibility of the audio player.
*/
@@ -361,4 +416,90 @@ function toggleAudioPlayerFullHeight() {
audioPlayerFullHeightToggle.addEventListener('click', toggleAudioPlayerFullHeight);
audioPlayerClose.addEventListener('click', toggleAudioPlayerVisibility);
/**
* Closes all comboboxes except for the one passed as an argument.
* @param {HTMLElement} exceptionCheckbox - The checkbox of the combobox that should remain open.
*/
function closeAllComboboxesExcept(exceptionCheckbox) {
const checkedCheckboxes = document.querySelectorAll('.enlightenment-toggle-checkbox:checked, .navigator-toggle-checkbox:checked');
checkedCheckboxes.forEach(function (checkbox) {
if (!exceptionCheckbox || checkbox.id !== exceptionCheckbox.id)
checkbox.checked = false;
});
}
/**
* Detects changes on any combobox checkbox. If a combobox is opened, this will ensure all other comboboxes are closed.
*/
document.addEventListener('change', function (e) {
if (e.target.matches('.enlightenment-toggle-checkbox, .navigator-toggle-checkbox'))
if (e.target.checked)
closeAllComboboxesExcept(e.target);
});
/**
* Event handler for when an option in the combobox is clicked.
* This updates the displayed value of the combobox to the clicked option and closes the dropdown.
*/
document.addEventListener('click', function (e) {
if (e.target.matches('.enlightenment-option')) {
var text = e.target.textContent;
var combobox = e.target.closest('.enlightenment-combobox');
var selectedText = combobox.querySelector('.enlightenment-selected-text');
if (selectedText)
selectedText.textContent = text;
var toggleCheckbox = combobox.querySelector('.enlightenment-toggle-checkbox');
if (toggleCheckbox)
toggleCheckbox.checked = false;
}
});
/**
* Global click event for the entire document. Closes all combobox dropdowns if the clicked target is outside any combobox.
*/
document.addEventListener('click', function (e) {
// enlightenment combobox logic
if (!e.target.closest('.enlightenment-combobox')) {
const checkbox = document.querySelector('.enlightenment-toggle-checkbox:checked');
if (checkbox)
checkbox.checked = false;
}
// navigator combobox logic
if (!e.target.closest('.navigator-combobox') && typeof addressBar !== 'undefined' && addressBar !== null) {
const checkbox = document.querySelector('.navigator-toggle-checkbox:checked');
if (checkbox)
checkbox.checked = false;
// when drop down closes, hide address bar overflow
addressBar.style.overflowX = 'auto';
addressBar.style.overflowY = 'hidden';
reattachDropdown();
}
});
/**
* Event handler for navigation combobox drop down item clicks.
*/
document.addEventListener("click", function (e) {
if (e.target.matches('.navigator-option')) {
// the address bar drop downs may be destroyed when an option is clicked - they are regenerated each time anyway
addressBar.removeEventListener('scroll', adjustDropdownPosition);
var parentElement = e.target.parentElement;
if (parentElement)
parentElement.remove();
}
});
/**
* Prevents the global document click event from propagating when clicking on a combobox.
* This ensures the dropdown doesn't close unintentionally.
*/
document.addEventListener('click', function (e) {
if (e.target.closest('.enlightenment-combobox, .navigator-combobox'))
e.stopPropagation();
});
document.addEventListener('DOMContentLoaded', initializeNavigation);