Add more links to build information
This commit is contained in:
parent
96372d8e50
commit
3dbc251b94
4 changed files with 21 additions and 6 deletions
|
|
@ -44,7 +44,10 @@ class Build(BaseModel):
|
||||||
pr: Optional[int]
|
pr: Optional[int]
|
||||||
git_commit: str
|
git_commit: str
|
||||||
image: str
|
image: str
|
||||||
link: str
|
deploy_link: str
|
||||||
|
repo_link: str
|
||||||
|
repo_commit_link: str
|
||||||
|
webui_link: str
|
||||||
status: models.BuildStatus
|
status: models.BuildStatus
|
||||||
created: datetime.datetime
|
created: datetime.datetime
|
||||||
last_scaled: Optional[datetime.datetime]
|
last_scaled: Optional[datetime.datetime]
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ class Build(BaseModel):
|
||||||
return self.make_slug(self.repo, self.target_branch, self.pr, self.git_commit)
|
return self.make_slug(self.repo, self.target_branch, self.pr, self.git_commit)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def link(self) -> str:
|
def deploy_link(self) -> str:
|
||||||
return f"http://{self.slug}.{settings.build_domain}"
|
return f"http://{self.slug}.{settings.build_domain}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
@ -140,9 +140,21 @@ class Build(BaseModel):
|
||||||
else:
|
else:
|
||||||
return f"{link}/tree/{self.target_branch}"
|
return f"{link}/tree/{self.target_branch}"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def repo_commit_link(self) -> str:
|
||||||
|
link = f"https://github.com/{self.repo}"
|
||||||
|
if self.pr:
|
||||||
|
return f"{link}/pull/{self.pr}/commits/{self.git_commit}"
|
||||||
|
else:
|
||||||
|
return f"{link}/commit/{self.git_commit}"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def webui_link(self) -> str:
|
||||||
|
return f"{settings.base_url}/builds/{self.name}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def live_link(self) -> str:
|
def live_link(self) -> str:
|
||||||
return f"{settings.base_url}/builds/{self.name}?live"
|
return f"{self.webui_link}?live"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def deploy(
|
async def deploy(
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ async def build(request: Request, name: str, live: Optional[str] = None):
|
||||||
if not build:
|
if not build:
|
||||||
raise HTTPException(status.HTTP_404_NOT_FOUND)
|
raise HTTPException(status.HTTP_404_NOT_FOUND)
|
||||||
if live is not None and build.status == BuildStatus.started:
|
if live is not None and build.status == BuildStatus.started:
|
||||||
return RedirectResponse(url=build.link)
|
return RedirectResponse(url=build.deploy_link)
|
||||||
return templates.TemplateResponse(
|
return templates.TemplateResponse(
|
||||||
"build.html", {"request": request, "build": build}
|
"build.html", {"request": request, "build": build}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>Branch: <a href="{{ build.repo_link }}">{{ build.target_branch }}</a></p>
|
<p>Branch: <a href="{{ build.repo_link }}">{{ build.target_branch }}</a></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<p>Commit: {{ build.git_commit }}</p>
|
<p>Commit: <a href="{{ build.repo_commit_link }}">{{ build.git_commit }}</a></p>
|
||||||
<p>Status: {{ build.status }}</p>
|
<p>Status: {{ build.status }}</p>
|
||||||
{% if build.status == 'started' %}
|
{% if build.status == 'started' %}
|
||||||
<p><a href="{{ build.live_link }}">=> live</a></p>
|
<p><a href="{{ build.deploy_link }}">=> live</a></p>
|
||||||
<button onclick="stop()">stop</button>
|
<button onclick="stop()">stop</button>
|
||||||
{% else %}
|
{% else %}
|
||||||
<button onclick="start()">start</button>
|
<button onclick="start()">start</button>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue