updated player deploy and config
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
36827
|
77016
|
||||||
36829
|
77018
|
||||||
36831
|
77020
|
||||||
36833
|
77022
|
||||||
36835
|
77024
|
||||||
|
|||||||
@@ -267,6 +267,86 @@ def add_content_to_playlist(playlist_id: int):
|
|||||||
return redirect(url_for('content.manage_playlist_content', playlist_id=playlist_id))
|
return redirect(url_for('content.manage_playlist_content', playlist_id=playlist_id))
|
||||||
|
|
||||||
|
|
||||||
|
@content_bp.route('/add-weblink', methods=['POST'])
|
||||||
|
@login_required
|
||||||
|
def add_weblink():
|
||||||
|
"""Create a web link content item from the Upload Media page.
|
||||||
|
|
||||||
|
Optionally adds it directly to a playlist if playlist_id is supplied.
|
||||||
|
Returns JSON when the request carries Accept: application/json, otherwise
|
||||||
|
redirects back to the upload page.
|
||||||
|
"""
|
||||||
|
use_json = 'application/json' in request.accept_mimetypes.best or \
|
||||||
|
request.headers.get('X-Requested-With') == 'XMLHttpRequest'
|
||||||
|
|
||||||
|
try:
|
||||||
|
web_url = (request.form.get('url') or '').strip()
|
||||||
|
duration = request.form.get('duration', type=int, default=30)
|
||||||
|
description = (request.form.get('description') or '').strip() or None
|
||||||
|
playlist_id = request.form.get('playlist_id', type=int)
|
||||||
|
|
||||||
|
parsed = urlparse(web_url)
|
||||||
|
if parsed.scheme.lower() not in ('http', 'https') or not parsed.netloc:
|
||||||
|
if use_json:
|
||||||
|
return jsonify({'success': False, 'error': 'Please enter a valid http:// or https:// web address.'}), 400
|
||||||
|
flash('Please enter a valid http:// or https:// web address.', 'warning')
|
||||||
|
return redirect(url_for('content.upload_media_page'))
|
||||||
|
|
||||||
|
if not duration or duration < 1:
|
||||||
|
duration = 30
|
||||||
|
|
||||||
|
content = Content(
|
||||||
|
filename=f'weblink-{uuid.uuid4().hex[:12]}',
|
||||||
|
content_type='weblink',
|
||||||
|
url=web_url,
|
||||||
|
duration=duration,
|
||||||
|
description=description or web_url,
|
||||||
|
uploaded_at=datetime.utcnow(),
|
||||||
|
)
|
||||||
|
db.session.add(content)
|
||||||
|
db.session.flush()
|
||||||
|
|
||||||
|
if playlist_id:
|
||||||
|
playlist = Playlist.query.get(playlist_id)
|
||||||
|
if playlist:
|
||||||
|
from sqlalchemy import select, func
|
||||||
|
max_pos = db.session.execute(
|
||||||
|
select(func.max(playlist_content.c.position)).where(
|
||||||
|
playlist_content.c.playlist_id == playlist_id
|
||||||
|
)
|
||||||
|
).scalar() or 0
|
||||||
|
db.session.execute(
|
||||||
|
playlist_content.insert().values(
|
||||||
|
playlist_id=playlist_id,
|
||||||
|
content_id=content.id,
|
||||||
|
position=max_pos + 1,
|
||||||
|
duration=duration,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
playlist.increment_version()
|
||||||
|
log_action('info', f'Web link "{web_url}" added to playlist "{playlist.name}"')
|
||||||
|
else:
|
||||||
|
log_action('warning', f'Web link "{web_url}" created; playlist {playlist_id} not found')
|
||||||
|
else:
|
||||||
|
log_action('info', f'Web link "{web_url}" added to media library')
|
||||||
|
|
||||||
|
db.session.commit()
|
||||||
|
cache.clear()
|
||||||
|
|
||||||
|
if use_json:
|
||||||
|
return jsonify({'success': True, 'content_id': content.id, 'message': 'Web link added successfully.'})
|
||||||
|
flash('Web link added successfully.', 'success')
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
db.session.rollback()
|
||||||
|
log_action('error', f'Error adding web link: {str(e)}')
|
||||||
|
if use_json:
|
||||||
|
return jsonify({'success': False, 'error': 'Failed to add web link.'}), 500
|
||||||
|
flash('Error adding web link.', 'danger')
|
||||||
|
|
||||||
|
return redirect(url_for('content.upload_media_page'))
|
||||||
|
|
||||||
|
|
||||||
@content_bp.route('/playlist/<int:playlist_id>/add-weblink', methods=['POST'])
|
@content_bp.route('/playlist/<int:playlist_id>/add-weblink', methods=['POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def add_weblink_to_playlist(playlist_id: int):
|
def add_weblink_to_playlist(playlist_id: int):
|
||||||
|
|||||||
@@ -315,6 +315,67 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<!-- ── Web Link Card ─────────────────────────────────────────────────── -->
|
||||||
|
<div class="card" style="margin-top: 20px;">
|
||||||
|
<h2 style="margin-bottom: 15px; font-size: 18px; display: flex; align-items: center; gap: 0.5rem;">
|
||||||
|
🌐 Add Web Page Link
|
||||||
|
</h2>
|
||||||
|
<p style="color: #6c757d; font-size: 13px; margin-bottom: 16px;">
|
||||||
|
Add a website URL to display on the player (e.g. a dashboard, live feed, or any public web page).
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<form id="weblink-form" method="POST" action="{{ request.script_root }}/content/add-weblink">
|
||||||
|
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 16px;">
|
||||||
|
|
||||||
|
<!-- URL -->
|
||||||
|
<div class="form-group" style="grid-column: 1 / -1;">
|
||||||
|
<label for="wl-url">Web Page URL <span style="color:#e53e3e;">*</span></label>
|
||||||
|
<input type="url" id="wl-url" name="url" class="form-control"
|
||||||
|
placeholder="https://example.com" required>
|
||||||
|
<small style="color:#6c757d; font-size:11px;">Must start with http:// or https://</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Description -->
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="wl-description">Label / Description</label>
|
||||||
|
<input type="text" id="wl-description" name="description" class="form-control"
|
||||||
|
placeholder="e.g. Live Dashboard">
|
||||||
|
<small style="color:#6c757d; font-size:11px;">Optional — shown in the media library</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Duration -->
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="wl-duration">Display Duration (seconds)</label>
|
||||||
|
<input type="number" id="wl-duration" name="duration" class="form-control"
|
||||||
|
value="30" min="5" max="3600">
|
||||||
|
<small style="color:#6c757d; font-size:11px;">How long to show the page per loop</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Playlist -->
|
||||||
|
<div class="form-group" style="grid-column: 1 / -1;">
|
||||||
|
<label for="wl-playlist">Add to Playlist (Optional)</label>
|
||||||
|
<select id="wl-playlist" name="playlist_id" class="form-control">
|
||||||
|
<option value="">-- Media Library Only --</option>
|
||||||
|
{% for playlist in playlists %}
|
||||||
|
<option value="{{ playlist.id }}">
|
||||||
|
{{ playlist.name }} ({{ playlist.orientation }}) — {{ playlist.content_count }} items
|
||||||
|
</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="display:flex; align-items:center; gap:12px; margin-top:8px;">
|
||||||
|
<button type="submit" class="btn-upload" id="wl-submit-btn"
|
||||||
|
style="display:inline-flex; align-items:center; gap:0.5rem; padding:10px 24px;">
|
||||||
|
🌐 Add Web Link
|
||||||
|
</button>
|
||||||
|
<span id="wl-status" style="font-size:13px; display:none;"></span>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -509,6 +570,43 @@
|
|||||||
uploadBtn.disabled = true;
|
uploadBtn.disabled = true;
|
||||||
uploadBtn.innerHTML = '⏳ Uploading...';
|
uploadBtn.innerHTML = '⏳ Uploading...';
|
||||||
});
|
});
|
||||||
|
// ── Web Link form — AJAX submit ────────────────────────────────────────
|
||||||
|
const wlForm = document.getElementById('weblink-form');
|
||||||
|
const wlBtn = document.getElementById('wl-submit-btn');
|
||||||
|
const wlStatus = document.getElementById('wl-status');
|
||||||
|
|
||||||
|
wlForm.addEventListener('submit', async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
wlBtn.disabled = true;
|
||||||
|
wlBtn.textContent = '⏳ Adding…';
|
||||||
|
wlStatus.style.display = 'none';
|
||||||
|
|
||||||
|
try {
|
||||||
|
const resp = await fetch(wlForm.action, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
||||||
|
body: new FormData(wlForm),
|
||||||
|
});
|
||||||
|
const data = await resp.json();
|
||||||
|
|
||||||
|
if (data.success) {
|
||||||
|
wlStatus.style.color = '#38a169';
|
||||||
|
wlStatus.textContent = '✓ ' + data.message;
|
||||||
|
wlForm.reset();
|
||||||
|
document.getElementById('wl-duration').value = 30;
|
||||||
|
} else {
|
||||||
|
wlStatus.style.color = '#e53e3e';
|
||||||
|
wlStatus.textContent = '✗ ' + (data.error || 'Failed to add web link.');
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
wlStatus.style.color = '#e53e3e';
|
||||||
|
wlStatus.textContent = '✗ Network error — please try again.';
|
||||||
|
}
|
||||||
|
|
||||||
|
wlStatus.style.display = 'inline';
|
||||||
|
wlBtn.disabled = false;
|
||||||
|
wlBtn.innerHTML = '🌐 Add Web Link';
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user