FEATURE: Display created and last_used dates for API keys

This commit is contained in:
David Taylor
2019-10-09 14:24:14 +01:00
parent 10478cb395
commit 445a3851d6
3 changed files with 21 additions and 1 deletions

View File

@ -3,6 +3,8 @@
<thead> <thead>
<th>{{i18n "admin.api.key"}}</th> <th>{{i18n "admin.api.key"}}</th>
<th>{{i18n "admin.api.user"}}</th> <th>{{i18n "admin.api.user"}}</th>
<th>{{i18n "admin.api.created"}}</th>
<th>{{i18n "admin.api.last_used"}}</th>
<th>&nbsp;</th> <th>&nbsp;</th>
</thead> </thead>
<tbody> <tbody>
@ -10,6 +12,7 @@
<tr> <tr>
<td class="key">{{k.key}}</td> <td class="key">{{k.key}}</td>
<td class="key-user"> <td class="key-user">
<div class="label">{{i18n 'admin.api.user'}}</div>
{{#if k.user}} {{#if k.user}}
{{#link-to "adminUser" k.user}} {{#link-to "adminUser" k.user}}
{{avatar k.user imageSize="small"}} {{avatar k.user imageSize="small"}}
@ -18,6 +21,18 @@
{{i18n "admin.api.all_users"}} {{i18n "admin.api.all_users"}}
{{/if}} {{/if}}
</td> </td>
<td class="key-created">
<div class="label">{{i18n 'admin.api.created'}}</div>
{{format-date k.created_at}}
</td>
<td class="key-last-used">
<div class="label">{{i18n 'admin.api.last_used'}}</div>
{{#if k.last_used_at}}
{{format-date k.last_used_at}}
{{else}}
{{i18n "admin.api.never_used"}}
{{/if}}
</td>
<td class="key-controls"> <td class="key-controls">
{{d-button {{d-button
class="btn-default" class="btn-default"

View File

@ -3,7 +3,9 @@
class ApiKeySerializer < ApplicationSerializer class ApiKeySerializer < ApplicationSerializer
attributes :id, attributes :id,
:key :key,
:last_used_at,
:created_at
has_one :user, serializer: BasicUserSerializer, embed: :objects has_one :user, serializer: BasicUserSerializer, embed: :objects

View File

@ -3302,6 +3302,9 @@ en:
user: "User" user: "User"
title: "API" title: "API"
key: "API Key" key: "API Key"
created: Created
last_used: Last Used
never_used: (never)
generate: "Generate" generate: "Generate"
regenerate: "Regenerate" regenerate: "Regenerate"
revoke: "Revoke" revoke: "Revoke"