mirror of
https://github.com/Quiq/docker-registry-ui.git
synced 2025-07-16 15:25:59 +00:00
Natural sorting of tags, add last 5 event to tags page.
This commit is contained in:
parent
1e0bb7d8ff
commit
9c73934382
4
main.go
4
main.go
@ -185,6 +185,7 @@ func (a *apiClient) viewTags(c echo.Context) error {
|
||||
data.Set("repo", repo)
|
||||
data.Set("tags", tags)
|
||||
data.Set("deleteAllowed", deleteAllowed)
|
||||
data.Set("events", registry.GetEvents(repo))
|
||||
|
||||
return c.Render(http.StatusOK, "tags.html", data)
|
||||
}
|
||||
@ -279,9 +280,8 @@ func (a *apiClient) checkDeletePermission(user string) bool {
|
||||
|
||||
// viewLog view events from sqlite.
|
||||
func (a *apiClient) viewLog(c echo.Context) error {
|
||||
events := registry.GetEvents()
|
||||
data := jet.VarMap{}
|
||||
data.Set("events", events)
|
||||
data.Set("events", registry.GetEvents(""))
|
||||
|
||||
return c.Render(http.StatusOK, "event_log.html", data)
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ func ProcessEvents(request *http.Request, retention int) {
|
||||
}
|
||||
|
||||
// GetEvents retrieve events from sqlite db
|
||||
func GetEvents() []EventRow {
|
||||
func GetEvents(repository string) []EventRow {
|
||||
var events []EventRow
|
||||
db, err := sql.Open("sqlite3", dbFile)
|
||||
if err != nil {
|
||||
@ -112,7 +112,11 @@ func GetEvents() []EventRow {
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
rows, err := db.Query("SELECT * FROM events ORDER BY id DESC LIMIT 1000")
|
||||
query := "SELECT * FROM events ORDER BY id DESC LIMIT 1000"
|
||||
if repository != "" {
|
||||
query = fmt.Sprintf("SELECT * FROM events WHERE repository='%s' ORDER BY id DESC LIMIT 5", repository)
|
||||
}
|
||||
rows, err := db.Query(query)
|
||||
if err != nil {
|
||||
logger.Error("Error selecting from table: ", err)
|
||||
return events
|
||||
|
@ -64,7 +64,7 @@ func PurgeOldTags(client *Client, purgeDryRun bool, purgeTagsKeepDays, purgeTags
|
||||
for _, tag := range tags {
|
||||
_, infoV1, _ := client.TagInfo(repo, tag, true)
|
||||
if infoV1 == "" {
|
||||
logger.Errorf("[%s] manifest missed for tag %s", repo, tag)
|
||||
logger.Errorf("[%s] missing manifest v1 for tag %s", repo, tag)
|
||||
continue
|
||||
}
|
||||
created := gjson.Get(gjson.Get(infoV1, "history.0.v1Compatibility").String(), "created").Time()
|
||||
|
@ -33,7 +33,7 @@
|
||||
<tr>
|
||||
<td>{{ e.Action }}</td>
|
||||
{{if hasPrefix(e.Tag,"sha256") }}
|
||||
<td>{{ e.Repository }}@{{ e.Tag[:12] }}.....{{ e.Tag[66:] }}</td>
|
||||
<td title="{{ e.Tag }}">{{ e.Repository }}@{{ e.Tag[:19] }}...</td>
|
||||
{{else}}
|
||||
<td>{{ e.Repository }}:{{ e.Tag }}</td>
|
||||
{{end}}
|
||||
|
@ -11,7 +11,7 @@
|
||||
<li><a href="/{{ namespace }}/{{ repo }}">{{ repo }}</a></li>
|
||||
<li class="active">{{ tag }}</li>
|
||||
</ol>
|
||||
<table class="table table-striped table-bordered">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead bgcolor="#ddd">
|
||||
<tr>
|
||||
<th colspan="2">Image Details</th>
|
||||
|
@ -2,12 +2,16 @@
|
||||
|
||||
{{block head()}}
|
||||
<script type="text/javascript" src="/static/bootstrap-confirmation.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.16/sorting/natural.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#datatable').DataTable({
|
||||
"pageLength": 10,
|
||||
"order": [[ 0, 'desc' ]],
|
||||
"stateSave": true
|
||||
"stateSave": true,
|
||||
columnDefs: [
|
||||
{ type: 'natural', targets: 0 }
|
||||
]
|
||||
})
|
||||
function populateConfirmation() {
|
||||
$('[data-toggle=confirmation]').confirmation({
|
||||
@ -17,6 +21,8 @@
|
||||
}
|
||||
populateConfirmation()
|
||||
$('#datatable').on('draw.dt', populateConfirmation)
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
{{end}}
|
||||
@ -49,4 +55,33 @@
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h4>Latest events on this repo</h4>
|
||||
<table id="datatable_log" class="table table-striped table-bordered">
|
||||
<thead bgcolor="#ddd">
|
||||
<tr>
|
||||
<th>Action</th>
|
||||
<th>Image</th>
|
||||
<th>IP Address</th>
|
||||
<th>User</th>
|
||||
<th>Time</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range e := events}}
|
||||
<tr>
|
||||
<td>{{ e.Action }}</td>
|
||||
{{if hasPrefix(e.Tag,"sha256") }}
|
||||
<td title="{{ e.Tag }}">{{ e.Repository }}@{{ e.Tag[:19] }}...</td>
|
||||
{{else}}
|
||||
<td>{{ e.Repository }}:{{ e.Tag }}</td>
|
||||
{{end}}
|
||||
<td>{{ e.IP }}</td>
|
||||
<td>{{ e.User }}</td>
|
||||
<td>{{ e.Created }}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{{end}}
|
||||
|
Loading…
Reference in New Issue
Block a user