Compare commits
8 Commits
0fa3c00319
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4733c11832 | ||
|
|
d131948c13 | ||
|
|
31ea3107e6 | ||
|
|
a1b48e35d6 | ||
|
|
296e59e709 | ||
|
|
0a39ac69de | ||
|
|
61ee174cff | ||
|
|
1cb260fa80 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,6 +3,8 @@ __pycache__/
|
||||
test*
|
||||
*.old
|
||||
.venv/
|
||||
.DS_Store
|
||||
.vscode
|
||||
media/
|
||||
*.mp4
|
||||
*.mov
|
||||
|
||||
33
AGENTS.md
Normal file
33
AGENTS.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# CANCOM Simple Signage — Agent Guide
|
||||
|
||||
## Start
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
python app.py
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
`python app.py` serves on `http://localhost:5005`. `app.py` runs Flask with `debug=True`, `host="0.0.0.0"`, and `port=5005`.
|
||||
|
||||
## Source Of Truth
|
||||
|
||||
- Single Flask app in `app.py`; there is no database.
|
||||
- Persistent state is `config.json` plus files under `media/<screen>/`.
|
||||
- `README.md` is stale on the port number; trust `app.py`.
|
||||
- Existing repo instructions in this file are the main local guidance; there is no `opencode.json` or workflow config in this repo.
|
||||
|
||||
## Behavior To Preserve
|
||||
|
||||
- `GET /player/<screen>` renders the playlist and auto-reloads from `/playlist/<screen>/hash`.
|
||||
- `GET /admin` requires login; `config.json.admin` holds the credentials.
|
||||
- URL playlist items are stored as dicts like `{"url": "https://...", "zoom": 0.8}` and the zoom value must survive save/reorder flows.
|
||||
- `.html` items in `media/` are rendered inline as content, not in an iframe.
|
||||
- `config.priority.enabled` makes the priority playlist show on every screen.
|
||||
- `POST /api/customer` generates `welcome.html` and inserts it at the front of the lobby playlist.
|
||||
|
||||
## Repo Quirks
|
||||
|
||||
- `media/` and media file extensions are gitignored.
|
||||
- The app has no configured tests, lint, typecheck, formatter, or CI.
|
||||
- Hardcoded secrets exist in tracked files; do not commit new secrets or reshuffle them casually.
|
||||
12
Dockerfile
Normal file
12
Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt ./
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 5005
|
||||
|
||||
CMD ["python", "app.py"]
|
||||
@@ -91,7 +91,7 @@ python app.py
|
||||
Server läuft auf:
|
||||
|
||||
```
|
||||
http://localhost:5000
|
||||
http://localhost:5005
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
191
app.py
191
app.py
@@ -1,11 +1,13 @@
|
||||
import os
|
||||
import json
|
||||
import socket
|
||||
import hashlib
|
||||
# Import welcome page functions
|
||||
import generate_welcome_page
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from flask import (
|
||||
Flask, render_template,
|
||||
Flask, jsonify, render_template,
|
||||
send_from_directory, redirect,
|
||||
request, abort
|
||||
)
|
||||
@@ -16,6 +18,7 @@ from flask_login import (
|
||||
)
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
|
||||
# -------------------------------------------------
|
||||
# Grundkonfiguration
|
||||
# -------------------------------------------------
|
||||
@@ -23,7 +26,7 @@ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
MEDIA_DIR = os.path.join(BASE_DIR, "media")
|
||||
CONFIG_FILE = os.path.join(BASE_DIR, "config.json")
|
||||
|
||||
APP_VERSION = "3.6.0"
|
||||
APP_VERSION = "4.1.1"
|
||||
UPLOAD_EXTENSIONS = {".jpg", ".jpeg", ".png", ".mp4"}
|
||||
|
||||
app = Flask(__name__)
|
||||
@@ -67,6 +70,16 @@ def normalize_url(value):
|
||||
return None
|
||||
|
||||
|
||||
def playlist_item_enabled(item):
|
||||
return not (isinstance(item, dict) and item.get("enabled") is False)
|
||||
|
||||
|
||||
def playlist_item_name(item):
|
||||
if isinstance(item, dict):
|
||||
return item.get("url") or item.get("name")
|
||||
return item
|
||||
|
||||
|
||||
# -------------------------------------------------
|
||||
# Auth / Benutzer
|
||||
# -------------------------------------------------
|
||||
@@ -101,6 +114,87 @@ def logout():
|
||||
logout_user()
|
||||
return redirect("/login")
|
||||
|
||||
# -------------------------------------------------
|
||||
# Customer / Willkommensseite
|
||||
# -------------------------------------------------
|
||||
@app.route("/customer", methods=["GET", "POST"])
|
||||
# @login_required
|
||||
def add_customer():
|
||||
"""Add new customer with logo search and welcome page"""
|
||||
error = None
|
||||
success = None
|
||||
logo_url = None
|
||||
|
||||
if request.method == "POST":
|
||||
customer_name = request.form.get("customer_name", "").strip()
|
||||
print(f"🔍 APP.PY - Suche nach Kunde: '{customer_name}'")
|
||||
if not customer_name:
|
||||
error = "Kundenname erforderlich"
|
||||
else:
|
||||
try:
|
||||
# Search for logo
|
||||
logo_url = generate_welcome_page.search_customer_logo(customer_name)
|
||||
|
||||
if not logo_url:
|
||||
error = "Logo konnte nicht gefunden werden"
|
||||
else:
|
||||
# Generate and save welcome page
|
||||
html_filename = generate_welcome_page.save_welcome_page(customer_name, logo_url)
|
||||
|
||||
if html_filename:
|
||||
# Add to lobby playlist
|
||||
if generate_welcome_page.add_customer_to_lobby_playlist(html_filename):
|
||||
success = f"✅ Kunde '{customer_name}' erfolgreich hinzugefügt!"
|
||||
else:
|
||||
error = "Fehler beim Hinzufügen zur Playliste"
|
||||
else:
|
||||
error = "Fehler beim Speichern der Willkommensseite"
|
||||
except ValueError as e:
|
||||
error = f"Konfigurationsfehler: {str(e)}"
|
||||
except Exception as e:
|
||||
error = f"Fehler: {str(e)}"
|
||||
|
||||
return render_template("customer.html", error=error, success=success, logo_url=logo_url)
|
||||
|
||||
@app.route("/api/customer", methods=["POST"])
|
||||
# @login_required
|
||||
def api_add_customer():
|
||||
"""API endpoint for customer creation"""
|
||||
try:
|
||||
data = request.get_json()
|
||||
customer_name = data.get("customer_name", "").strip()
|
||||
|
||||
if not customer_name:
|
||||
return jsonify({"error": "Customer name required"}), 400
|
||||
|
||||
# Search for logo
|
||||
logo_url = generate_welcome_page.search_customer_logo(customer_name)
|
||||
|
||||
if not logo_url:
|
||||
return jsonify({"error": "Logo not found"}), 400
|
||||
|
||||
# Generate and save welcome page
|
||||
html_filename = generate_welcome_page.save_welcome_page(customer_name, logo_url)
|
||||
|
||||
if not html_filename:
|
||||
return jsonify({"error": "Failed to create welcome page"}), 500
|
||||
|
||||
# Add to lobby playlist
|
||||
if generate_welcome_page.add_customer_to_lobby_playlist(html_filename):
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"message": f"Customer '{customer_name}' added successfully",
|
||||
"welcome_page": html_filename,
|
||||
"logo_url": logo_url
|
||||
}), 201
|
||||
else:
|
||||
return jsonify({"error": "Failed to add to playlist"}), 500
|
||||
|
||||
except ValueError as e:
|
||||
return jsonify({"error": str(e)}), 400
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
# -------------------------------------------------
|
||||
# Medien ausliefern
|
||||
# -------------------------------------------------
|
||||
@@ -136,6 +230,8 @@ def player(screen):
|
||||
return show_images
|
||||
if ext.endswith(".mp4"):
|
||||
return show_videos
|
||||
if ext.endswith((".html", ".htm")):
|
||||
return True
|
||||
return False
|
||||
|
||||
# ------------------------------
|
||||
@@ -145,25 +241,29 @@ def player(screen):
|
||||
|
||||
# 1. Playlist-Reihenfolge
|
||||
for item in playlist:
|
||||
if not playlist_item_enabled(item):
|
||||
continue
|
||||
item_name = playlist_item_name(item)
|
||||
if is_url(item):
|
||||
url_data = normalize_url(item)
|
||||
if url_data:
|
||||
normal_files.append({"kind": "url", "url": url_data["url"], "zoom": url_data.get("zoom", 1.0)})
|
||||
normal_files.append({"kind": "url", "url": url_data["url"], "zoom": url_data.get("zoom", 1.0), "enabled": True})
|
||||
continue
|
||||
|
||||
if os.path.exists(os.path.join(folder, item)) and allowed_file(item):
|
||||
normal_files.append({"kind": "file", "name": item})
|
||||
if item_name and os.path.exists(os.path.join(folder, item_name)) and allowed_file(item_name):
|
||||
normal_files.append({"kind": "file", "name": item_name, "enabled": True})
|
||||
|
||||
existing_file_names = {
|
||||
item["name"] for item in normal_files if item["kind"] == "file"
|
||||
}
|
||||
|
||||
# 2. Neue Dateien hintendran
|
||||
for f in sorted(os.listdir(folder)):
|
||||
if f in existing_file_names or f.startswith("._"):
|
||||
continue
|
||||
if allowed_file(f):
|
||||
normal_files.append({"kind": "file", "name": f})
|
||||
if not playlist:
|
||||
for f in sorted(os.listdir(folder)):
|
||||
if f in existing_file_names or f.startswith("._"):
|
||||
continue
|
||||
if allowed_file(f):
|
||||
normal_files.append({"kind": "file", "name": f})
|
||||
|
||||
# ------------------------------
|
||||
# Priority-Playlist (global)
|
||||
@@ -174,23 +274,26 @@ def player(screen):
|
||||
if priority_cfg.get("enabled", False):
|
||||
prio_files = []
|
||||
for item in priority_cfg.get("playlist", []):
|
||||
if not playlist_item_enabled(item):
|
||||
continue
|
||||
item_name = playlist_item_name(item)
|
||||
if is_url(item):
|
||||
url_data = normalize_url(item)
|
||||
if url_data:
|
||||
prio_files.append({"kind": "url", "url": url_data["url"], "zoom": url_data.get("zoom", 1.0)})
|
||||
prio_files.append({"kind": "url", "url": url_data["url"], "zoom": url_data.get("zoom", 1.0), "enabled": True})
|
||||
continue
|
||||
|
||||
file_path = os.path.join(MEDIA_DIR, "priority", item)
|
||||
file_path = os.path.join(MEDIA_DIR, "priority", item_name)
|
||||
if os.path.exists(file_path):
|
||||
prio_files.append({"kind": "file", "name": item})
|
||||
prio_files.append({"kind": "file", "name": item_name, "enabled": True})
|
||||
else:
|
||||
prio_files = []
|
||||
|
||||
return render_template(
|
||||
"player.html",
|
||||
screen=screen,
|
||||
normal_files=normal_files, # ✅ explizit
|
||||
prio_files=prio_files, # ✅ IMMER Liste
|
||||
normal_files=[item for item in normal_files if item.get("enabled", True)],
|
||||
prio_files=[item for item in prio_files if item.get("enabled", True)],
|
||||
interval=screen_cfg.get("interval", 10),
|
||||
newsticker_text=screen_cfg.get("newsticker_text", ""),
|
||||
newsticker_enabled=screen_cfg.get("newsticker_enabled", False)
|
||||
@@ -250,6 +353,8 @@ def admin():
|
||||
|
||||
# 1️⃣ Playlist-Reihenfolge
|
||||
for item in playlist:
|
||||
item_name = playlist_item_name(item)
|
||||
|
||||
if is_url(item):
|
||||
url_data = normalize_url(item)
|
||||
if url_data:
|
||||
@@ -257,27 +362,36 @@ def admin():
|
||||
"name": url_data["url"],
|
||||
"type": "url",
|
||||
"size": "URL",
|
||||
"zoom": url_data.get("zoom", 1.0)
|
||||
"zoom": url_data.get("zoom", 1.0),
|
||||
"enabled": playlist_item_enabled(item)
|
||||
})
|
||||
continue
|
||||
|
||||
file_path = os.path.join(path, item)
|
||||
file_path = os.path.join(path, item_name)
|
||||
if not os.path.exists(file_path):
|
||||
continue
|
||||
|
||||
ext = os.path.splitext(item)[1].lower()
|
||||
ftype = "video" if ext == ".mp4" else "image"
|
||||
ext = os.path.splitext(item_name)[1].lower()
|
||||
if ext == ".mp4":
|
||||
ftype = "video"
|
||||
if ext in (".jpg", ".jpeg", ".png"):
|
||||
ftype = "image"
|
||||
if ext == ".html":
|
||||
ftype = "html"
|
||||
|
||||
size = os.path.getsize(file_path) // 1024
|
||||
|
||||
files.append({
|
||||
"name": item,
|
||||
"name": item_name,
|
||||
"type": ftype,
|
||||
"size": size
|
||||
"size": size,
|
||||
"enabled": playlist_item_enabled(item)
|
||||
})
|
||||
|
||||
# 2️⃣ Neue Dateien anhängen (nicht in Playlist)
|
||||
playlist_names = {playlist_item_name(item) for item in playlist}
|
||||
for f in sorted(os.listdir(path)):
|
||||
if f in playlist or f.startswith("._"):
|
||||
if f in playlist_names or f.startswith("._"):
|
||||
continue
|
||||
|
||||
file_path = os.path.join(path, f)
|
||||
@@ -305,6 +419,7 @@ def admin():
|
||||
|
||||
# 1️⃣ Playlist-Reihenfolge
|
||||
for item in prio_playlist:
|
||||
item_name = playlist_item_name(item)
|
||||
if is_url(item):
|
||||
url_data = normalize_url(item)
|
||||
if url_data:
|
||||
@@ -312,22 +427,24 @@ def admin():
|
||||
"name": url_data["url"],
|
||||
"type": "url",
|
||||
"size": "URL",
|
||||
"zoom": url_data.get("zoom", 1.0)
|
||||
})
|
||||
"zoom": url_data.get("zoom", 1.0),
|
||||
"enabled": playlist_item_enabled(item)
|
||||
})
|
||||
continue
|
||||
|
||||
file_path = os.path.join(prio_dir, item)
|
||||
file_path = os.path.join(prio_dir, item_name)
|
||||
if not os.path.exists(file_path):
|
||||
continue
|
||||
|
||||
ext = os.path.splitext(item)[1].lower()
|
||||
ext = os.path.splitext(item_name)[1].lower()
|
||||
ftype = "video" if ext == ".mp4" else "image"
|
||||
size = os.path.getsize(file_path) // 1024
|
||||
|
||||
priority_files.append({
|
||||
"name": item,
|
||||
"name": item_name,
|
||||
"type": ftype,
|
||||
"size": size
|
||||
"size": size,
|
||||
"enabled": playlist_item_enabled(item)
|
||||
})
|
||||
|
||||
# 2️⃣ Neue Dateien anhängen (nicht in Playlist)
|
||||
@@ -484,6 +601,7 @@ def save_playlist(screen):
|
||||
cfg = load_config()
|
||||
data = request.get_json()
|
||||
new_order = data["playlist"] # List of filenames/URLs as strings
|
||||
enabled_map = data.get("enabled", {})
|
||||
|
||||
# Get the current playlist with all data (including zoom factors)
|
||||
if screen == "priority":
|
||||
@@ -494,20 +612,17 @@ def save_playlist(screen):
|
||||
# Create a mapping: filename/url -> full item (preserves zoom factor)
|
||||
item_map = {}
|
||||
for item in old_playlist:
|
||||
if isinstance(item, dict) and "url" in item:
|
||||
key = item["url"] # URL as key
|
||||
else:
|
||||
key = item # Filename as key
|
||||
item_map[key] = item
|
||||
item_map[playlist_item_name(item)] = item
|
||||
|
||||
# Build new playlist: use the mapping to preserve zoom factors
|
||||
new_playlist = []
|
||||
for key in new_order:
|
||||
if key in item_map:
|
||||
new_playlist.append(item_map[key])
|
||||
item = dict(item_map[key]) if isinstance(item_map[key], dict) else {"name": item_map[key]}
|
||||
item["enabled"] = enabled_map.get(key, True if not isinstance(item_map[key], dict) else item_map[key].get("enabled", True))
|
||||
new_playlist.append(item)
|
||||
else:
|
||||
# Item not found in mapping - add as is
|
||||
new_playlist.append(key)
|
||||
new_playlist.append({"url": key, "zoom": 1.0, "enabled": enabled_map.get(key, True)} if is_url(key) else {"name": key, "enabled": enabled_map.get(key, True)})
|
||||
|
||||
if screen == "priority":
|
||||
cfg.setdefault("priority", {})["playlist"] = new_playlist
|
||||
@@ -522,4 +637,4 @@ def save_playlist(screen):
|
||||
# Main
|
||||
# -------------------------------------------------
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True, host="0.0.0.0", port=5005)
|
||||
app.run(debug=True, host="0.0.0.0", port=5005)
|
||||
|
||||
57
config.json
57
config.json
@@ -3,36 +3,69 @@
|
||||
"enabled": true,
|
||||
"playlist": [
|
||||
{
|
||||
"url": "https://www.meteoblue.com/en/meteotv/d7b0fd",
|
||||
"zoom": 1.0
|
||||
"url": "https://wbxroompresence.cancom.io/standort?find=Stuttgart",
|
||||
"zoom": 0.8,
|
||||
"enabled": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"screens": {
|
||||
"lobby": {
|
||||
"interval": 15,
|
||||
"interval": 10,
|
||||
"show_images": true,
|
||||
"show_videos": false,
|
||||
"playlist": [
|
||||
"Hilfe_KI.jpg",
|
||||
"e00a687f-d82a-446d-b8f3-07895fbc7309.png",
|
||||
"Video_CANCOM_LIVE_2025_Stuttgart.MP4",
|
||||
"welcome.html",
|
||||
{
|
||||
"url": "https://wbxroompresence.cancom.io/standort?find=Stuttgart",
|
||||
"zoom": 0.8
|
||||
"name": "welcome.html",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"url": "https://www.meteoblue.com/en/meteotv/d7b0fd",
|
||||
"zoom": 1.0,
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"name": "Cancom_Leitsatz.JPG",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"url": "http://localhost:5005/static/heise.html",
|
||||
"zoom": 0.9,
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"name": "heise.html",
|
||||
"enabled": false
|
||||
}
|
||||
],
|
||||
"newsticker_text": "Herzlich willkommen bei der CANCOM - wir begr\u00fc\u00dfen unsere G\u00e4ste - wir w\u00fcnschen ihnen einen sch\u00f6nen Tag",
|
||||
"newsticker_text": "Herzlich Willkommen bei der CANCOM - wir begr\u00fc\u00dfen unsere G\u00e4ste und w\u00fcnschen Ihnen einen angenehmen Tag! !",
|
||||
"newsticker_enabled": true
|
||||
},
|
||||
"casino": {
|
||||
"interval": 10,
|
||||
"interval": 15,
|
||||
"show_images": true,
|
||||
"show_videos": true,
|
||||
"playlist": [
|
||||
"https://wbxroompresence.cancom.io/standort?find=Stuttgart"
|
||||
{
|
||||
"url": "https://www.meteoblue.com/en/meteotv/d7b0fd",
|
||||
"zoom": 1.0,
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "Video_CANCOM_LIVE_2025_Stuttgart.MP4",
|
||||
"enabled": true
|
||||
}
|
||||
],
|
||||
"newsticker_text": "Hallo dies ist der Newsticker",
|
||||
"newsticker_text": "Herzlich willkommen bei der CANCOM - wir w\u00fcnschen ihnen einen sch\u00f6nen Tag",
|
||||
"newsticker_enabled": true
|
||||
},
|
||||
"videosysteme": {
|
||||
"interval": 20,
|
||||
"show_images": false,
|
||||
"show_videos": false,
|
||||
"playlist": [],
|
||||
"newsticker_text": "Hallo dies ist ein Test f\u00fcr Michael",
|
||||
"newsticker_enabled": false
|
||||
}
|
||||
},
|
||||
|
||||
16
docker-compose.yml
Normal file
16
docker-compose.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
services:
|
||||
signage:
|
||||
container_name: signage
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
platforms:
|
||||
- linux/amd64
|
||||
image: gitea.teamthiele.de/ethiele/signage:latest
|
||||
ports:
|
||||
- "5005:5005"
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- OPENAI_API_KEY="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"
|
||||
- BRANDFETCH_API_KEY="eBwCQW_DcQ_jvdqZRNph0JBtRA36XoMTufaaU4AoirOBnqXX9fMqHDw7uYfiz8kSFYMNKGMZtuHxrmud9hn0WQ"
|
||||
2
env.sh
Executable file
2
env.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
export OPENAI_API_KEY="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"
|
||||
export BRANDFETCH_API_KEY="eBwCQW_DcQ_jvdqZRNph0JBtRA36XoMTufaaU4AoirOBnqXX9fMqHDw7uYfiz8kSFYMNKGMZtuHxrmud9hn0WQ"
|
||||
262
generate_welcome_page.py
Normal file
262
generate_welcome_page.py
Normal file
@@ -0,0 +1,262 @@
|
||||
import os
|
||||
import json
|
||||
from openai import OpenAI
|
||||
|
||||
# -------------------------------------------------
|
||||
# Customer / Willkommensseite
|
||||
# -------------------------------------------------
|
||||
|
||||
WELCOME_DIR = os.path.join(os.path.dirname(__file__), "media", "lobby")
|
||||
|
||||
os.makedirs(WELCOME_DIR, exist_ok=True)
|
||||
|
||||
WELCOME_FILENAME = "welcome.html"
|
||||
|
||||
def get_openai_client():
|
||||
"""Initialize OpenAI client from environment variable"""
|
||||
# api_key = os.getenv("OPENAI_API_KEY")
|
||||
api_key = "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"
|
||||
if not api_key:
|
||||
raise ValueError("OPENAI_API_KEY environment variable not set")
|
||||
return OpenAI(api_key=api_key)
|
||||
|
||||
def get_brandfetch_logo(domain):
|
||||
"""Try to fetch a logo URL from Brandfetch CDN."""
|
||||
print(f"🔍 Generate - Versuche Brandfetch für Domain: {domain}")
|
||||
# Direct CDN URL construction - Brandfetch provides logos via cdn.brandfetch.io
|
||||
logo_url = f"https://cdn.brandfetch.io/{domain}/logo?c=1idyd4Tpb2nKaXIIc8T"
|
||||
|
||||
# if validate_logo_url(logo_url):
|
||||
print(f"✅ Generate - Brandfetch Logo gefunden: {logo_url}")
|
||||
return logo_url
|
||||
|
||||
# return None
|
||||
|
||||
|
||||
def search_customer_logo(customer_name):
|
||||
print(f"✅ Generate - Suche nach Kundenlogo für: {customer_name}")
|
||||
"""Search for customer logo URL using OpenAI and web search"""
|
||||
try:
|
||||
client = get_openai_client()
|
||||
|
||||
response = client.chat.completions.create(
|
||||
model="gpt-4",
|
||||
messages=[
|
||||
{
|
||||
"role": "system",
|
||||
"content": """Du bist ein Experte für die Suche nach Domain Namen. Du findest anhand des Firmennamens die richtige Domain dazu
|
||||
Gib nur den Domain Namen zurück, keine weiteren Informationen.
|
||||
FALLBACK: Wenn du kein direkt Aufrufbare Domain findest, antworte mit "FALLBACK"."""
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": f"Finde die Domain für dasUnternehmen: {customer_name}"
|
||||
}
|
||||
],
|
||||
temperature=0.1,
|
||||
max_tokens=100
|
||||
)
|
||||
|
||||
logo_url = response.choices[0].message.content.strip()
|
||||
print (f"🔍 OpenAI Logo-URL: {logo_url}")
|
||||
if logo_url.upper() == "FALLBACK":
|
||||
logo_url = None
|
||||
|
||||
if logo_url:
|
||||
brandfetch_url = get_brandfetch_logo(logo_url)
|
||||
if brandfetch_url:
|
||||
return brandfetch_url
|
||||
|
||||
return None
|
||||
except Exception as e:
|
||||
print(f"❌ Logo search error: {e}")
|
||||
return None
|
||||
|
||||
|
||||
def generate_welcome_html(customer_name, logo_url):
|
||||
print(f"✅ Generate - Willkommensseite wird generiert für: {customer_name} mit Logo: {logo_url}")
|
||||
"""Generate a welcome page HTML with full-screen design"""
|
||||
# CANCOM SVG logo inline
|
||||
cancom_svg = '''<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xcs="https://www.xtool.com/pages/software" version="1.1" preserveAspectRatio="xMinYMin meet" width="61.682394106284505mm" height="9.909010347638684mm" viewBox="136.55880294685778 209.2954948261807 61.682394106284505 9.909010347638684" xcs:version="2.7.22"><style></style><path transform="matrix(0.158038,0,0,0.158038,133.2558,163.322122)" stroke="none" fill="currentColor" data-view-type="laser" d="M125.9,352.1h18.9L119,291.7h-16.2l-25,60.4h18.2l14.6-38.9L125.9,352.1z M323.6,322 c0,8.8-6.1,16.4-15.4,16.4c-9.1,0-15.4-7.6-15.4-16.4s6.1-16.4,15.2-16.4C317,305.6,323.6,313.4,323.6,322 M340.5,322.3 c0-17.4-13.4-31.3-32.3-31.3c-18.7,0-32.3,14.1-32.3,31.3c0,17.4,13.4,31.3,32.3,31.3C326.9,353.6,340.5,339.4,340.5,322.3 M230.4,322.5c0-8.8,6.1-16.4,14.9-16.4c3,0,5.8,0.8,8.1,2l6.6-13.4c-3-2-8.1-3.8-14.9-3.8c-18.2,0-31.6,14.1-31.6,31.3 c0,18.2,12.6,31.1,31.6,31.1c17.2,0,26-10.6,28.8-21l-13.6-5.6c-1.8,5.8-6.3,11.6-14.4,11.6C236.5,338.4,230.4,331.4,230.4,322.5 M38,322.5c0-8.8,6.1-16.4,14.9-16.4c3,0,5.8,0.8,8.1,2l6.6-13.4c-3-2-8.1-3.8-14.9-3.8c-18.4,0-31.8,14.1-31.8,31.3 c0,18.2,12.6,31.1,31.6,31.1c17.2,0,26-10.6,28.8-21l-13.6-5.6c-1.8,5.8-6.3,11.6-14.4,11.6C44,338.4,38,331.4,38,322.5 M191.8,352.1h14.4v-59.8H190v33.1l-25-33.1h-15.4v60.1h16.2v-34.1L191.8,352.1z M411.2,352.1v-59.8h-17.7l-14.4,23.2l-14.4-23.2 h-17.7v60.1h16.4V318l15.4,23.2h0.3l15.4-23.5v34.6L411.2,352.1L411.2,352.1z" fill-rule="nonzero"></path></svg>'''
|
||||
|
||||
html_content = f"""<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Willkommen bei CANCOM</title>
|
||||
|
||||
<!-- Tabler CSS -->
|
||||
<link rel="stylesheet"
|
||||
href="https://unpkg.com/@tabler/core@1.0.0-beta20/dist/css/tabler.min.css">
|
||||
<!-- Tabler JS -->
|
||||
<script defer
|
||||
src="https://unpkg.com/@tabler/core@1.0.0-beta20/dist/js/tabler.min.js">
|
||||
</script>
|
||||
|
||||
<style>
|
||||
* {{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}}
|
||||
body {{
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
font-family: 'Segoe UI', 'Helvetica Neue', sans-serif;
|
||||
background: linear-gradient(135deg, #87CEEB 0%, #B0E0E6 100%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-image: url("/static/wallpaper.png");
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
}}
|
||||
.screen {{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
justify-content: space-between;
|
||||
padding: 60px;
|
||||
background-size: cover;
|
||||
background-position: center left;
|
||||
background-repeat: no-repeat;
|
||||
}}
|
||||
.logo-section {{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 10px;
|
||||
z-index: 10;
|
||||
}}
|
||||
.cancom-logo {{
|
||||
width: 235px;
|
||||
height: auto;
|
||||
color: #DA002D;
|
||||
object-fit: contain;
|
||||
filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.1));
|
||||
}}
|
||||
.meets {{
|
||||
font-size: 2.5rem;
|
||||
font-weight: 400;
|
||||
color: #000;
|
||||
margin-top: -8px;
|
||||
margin-bottom: 10px;
|
||||
letter-spacing: 1px;
|
||||
}}
|
||||
.customer-logo {{
|
||||
max-width: 300px;
|
||||
max-height: 180px;
|
||||
width: auto;
|
||||
height: auto;
|
||||
object-fit: contain;
|
||||
filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
|
||||
margin-top: 18px;
|
||||
}}
|
||||
.customer-logo {{
|
||||
max-width: 300px;
|
||||
max-height: 180px;
|
||||
width: auto;
|
||||
height: auto;
|
||||
object-fit: contain;
|
||||
filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
|
||||
}}
|
||||
.content {{
|
||||
text-align: right;
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 30px;
|
||||
}}
|
||||
.headline {{
|
||||
font-size: 4.5rem;
|
||||
font-weight: 300;
|
||||
letter-spacing: 2px;
|
||||
line-height: 1.2;
|
||||
color: #000;
|
||||
text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.3);
|
||||
}}
|
||||
.headline .red {{
|
||||
color: #DA002D;
|
||||
font-weight: 700;
|
||||
}}
|
||||
.meets {{
|
||||
font-size: 2.5rem;
|
||||
font-weight: 400;
|
||||
color: #000;
|
||||
margin-bottom: 40px;
|
||||
letter-spacing: 1px;
|
||||
}}
|
||||
.welcome-block {{
|
||||
font-size: 4rem;
|
||||
font-weight: 700;
|
||||
line-height: 1.3;
|
||||
color: #000;
|
||||
text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.3);
|
||||
}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="screen">
|
||||
<div class="logo-section">
|
||||
<div class="cancom-logo">{cancom_svg}</div>
|
||||
<div class="meets">meets</div>
|
||||
{f'<img src="{logo_url}" alt="Kundenlogo" class="customer-logo" crossorigin="anonymous">' if logo_url else ''}
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="welcome-block">
|
||||
Herzlich <span style="color: #DA002D;">Willkommen</span><br>
|
||||
<span style="color: #DA002D;">in</span> unserer<br>
|
||||
Niederlassung <span style="color: #DA002D;">Stuttgart!</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>"""
|
||||
return html_content
|
||||
|
||||
|
||||
def save_welcome_page(customer_name, logo_url):
|
||||
"""Save welcome page and return filename"""
|
||||
try:
|
||||
filepath = os.path.join(os.path.abspath(WELCOME_DIR), WELCOME_FILENAME)
|
||||
html_content = generate_welcome_html(customer_name, logo_url)
|
||||
|
||||
with open(filepath, "w", encoding="utf-8") as f:
|
||||
f.write(html_content)
|
||||
if os.path.getsize(filepath) == 0:
|
||||
raise IOError("File not written")
|
||||
print(f"✅ Generate - Willkommensseite generiert für: {customer_name}")
|
||||
print(f"✅ Generate - Willkommensseite gespeichert in: {filepath}")
|
||||
print(f"✅ Generate - Willkommensseite gespeichert: {WELCOME_FILENAME}")
|
||||
return WELCOME_FILENAME
|
||||
except Exception as e:
|
||||
print(f"❌ Error saving welcome page: {e}")
|
||||
return None
|
||||
|
||||
|
||||
def add_customer_to_lobby_playlist(html_filename):
|
||||
"""Add customer welcome page to lobby playlist"""
|
||||
try:
|
||||
# Import here to avoid circular imports
|
||||
from app import load_config, save_config
|
||||
|
||||
config = load_config()
|
||||
screens = config.setdefault("screens", {})
|
||||
lobby = screens.setdefault("lobby", {})
|
||||
playlist = lobby.setdefault("playlist", [])
|
||||
|
||||
full_filename = f"{html_filename}"
|
||||
if full_filename in playlist:
|
||||
playlist.remove(full_filename)
|
||||
playlist.insert(0, full_filename)
|
||||
save_config(config)
|
||||
print(f"✅ Generate - Willkommensseite in Lobby-Playliste platziert")
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"❌ Generate - Error adding to playlist: {e}")
|
||||
return False
|
||||
@@ -1,3 +1,6 @@
|
||||
flask
|
||||
flask-login
|
||||
werkzeug
|
||||
openai
|
||||
requests
|
||||
urllib3
|
||||
|
||||
107
static/heise.html
Normal file
107
static/heise.html
Normal file
@@ -0,0 +1,107 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Heise News Ticker</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #F4F6F8;
|
||||
color: #212121;
|
||||
margin: 0;
|
||||
padding: 1em;
|
||||
}
|
||||
h1 {
|
||||
font-size: 1.2em;
|
||||
margin-bottom: .7em;
|
||||
color: #DA002D;
|
||||
}
|
||||
ul {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
li {
|
||||
margin-bottom: 1em;
|
||||
background: #fff;
|
||||
border-left: 6px solid #DA002D;
|
||||
padding: 0.8em 0.7em 0.8em 1em;
|
||||
font-size: 1.05em;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 6px rgba(218, 0, 45, 0.03);
|
||||
transition: box-shadow 0.2s;
|
||||
}
|
||||
li:hover {
|
||||
box-shadow: 0 4px 18px rgba(218,0,45,0.08), 0 1.5px 4px #DA002D22;
|
||||
}
|
||||
a {
|
||||
color: #DA002D;
|
||||
text-decoration: none;
|
||||
font-weight: 600;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
color: #B00024;
|
||||
}
|
||||
.time {
|
||||
display: block;
|
||||
color: #6c757d;
|
||||
font-size: 0.95em;
|
||||
font-weight: 400;
|
||||
margin-top: 0.15em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Heise TOP IT-News</h1>
|
||||
<ul id="news-list"></ul>
|
||||
<script>
|
||||
const FEED_URL = 'https://www.heise.de/rss/heise-atom.xml';
|
||||
|
||||
async function loadNews() {
|
||||
try {
|
||||
const response = await fetch(FEED_URL);
|
||||
const text = await response.text();
|
||||
const parser = new DOMParser();
|
||||
const xml = parser.parseFromString(text, 'application/xml');
|
||||
|
||||
// Atom Feed uses <entry>, not <item>
|
||||
const items = Array.from(xml.getElementsByTagName('entry')).slice(0, 6);
|
||||
const list = document.getElementById('news-list');
|
||||
if (items.length === 0) {
|
||||
list.innerHTML = '<li>Momentan keine News gefunden.</li>';
|
||||
return;
|
||||
}
|
||||
items.forEach(item => {
|
||||
const title = item.querySelector('title')?.textContent || 'Unbenannt';
|
||||
const link = item.querySelector('link')?.getAttribute('href') || '#';
|
||||
const pubDateRaw = item.querySelector('updated')?.textContent || '';
|
||||
const summaryRaw = item.querySelector('summary')?.textContent || '';
|
||||
|
||||
let formattedDate = '';
|
||||
if (pubDateRaw) {
|
||||
const d = new Date(pubDateRaw);
|
||||
// Format zu TT-MM-JJJJ hh:mm
|
||||
const pad = n => (n<10 ? '0'+n : n);
|
||||
formattedDate = `${pad(d.getDate())}.${pad(d.getMonth()+1)}.${d.getFullYear()} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
||||
}
|
||||
|
||||
const li = document.createElement('li');
|
||||
li.innerHTML = `
|
||||
<span class="time">${formattedDate}</span>
|
||||
<a href="${link}" target="_blank">${title}</a>
|
||||
<div class="summary" style="color:#555;font-size:1em;line-height:1.5;margin-top:0.35em;font-weight:400;">
|
||||
${summaryRaw}
|
||||
</div>
|
||||
`;
|
||||
list.appendChild(li);
|
||||
});
|
||||
} catch (err) {
|
||||
document.getElementById('news-list').innerHTML = '<li>Fehler beim Laden des Feeds!</li>';
|
||||
}
|
||||
}
|
||||
loadNews();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -64,6 +64,7 @@
|
||||
.playlist-row {
|
||||
display: grid;
|
||||
grid-template-columns:
|
||||
28px /* Enabled */
|
||||
1fr /* Name */
|
||||
90px /* Typ */
|
||||
80px /* Größe */
|
||||
@@ -136,6 +137,7 @@
|
||||
</a>
|
||||
|
||||
<div class="d-none d-sm-inline">
|
||||
<a href="/customer" class="btn">Willkommensseite</a>
|
||||
<a href="/logout" class="btn">Logout</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -167,7 +169,7 @@
|
||||
</p>
|
||||
|
||||
<!-- Upload -->
|
||||
<h4>Medien hochladen</h4>
|
||||
<h4>Medien hochladen - ⚠ PRIORITY Playlist</h4>
|
||||
<form action="/admin/upload/priority"
|
||||
method="post" enctype="multipart/form-data">
|
||||
<div class="input-group mb-3">
|
||||
@@ -190,13 +192,18 @@
|
||||
</form>
|
||||
|
||||
<!-- Playlist -->
|
||||
<h4>Playlist Reihenfolge</h4>
|
||||
<h4>Playlist Reihenfolge - ⚠ PRIORITY Playlist</h4>
|
||||
|
||||
<ul class="list-group mb-3" id="playlist-priority">
|
||||
{% for file in priority_files %}
|
||||
<li class="list-group-item playlist-row"
|
||||
data-file="{{ file.name }}">
|
||||
|
||||
<input class="form-check-input playlist-enabled"
|
||||
type="checkbox"
|
||||
{% if file.enabled %}checked{% endif %}
|
||||
title="Element aktivieren">
|
||||
|
||||
<span class="playlist-name"
|
||||
{% if file.type == "image" %}
|
||||
data-bs-toggle="tooltip"
|
||||
@@ -211,7 +218,7 @@
|
||||
|
||||
{% if file.type == "image" %}
|
||||
<span class="badge bg-purple text-purple-fg">Bild</span>
|
||||
{% elif file.type == "url" %}
|
||||
{% elif file.type == "url" or file.type == "html" %}
|
||||
<span class="badge bg-blue text-blue-fg">URL</span>
|
||||
{% else %}
|
||||
<span class="badge bg-orange text-orange-fg">Video</span>
|
||||
@@ -247,7 +254,7 @@
|
||||
|
||||
<button class="btn btn-primary"
|
||||
onclick="savePlaylist('priority')">
|
||||
Priority-Reihenfolge speichern
|
||||
Priority-Playlist speichern
|
||||
</button>
|
||||
|
||||
</div>
|
||||
@@ -321,7 +328,7 @@
|
||||
<hr>
|
||||
|
||||
<!-- Upload -->
|
||||
<h2>Medien hochladen / URL hinzufügen</h2>
|
||||
<h2>Medien hochladen / URL hinzufügen - {{ screen }}</h2>
|
||||
<form action="/admin/upload/{{ screen }}"
|
||||
method="post" enctype="multipart/form-data">
|
||||
<div class="input-group mb-3">
|
||||
@@ -346,13 +353,18 @@
|
||||
<hr>
|
||||
|
||||
<!-- Playlist -->
|
||||
<h2>Playlist Reihenfolge</h2>
|
||||
<h2>Playlist Reihenfolge - {{ screen }}</h2>
|
||||
|
||||
<ul class="list-group mb-3" id="playlist-{{ screen }}">
|
||||
{% for file in media_files[screen] %}
|
||||
<li class="list-group-item playlist-row"
|
||||
data-file="{{ file.name }}">
|
||||
|
||||
<input class="form-check-input playlist-enabled"
|
||||
type="checkbox"
|
||||
{% if file.enabled %}checked{% endif %}
|
||||
title="Element aktivieren">
|
||||
|
||||
<span class="playlist-name"
|
||||
{% if file.type == "image" %}
|
||||
data-bs-toggle="tooltip"
|
||||
@@ -367,7 +379,7 @@
|
||||
|
||||
{% if file.type == "image" %}
|
||||
<span class="badge bg-purple text-purple-fg">Bild</span>
|
||||
{% elif file.type == "url" %}
|
||||
{% elif file.type == "url" or file.type == "html" %}
|
||||
<span class="badge bg-blue text-blue-fg">URL</span>
|
||||
{% else %}
|
||||
<span class="badge bg-orange text-orange-fg">Video</span>
|
||||
@@ -399,7 +411,7 @@
|
||||
|
||||
<button class="btn btn-primary"
|
||||
onclick="savePlaylist('{{ screen }}')">
|
||||
Reihenfolge speichern
|
||||
Playlist speichern
|
||||
</button>
|
||||
|
||||
</div>
|
||||
@@ -447,12 +459,22 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
const items = document.querySelectorAll(
|
||||
"#playlist-" + screen + " li"
|
||||
);
|
||||
const playlist = [];
|
||||
|
||||
const enabled = {};
|
||||
items.forEach((item) => {
|
||||
const checkbox = item.querySelector(".playlist-enabled");
|
||||
const fileName = item.dataset.file;
|
||||
enabled[fileName] = !!(checkbox && checkbox.checked);
|
||||
playlist.push(fileName);
|
||||
});
|
||||
|
||||
fetch("/admin/playlist/" + screen, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
playlist: Array.from(items).map(i => i.dataset.file)
|
||||
playlist: playlist,
|
||||
enabled: enabled
|
||||
})
|
||||
}).then(() => location.reload());
|
||||
}
|
||||
@@ -470,5 +492,3 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
133
templates/customer.html
Normal file
133
templates/customer.html
Normal file
@@ -0,0 +1,133 @@
|
||||
<!doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||
<title>Kunde hinzufügen</title>
|
||||
<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||
|
||||
<link rel="stylesheet"
|
||||
href="https://unpkg.com/@tabler/core@1.0.0-beta20/dist/css/tabler.min.css">
|
||||
<script defer
|
||||
src="https://unpkg.com/@tabler/core@1.0.0-beta20/dist/js/tabler.min.js"></script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
background-color: #F4F6F8;
|
||||
color: #212121;
|
||||
}
|
||||
.navbar {
|
||||
background-color: #DA002D;
|
||||
}
|
||||
.navbar-brand,
|
||||
.navbar-brand h2,
|
||||
.navbar-brand .page-pretitle {
|
||||
color: #ffffff !important;
|
||||
}
|
||||
.card-header {
|
||||
background-color: #eeeeee;
|
||||
border-left: 6px solid #DA002D;
|
||||
padding-left: 1rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
.btn-primary {
|
||||
background-color: #DA002D;
|
||||
border-color: #DA002D;
|
||||
}
|
||||
.btn-primary:hover {
|
||||
background-color: #B00024;
|
||||
border-color: #B00024;
|
||||
}
|
||||
.form-label {
|
||||
font-weight: 600;
|
||||
}
|
||||
.card {
|
||||
box-shadow: 0 20px 60px rgba(0,0,0,0.08);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="page">
|
||||
<header class="navbar navbar-expand-md">
|
||||
<div class="container-xl">
|
||||
<a class="navbar-brand d-flex align-items-center"
|
||||
href="/admin">
|
||||
<img src="{{ url_for('static', filename='cancom.svg') }}"
|
||||
alt="CANCOM"
|
||||
height="32"
|
||||
class="me-2">
|
||||
<span class="page-pretitle text-white">
|
||||
Admin Dashboard
|
||||
<h2 class="page-title text-white">Simple Signage</h2>
|
||||
</span>
|
||||
</a>
|
||||
<div class="d-none d-sm-inline">
|
||||
<a href="/admin" class="btn">Zurück</a>
|
||||
<a href="/logout" class="btn">Logout</a>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="page-wrapper">
|
||||
<div class="container-xl mt-4">
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
<div class="page-pretitle">Willkommensseite</div>
|
||||
<h2 class="page-title">Kundeninformationen eingeben</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if error %}
|
||||
<div class="alert alert-danger">
|
||||
{{ error }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if success %}
|
||||
<div class="alert alert-success">
|
||||
{{ success }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if logo_url %}
|
||||
<div class="alert alert-secondary d-flex align-items-center gap-3">
|
||||
<div>
|
||||
<strong>Logo Vorschau</strong>
|
||||
<div class="text-muted">Wenn das Logo erfolgreich gefunden wurde, wird es hier angezeigt.</div>
|
||||
</div>
|
||||
<img src="{{ logo_url }}"
|
||||
alt="Logo Vorschau"
|
||||
class="img-fluid border"
|
||||
style="max-height: 120px; max-width: 240px; object-fit: contain;">
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<form method="POST">
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="customer_name">Kundenname</label>
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
id="customer_name"
|
||||
name="customer_name"
|
||||
placeholder="z. B. Beispiel GmbH"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 text-muted">
|
||||
<p class="mb-1">Das System sucht automatisch nach dem Kundenlogo</p>
|
||||
<p class="mb-0">und erstellt eine angepasste Willkommensseite für die Lobby-Playlist.</p>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Kundenlogo & Willkommensseite generieren
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -131,6 +131,9 @@ function normalizeItem(item) {
|
||||
if (item.kind === "url" && !("zoom" in item)) {
|
||||
item.zoom = 1.0;
|
||||
}
|
||||
if (!("enabled" in item)) {
|
||||
item.enabled = true;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -142,32 +145,38 @@ function isImage(item) {
|
||||
return item.kind === "file" && /\.(jpg|jpeg|png)$/i.test(item.name);
|
||||
}
|
||||
|
||||
function isHtml(item) {
|
||||
return item.kind === "file" && /\.(html?|htm)$/i.test(item.name);
|
||||
}
|
||||
|
||||
function getNextItem() {
|
||||
const normalizedNormal = normalFiles.map(normalizeItem);
|
||||
const normalizedPrio = prioFiles.map(normalizeItem);
|
||||
const activeNormal = normalizedNormal.filter(item => item.enabled !== false);
|
||||
const activePrio = normalizedPrio.filter(item => item.enabled !== false);
|
||||
|
||||
// ✅ Sonderfall: nur Priority vorhanden
|
||||
if (normalizedNormal.length === 0 && normalizedPrio.length > 0) {
|
||||
if (activeNormal.length === 0 && activePrio.length > 0) {
|
||||
return {
|
||||
item: normalizedPrio[prioIndex++ % normalizedPrio.length],
|
||||
item: activePrio[prioIndex++ % activePrio.length],
|
||||
isPrio: true
|
||||
};
|
||||
}
|
||||
|
||||
// ✅ Sonderfall: nur normale Playlist vorhanden
|
||||
if (normalizedPrio.length === 0 && normalizedNormal.length > 0) {
|
||||
if (activePrio.length === 0 && activeNormal.length > 0) {
|
||||
return {
|
||||
item: normalizedNormal[normalIndex++ % normalizedNormal.length],
|
||||
item: activeNormal[normalIndex++ % activeNormal.length],
|
||||
isPrio: false
|
||||
};
|
||||
}
|
||||
|
||||
// ✅ Normal-Phase
|
||||
if (mode === "normal") {
|
||||
const item = normalizedNormal[normalIndex++];
|
||||
if (normalIndex >= normalizedNormal.length) {
|
||||
const item = activeNormal[normalIndex++];
|
||||
if (normalIndex >= activeNormal.length) {
|
||||
normalIndex = 0;
|
||||
if (normalizedPrio.length > 0) {
|
||||
if (activePrio.length > 0) {
|
||||
mode = "prio"; // ➜ nach kompletter Normal-Playlist wechseln
|
||||
}
|
||||
}
|
||||
@@ -176,8 +185,8 @@ function getNextItem() {
|
||||
|
||||
// ✅ Priority-Phase
|
||||
if (mode === "prio") {
|
||||
const item = normalizedPrio[prioIndex++];
|
||||
if (prioIndex >= normalizedPrio.length) {
|
||||
const item = activePrio[prioIndex++];
|
||||
if (prioIndex >= activePrio.length) {
|
||||
prioIndex = 0;
|
||||
mode = "normal"; // ➜ nach kompletter Priority zurück
|
||||
}
|
||||
@@ -234,6 +243,13 @@ function playNext() {
|
||||
vid.src = src;
|
||||
vid.onended = playNext;
|
||||
vid.play();
|
||||
} else if (isHtml(item)) {
|
||||
iframe.style.display = "block";
|
||||
iframe.src = src;
|
||||
iframe.style.width = `100vw`;
|
||||
iframe.style.height = `100vh`;
|
||||
iframe.style.transform = `translate(-50%, -50%)`;
|
||||
setTimeout(playNext, interval);
|
||||
} else {
|
||||
img.style.display = "block";
|
||||
img.src = src;
|
||||
@@ -269,4 +285,3 @@ setInterval(checkForUpdates, 5000);
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user