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]
|
||||
git_commit: str
|
||||
image: str
|
||||
link: str
|
||||
deploy_link: str
|
||||
repo_link: str
|
||||
repo_commit_link: str
|
||||
webui_link: str
|
||||
status: models.BuildStatus
|
||||
created: 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)
|
||||
|
||||
@property
|
||||
def link(self) -> str:
|
||||
def deploy_link(self) -> str:
|
||||
return f"http://{self.slug}.{settings.build_domain}"
|
||||
|
||||
@property
|
||||
|
|
@ -140,9 +140,21 @@ class Build(BaseModel):
|
|||
else:
|
||||
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
|
||||
def live_link(self) -> str:
|
||||
return f"{settings.base_url}/builds/{self.name}?live"
|
||||
return f"{self.webui_link}?live"
|
||||
|
||||
@classmethod
|
||||
async def deploy(
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ async def build(request: Request, name: str, live: Optional[str] = None):
|
|||
if not build:
|
||||
raise HTTPException(status.HTTP_404_NOT_FOUND)
|
||||
if live is not None and build.status == BuildStatus.started:
|
||||
return RedirectResponse(url=build.link)
|
||||
return RedirectResponse(url=build.deploy_link)
|
||||
return templates.TemplateResponse(
|
||||
"build.html", {"request": request, "build": build}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@
|
|||
{% else %}
|
||||
<p>Branch: <a href="{{ build.repo_link }}">{{ build.target_branch }}</a></p>
|
||||
{% 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>
|
||||
{% 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>
|
||||
{% else %}
|
||||
<button onclick="start()">start</button>
|
||||
|
|
|
|||
Loading…
Reference in a new issue