wip - nicegui

This commit is contained in:
Stephan Lüscher 2024-05-06 15:16:52 +00:00
parent c3ed45a21b
commit 85b0b3fdc5
No known key found for this signature in database
GPG key ID: 445779060FF3D3CF
39 changed files with 2748 additions and 896 deletions

View file

@ -0,0 +1 @@
from nicegui import ui

View file

@ -0,0 +1,10 @@
from nicegui import ui
from utils import get_project_root
def content() -> None:
project_root = str(get_project_root())
ui.label("Work in progress...").classes("text-h6")
ui.image(project_root + "/nicegui/pages/assets/work-in-progress.png").classes(
"w-[200%]"
)

View file

@ -0,0 +1,54 @@
import ansible_runner
import re
from nicegui import ui
from utils import get_project_root
# Ansible integration
def run_ansible_playbook(playbook_name: str, ngui_log: ui.log):
project_root = str(get_project_root())
playbook_path = project_root + "/ansible/playbooks/"
inventory_path = project_root + "/ansible/inventory.yml"
response, error, return_code = ansible_runner.interface.run_command(
executable_cmd="ansible-playbook",
cmdline_args=[playbook_path + playbook_name, "-i", inventory_path],
)
# remove color characters from response until clear how to display them in a log
ansi_escape = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-9;#]+[mGK]?)")
ansible_log = format(ansi_escape.sub("", response))
ngui_log.clear()
ngui_log.push(ansible_log)
# Page content
def content() -> None:
with ui.row().classes("w-full"):
with ui.row().classes("w-full"):
# First Row
with ui.card().classes("h-full"):
ui.label("Build").classes("text-h6")
ui.button(
text="Clone project",
on_click=lambda: run_ansible_playbook(
"project_clone.yml", ngui_log=log
),
)
ui.button(
text="Build project",
on_click=lambda: run_ansible_playbook(
"project_build.yml", ngui_log=log
),
)
# Second Row
with ui.card().classes("h-full"):
ui.label("Deploy").classes("text-h6")
ui.button(
"Deploy VM",
on_click=lambda: ui.notify("This playbook is not implemented yet"),
)
with ui.row().classes("w-full"):
with ui.card().classes("w-full"):
ui.label("Playbook Log").classes("text-h6")
ui.button("Clear Log", on_click=lambda: log.clear())
log = ui.log().classes("w-full h-full")

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 KiB

View file

@ -0,0 +1,10 @@
from nicegui import ui
from utils import get_project_root
def content() -> None:
project_root = str(get_project_root())
ui.label("Work in progress...").classes("text-h6")
ui.image(project_root + "/nicegui/pages/assets/work-in-progress.png").classes(
"w-[200%]"
)

View file

@ -0,0 +1,10 @@
from nicegui import ui
from utils import get_project_root
def content() -> None:
project_root = str(get_project_root())
ui.label("Work in progress...").classes("text-h6")
ui.image(project_root + "/nicegui/pages/assets/work-in-progress.png").classes(
"w-[200%]"
)