mirror of
https://github.com/Quiq/docker-registry-ui.git
synced 2025-07-17 07:41:18 +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("repo", repo)
|
||||||
data.Set("tags", tags)
|
data.Set("tags", tags)
|
||||||
data.Set("deleteAllowed", deleteAllowed)
|
data.Set("deleteAllowed", deleteAllowed)
|
||||||
|
data.Set("events", registry.GetEvents(repo))
|
||||||
|
|
||||||
return c.Render(http.StatusOK, "tags.html", data)
|
return c.Render(http.StatusOK, "tags.html", data)
|
||||||
}
|
}
|
||||||
@ -279,9 +280,8 @@ func (a *apiClient) checkDeletePermission(user string) bool {
|
|||||||
|
|
||||||
// viewLog view events from sqlite.
|
// viewLog view events from sqlite.
|
||||||
func (a *apiClient) viewLog(c echo.Context) error {
|
func (a *apiClient) viewLog(c echo.Context) error {
|
||||||
events := registry.GetEvents()
|
|
||||||
data := jet.VarMap{}
|
data := jet.VarMap{}
|
||||||
data.Set("events", events)
|
data.Set("events", registry.GetEvents(""))
|
||||||
|
|
||||||
return c.Render(http.StatusOK, "event_log.html", data)
|
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
|
// GetEvents retrieve events from sqlite db
|
||||||
func GetEvents() []EventRow {
|
func GetEvents(repository string) []EventRow {
|
||||||
var events []EventRow
|
var events []EventRow
|
||||||
db, err := sql.Open("sqlite3", dbFile)
|
db, err := sql.Open("sqlite3", dbFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -112,7 +112,11 @@ func GetEvents() []EventRow {
|
|||||||
}
|
}
|
||||||
defer db.Close()
|
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 {
|
if err != nil {
|
||||||
logger.Error("Error selecting from table: ", err)
|
logger.Error("Error selecting from table: ", err)
|
||||||
return events
|
return events
|
||||||
|
@ -64,7 +64,7 @@ func PurgeOldTags(client *Client, purgeDryRun bool, purgeTagsKeepDays, purgeTags
|
|||||||
for _, tag := range tags {
|
for _, tag := range tags {
|
||||||
_, infoV1, _ := client.TagInfo(repo, tag, true)
|
_, infoV1, _ := client.TagInfo(repo, tag, true)
|
||||||
if infoV1 == "" {
|
if infoV1 == "" {
|
||||||
logger.Errorf("[%s] manifest missed for tag %s", repo, tag)
|
logger.Errorf("[%s] missing manifest v1 for tag %s", repo, tag)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
created := gjson.Get(gjson.Get(infoV1, "history.0.v1Compatibility").String(), "created").Time()
|
created := gjson.Get(gjson.Get(infoV1, "history.0.v1Compatibility").String(), "created").Time()
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{{ e.Action }}</td>
|
<td>{{ e.Action }}</td>
|
||||||
{{if hasPrefix(e.Tag,"sha256") }}
|
{{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}}
|
{{else}}
|
||||||
<td>{{ e.Repository }}:{{ e.Tag }}</td>
|
<td>{{ e.Repository }}:{{ e.Tag }}</td>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<li><a href="/{{ namespace }}/{{ repo }}">{{ repo }}</a></li>
|
<li><a href="/{{ namespace }}/{{ repo }}">{{ repo }}</a></li>
|
||||||
<li class="active">{{ tag }}</li>
|
<li class="active">{{ tag }}</li>
|
||||||
</ol>
|
</ol>
|
||||||
<table class="table table-striped table-bordered">
|
<table class="table table-striped table-bordered">
|
||||||
<thead bgcolor="#ddd">
|
<thead bgcolor="#ddd">
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2">Image Details</th>
|
<th colspan="2">Image Details</th>
|
||||||
|
@ -2,12 +2,16 @@
|
|||||||
|
|
||||||
{{block head()}}
|
{{block head()}}
|
||||||
<script type="text/javascript" src="/static/bootstrap-confirmation.min.js"></script>
|
<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">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#datatable').DataTable({
|
$('#datatable').DataTable({
|
||||||
"pageLength": 10,
|
"pageLength": 10,
|
||||||
"order": [[ 0, 'desc' ]],
|
"order": [[ 0, 'desc' ]],
|
||||||
"stateSave": true
|
"stateSave": true,
|
||||||
|
columnDefs: [
|
||||||
|
{ type: 'natural', targets: 0 }
|
||||||
|
]
|
||||||
})
|
})
|
||||||
function populateConfirmation() {
|
function populateConfirmation() {
|
||||||
$('[data-toggle=confirmation]').confirmation({
|
$('[data-toggle=confirmation]').confirmation({
|
||||||
@ -17,6 +21,8 @@
|
|||||||
}
|
}
|
||||||
populateConfirmation()
|
populateConfirmation()
|
||||||
$('#datatable').on('draw.dt', populateConfirmation)
|
$('#datatable').on('draw.dt', populateConfirmation)
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{{end}}
|
{{end}}
|
||||||
@ -49,4 +55,33 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</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}}
|
{{end}}
|
||||||
|
Loading…
Reference in New Issue
Block a user