From b5f4f81f1e1018a157226d63e74fecd4a8ee0300 Mon Sep 17 00:00:00 2001
From: Frederick Borges <fborges@opennebula.io>
Date: Mon, 11 Jan 2021 17:41:33 +0100
Subject: [PATCH] F #5066: Add registration time to Services

Signed-off-by: Frederick Borges <fborges@opennebula.io>
---
 src/sunstone/etc/sunstone-views/kvm/admin.yaml             | 5 +++--
 src/sunstone/etc/sunstone-views/kvm/groupadmin.yaml        | 5 +++--
 src/sunstone/etc/sunstone-views/kvm/user.yaml              | 5 +++--
 src/sunstone/etc/sunstone-views/mixed/admin.yaml           | 5 +++--
 src/sunstone/etc/sunstone-views/mixed/groupadmin.yaml      | 5 +++--
 src/sunstone/etc/sunstone-views/mixed/user.yaml            | 5 +++--
 src/sunstone/etc/sunstone-views/vcenter/admin.yaml         | 5 +++--
 src/sunstone/etc/sunstone-views/vcenter/groupadmin.yaml    | 5 +++--
 src/sunstone/etc/sunstone-views/vcenter/user.yaml          | 5 +++--
 .../public/app/tabs/oneflow-services-tab/datatable.js      | 7 +++++--
 .../public/app/tabs/oneflow-services-tab/panels/info.js    | 5 ++++-
 .../app/tabs/oneflow-services-tab/panels/info/html.hbs     | 5 +++++
 12 files changed, 41 insertions(+), 21 deletions(-)

diff --git a/src/sunstone/etc/sunstone-views/kvm/admin.yaml b/src/sunstone/etc/sunstone-views/kvm/admin.yaml
index a6831ea0e5..b5aeb0802d 100644
--- a/src/sunstone/etc/sunstone-views/kvm/admin.yaml
+++ b/src/sunstone/etc/sunstone-views/kvm/admin.yaml
@@ -475,8 +475,9 @@ tabs:
             - 3         # Owner
             - 4         # Group
             - 5         # State
-            #- 6        # Labels
-            #- 7        # Search data
+            - 6         # Registration time
+            #- 7        # Labels
+            #- 8        # Search data
         actions:
             Service.refresh: true
             Service.create_dialog: true
diff --git a/src/sunstone/etc/sunstone-views/kvm/groupadmin.yaml b/src/sunstone/etc/sunstone-views/kvm/groupadmin.yaml
index 3cc32a1564..2a5c61215e 100644
--- a/src/sunstone/etc/sunstone-views/kvm/groupadmin.yaml
+++ b/src/sunstone/etc/sunstone-views/kvm/groupadmin.yaml
@@ -474,8 +474,9 @@ tabs:
             #- 3        # Owner
             - 4         # Group
             - 5         # State
-            #- 6        # Labels
-            #- 7        # Search data
+            - 6         # Registration time
+            #- 7        # Labels
+            #- 8        # Search data
         actions:
             Service.refresh: true
             Service.create_dialog: true
diff --git a/src/sunstone/etc/sunstone-views/kvm/user.yaml b/src/sunstone/etc/sunstone-views/kvm/user.yaml
index 62b8b4cc61..f1d641e570 100644
--- a/src/sunstone/etc/sunstone-views/kvm/user.yaml
+++ b/src/sunstone/etc/sunstone-views/kvm/user.yaml
@@ -467,8 +467,9 @@ tabs:
             - 3         # Group
             - 4         # Name
             - 5         # State
-            #- 6        # Labels
-            #- 7        # Search data
+            - 6         # Registration time
+            #- 7        # Labels
+            #- 8        # Search data
         actions:
             Service.refresh: true
             Service.create_dialog: true
diff --git a/src/sunstone/etc/sunstone-views/mixed/admin.yaml b/src/sunstone/etc/sunstone-views/mixed/admin.yaml
index 4f38b893b5..f2a903aa50 100644
--- a/src/sunstone/etc/sunstone-views/mixed/admin.yaml
+++ b/src/sunstone/etc/sunstone-views/mixed/admin.yaml
@@ -475,8 +475,9 @@ tabs:
             - 3         # Owner
             - 4         # Group
             - 5         # State
-            #- 6        # Labels
-            #- 7        # Search data
+            - 6         # Registration time
+            #- 7        # Labels
+            #- 8        # Search data
         actions:
             Service.refresh: true
             Service.create_dialog: true
diff --git a/src/sunstone/etc/sunstone-views/mixed/groupadmin.yaml b/src/sunstone/etc/sunstone-views/mixed/groupadmin.yaml
index d162af851e..3a826357f2 100644
--- a/src/sunstone/etc/sunstone-views/mixed/groupadmin.yaml
+++ b/src/sunstone/etc/sunstone-views/mixed/groupadmin.yaml
@@ -474,8 +474,9 @@ tabs:
             #- 3        # Owner
             - 4         # Group
             - 5         # State
-            #- 6        # Labels
-            #- 7        # Search data
+            - 6         # Registration time
+            #- 7        # Labels
+            #- 8        # Search data
         actions:
             Service.refresh: true
             Service.create_dialog: true
diff --git a/src/sunstone/etc/sunstone-views/mixed/user.yaml b/src/sunstone/etc/sunstone-views/mixed/user.yaml
index 78449db810..fe0cad9298 100644
--- a/src/sunstone/etc/sunstone-views/mixed/user.yaml
+++ b/src/sunstone/etc/sunstone-views/mixed/user.yaml
@@ -467,8 +467,9 @@ tabs:
             - 3         # Group
             - 4         # Name
             - 5         # State
-            #- 6        # Labels
-            #- 7        # Search data
+            - 6         # Registration time
+            #- 7        # Labels
+            #- 8        # Search data
         actions:
             Service.refresh: true
             Service.create_dialog: true
diff --git a/src/sunstone/etc/sunstone-views/vcenter/admin.yaml b/src/sunstone/etc/sunstone-views/vcenter/admin.yaml
index db1d7ff94a..1ab8160676 100644
--- a/src/sunstone/etc/sunstone-views/vcenter/admin.yaml
+++ b/src/sunstone/etc/sunstone-views/vcenter/admin.yaml
@@ -473,8 +473,9 @@ tabs:
             - 3         # Owner
             - 4         # Group
             - 5         # State
-            #- 6        # Labels
-            #- 7        # Search data
+            - 6         # Registration time
+            #- 7        # Labels
+            #- 8        # Search data
         actions:
             Service.refresh: true
             Service.create_dialog: true
diff --git a/src/sunstone/etc/sunstone-views/vcenter/groupadmin.yaml b/src/sunstone/etc/sunstone-views/vcenter/groupadmin.yaml
index f72f7e36b7..a79821750d 100644
--- a/src/sunstone/etc/sunstone-views/vcenter/groupadmin.yaml
+++ b/src/sunstone/etc/sunstone-views/vcenter/groupadmin.yaml
@@ -474,8 +474,9 @@ tabs:
             #- 3        # Owner
             - 4         # Group
             - 5         # State
-            #- 6        # Labels
-            #- 7        # Search data
+            - 6         # Registration time
+            #- 7        # Labels
+            #- 8        # Search data
         actions:
             Service.refresh: true
             Service.create_dialog: true
diff --git a/src/sunstone/etc/sunstone-views/vcenter/user.yaml b/src/sunstone/etc/sunstone-views/vcenter/user.yaml
index 78449db810..fe0cad9298 100644
--- a/src/sunstone/etc/sunstone-views/vcenter/user.yaml
+++ b/src/sunstone/etc/sunstone-views/vcenter/user.yaml
@@ -467,8 +467,9 @@ tabs:
             - 3         # Group
             - 4         # Name
             - 5         # State
-            #- 6        # Labels
-            #- 7        # Search data
+            - 6         # Registration time
+            #- 7        # Labels
+            #- 8        # Search data
         actions:
             Service.refresh: true
             Service.create_dialog: true
diff --git a/src/sunstone/public/app/tabs/oneflow-services-tab/datatable.js b/src/sunstone/public/app/tabs/oneflow-services-tab/datatable.js
index c617745474..2c65694101 100644
--- a/src/sunstone/public/app/tabs/oneflow-services-tab/datatable.js
+++ b/src/sunstone/public/app/tabs/oneflow-services-tab/datatable.js
@@ -26,6 +26,7 @@ define(function(require) {
   var LabelsUtils = require('utils/labels/utils');
   var SearchDropdown = require('hbs!./datatable/search');
   var Status = require('utils/status');
+  var Humanize = require('utils/humanize');
 
   /*
     CONSTANTS
@@ -34,8 +35,8 @@ define(function(require) {
   var RESOURCE = "Service";
   var XML_ROOT = "DOCUMENT";
   var TAB_NAME = require('./tabId');
-  var LABELS_COLUMN = 6;
-  var SEARCH_COLUMN = 7;
+  var LABELS_COLUMN = 7;
+  var SEARCH_COLUMN = 8;
   var TEMPLATE_ATTR = 'TEMPLATE';
 
   /*
@@ -69,6 +70,7 @@ define(function(require) {
       Locale.tr("Group"),
       Locale.tr("Name"),
       Locale.tr("State"),
+      Locale.tr("Registration time"),
       Locale.tr("Labels"),
       "search_data"
     ];
@@ -122,6 +124,7 @@ define(function(require) {
         element.GNAME,
         element.NAME,
         state,
+        Humanize.prettyTime(element.TEMPLATE.BODY['registration_time']),
         (LabelsUtils.labelsStr(element[TEMPLATE_ATTR])||''),
         btoa(unescape(encodeURIComponent(JSON.stringify(search))))
     ];
diff --git a/src/sunstone/public/app/tabs/oneflow-services-tab/panels/info.js b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/info.js
index 71bcf18560..4ff0a923c9 100644
--- a/src/sunstone/public/app/tabs/oneflow-services-tab/panels/info.js
+++ b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/info.js
@@ -23,6 +23,7 @@ define(function(require) {
   var RenameTr = require('utils/panel/rename-tr');
   var PermissionsTable = require('utils/panel/permissions-table');
   var OpenNebulaService = require('opennebula/service');
+  var Humanize = require('utils/humanize');
 
   /*
     TEMPLATES
@@ -65,12 +66,14 @@ define(function(require) {
   function _html() {
     var renameTrHTML = RenameTr.html(TAB_ID, RESOURCE, this.element.NAME);
     var permissionsTableHTML = PermissionsTable.html(TAB_ID, RESOURCE, this.element);
+    var prettyRegTime = Humanize.prettyTime(this.element.TEMPLATE.BODY['registration_time']);
 
     return TemplateHTML({
       'element': this.element,
       'renameTrHTML': renameTrHTML,
       'permissionsTableHTML': permissionsTableHTML,
-      'stateStr': OpenNebulaService.stateStr(this.element.TEMPLATE.BODY.state)
+      'stateStr': OpenNebulaService.stateStr(this.element.TEMPLATE.BODY.state),
+      'prettyRegTime': prettyRegTime
     });
   }
 
diff --git a/src/sunstone/public/app/tabs/oneflow-services-tab/panels/info/html.hbs b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/info/html.hbs
index d88ecde799..5bb50acec2 100644
--- a/src/sunstone/public/app/tabs/oneflow-services-tab/panels/info/html.hbs
+++ b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/info/html.hbs
@@ -28,6 +28,11 @@
           <td class="value_td" colspan="2">{{element.ID}}</td>
         </tr>
         {{{renameTrHTML}}}
+        <tr>
+          <td class="key_td">{{tr "Register time"}}</td>
+          <td class="value_td">{{prettyRegTime}}</td>
+          <td></td>
+        </tr>
         <tr>
           <td class="key_td">{{tr "Strategy"}}</td>
           <td class="value_td">{{element.TEMPLATE.BODY.deployment}}</td>