diff --git a/.idea/ForrestHub.iml b/.idea/ForrestHub.iml index 0be6369..1036da2 100644 --- a/.idea/ForrestHub.iml +++ b/.idea/ForrestHub.iml @@ -1,8 +1,10 @@ - - + + + + diff --git a/ForrestHub-app/ForrestHub-data.json b/ForrestHub-app/ForrestHub-data.json index 9d3baf3..29287b8 100644 --- a/ForrestHub-app/ForrestHub-data.json +++ b/ForrestHub-app/ForrestHub-data.json @@ -1 +1 @@ -{"records": [{"id": 1, "time": "16:16:48", "date": "22/09/2024"}, {"id": 2, "time": "16:16:49", "date": "22/09/2024"}, {"id": 3, "time": "16:16:49", "date": "22/09/2024"}, {"id": 4, "time": "16:16:50", "date": "22/09/2024"}, {"id": 5, "time": "16:24:44", "date": "22. 9. 2024"}, {"id": 6, "time": "4:24:48 PM", "date": "9/22/2024"}, {"id": 7, "time": "22:46:52", "date": "22/09/2024"}, {"id": 8, "time": "22:46:53", "date": "22/09/2024"}, {"id": 9, "time": "22:46:54", "date": "22/09/2024"}, {"id": 10, "time": "22:46:56", "date": "22/09/2024"}, {"id": 11, "time": "22:46:57", "date": "22/09/2024"}, {"id": 12, "time": "22:46:58", "date": "22/09/2024"}, {"id": 13, "time": "22:47:47", "date": "22/09/2024"}, {"id": 14, "time": "22:47:48", "date": "22/09/2024"}, {"id": 15, "time": "22:47:49", "date": "22/09/2024"}], "prijem_queue": [], "odeslani_queue": [], "los_queue": [], "numbersList": ["1234"]} \ No newline at end of file +{"device_8639": {"T\u00fdm A": 1.696, "T\u00fdm B+": 9.591, "T\u00fdm C+": 13.205, "T\u00fdm D+": 200.69199999999998}, "game_config": {"teamCount": 4, "teamNames": ["T\u00fdm A", "T\u00fdm B", "T\u00fdm C", "T\u00fdm D-"], "slowdown": 1000}, "device_1950": {"T\u00fdm A": 0, "T\u00fdm B": 0, "T\u00fdm C": 0, "T\u00fdm D": 0}, "device_9669": {"T\u00fdm A": 1.562, "T\u00fdm B": 14.672999999999998, "T\u00fdm C": 25.554000000000002, "T\u00fdm D": 162.25}, "device_7932": {"T\u00fdm A": 77.605, "T\u00fdm B": 3.4, "T\u00fdm C": null, "T\u00fdm D": 0}, "slowdown": 1000, "device_8412": {"T\u00fdm A": 126.43360000000001, "T\u00fdm B": null, "T\u00fdm C": 1962.7977999999996, "T\u00fdm D": 2.1998}, "device_1502": {"T\u00fdm A": 618.3, "T\u00fdm B": null, "T\u00fdm C": null, "T\u00fdm D": 5961.326700000001}, "device_1011": {"T\u00fdm A": null, "T\u00fdm B": 100.9, "T\u00fdm C": 199.89999999999998, "T\u00fdm D": 55.5}, "device_2292": {"T\u00fdm A": 1, "T\u00fdm B": 1, "T\u00fdm C": 12.962000000000002, "T\u00fdm D-": 2}, "device_4096": {"T\u00fdm A": 0, "T\u00fdm B": 0, "T\u00fdm C": 0, "T\u00fdm D-": 0}, "device_7985": {"T\u00fdm A": 0, "T\u00fdm B": 9.001, "T\u00fdm C": 0.068, "T\u00fdm D-": 0}, "device_3439": {"T\u00fdm A": 6.375, "T\u00fdm B": 4.324, "T\u00fdm C": 5.667, "T\u00fdm D-": 3}, "los_queue": [{"number": 246, "time": "01:58:07", "category": "los_queue"}], "odeslani_queue": [{"number": 360, "time": "01:58:08", "category": "odeslani_queue"}], "numbersList": ["1234", "1233"], "team_times": {"A": 0, "B": 0, "C": 0, "D": 1.251}, "active_team": "D", "records": [{"id": 1, "time": "12:53:55", "date": "27/09/2024"}, {"id": 2, "time": "12:53:55", "date": "27/09/2024"}, {"id": 3, "time": "12:53:56", "date": "27/09/2024"}, {"id": 4, "time": "12:53:56", "date": "27/09/2024"}, {"id": 5, "time": "12:53:57", "date": "27/09/2024"}], "generatedNumber": {"number": 854, "time": "13:07:47"}} \ No newline at end of file diff --git a/ForrestHub-app/app/custom_loader.py b/ForrestHub-app/app/custom_loader.py index 984c61d..70160a9 100644 --- a/ForrestHub-app/app/custom_loader.py +++ b/ForrestHub-app/app/custom_loader.py @@ -9,15 +9,13 @@ class CustomLoader(FileSystemLoader): def get_source(self, environment, template): if template.startswith("templates/"): - # {% include 'templates/header.html' %} - if current_app.config.get("LIVE_DATA_USED") and current_app.config.get("LIVE_DATA_FOLDER").exists(): - template_path = pathlib.Path(current_app.config["TEMPLATES_FOLDER_LIVE"]) / template[10:] - else: - template_path = pathlib.Path(current_app.config["TEMPLATES_FOLDER"]) / template[10:] - elif current_app.config.get("LIVE_DATA_USED") and Path(current_app.config["GAMES_FOLDER_LIVE"]/template).exists(): + template_path = pathlib.Path(current_app.config["TEMPLATES_FOLDER"]) / template[10:] + elif current_app.config.get("LIVE_GAMES_MODE") and Path(current_app.config["GAMES_FOLDER_LIVE"]/template).exists(): template_path = pathlib.Path(current_app.config["GAMES_FOLDER_LIVE"]) / template elif Path(current_app.config["GAMES_FOLDER"]/template).exists(): template_path = pathlib.Path(current_app.config["GAMES_FOLDER"]) / template + elif Path(current_app.config["PAGES_FOLDER"]/template).exists(): + template_path = pathlib.Path(current_app.config["PAGES_FOLDER"]) / template else: template_path = pathlib.Path(current_app.config["TEMPLATES_FOLDER"]) / "menu.html" @@ -26,7 +24,7 @@ def get_source(self, environment, template): with open( template_path, "r", encoding="utf-8" - ) as f: # Specify the encoding here + ) as f: source = f.read() mtime = os.path.getmtime(template_path) return source, template_path, lambda: mtime == os.path.getmtime(template_path) diff --git a/ForrestHub-app/app/init.py b/ForrestHub-app/app/init.py index 19ca5ba..c1810dc 100644 --- a/ForrestHub-app/app/init.py +++ b/ForrestHub-app/app/init.py @@ -23,12 +23,11 @@ def create_app(config_class="config.Config"): app.config.get("GAMES_FOLDER"), app.config.get("TEMPLATES_FOLDER"), app.config.get("ASSETS_FOLDER"), + app.config.get("PAGES_FOLDER"), ] - if app.config.get("LIVE_DATA_USED"): + if app.config.get("LIVE_GAMES_MODE"): loader_locations.append(app.config.get("GAMES_FOLDER_LIVE")) - loader_locations.append(app.config.get("TEMPLATES_FOLDER_LIVE")) - loader_locations.append(app.config.get("ASSETS_FOLDER_LIVE")) app.jinja_loader = CustomLoader(loader_locations) diff --git a/ForrestHub-app/app/routes.py b/ForrestHub-app/app/routes.py index 8ec2b81..b67bec4 100644 --- a/ForrestHub-app/app/routes.py +++ b/ForrestHub-app/app/routes.py @@ -1,3 +1,4 @@ +from http.cookiejar import debug from pathlib import Path from app.init import db @@ -18,8 +19,11 @@ def get_html_and_folders(folder: Path): res = [] + ignore = [".git", ".vscode", "__pycache__", "node_modules"] if folder.exists(): for folder_iter in folder.iterdir(): + if folder_iter.name in ignore: + continue if folder_iter.is_dir(): res.append( { @@ -52,7 +56,10 @@ def get_selected_level_routes(folder: str): @main.route("/") def index(): return render_template( - "index.html", title="Menu", same_level_routes=get_selected_level_routes(".") + "index.html", + title="Menu", + same_level_routes=get_selected_level_routes("."), + debug=current_app.config.get("DEBUG"), ) @@ -125,6 +132,7 @@ def render_page(folder: str, page: str): data=db.get_data(), ip_address=get_local_ip_address(), config=current_app.config, + debug=current_app.config.get("DEBUG"), same_level_routes=get_selected_level_routes(folder), ) diff --git a/ForrestHub-app/app/socketio_events.py b/ForrestHub-app/app/socketio_events.py index afb8976..3d4880a 100644 --- a/ForrestHub-app/app/socketio_events.py +++ b/ForrestHub-app/app/socketio_events.py @@ -3,10 +3,22 @@ from app.init import socketio, db +from flask import ( + Blueprint, + render_template, + abort, + send_from_directory, + current_app, + jsonify, + request, +) + socketio_bp = Blueprint("socketio", __name__) connected_clients = 0 connected_admins = 0 + + game_status = "running" @@ -86,3 +98,96 @@ def handle_get_key(json: dict) -> dict: def handle_delete_key(key: str) -> dict: db.delete_data_key(key) return {"status": "ok"} + + +# add_new_game - create folder with game name +@socketio.on("add_new_game") +def handle_add_new_game(game_name: str) -> dict: + game_folder = current_app.config.get("GAMES_FOLDER") + if not game_folder: + return {"status": "error", "message": "No live data folder"} + + game_folder = game_folder / game_name + + if game_folder.exists(): + return {"status": "error", "message": "Game already exists"} + game_folder.mkdir() + return {"status": "ok"} + + + +# add_new_game_page - create new page in game folder +@socketio.on("add_new_game_page") +def handle_add_new_game_page(json: dict) -> dict: + game_name = json.get("game") + game_page = json.get("page") + page_content = json.get("content") + + + game_folder = current_app.config.get("GAMES_FOLDER_LIVE") + if not game_folder: + return {"status": "error", "message": "No live data folder"} + + game_folder = game_folder / game_name + + if not game_folder.exists(): + game_folder.mkdir() + + page_path = game_folder / f"{game_page}.html" + if page_path.exists(): + return {"status": "error", "message": "Page already exists"} + + with open(page_path, "w") as f: + f.write(page_content) + return {"status": "ok"} + +# get_page_html - get html content of page +@socketio.on("get_page_html") +def handle_get_page_html(json: dict) -> dict: + game_name = json.get("game") + game_page = json.get("page") + + game_folder = current_app.config.get("GAMES_FOLDER_LIVE") + if not game_folder: + return {"status": "error", "message": "No live data folder"} + + game_folder = game_folder / game_name + + if not game_folder.exists(): + return {"status": "error", "message": "Tuhle hru nemám k editaci"} + + page_path = game_folder / f"{game_page}.html" + if not page_path.exists(): + return {"status": "error", "message": "Tuhle stránku hry nemám k editaci"} + + with open(page_path, "r") as f: + content = f.read() + return {"status": "ok", "content": content} + +# set_page_html - set html content of page +@socketio.on("set_page_html") +def handle_set_page_html(json: dict) -> dict: + game_name = json.get("game") + game_page = json.get("page") + page_content = json.get("content") + + header = "{% extends" + if header not in page_content: + return {"status": "error", "message": f"Zapomněli jste přidat {header}... na začátek souboru - mrkni na příklady"} + + game_folder = current_app.config.get("GAMES_FOLDER_LIVE") + if not game_folder: + return {"status": "error", "message": "No live data folder"} + + game_folder = game_folder / game_name + + if not game_folder.exists(): + return {"status": "error", "message": "Game does not exist"} + + page_path = game_folder / f"{game_page}.html" + if not page_path.exists(): + return {"status": "error", "message": "Page does not exist"} + + with open(page_path, "w") as f: + f.write(page_content) + return {"status": "ok"} \ No newline at end of file diff --git a/ForrestHub-app/assets/img/ForrestHub-helceletka.png b/ForrestHub-app/assets/img/ForrestHub-helceletka.png new file mode 100644 index 0000000..07370ef Binary files /dev/null and b/ForrestHub-app/assets/img/ForrestHub-helceletka.png differ diff --git a/ForrestHub-app/assets/img/ForrestHub-helceletka.svg b/ForrestHub-app/assets/img/ForrestHub-helceletka.svg new file mode 100644 index 0000000..7117ca6 --- /dev/null +++ b/ForrestHub-app/assets/img/ForrestHub-helceletka.svg @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ForrestHub-app/assets/img/ForrestHub-icon-b.png b/ForrestHub-app/assets/img/ForrestHub-icon-b.png new file mode 100644 index 0000000..4818327 Binary files /dev/null and b/ForrestHub-app/assets/img/ForrestHub-icon-b.png differ diff --git a/ForrestHub-app/assets/img/ForrestHub-icon.png b/ForrestHub-app/assets/img/ForrestHub-icon.png new file mode 100644 index 0000000..c07ebaf Binary files /dev/null and b/ForrestHub-app/assets/img/ForrestHub-icon.png differ diff --git a/ForrestHub-app/assets/img/ForrestHub-icon.svg b/ForrestHub-app/assets/img/ForrestHub-icon.svg new file mode 100644 index 0000000..f3acf60 Binary files /dev/null and b/ForrestHub-app/assets/img/ForrestHub-icon.svg differ diff --git a/ForrestHub-app/assets/img/ForrestHub-tech.png b/ForrestHub-app/assets/img/ForrestHub-tech.png new file mode 100644 index 0000000..0d9c58c Binary files /dev/null and b/ForrestHub-app/assets/img/ForrestHub-tech.png differ diff --git a/ForrestHub-app/assets/img/ForrestHub-tech.svg b/ForrestHub-app/assets/img/ForrestHub-tech.svg new file mode 100644 index 0000000..2b491d8 --- /dev/null +++ b/ForrestHub-app/assets/img/ForrestHub-tech.svg @@ -0,0 +1,236 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Technologie + v táborové pedagogice + + + + diff --git a/ForrestHub-app/assets/img/ForrestHub.png b/ForrestHub-app/assets/img/ForrestHub.png new file mode 100644 index 0000000..c6c16cc Binary files /dev/null and b/ForrestHub-app/assets/img/ForrestHub.png differ diff --git a/ForrestHub-app/assets/img/ForrestHub.svg b/ForrestHub-app/assets/img/ForrestHub.svg new file mode 100644 index 0000000..9702cb1 --- /dev/null +++ b/ForrestHub-app/assets/img/ForrestHub.svg @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ForrestHub-app/assets/img/helceletka.svg b/ForrestHub-app/assets/img/Helceletka.svg similarity index 100% rename from ForrestHub-app/assets/img/helceletka.svg rename to ForrestHub-app/assets/img/Helceletka.svg diff --git a/ForrestHub-app/assets/img/forrestHub.png b/ForrestHub-app/assets/img/forrestHub.png deleted file mode 100644 index a91ca79..0000000 Binary files a/ForrestHub-app/assets/img/forrestHub.png and /dev/null differ diff --git a/ForrestHub-app/assets/img/forrestHubIcon.ico b/ForrestHub-app/assets/img/forrestHubIcon.ico deleted file mode 100644 index 9664b85..0000000 Binary files a/ForrestHub-app/assets/img/forrestHubIcon.ico and /dev/null differ diff --git a/ForrestHub-app/assets/img/forrestHubIcon.png b/ForrestHub-app/assets/img/forrestHubIcon.png deleted file mode 100644 index 1498ed4..0000000 Binary files a/ForrestHub-app/assets/img/forrestHubIcon.png and /dev/null differ diff --git a/ForrestHub-app/assets/js/forrestHubLib.js b/ForrestHub-app/assets/js/forrestHubLib.js index a2dfea7..43c1019 100644 --- a/ForrestHub-app/assets/js/forrestHubLib.js +++ b/ForrestHub-app/assets/js/forrestHubLib.js @@ -66,7 +66,10 @@ class ForrestHubLib { if (response && response.status === 'ok') { resolve(response); } else { - const message = `Chyba při zpracování události: ${event}`; + let message = `Chyba při zpracování události: ${event}`; + if (response && response.message) { + message = response.message; + } console.error(message); this.showOverlay(message, null); reject(new Error(message)); @@ -236,3 +239,5 @@ class ForrestHubLib { } } } + +window.forrestHubLib = new ForrestHubLib(); diff --git a/ForrestHub-app/config.py b/ForrestHub-app/config.py index dd253e2..32afa8b 100644 --- a/ForrestHub-app/config.py +++ b/ForrestHub-app/config.py @@ -11,9 +11,10 @@ class Config: ALLOWED_EXTENSIONS = ["json"] TEMPLATES_DIR = "templates" GAMES_DIR = "games" + GAMES_DIR_LIVE = "ForrestHub-games" ASSETS_DIR = "assets" + PAGES_DIR = "pages" - LIVE_DATA_DIR = "forrestHub-live" IP_ADDRESS = get_local_ip_address() DEBUG = True @@ -31,32 +32,18 @@ class Config: DATA_DIR = EXECUTABLE_DIR # use live data if it exists - LIVE_DATA_FOLDER = Path(EXECUTABLE_DIR) / LIVE_DATA_DIR TEMPLATES_FOLDER = Path(DATA_DIR) / TEMPLATES_DIR GAMES_FOLDER = Path(DATA_DIR) / GAMES_DIR ASSETS_FOLDER = Path(DATA_DIR) / ASSETS_DIR - LIVE_DATA_USED = False + PAGES_FOLDER = Path(DATA_DIR) / PAGES_DIR - if LIVE_DATA_FOLDER.exists(): - LIVE_DATA_USED = True - TEMPLATES_FOLDER_LIVE = Path(LIVE_DATA_FOLDER) / TEMPLATES_DIR - GAMES_FOLDER_LIVE = Path(LIVE_DATA_FOLDER) / GAMES_DIR - ASSETS_FOLDER_LIVE = Path(LIVE_DATA_FOLDER) / ASSETS_DIR + LIVE_GAMES_MODE = False + GAMES_FOLDER_LIVE = Path(EXECUTABLE_DIR) / GAMES_DIR_LIVE - # check if exist - if not TEMPLATES_FOLDER_LIVE.exists(): - TEMPLATES_FOLDER_LIVE = None - # raise FileNotFoundError(f"Templates folder not found: {TEMPLATES_FOLDER}") - - if not GAMES_FOLDER_LIVE.exists(): - GAMES_FOLDER_LIVE = None - # raise FileNotFoundError(f"Games folder not found: {GAMES_FOLDER}") - - if not ASSETS_FOLDER_LIVE.exists(): - ASSETS_FOLDER_LIVE = None - # raise FileNotFoundError(f"Assets folder not found: {ASSETS_FOLDER}") + if GAMES_FOLDER_LIVE.exists(): + LIVE_GAMES_MODE = True # Disable debug and reloader when using frozen data with live data - production mode - if not LIVE_DATA_USED and FROZEN: + if not LIVE_GAMES_MODE and FROZEN: DEBUG = False USE_RELOADER = False diff --git "a/ForrestHub-app/games/Nedokon\304\215en\303\251 k\303\263dy/QRgen.html" "b/ForrestHub-app/games/Nedokon\304\215en\303\251 k\303\263dy/QRgen.html" new file mode 100644 index 0000000..b8a9714 --- /dev/null +++ "b/ForrestHub-app/games/Nedokon\304\215en\303\251 k\303\263dy/QRgen.html" @@ -0,0 +1,480 @@ + + + + + + Investiční aplikace + + + +
+
+

Investment

+
+ + +
+
+ +
+ + + +
+
+
+
Yes
+ +
+
+

Outcome

+
+
+ + + + + +
+
+ + +
+
+
+
+
+
+
+
+

Investment Log

+
+
+ + + + diff --git "a/ForrestHub-app/games/Robo\305\241roti\305\241t\304\233 (2024)/Robosroti-dilna-pocitadlo.html" "b/ForrestHub-app/games/Robo\305\241roti\305\241t\304\233 (2024)/Robosroti-dilna-pocitadlo.html" new file mode 100644 index 0000000..d7f0c4e --- /dev/null +++ "b/ForrestHub-app/games/Robo\305\241roti\305\241t\304\233 (2024)/Robosroti-dilna-pocitadlo.html" @@ -0,0 +1,248 @@ +{% extends "templates/base.html" %} +{% set game_name = "Pořadové číslo a čas" %} +{% block content %} + + + + +
+
+ +
+
+ +
+

Výrobní log

+ +
+ + + +{% endblock %} \ No newline at end of file diff --git "a/ForrestHub-app/games/V\303\275m\304\233na identit (2024)/Vymena tel.html" "b/ForrestHub-app/games/V\303\275m\304\233na identit (2024)/Vymena tel.html" new file mode 100644 index 0000000..f04e4aa --- /dev/null +++ "b/ForrestHub-app/games/V\303\275m\304\233na identit (2024)/Vymena tel.html" @@ -0,0 +1,122 @@ +{% extends "templates/base.html" %} +{% set game_name = "Pořadové číslo a čas" %} +{% block content %} + + +
+

Zadej přístupový kód:

+
+ + + + +
+
+
+ + + +{% endblock %} diff --git a/ForrestHub-app/games/demo/decrement.js b/ForrestHub-app/games/demo/decrement.js index 68f21e1..b606d58 100644 --- a/ForrestHub-app/games/demo/decrement.js +++ b/ForrestHub-app/games/demo/decrement.js @@ -1,4 +1,4 @@ -const forrestHubLib = new ForrestHubLib(); +forrestHubLib = window.forrestHubLib || new ForrestHubLib(); document.addEventListener('DOMContentLoaded', function () { const counterElement = document.getElementById('counter'); diff --git a/ForrestHub-app/games/demo/increment.html b/ForrestHub-app/games/demo/increment.html index 254f0c4..125bcbc 100644 --- a/ForrestHub-app/games/demo/increment.html +++ b/ForrestHub-app/games/demo/increment.html @@ -10,14 +10,14 @@

Demo úkázka použití šablony

+ +{% endblock %} diff --git a/ForrestHub-app/games/dobyvatel-jeden-graf/b.html b/ForrestHub-app/games/dobyvatel-jeden-graf/b.html new file mode 100644 index 0000000..4cff6d0 --- /dev/null +++ b/ForrestHub-app/games/dobyvatel-jeden-graf/b.html @@ -0,0 +1,58 @@ +{% extends "templates/base.html" %} +{% set game_name = "Obsazování území - Tabule" %} +{% block content %} +
+

Stav obsazení území

+ +
+ + + + +{% endblock %} diff --git "a/ForrestHub-app/games/dobyvatel-v\303\255ce graf\305\257-adv/a.html" "b/ForrestHub-app/games/dobyvatel-v\303\255ce graf\305\257-adv/a.html" new file mode 100644 index 0000000..ae3de34 --- /dev/null +++ "b/ForrestHub-app/games/dobyvatel-v\303\255ce graf\305\257-adv/a.html" @@ -0,0 +1,94 @@ +{% extends "templates/base.html" %} +{% set game_name = "Obsazování území - Odesílací stránka" %} +{% block content %} +
+

Obsazování území - Odesílací stránka

+

Název odesílací stránky:

+
+ + + + +
+

Aktuální tým: Žádný

+ + +
+ +
+
+ + + + +{% endblock %} diff --git "a/ForrestHub-app/games/dobyvatel-v\303\255ce graf\305\257-adv/b.html" "b/ForrestHub-app/games/dobyvatel-v\303\255ce graf\305\257-adv/b.html" new file mode 100644 index 0000000..a858901 --- /dev/null +++ "b/ForrestHub-app/games/dobyvatel-v\303\255ce graf\305\257-adv/b.html" @@ -0,0 +1,84 @@ +{% extends "templates/base.html" %} +{% set game_name = "Obsazování území - Tabule" %} +{% block content %} +
+

Stav obsazení území ze všech zařízení

+
+ +
+
+ + + + +{% endblock %} diff --git "a/ForrestHub-app/games/dobyvatel-v\303\255ce graf\305\257/a.html" "b/ForrestHub-app/games/dobyvatel-v\303\255ce graf\305\257/a.html" new file mode 100644 index 0000000..853b1fa --- /dev/null +++ "b/ForrestHub-app/games/dobyvatel-v\303\255ce graf\305\257/a.html" @@ -0,0 +1,101 @@ +{% extends "templates/base.html" %} +{% set game_name = "Obsazování území - Konfigurace" %} +{% block content %} +
+

Konfigurace hry

+
+
+ + +
+
+ +
+ +{# set slowdown #} + + + +
+
+ +
+ + + +
+
+
+ + +{% endblock %} diff --git "a/ForrestHub-app/games/dobyvatel-v\303\255ce graf\305\257/b.html" "b/ForrestHub-app/games/dobyvatel-v\303\255ce graf\305\257/b.html" new file mode 100644 index 0000000..7ac0ef8 --- /dev/null +++ "b/ForrestHub-app/games/dobyvatel-v\303\255ce graf\305\257/b.html" @@ -0,0 +1,125 @@ +{% extends "templates/base.html" %} +{% set game_name = "Obsazování území - Odesílací stránka" %} +{% block content %} +
+

Obsazování území - Odesílací stránka

+

Název odesílací stránky:

+
+ +
+

Aktuální tým: Žádný

+ + +
+ +
+
+ + + +{% endblock %} diff --git "a/ForrestHub-app/games/dobyvatel-v\303\255ce graf\305\257/c.html" "b/ForrestHub-app/games/dobyvatel-v\303\255ce graf\305\257/c.html" new file mode 100644 index 0000000..f95308c --- /dev/null +++ "b/ForrestHub-app/games/dobyvatel-v\303\255ce graf\305\257/c.html" @@ -0,0 +1,86 @@ +{% extends "templates/base.html" %} +{% set game_name = "Obsazování území - Tabule" %} +{% block content %} +
+

Stav obsazení území ze všech zařízení

+
+ +
+
+ + + +{% endblock %} diff --git a/ForrestHub-app/games/admin/index.css b/ForrestHub-app/games/dobyvatel/a.html similarity index 100% rename from ForrestHub-app/games/admin/index.css rename to ForrestHub-app/games/dobyvatel/a.html diff --git a/ForrestHub-app/games/dobyvatel/b.html b/ForrestHub-app/games/dobyvatel/b.html new file mode 100644 index 0000000..e69de29 diff --git a/ForrestHub-app/games/kraje/b.html b/ForrestHub-app/games/kraje/b.html new file mode 100644 index 0000000..52ee6d5 --- /dev/null +++ b/ForrestHub-app/games/kraje/b.html @@ -0,0 +1,55 @@ +{% extends "templates/base.html" %} +{% set game_name = "Hra - Tabule kraje" %} +{% block content %} +
+

Kraj: ?

+
+

Aktuální držitel: Neobsazeno

+ + +
+
+ + +{% endblock %} diff --git a/ForrestHub-app/games/kraje/kraje.html b/ForrestHub-app/games/kraje/kraje.html new file mode 100644 index 0000000..3b73f24 --- /dev/null +++ b/ForrestHub-app/games/kraje/kraje.html @@ -0,0 +1,66 @@ +{% extends "templates/base.html" %} +{% set game_name = "Hra - Držení krajů" %} +{% block content %} +
+

Centrální pult

+
+
+

Seznam krajů:

+
    + +
+
+
+ + +
+ + +{% endblock %} diff --git a/ForrestHub-app/games/nahodne-cislo/nahodne-cislo.html b/ForrestHub-app/games/nahodne-cislo/nahodne-cislo.html new file mode 100644 index 0000000..bc373aa --- /dev/null +++ b/ForrestHub-app/games/nahodne-cislo/nahodne-cislo.html @@ -0,0 +1,65 @@ +{% extends "templates/base.html" %} +{% set game_name = "Náhodné číslo - Zobrazení času" %} +{% block content %} +
+

Vygeneruj náhodné číslo

+
+ +
+

Vygenerované číslo:

+ +

Poslední změna čísla:

+ +
+ + +{% endblock %} diff --git "a/ForrestHub-app/games/pen\303\255ze/a.html" "b/ForrestHub-app/games/pen\303\255ze/a.html" new file mode 100644 index 0000000..3a32713 --- /dev/null +++ "b/ForrestHub-app/games/pen\303\255ze/a.html" @@ -0,0 +1,194 @@ +{% extends "templates/base.html" %} +{% set game_name = "Počítadlo vlivu týmů" %} +{% block content %} +
+

Počítadlo vlivu týmů

+
+
+
+ + Modrý tým + +
+
+
+
+
+ + Červený tým + +
+
+
+
+
+ + Zelený tým + +
+
+
+
+
+ + Žlutý tým + +
+
+
+
+ +
+ + {% for i in range(25) %} +
+ {% for j in range(12) %} +
+ {% endfor %} +
+ {% endfor %} +
+
+ + + + +{% endblock %} diff --git "a/ForrestHub-app/games/pen\303\255ze/b.html" "b/ForrestHub-app/games/pen\303\255ze/b.html" new file mode 100644 index 0000000..52a41fc --- /dev/null +++ "b/ForrestHub-app/games/pen\303\255ze/b.html" @@ -0,0 +1,508 @@ +{% extends "templates/base.html" %} +{% set game_name = "Investiční hra" %} +{% block content %} +
+ +
+ +
+

Investice

+
+ + +
+
+ +
+ + + +
+
+
+ + +
+ +
+

Vyhodnocení

+
+
+ + + + + +
+
+ + +
+
+
+
+
+ +
+
+
+ +
+

Investiční Log

+
+
+ +
+

Statistiky Investic

+
+
+
+ + + + +{% endblock %} diff --git a/ForrestHub-app/games/synchronizace/index.html b/ForrestHub-app/games/synchronizace/index.html index 02ff909..1e9e521 100644 --- a/ForrestHub-app/games/synchronizace/index.html +++ b/ForrestHub-app/games/synchronizace/index.html @@ -1,20 +1,24 @@ {% extends "templates/base.html" %} {% set game_name = "Pořadové číslo a čas" %} {% block content %} -
-

Odesílání pořadového čísla a času

- -

Pořadová čísla a časy:

-
    +
    +

    Odesílání pořadového čísla a času

    +
    + + +
    +

    Pořadová čísla a časy:

    +
      {% endblock %} diff --git a/ForrestHub-app/games/udavac/kontrolor.html b/ForrestHub-app/games/udavac/kontrolor.html new file mode 100644 index 0000000..5d7072b --- /dev/null +++ b/ForrestHub-app/games/udavac/kontrolor.html @@ -0,0 +1,101 @@ +{% extends "templates/base.html" %} +{% block content %} +
      +
      + Helceletka +
      + + + + +
      +
      + +
      +

      Stiskni tlačítko nebo klikni na ENTER

      + +
      +
      + + + + +{% endblock %} diff --git a/ForrestHub-app/games/udavac/udavac.html b/ForrestHub-app/games/udavac/udavac.html new file mode 100644 index 0000000..49cfa65 --- /dev/null +++ b/ForrestHub-app/games/udavac/udavac.html @@ -0,0 +1,103 @@ +{% extends "templates/base.html" %} +{% block content %} +
      +
      + Helceletka +
      + + + + +
      +
      + +
      +

      Stiskni tlačítko nebo klikni na ENTER

      + +
      +
      + + + + +{% endblock %} diff --git "a/ForrestHub-app/games/udava\304\215/kontrolor.css" "b/ForrestHub-app/games/udava\304\215/kontrolor.css" deleted file mode 100644 index abc426f..0000000 --- "a/ForrestHub-app/games/udava\304\215/kontrolor.css" +++ /dev/null @@ -1,3 +0,0 @@ -#content { - font-size: 30px; -} \ No newline at end of file diff --git "a/ForrestHub-app/games/udava\304\215/kontrolor.html" "b/ForrestHub-app/games/udava\304\215/kontrolor.html" deleted file mode 100644 index 89b388e..0000000 --- "a/ForrestHub-app/games/udava\304\215/kontrolor.html" +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "templates/base.html" %} -{% block content %} -
      -
      - Helceletka - - -
      - -
      -

      Stiskni tlačítko nebo klikni na ENTER

      - -
      -
      -{% endblock %} diff --git "a/ForrestHub-app/games/udava\304\215/kontrolor.js" "b/ForrestHub-app/games/udava\304\215/kontrolor.js" deleted file mode 100644 index 0f98927..0000000 --- "a/ForrestHub-app/games/udava\304\215/kontrolor.js" +++ /dev/null @@ -1,58 +0,0 @@ -const forrestHubLib = new ForrestHubLib(); - -const numberInput = document.querySelector('#number'); -const checkButton = document.querySelector('#check'); -const resultDiv = document.querySelector('#result'); - -let timeout = null; - -async function checkNumber(number) { - let numbersList = await forrestHubLib.getKey('numbersList') || []; - - if (number.length !== 4 || isNaN(number)) { - resultDiv.innerText = 'Zadej čtyřmístné číslo'; - resultDiv.classList.add('alert', 'alert-danger'); - numberInput.value = ""; - - timeout && clearTimeout(timeout); - timeout = setTimeout(() => { - resultDiv.innerText = ''; - resultDiv.classList.remove('alert', 'alert-danger'); - }, 3000); - return; - } - - if (numbersList.includes(number)) { - resultDiv.innerText = 'Stůj'; - resultDiv.classList.remove('alert', 'alert-danger', 'alert-success'); - resultDiv.classList.add('alert', 'alert-danger'); - } else { - resultDiv.innerText = 'Můžeš dál'; - resultDiv.classList.remove('alert', 'alert-danger', 'alert-success'); - resultDiv.classList.add('alert', 'alert-success'); - } - numberInput.value = ""; - timeout && clearTimeout(timeout); - timeout = setTimeout(() => { - resultDiv.innerText = ''; - resultDiv.classList.remove('alert', 'alert-danger', 'alert-success'); - }, 3000); -} - -checkButton.addEventListener('click', async () => { - let number = numberInput.value; - await checkNumber(number); -}); - -numberInput.addEventListener('keyup', async (event) => { - if (event.key === "Backspace") { - return; - } - - // Check if the pressed key is NOT a number (0-9) - if (!event.key.match(/[0-9]/)) { - event.preventDefault(); - let number = numberInput.value; - await checkNumber(number); - } -}); diff --git "a/ForrestHub-app/games/udava\304\215/udavac.css" "b/ForrestHub-app/games/udava\304\215/udavac.css" deleted file mode 100644 index abc426f..0000000 --- "a/ForrestHub-app/games/udava\304\215/udavac.css" +++ /dev/null @@ -1,3 +0,0 @@ -#content { - font-size: 30px; -} \ No newline at end of file diff --git "a/ForrestHub-app/games/udava\304\215/udavac.html" "b/ForrestHub-app/games/udava\304\215/udavac.html" deleted file mode 100644 index 2b7b497..0000000 --- "a/ForrestHub-app/games/udava\304\215/udavac.html" +++ /dev/null @@ -1,15 +0,0 @@ -{% extends "templates/base.html" %} -{% block content %} -
      -
      - Helceletka - - -
      - -
      -

      Stiskni tlačítko nebo klikni na ENTER

      - -
      -
      -{% endblock %} diff --git "a/ForrestHub-app/games/udava\304\215/udavac.js" "b/ForrestHub-app/games/udava\304\215/udavac.js" deleted file mode 100644 index 843ac6e..0000000 --- "a/ForrestHub-app/games/udava\304\215/udavac.js" +++ /dev/null @@ -1,59 +0,0 @@ -const forrestHubLib = new ForrestHubLib(); - -const numberInput = document.querySelector('#number'); -const udavacButton = document.querySelector('#udavac'); -const resultDiv = document.querySelector('#result'); - -let timeout = null; -async function addNumber(number) { - let numbersList = await forrestHubLib.getKey('numbersList') || []; - - if (number.length !== 4 || isNaN(number)) { - resultDiv.innerText = 'Zadej čtyřmístné číslo'; - resultDiv.classList.add('alert', 'alert-danger'); - numberInput.value = ""; - - timeout && clearTimeout(timeout); - timeout = setTimeout(() => { - resultDiv.innerText = ''; - resultDiv.classList.remove('alert', 'alert-danger'); - }, 3000); - return; - } - - - if (!numbersList.includes(number)) { - numbersList.push(number); - } - await forrestHubLib.setKey('numbersList', numbersList); - resultDiv.innerText = 'Číslo bylo přidáno'; - resultDiv.classList.remove('alert', 'alert-danger', 'alert-success'); - resultDiv.classList.add('alert', 'alert-success'); - - numberInput.value = ""; - timeout && clearTimeout(timeout); - timeout = setTimeout(() => { - resultDiv.innerText = ''; - resultDiv.classList.remove('alert', 'alert-danger', 'alert-success'); - resultDiv.classList.remove('alert', 'alert-success'); - }, 3000); -} - -udavacButton.addEventListener('click', async () => { - let number = numberInput.value; - await addNumber(number); -}); - -numberInput.addEventListener('keyup', async (event) => { - // if backspace is pressed - if (event.key === "Backspace") { - return; - } - - // Check if the pressed key is NOT a number (0-9) - if (!event.key.match(/[0-9]/)) { - event.preventDefault(); - let number = numberInput.value; - await addNumber(number); - } -}); \ No newline at end of file diff --git a/ForrestHub-app/pages/admin/index.css b/ForrestHub-app/pages/admin/index.css new file mode 100644 index 0000000..e69de29 diff --git a/ForrestHub-app/games/admin/index.html b/ForrestHub-app/pages/admin/index.html similarity index 100% rename from ForrestHub-app/games/admin/index.html rename to ForrestHub-app/pages/admin/index.html diff --git a/ForrestHub-app/games/admin/index.js b/ForrestHub-app/pages/admin/index.js similarity index 98% rename from ForrestHub-app/games/admin/index.js rename to ForrestHub-app/pages/admin/index.js index 4f63735..7eecb51 100644 --- a/ForrestHub-app/games/admin/index.js +++ b/ForrestHub-app/pages/admin/index.js @@ -1,4 +1,8 @@ -const forrestHubLib = new ForrestHubLib(); + +if (!forrestHubLib) { + forrestHubLib = window.forrestHubLib || new ForrestHubLib(); +} + forrestHubLib.setAdmin(true); forrestHubLib.setGameMode(false); diff --git a/ForrestHub-app/games/index.html b/ForrestHub-app/pages/index.html similarity index 60% rename from ForrestHub-app/games/index.html rename to ForrestHub-app/pages/index.html index 9628233..e770cd1 100644 --- a/ForrestHub-app/games/index.html +++ b/ForrestHub-app/pages/index.html @@ -2,14 +2,16 @@ {% block content %}

      Menu

      -

      Verze aplikace: {{ config.VERSION }}

      +

      Verze aplikace: {{ config.VERSION }}

      {% include "templates/author.html" %} {% include "templates/list_folders.html" %} + {% include "templates/add_game.html" %} +
      diff --git a/ForrestHub-app/pyinstaller.spec b/ForrestHub-app/pyinstaller.spec index 9fa7de0..4f10abb 100644 --- a/ForrestHub-app/pyinstaller.spec +++ b/ForrestHub-app/pyinstaller.spec @@ -10,6 +10,7 @@ a = Analysis( ('templates', 'templates'), ('assets', 'assets'), ('games', 'games'), + ('pages', 'pages'), ('config.py', '.'), ('app', 'app'), ], diff --git a/ForrestHub-app/run.py b/ForrestHub-app/run.py index 8b47ec0..090a1ff 100644 --- a/ForrestHub-app/run.py +++ b/ForrestHub-app/run.py @@ -59,9 +59,9 @@ def run_flask(config="config.Config"): logger = setup_logging(config.EXECUTABLE_DIR, config.LOG_FOLDER) logging.basicConfig(level=logging.INFO) - # if not config.DEBUG: - webbrowser.open(f"http://{config.IP_ADDRESS}:{config.PORT}") - webbrowser.open(f"http://{config.IP_ADDRESS}:{config.PORT}/admin") + if config.FROZEN: + webbrowser.open(f"http://{config.IP_ADDRESS}:{config.PORT}") + webbrowser.open(f"http://{config.IP_ADDRESS}:{config.PORT}/admin") try: local_ip = f"http://{config.IP_ADDRESS}:{config.PORT}" diff --git a/ForrestHub-app/templates/add_game.html b/ForrestHub-app/templates/add_game.html new file mode 100644 index 0000000..48dfdd5 --- /dev/null +++ b/ForrestHub-app/templates/add_game.html @@ -0,0 +1,60 @@ + +{% if debug == true %} +
      +

      Správa her

      + +
      + + + + + +{% endif %} \ No newline at end of file diff --git a/ForrestHub-app/templates/add_game_subpage.html b/ForrestHub-app/templates/add_game_subpage.html new file mode 100644 index 0000000..7cad3d0 --- /dev/null +++ b/ForrestHub-app/templates/add_game_subpage.html @@ -0,0 +1,74 @@ +{% if debug == true %} +
      +

      Správa her

      + +
      + + + + + +{% endif %} \ No newline at end of file diff --git a/ForrestHub-app/templates/base.html b/ForrestHub-app/templates/base.html index 036f7cc..bf903b1 100644 --- a/ForrestHub-app/templates/base.html +++ b/ForrestHub-app/templates/base.html @@ -10,5 +10,6 @@
      {% include 'templates/footer.html' %} {% include 'templates/scripts.html' %} +{% include 'templates/editor.html' %} diff --git a/ForrestHub-app/templates/editor.html b/ForrestHub-app/templates/editor.html new file mode 100644 index 0000000..288730d --- /dev/null +++ b/ForrestHub-app/templates/editor.html @@ -0,0 +1,88 @@ +{% if debug == true %} + + + + + + + + + +{% endif %} diff --git a/ForrestHub-app/templates/head.html b/ForrestHub-app/templates/head.html index 75d20c0..d53d455 100644 --- a/ForrestHub-app/templates/head.html +++ b/ForrestHub-app/templates/head.html @@ -1,7 +1,7 @@ - + {{ title }} diff --git a/ForrestHub-app/templates/header.html b/ForrestHub-app/templates/header.html index 2472017..0fdc0a0 100644 --- a/ForrestHub-app/templates/header.html +++ b/ForrestHub-app/templates/header.html @@ -1,7 +1,7 @@