You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.5 KiB
55 lines
1.5 KiB
import flet as ft
|
|
import requests
|
|
from requests.auth import HTTPBasicAuth
|
|
import csv
|
|
from globalState import AppState
|
|
import asyncio
|
|
import aiohttp
|
|
|
|
def dom(page: ft.Page):
|
|
page.title = "Domains"
|
|
|
|
user = AppState.user
|
|
password = AppState.password
|
|
url = AppState.url
|
|
if url.endswith("/"):
|
|
url = url[:-1]
|
|
url = f"{url}:1443/api/domains"
|
|
|
|
response = requests.get(url, auth=HTTPBasicAuth(user, password), verify=False)
|
|
|
|
if response.status_code == 200:
|
|
data = response.json()
|
|
domains = data['_embedded']['ngcp:domains']
|
|
|
|
rows = []
|
|
|
|
for domain in domains:
|
|
domain_id = domain['id']
|
|
domain_reseller = domain["reseller_id"]
|
|
domain_domain = domain['domain']
|
|
rows.append(
|
|
ft.DataRow(
|
|
cells=[
|
|
ft.DataCell(ft.Text(str(domain_id))),
|
|
ft.DataCell(ft.Text(domain_reseller)),
|
|
ft.DataCell(ft.Text(domain_domain)),
|
|
]
|
|
)
|
|
)
|
|
|
|
table = ft.DataTable(
|
|
columns=[
|
|
ft.DataColumn(ft.Text("#")),
|
|
ft.DataColumn(ft.Text("Reseller")),
|
|
ft.DataColumn(ft.Text("Domain")),
|
|
],
|
|
rows=rows
|
|
)
|
|
|
|
page.add(table)
|
|
page.update()
|
|
else:
|
|
page.add(ft.Text(f"Error al obtener datos: {response.status_code}"))
|
|
page.update()
|
|
|