FEATURE: Display created and last_used dates for API keys

FEATURE: Display created and last_used dates for API keys

diff --git a/app/assets/javascripts/admin/templates/api-keys.hbs b/app/assets/javascripts/admin/templates/api-keys.hbs
index d631e41..a1254f3 100644
--- a/app/assets/javascripts/admin/templates/api-keys.hbs
+++ b/app/assets/javascripts/admin/templates/api-keys.hbs
@@ -3,6 +3,8 @@
   <thead>
     <th>{{i18n "admin.api.key"}}</th>
     <th>{{i18n "admin.api.user"}}</th>
+    <th>{{i18n "admin.api.created"}}</th>
+    <th>{{i18n "admin.api.last_used"}}</th>
     <th>&nbsp;</th>
   </thead>
   <tbody>
@@ -10,6 +12,7 @@
       <tr>
         <td class="key">{{k.key}}</td>
         <td class="key-user">
+          <div class="label">{{i18n 'admin.api.user'}}</div>
           {{#if k.user}}
             {{#link-to "adminUser" k.user}}
               {{avatar k.user imageSize="small"}}
@@ -18,6 +21,18 @@
             {{i18n "admin.api.all_users"}}
           {{/if}}
         </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">
           {{d-button
             class="btn-default"
diff --git a/app/serializers/api_key_serializer.rb b/app/serializers/api_key_serializer.rb
index bb80726..59f874b 100644
--- a/app/serializers/api_key_serializer.rb
+++ b/app/serializers/api_key_serializer.rb
@@ -3,7 +3,9 @@
 class ApiKeySerializer < ApplicationSerializer
 
   attributes :id,
-             :key
+             :key,
+             :last_used_at,
+             :created_at
 
   has_one :user, serializer: BasicUserSerializer, embed: :objects
 
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 91685d6..f30f108 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -3302,6 +3302,9 @@ en:
         user: "User"
         title: "API"
         key: "API Key"
+        created: Created
+        last_used: Last Used
+        never_used: (never)
         generate: "Generate"
         regenerate: "Regenerate"
         revoke: "Revoke"

GitHub sha: 445a3851

1 Like