Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/replace localhost #29

Merged
merged 7 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ BLITZ_PORT=8100
DEFAULT_FILE="blitz.json"
BLITZ_DB_TYPE="MEMORY"
BLITZ_OPENAI_API_KEY=""
BLITZ_READ_ONLY=False
BLITZ_READ_ONLY=False
BLITZ_BASE_URL="http://0.0.0.0:8100"
2 changes: 1 addition & 1 deletion blitz/api/blitz_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, blitz_app: "BlitzApp", settings: Settings = get_settings()) -
Link(
label="Go Back to Dashboard",
icon="fa fa-link",
url=f"http://0.0.0.0:{settings.BLITZ_PORT}/dashboard/projects/{self.blitz_app.name}",
url=f"/dashboard/projects/{self.blitz_app.name}",
)
)
self.admin.add_view(Link(label="GitHub", icon="fa-brands fa-github", url="https://github.com/Paperz-org/blitz"))
Expand Down
2 changes: 2 additions & 0 deletions blitz/cli/commands/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def start_blitz(
reload_excludes=["*_migration.py", "migrations/*.py"],
log_config=None,
log_level="info",
proxy_headers=True,
forwarded_allow_ips="*",
)
server = uvicorn.Server(server_config)
ChangeReload(server_config, target=server.run, sockets=[server_config.bind_socket()]).run()
Expand Down
1 change: 1 addition & 0 deletions blitz/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Config:
BLITZ_DB_TYPE: DBTypes = DBTypes.SQLITE
BLITZ_OPENAI_API_KEY: str = ""
BLITZ_READ_ONLY: bool = False
BLITZ_BASE_URL: str = "http://0.0.0.0:8100"


@lru_cache()
Expand Down
3 changes: 2 additions & 1 deletion blitz/ui/components/drawers/dashboard.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from blitz.ui.components.links.menu_link import MenuLink

from .base import BaseLeftDrawer


Expand All @@ -10,7 +11,7 @@ def render(self) -> None:
super().render()
with self:
MenuLink("Dashboard", f"/projects/{self.current_project}", "dashboard")
MenuLink("Admin", f"{self.blitz_ui.localhost_url}/admin/", "table_chart")
MenuLink("Admin", f"{self.blitz_ui.settings.BLITZ_BASE_URL}/admin/", "table_chart")
MenuLink("Swagger", f"/projects/{self.current_project}/swagger", "api")
MenuLink("Blitz File", f"/projects/{self.current_project}/blitz-file", "article")
MenuLink("Diagram", f"/projects/{self.current_project}/diagram", "account_tree")
Expand Down
2 changes: 1 addition & 1 deletion blitz/ui/components/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def render(self) -> None:
HeaderElement(label="Blitz Dashboard", link=f"/projects/{self.blitz_ui.current_project}")

with ItemsCenterContentCenterRow(classes="justify-between"):
with HeaderElement(label="Projects", link=f"{self.blitz_ui.localhost_url}/projects").disabled():
with HeaderElement(label="Projects", link="/projects").disabled():
Tooltip("Multiple App management is coming soon")
HeaderElement(label="GPT Builder", link="/gpt")
HeaderElement("Documentation", "https://paperz-org.github.io/blitz/", new_tab=True)
Expand Down
6 changes: 4 additions & 2 deletions blitz/ui/components/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ def __init__(
classes: str = "",
**kwargs: Any,
) -> None:

Timer(10.0, self._set_status)
super().__init__(*args, props=props, classes=classes, **kwargs)

async def _is_api_up(self) -> bool:
async with AsyncClient() as client:
response = await client.get(f"{self.blitz_ui.localhost_url}/api")
response = await client.get(f"{self.blitz_ui.settings.BLITZ_BASE_URL}/api")
return response.status_code == 200

async def _is_admin_up(self) -> bool:
async with AsyncClient() as client:
response = await client.get(f"{self.blitz_ui.localhost_url}/admin/")
print(self.blitz_ui.settings.BLITZ_BASE_URL)
response = await client.get(f"{self.blitz_ui.settings.BLITZ_BASE_URL}/admin/")
return response.status_code == 200

async def _set_status(self) -> None:
Expand Down
5 changes: 3 additions & 2 deletions blitz/ui/pages/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from pathlib import Path
from blitz.ui.blitz_ui import BlitzUI, get_blitz_ui

from nicegui import ui

from blitz.ui.blitz_ui import BlitzUI, get_blitz_ui
from blitz.ui.components.element.base import IFrame


Expand All @@ -16,7 +17,7 @@ def resize_iframe(self) -> None:
def render_page(self) -> None:
self.resize_iframe()
self.ng = IFrame(
src=f"{self.blitz_ui.localhost_url}/admin/",
src="/admin/",
frameborder=0,
classes="w-full rounded-sm bg-white h-screen overflow-hidden",
props="onload=resizeIframe()",
Expand Down
6 changes: 4 additions & 2 deletions blitz/ui/pages/swagger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from pathlib import Path

from nicegui import ui

from blitz.ui.components.element.base import IFrame
from pathlib import Path
from blitz.ui.pages.base import BasePage


Expand All @@ -14,7 +16,7 @@ def resize_iframe(self) -> None:
def render(self) -> None:
self.resize_iframe()
self.ng = IFrame(
src=f"{self.blitz_ui.localhost_url}/api/docs",
src=f"{self.blitz_ui.settings.BLITZ_BASE_URL}/api/docs",
frameborder=0,
classes="w-full rounded-sm bg-white h-screen overflow-hidden",
props="onload=resizeIframe()",
Expand Down
Loading