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.
58 lines
1.6 KiB
58 lines
1.6 KiB
import flet as ft
|
|
import requests
|
|
from requests.auth import HTTPBasicAuth
|
|
import csv
|
|
from globalState import AppState
|
|
import asyncio
|
|
import aiohttp
|
|
|
|
def rewrite(page: ft.Page):
|
|
page.title = "Admins"
|
|
|
|
user = AppState.user
|
|
password = AppState.password
|
|
url = AppState.url
|
|
if url.endswith("/"):
|
|
url = url[:-1]
|
|
url = f"{url}:1443/api/rewriterulesets"
|
|
|
|
response = requests.get(url, auth=HTTPBasicAuth(user, password), verify=False)
|
|
|
|
if response.status_code == 200:
|
|
data = response.json()
|
|
rules = data['_embedded']['ngcp:rewriterulesets']
|
|
|
|
rows = []
|
|
|
|
for rule in rules:
|
|
rule_id = rule['id']
|
|
rule_resellers = rule['reseller_id']
|
|
rule_name = rule['name']
|
|
rule_description = rule['description']
|
|
|
|
rows.append(
|
|
ft.DataRow(
|
|
cells=[
|
|
ft.DataCell(ft.Text(str(rule_id))),
|
|
ft.DataCell(ft.Text(rule_resellers)),
|
|
ft.DataCell(ft.Text(rule_name)),
|
|
ft.DataCell(ft.Text(rule_description))
|
|
]
|
|
)
|
|
)
|
|
|
|
table = ft.DataTable(
|
|
columns=[
|
|
ft.DataColumn(ft.Text("#")),
|
|
ft.DataColumn(ft.Text("Reseller")),
|
|
ft.DataColumn(ft.Text("Name")),
|
|
ft.DataColumn(ft.Text("Description"))
|
|
],
|
|
rows=rows
|
|
)
|
|
|
|
page.add(table)
|
|
page.update()
|
|
else:
|
|
page.add(ft.Text(f"Error al obtener datos: {response.status_code}"))
|
|
page.update() |