162 lines
7.3 KiB
HTML
162 lines
7.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Upload Content</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<style>
|
|
body.dark-mode {
|
|
background-color: #121212;
|
|
color: #ffffff;
|
|
}
|
|
.card.dark-mode {
|
|
background-color: #1e1e1e;
|
|
color: #ffffff;
|
|
}
|
|
.dark-mode label, .dark-mode th, .dark-mode td {
|
|
color: #ffffff;
|
|
}
|
|
.popup-message {
|
|
position: fixed;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
background-color: rgba(0, 0, 0, 0.8);
|
|
color: white;
|
|
padding: 20px;
|
|
border-radius: 10px;
|
|
display: none;
|
|
z-index: 1000;
|
|
}
|
|
.logo {
|
|
max-height: 100px;
|
|
margin-right: 20px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body class="{{ 'dark-mode' if theme == 'dark' else '' }}">
|
|
<div class="container py-5">
|
|
<div class="d-flex justify-content-start align-items-center mb-4">
|
|
{% if logo_exists %}
|
|
<img src="{{ url_for('static', filename='uploads/logo.png') }}" alt="Logo" class="logo">
|
|
{% endif %}
|
|
<h1 class="mb-0">Upload Content</h1>
|
|
</div>
|
|
<form id="upload-form" action="{{ url_for('upload_content') }}" method="post" enctype="multipart/form-data" onsubmit="showPopupMessage('Content uploaded successfully!')">
|
|
<input type="hidden" name="return_url" value="{{ return_url }}">
|
|
<div class="mb-3">
|
|
<label for="target_type" class="form-label">Target Type:</label>
|
|
<select name="target_type" id="target_type" class="form-select" required {% if target_type %}disabled{% endif %} onchange="updateTargetIdOptions()">
|
|
<option value="player" {% if target_type == 'player' %}selected{% endif %}>Player</option>
|
|
<option value="group" {% if target_type == 'group' %}selected{% endif %}>Group</option>
|
|
</select>
|
|
{% if target_type %}
|
|
<input type="hidden" name="target_type" value="{{ target_type }}">
|
|
{% endif %}
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="target_id" class="form-label">Target ID:</label>
|
|
<select name="target_id" id="target_id" class="form-select" required {% if target_id %}disabled{% endif %}>
|
|
{% if target_type == 'player' %}
|
|
<optgroup label="Players">
|
|
{% for player in players %}
|
|
<option value="{{ player.id }}" {% if target_id == player.id %}selected{% endif %}>{{ player.username }}</option>
|
|
{% endfor %}
|
|
</optgroup>
|
|
{% elif target_type == 'group' %}
|
|
<optgroup label="Groups">
|
|
{% for group in groups %}
|
|
<option value="{{ group.id }}" {% if target_id == group.id %}selected{% endif %}>{{ group.name }}</option>
|
|
{% endfor %}
|
|
</optgroup>
|
|
{% endif %}
|
|
</select>
|
|
{% if target_id %}
|
|
<input type="hidden" name="target_id" value="{{ target_id }}">
|
|
{% endif %}
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="media_type" class="form-label">Media Type:</label>
|
|
<select name="media_type" id="media_type" class="form-select" required>
|
|
<option value="image">Image</option>
|
|
<option value="video">Video</option>
|
|
<option value="pdf">PDF</option>
|
|
<option value="ppt">PPT/PPTX</option>
|
|
</select>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="files" class="form-label">Files:</label>
|
|
<input type="file" name="files" id="files" class="form-control" multiple required>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="duration" class="form-label">Duration (seconds):</label>
|
|
<input type="number" name="duration" id="duration" class="form-control" required>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Upload</button>
|
|
</form>
|
|
<a href="{{ return_url }}" class="btn btn-secondary mt-3">Back</a>
|
|
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary mt-3">Back to Dashboard</a>
|
|
</div>
|
|
|
|
<div id="popup-message" class="popup-message"></div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script>
|
|
function updateTargetIdOptions() {
|
|
const targetType = document.getElementById('target_type').value;
|
|
const targetIdSelect = document.getElementById('target_id');
|
|
targetIdSelect.innerHTML = ''; // Clear existing options
|
|
|
|
if (targetType === 'player') {
|
|
const players = {{ players|tojson }};
|
|
const optgroup = document.createElement('optgroup');
|
|
optgroup.label = 'Players';
|
|
players.forEach(player => {
|
|
const option = document.createElement('option');
|
|
option.value = player.id;
|
|
option.textContent = player.username;
|
|
optgroup.appendChild(option);
|
|
});
|
|
targetIdSelect.appendChild(optgroup);
|
|
} else if (targetType === 'group') {
|
|
const groups = {{ groups|tojson }};
|
|
const optgroup = document.createElement('optgroup');
|
|
optgroup.label = 'Groups';
|
|
groups.forEach(group => {
|
|
const option = document.createElement('option');
|
|
option.value = group.id;
|
|
option.textContent = group.name;
|
|
optgroup.appendChild(option);
|
|
});
|
|
targetIdSelect.appendChild(optgroup);
|
|
}
|
|
}
|
|
|
|
document.getElementById('files').addEventListener('change', function(event) {
|
|
const files = event.target.files;
|
|
const mediaType = document.getElementById('media_type').value;
|
|
if (mediaType === 'video' && files.length > 0) {
|
|
const videoFile = files[0];
|
|
const videoElement = document.createElement('video');
|
|
videoElement.preload = 'metadata';
|
|
videoElement.onloadedmetadata = function() {
|
|
window.URL.revokeObjectURL(videoElement.src);
|
|
const duration = videoElement.duration;
|
|
document.getElementById('duration').value = Math.round(duration);
|
|
}
|
|
videoElement.src = URL.createObjectURL(videoFile);
|
|
}
|
|
});
|
|
|
|
function showPopupMessage(message) {
|
|
const popup = document.getElementById('popup-message');
|
|
popup.textContent = message;
|
|
popup.style.display = 'block';
|
|
setTimeout(() => {
|
|
popup.style.display = 'none';
|
|
document.getElementById('upload-form').submit();
|
|
}, 5000); // Display time set to 5 seconds
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|