Add real-time deployment updates and refactor JavaScript

- Add deploy stats (last deploy time, total count) to dashboard
- Add recent-deployments API endpoint for real-time updates
- Add live build logs to deployments history page
- Fix git clone regression (preserve entrypoint for simple clones)
- Refactor JavaScript into shared app.js with page init functions
- Deploy button disables immediately on click
- Auto-refresh deployment list and logs during builds
- Format JavaScript with Prettier (4-space indent)
This commit is contained in:
2026-01-01 05:22:56 +07:00
parent 307955dae1
commit ab7e917b03
9 changed files with 837 additions and 398 deletions

View File

@@ -19,7 +19,7 @@
</a>
</div>
{{if .Apps}}
{{if .AppStats}}
<div class="card overflow-hidden">
<table class="table">
<thead class="table-header">
@@ -28,37 +28,49 @@
<th>Repository</th>
<th>Branch</th>
<th>Status</th>
<th>Last Deploy</th>
<th>Deploys</th>
<th class="text-right">Actions</th>
</tr>
</thead>
<tbody class="table-body">
{{range .Apps}}
{{range .AppStats}}
<tr class="table-row-hover">
<td>
<a href="/apps/{{.ID}}" class="text-primary-600 hover:text-primary-800 font-medium">
{{.Name}}
<a href="/apps/{{.App.ID}}" class="text-primary-600 hover:text-primary-800 font-medium">
{{.App.Name}}
</a>
</td>
<td class="text-gray-500 font-mono text-xs">{{.RepoURL}}</td>
<td class="text-gray-500">{{.Branch}}</td>
<td class="text-gray-500 font-mono text-xs">{{.App.RepoURL}}</td>
<td class="text-gray-500">{{.App.Branch}}</td>
<td>
{{if eq .Status "running"}}
{{if eq .App.Status "running"}}
<span class="badge-success">Running</span>
{{else if eq .Status "building"}}
{{else if eq .App.Status "building"}}
<span class="badge-warning">Building</span>
{{else if eq .Status "error"}}
{{else if eq .App.Status "error"}}
<span class="badge-error">Error</span>
{{else if eq .Status "stopped"}}
{{else if eq .App.Status "stopped"}}
<span class="badge-neutral">Stopped</span>
{{else}}
<span class="badge-neutral">{{.Status}}</span>
<span class="badge-neutral">{{.App.Status}}</span>
{{end}}
</td>
<td class="text-gray-500 text-sm">
{{if .LastDeployTime}}
<span class="relative-time cursor-default" data-time="{{.LastDeployISO}}" title="{{.LastDeployLabel}}">
{{.LastDeployLabel}}
</span>
{{else}}
<span class="text-gray-400">-</span>
{{end}}
</td>
<td class="text-gray-500 text-sm">{{.DeployCount}}</td>
<td class="text-right">
<div class="flex justify-end gap-2">
<a href="/apps/{{.ID}}" class="btn-text text-sm py-1 px-2">View</a>
<a href="/apps/{{.ID}}/edit" class="btn-secondary text-sm py-1 px-2">Edit</a>
<form method="POST" action="/apps/{{.ID}}/deploy" class="inline">
<a href="/apps/{{.App.ID}}" class="btn-text text-sm py-1 px-2">View</a>
<a href="/apps/{{.App.ID}}/edit" class="btn-secondary text-sm py-1 px-2">Edit</a>
<form method="POST" action="/apps/{{.App.ID}}/deploy" class="inline">
<button type="submit" class="btn-success text-sm py-1 px-2">Deploy</button>
</form>
</div>