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

@@ -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);