from textual.app import App, ComposeResult
from textual.widgets import Tree
from textual.widgets import Checkbox


class TreeApp(App):
    def compose(self) -> ComposeResult:
        tree: Tree[dict] = Tree("OpenLab")
        tree.root.expand()
        menu = tree.root.add("menu", expand=False)
        hyper = menu.add_leaf("Hypervisor")
        hyper.expand()
        hyper.add_leaf("KVM")
        hyper.add_leaf("ProxMox")
        ias = menu.add_leaf("Infrastructure as Code")
        ias.expand()
        ias.add_leaf("Terraform")
        ias.add_leaf("Pulumi")
        cloud_vm = menu.add("Cloud VM")
        cloud = cloud_vm.add_leaf("Cloud")
        cloud.expand()
        cloud.add_leaf("Digital Ocean")
       
        cloud.add_leaf("AWS")
        cloud.add_leaf("GCloud")
        cloud.add_leaf("Azure")
        proxy = cloud_vm.add_leaf("Reverse Proxy")
        proxy.expand_all()
        proxy.add_leaf("HAproxy")
        proxy.add_leaf("Nging")
        tunnel = cloud_vm.add_leaf("Wireguard tunnel")
        ss_proxy = cloud_vm.add_leaf("Shadow Socks proxy")

        provisioning = menu.add("Infra & Provisioning")
        k8s = provisioning.add("Kubernetes Nodes")
        k8s.expand()
        k8s_nodes = k8s.add_leaf("nodes config")
        k8s_nodes.add_leaf("master")
        k8s_nodes.add_leaf("worker")
        k8s_version = k8s.add_leaf("k8s version")
        k8s_version.expand()
        k8s_nodes.expand()
        k8s_ing = k8s.add_leaf("Ingress controller")
        k8s_ing.expand()
        k8s_cni = k8s.add_leaf("Container Network Interface")
        k8s_cni.add_leaf('Calico')
        k8s_cni.add_leaf('Flannel')
        k8s_cni.add_leaf('Weave')
        k8s_cni = k8s_cni.expand()
        k8s_ing.add_leaf("Nginx")
        k8s_ing.add_leaf("Haproxy")
        k8s_ing.add_leaf("Traefik")
        k8s_apps = k8s.add_leaf("Main apps")
        k8s_apps.expand()
        k8s_apps.add_leaf("CertManager")
        k8s_apps.add_leaf("MetalLB")
        k8s_apps.add_leaf("ArgoCD")
        k8s_apps.add_leaf("Kubeseal")
        k8s_mesh = k8s.add_leaf('Service Mesh')
        k8s_mesh.expand()
        k8s_mesh.add_leaf("Consul")
        k8s_mesh.add_leaf("Istio")
        k8s_secrets = k8s.add_leaf('Secrets')
        k8s_logs = k8s.add_leaf('Logs')
        static_vms = provisioning.add("Static Nodes")
        nodes_info = static_vms.add_leaf("nodes config")
        pve_vms = static_vms.add("PVE VMs")
        router_vyos = pve_vms.add_leaf("VyOS (virtual router)")
        router_opnsense = pve_vms.add_leaf("Opnsense (firewall)")
        true_nas_vm = pve_vms.add_leaf("True NAS")
        omv_vm = pve_vms.add_leaf("OpenMediaVault")
        docker = static_vms.add_leaf("Docker services")
        traefik = docker.add_leaf("Traefik")
        authelia = docker.add_leaf("Authelia")
        homepage = docker.add_leaf("Homepage")
        gluetun = docker.add_leaf("GlueTun")
        consul = docker.add_leaf("Consul")
        jelly = docker.add_leaf("jelly")
        plex = docker.add_leaf("plex")
        docker.expand()
        yield tree
        yield Checkbox("DryRun")
        yield Checkbox("Show config")
        yield Checkbox("Run")


if __name__ == "__main__":
    app = TreeApp()
    app.run()