Inital commit
This commit is contained in:
commit
a6af7dbfcb
114 files changed
+27520
No files matched your search
@@ -0,0 +1,198 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<%- include('../../partials/head'); -%>
|
||||
<%- include('../../partials/admin-editor-css'); -%>
|
||||
<title>Admin - Add Media</title>
|
||||
<style>
|
||||
.upload-progress {
|
||||
display: none;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
.upload-progress.active {
|
||||
display: block;
|
||||
}
|
||||
.progress-bar-container {
|
||||
width: 100%;
|
||||
height: 28px;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
border: 1px solid var(--border-muted);
|
||||
border-radius: 0;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
.progress-bar {
|
||||
height: 100%;
|
||||
width: 0%;
|
||||
background: var(--accent);
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
.progress-text {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 0.85rem;
|
||||
font-weight: bold;
|
||||
color: var(--text);
|
||||
text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
.progress-status {
|
||||
margin-top: 0.4rem;
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
.progress-status.error {
|
||||
color: var(--danger);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<%- include('../../winter'); -%>
|
||||
|
||||
<div class="editor-container">
|
||||
<a class="btn btn-back" href="<%= endpoint %>/dashboard">Back to dashboard</a>
|
||||
<section>
|
||||
<h1>Add New Media</h1>
|
||||
<form id="uploadForm" action="<%= endpoint %>/gallery/upload" method="post" enctype="multipart/form-data" class="editor-form editor-form--stacked">
|
||||
|
||||
<label>
|
||||
Name
|
||||
<input type="text" name="name" required>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Description
|
||||
<textarea name="description" rows="3"></textarea>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Artists (comma-separated)
|
||||
<input type="text" name="artists" class="multi-input">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Sources (comma-separated)
|
||||
<input type="text" name="sources" class="multi-input">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Tags (comma-separated)
|
||||
<input type="text" name="tags" class="multi-input">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Access Codes (comma-separated)
|
||||
<input type="text" name="accessCodes" class="multi-input">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Created Date
|
||||
<input type="date" name="created">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Main File (Image, Video, or Animated Image)
|
||||
<input type="file" name="image" accept="image/*,video/*" required>
|
||||
</label>
|
||||
|
||||
<div class="upload-progress" id="uploadProgress">
|
||||
<div class="progress-bar-container">
|
||||
<div class="progress-bar" id="progressBar"></div>
|
||||
<div class="progress-text" id="progressText">0%</div>
|
||||
</div>
|
||||
<div class="progress-status" id="progressStatus">Uploading...</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" id="submitBtn">Add Media</button>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
|
||||
<%- include('../../footer'); -%>
|
||||
<script>
|
||||
document.getElementById('uploadForm').addEventListener('submit', async function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const form = this;
|
||||
const submitBtn = document.getElementById('submitBtn');
|
||||
const progressContainer = document.getElementById('uploadProgress');
|
||||
const progressBar = document.getElementById('progressBar');
|
||||
const progressText = document.getElementById('progressText');
|
||||
const progressStatus = document.getElementById('progressStatus');
|
||||
|
||||
submitBtn.disabled = true;
|
||||
submitBtn.textContent = 'Uploading...';
|
||||
progressContainer.classList.add('active');
|
||||
progressBar.style.width = '0%';
|
||||
progressText.textContent = '0%';
|
||||
progressStatus.className = 'progress-status';
|
||||
progressStatus.textContent = 'Uploading file to server...';
|
||||
|
||||
try {
|
||||
// Step 1: Upload file
|
||||
const formData = new FormData(form);
|
||||
const uploadRes = await fetch(form.action, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
credentials: 'include'
|
||||
});
|
||||
|
||||
if (!uploadRes.ok) {
|
||||
throw new Error('Upload failed');
|
||||
}
|
||||
|
||||
const { jobId } = await uploadRes.json();
|
||||
|
||||
progressBar.style.width = '10%';
|
||||
progressText.textContent = '10%';
|
||||
progressStatus.textContent = 'File received. Processing...';
|
||||
|
||||
// Step 2: Connect to SSE for progress
|
||||
const evtSource = new EventSource(`<%= endpoint %>/gallery/progress/${jobId}`);
|
||||
|
||||
evtSource.onmessage = function(event) {
|
||||
const data = JSON.parse(event.data);
|
||||
|
||||
progressBar.style.width = data.progress + '%';
|
||||
progressText.textContent = data.progress + '%';
|
||||
progressStatus.textContent = data.message;
|
||||
|
||||
if (data.status === 'done') {
|
||||
evtSource.close();
|
||||
progressBar.style.width = '100%';
|
||||
progressText.textContent = '100%';
|
||||
progressStatus.textContent = 'Upload complete!';
|
||||
window.location.href = data.redirectUrl;
|
||||
} else if (data.status === 'error') {
|
||||
evtSource.close();
|
||||
progressStatus.className = 'progress-status error';
|
||||
progressStatus.textContent = 'Error: ' + (data.error || 'Unknown error');
|
||||
submitBtn.disabled = false;
|
||||
submitBtn.textContent = 'Add Media';
|
||||
}
|
||||
};
|
||||
|
||||
evtSource.onerror = function() {
|
||||
evtSource.close();
|
||||
progressStatus.className = 'progress-status error';
|
||||
progressStatus.textContent = 'Connection lost. Please try again.';
|
||||
submitBtn.disabled = false;
|
||||
submitBtn.textContent = 'Add Media';
|
||||
};
|
||||
|
||||
} catch (err) {
|
||||
progressStatus.className = 'progress-status error';
|
||||
progressStatus.textContent = 'Upload failed: ' + err.message;
|
||||
submitBtn.disabled = false;
|
||||
submitBtn.textContent = 'Add Media';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,88 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<%- include('../../partials/head'); -%>
|
||||
<%- include('../../partials/admin-editor-css'); -%>
|
||||
<title>Admin - Edit Image</title>
|
||||
</head>
|
||||
<body>
|
||||
<%- include('../../winter'); -%>
|
||||
|
||||
<div class="editor-container">
|
||||
<a class="btn btn-back" href="<%= endpoint %>/dashboard">Back to dashboard</a>
|
||||
<% if (image) { %>
|
||||
<section>
|
||||
<h1>Edit image</h1>
|
||||
|
||||
<form action="<%= endpoint %>/gallery/edit" method="post" class="editor-form editor-form--stacked">
|
||||
|
||||
<% if (image.isVideo) { %>
|
||||
<video class="editor-preview-img" src="/gallery/thumbnail/<%= image.thumbnailName %>" alt="<%= image.name %>" muted playsinline loop></video>
|
||||
<% } else { %>
|
||||
<img class="editor-preview-img" src="/gallery/thumbnail/<%= image.thumbnailName %>" alt="<%= image.name %>">
|
||||
<% } %>
|
||||
|
||||
<div class="editor-actions">
|
||||
<a class="btn" href="/gallery/thumbnail/<%= image.thumbnailName %>">Thumbnail</a>
|
||||
<% if (image.isVideo) { %>
|
||||
<a class="btn" href="/gallery/video/<%= image.id %>">Video</a>
|
||||
<% } else { %>
|
||||
<a class="btn" href="/gallery/image/<%= image.imageName %>">Image</a>
|
||||
<% } %>
|
||||
</div>
|
||||
|
||||
<input type="text" name="id" required value="<%= image.id %>" hidden>
|
||||
<label>
|
||||
Name
|
||||
<input type="text" name="name" required value="<%= image.name %>">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Description
|
||||
<textarea name="description" rows="3"><%= image.description %></textarea>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Artists (comma-separated)
|
||||
<input type="text" name="artists" class="multi-input" value="<%= image.artists.join(', ') %>">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Sources (comma-separated)
|
||||
<input type="text" name="sources" class="multi-input" value="<%= image.sources.join(', ') %>">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Tags (comma-separated)
|
||||
<input type="text" name="tags" class="multi-input" value="<%= image.tags.join(', ') %>">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Access Codes (comma-separated)
|
||||
<input type="text" name="accessCodes" class="multi-input" value="<%= image.accessCodes.join(', ') %>">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Created Image
|
||||
<input type="date" name="created" value="<%= image.createdAt.toISOString().split("T")[0] %>">
|
||||
</label>
|
||||
|
||||
<button type="submit">Edit</button>
|
||||
</form>
|
||||
|
||||
<form action="<%= endpoint %>/gallery/delete" method="post" class="editor-form editor-form--stacked">
|
||||
<input type="text" name="id" required value="<%= image.id %>" hidden>
|
||||
<button type="submit" class="delete">Delete</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<% } else { %>
|
||||
|
||||
<section><div>No image found</div></section>
|
||||
|
||||
<% } %>
|
||||
</div>
|
||||
|
||||
<%- include('../../footer'); -%>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<%- include('../../partials/head'); -%>
|
||||
<%- include('../../partials/admin-editor-css'); -%>
|
||||
<title>Admin - Gallery</title>
|
||||
</head>
|
||||
<body>
|
||||
<%- include('../../winter'); -%>
|
||||
|
||||
<div class="editor-container browse-panel">
|
||||
<a class="btn btn-back" href="<%= endpoint %>/dashboard">Back to dashboard</a>
|
||||
<%- include('../../partials/browse-editor', {
|
||||
searchAction: '/gallery',
|
||||
addHref: endpoint + '/gallery-add/',
|
||||
addLabel: 'Add media',
|
||||
items: images,
|
||||
editHrefPrefix: endpoint + '/gallery-edit/',
|
||||
thumbnailPrefix: '/gallery/thumbnail/',
|
||||
search,
|
||||
mode,
|
||||
currentPage,
|
||||
totalPages
|
||||
}); -%>
|
||||
</div>
|
||||
|
||||
<%- include('../../footer'); -%>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user