# Conflicts:
#	client/icons/close-144.png
#	client/icons/stat-100.png
This commit is contained in:
Eduard Wisch 2025-04-28 11:09:48 +02:00
commit d5e8c0b034
9 changed files with 53 additions and 19 deletions

View file

@ -3,10 +3,10 @@ log_level: DEBUG
log_rotation: time log_rotation: time
path_file: "media_path.yaml" path_file: "media_path.yaml"
server_ip: "0.0.0.0" server_ip: "0.0.0.0"
extern_http_url: localhost extern_http_url: localhost:8080
webserver_port: 8080 webserver_port: 8080
webserver_https: 0 webserver_https: 0
extern_websocket_url: localhost extern_websocket_url: localhost:8000
websocket_port: 8000 websocket_port: 8000
websocket_https: 0 websocket_https: 0
task_max: 1 task_max: 1

2
app/class_file_convert.py Normal file → Executable file
View file

@ -48,6 +48,7 @@ class Convert:
logging.info(f"Starte Konvertierung: {command}") logging.info(f"Starte Konvertierung: {command}")
await self.obj_websocket.send_websocket(self.obj_path.active_path_to_dict()) await self.obj_websocket.send_websocket(self.obj_path.active_path_to_dict())
await self.obj_websocket.send_websocket(self.obj_path.queue_path_to_dict())
try: try:
# Starte den Subprozess asynchron # Starte den Subprozess asynchron
@ -79,6 +80,7 @@ class Convert:
await self.obj_websocket.send_websocket(obj.to_dict()) await self.obj_websocket.send_websocket(obj.to_dict())
await self.obj_websocket.send_websocket(self.obj_path.active_path_to_dict()) await self.obj_websocket.send_websocket(self.obj_path.active_path_to_dict())
await self.obj_websocket.send_websocket(self.obj_path.queue_path_to_dict())
self.active_process.discard(obj) self.active_process.discard(obj)
self.active_tasks.discard(obj) self.active_tasks.discard(obj)
self.obj_path.save_paths() self.obj_path.save_paths()

0
app/class_file_convert_read_out.py Normal file → Executable file
View file

9
app/class_file_path.py Normal file → Executable file
View file

@ -185,4 +185,13 @@ class Path:
return {"data_convert": list_active_paths} return {"data_convert": list_active_paths}
def queue_path_to_dict(self):
list_active_paths = {}
for obj in self.paths.values():
if obj.status is None:
list_active_paths.update({obj.id: obj.to_dict_active_paths()})
return {"data_queue": list_active_paths}

0
app/class_media_file.py Normal file → Executable file
View file

0
app/class_media_file_stat.py Normal file → Executable file
View file

0
app/class_settings.py Normal file → Executable file
View file

19
app/main_server.py Normal file → Executable file
View file

@ -43,6 +43,7 @@ class Server:
if websocket not in self.clients: if websocket not in self.clients:
self.clients.add(websocket) self.clients.add(websocket)
await self.send_websocket(self.obj_path.active_path_to_dict()) await self.send_websocket(self.obj_path.active_path_to_dict())
await self.send_websocket(self.obj_path.queue_path_to_dict())
try: try:
async for message in websocket: async for message in websocket:
@ -50,6 +51,7 @@ class Server:
if data.get("data_path"): if data.get("data_path"):
self.obj_path.receive_paths(data.get("data_path")) self.obj_path.receive_paths(data.get("data_path"))
await self.send_websocket(self.obj_path.queue_path_to_dict())
if var_convert_active == False and self.yaml['autostart']: if var_convert_active == False and self.yaml['autostart']:
await self.obj_convert.snake_waiting() await self.obj_convert.snake_waiting()
@ -84,31 +86,24 @@ class Server:
# WebServer -------------------------------------------------------------------------------------------------------- # WebServer --------------------------------------------------------------------------------------------------------
# noinspection PyUnusedLocal
@staticmethod @staticmethod
async def handle_index(request): async def handle_index(request):
query = request.rel_url.query
if "debug" in query:
logging.info("Debug-Modus aktiv beim Seitenaufruf")
return web.FileResponse("./client/index.html") return web.FileResponse("./client/index.html")
# noinspection PyUnusedLocal
async def handle_ip(self, request): async def handle_ip(self, request):
query = request.rel_url.query
if "debug" in query:
logging.info("Debug-Modus aktiv beim Seitenaufruf")
url = self.yaml["extern_websocket_url"] url = self.yaml["extern_websocket_url"]
port = self.yaml["websocket_port"] port = self.yaml["websocket_port"]
websocket_https = self.yaml["websocket_https"] websocket_https = self.yaml["websocket_https"]
return web.json_response({"extern_websocket_url": url, "websocket_port": port, "websocket_https": websocket_https}) return web.json_response({"extern_websocket_url": url, "websocket_port": port, "websocket_https": websocket_https})
# noinspection PyUnusedLocal
@staticmethod @staticmethod
async def handle_stat(request): async def handle_stat(request):
query = request.rel_url.query
if "debug" in query:
logging.info("Debug-Modus aktiv beim Seitenaufruf")
obj_stat = Stat() obj_stat = Stat()
return web.json_response(obj_stat.read_stat()) return web.json_response(obj_stat.read_stat())
async def server_http(self): async def server_http(self):

View file

@ -17,20 +17,19 @@ async function getMediaStat() {
getServerConfig() getServerConfig()
.then(data => { .then(data => {
const externWebsocketUrl = data.extern_websocket_url; const externWebsocketUrl = data.extern_websocket_url;
const websocketPort = data.websocket_port;
const websocketHttps = data.websocket_https const websocketHttps = data.websocket_https
if (websocketHttps === 1){ if (websocketHttps === 1){
connect = "wss" connect = `wss://${externWebsocketUrl}`
} else { } else {
connect = "ws" connect = `ws://${externWebsocketUrl}`
} }
const ws = new WebSocket(`${connect}://${externWebsocketUrl}:${websocketPort}`); const ws = new WebSocket(connect);
ws.onopen = function() { ws.onopen = function() {
console.log("WebSocket ist geöffnet"); console.log("WebSocket ist geöffnet");
ws.send(JSON.stringify({"data_message": "Server Adresse: " + externWebsocketUrl + ":" + websocketPort})); ws.send(JSON.stringify({"data_message": "Server Adresse: " + externWebsocketUrl}));
}; };
ws.onmessage = function(messageEvent) { ws.onmessage = function(messageEvent) {
@ -42,6 +41,8 @@ getServerConfig()
updateVideoElement(packet); updateVideoElement(packet);
} else if(packet.data_convert !== undefined){ } else if(packet.data_convert !== undefined){
createVideoElement(packet); createVideoElement(packet);
} else if(packet.data_queue !== undefined){
createWaitingSnake(packet);
} }
} catch (e){ } catch (e){
console.error("Error parsing data flow"); console.error("Error parsing data flow");
@ -99,6 +100,33 @@ function createVideoElement(packet){
}); });
} }
function createWaitingSnake(packet){
const queue = document.getElementById('queue');
Object.keys(packet.data_queue).forEach(key => {
const video = packet.data_queue[key];
if(!videoActive[key]){
const card = document.createElement('div');
card.className = 'video-card';
card.id = key
card.innerHTML = `
<h3 title="${video.source_path}" align="center">${video.source_file_name}</h3>
<div>
<div class="delete-button"><img src="/client/icons/muell-128.png" class="conversion_icons"></div>
</div>
<div class="tooltip">
Quelle: ${video.key}<br>
</div>`;
queue.appendChild(card)
videoActive[key] = video;
}
});
}
function updateVideoElement(packet){ function updateVideoElement(packet){
let video = packet.data_flow; let video = packet.data_flow;
let container = document.getElementById(video.id); let container = document.getElementById(video.id);