[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Pki-devel] [PATCH] 675 Added property file for token state and transition labels.



On 2/3/2016 12:45 PM, Endi Sukma Dewata wrote:
The labels for token states and transitions are now stored in
token-states.properties. The labels will be loaded when the UI
is initialized. The dialog box for changing token status will
now show the transition labels.

The property file later can be moved into the theme package to
allow customization.

https://fedorahosted.org/pki/ticket/1289
https://fedorahosted.org/pki/ticket/1291

New patch attached. Fixed some typos.

--
Endi S. Dewata
>From 219672f57dfc277f85c127e3df0e2d9532106cac Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata redhat com>
Date: Wed, 3 Feb 2016 19:20:31 +0100
Subject: [PATCH] Added property file for token state and transition labels.

The labels for token states and transitions are now stored in
token-states.properties. The labels will be loaded when the UI
is initialized. The dialog box for changing token status will
now show the transition labels.

The property file later can be moved into the theme package to
allow customization.

https://fedorahosted.org/pki/ticket/1289
https://fedorahosted.org/pki/ticket/1291
---
 base/tps/shared/webapps/tps/js/token.js            | 14 ++++---------
 base/tps/shared/webapps/tps/ui/index.html          | 24 +++++++++++++++++++++-
 .../shared/webapps/tps/ui/token-states.properties  | 21 +++++++++++++++++++
 3 files changed, 48 insertions(+), 11 deletions(-)
 create mode 100644 base/tps/shared/webapps/tps/ui/token-states.properties

diff --git a/base/tps/shared/webapps/tps/js/token.js b/base/tps/shared/webapps/tps/js/token.js
index 1a4267f72de1c378522dc16ec18f3c90414f1dd7..a2d25fd6eaf39161fd6fb0e611929789ef87851d 100644
--- a/base/tps/shared/webapps/tps/js/token.js
+++ b/base/tps/shared/webapps/tps/js/token.js
@@ -19,15 +19,9 @@
  * @author Endi S. Dewata
  */
 
-var TokenStatus = {
-    UNINITIALIZED: "Uninitialized",
-    ACTIVE: "Active",
-    TEMP_LOST: "Temporarily lost",
-    PERM_LOST: "Permanently lost",
-    DAMAGED: "Physically damaged",
-    TEMP_LOST_PERM_LOST: "Temporarily lost then permanently lost",
-    TERMINATED: "Terminated"
-};
+// contents are defined in token-states.properties
+var TokenStatus = {};
+var TokenStateTransition = {};
 
 var TokenModel = Model.extend({
     urlRoot: "/tps/rest/tokens",
@@ -125,7 +119,7 @@ var TokenDialog = Dialog.extend({
         var nextStates = self.entry["nextStates"];
         _.each(nextStates, function(nextState) {
             $('<option/>', {
-                text: TokenStatus[nextState],
+                text: TokenStateTransition[status + '-' + nextState],
                 value: nextState
             }).appendTo(select);
         });
diff --git a/base/tps/shared/webapps/tps/ui/index.html b/base/tps/shared/webapps/tps/ui/index.html
index 2354e8d1c1cd0942a467ef4828612b4c6f81be9a..da899b303f68a6c3167231a13db51f12b9d86f2d 100644
--- a/base/tps/shared/webapps/tps/ui/index.html
+++ b/base/tps/shared/webapps/tps/ui/index.html
@@ -22,6 +22,7 @@
     <link href="/pki/css/patternfly.css" rel="stylesheet" media="screen, print">
     <link href="/pki/css/pki-ui.css" rel="stylesheet" type="text/css">
     <script src="/pki/js/jquery.js"></script>
+    <script src="/pki/js/jquery.i18n.properties.js"></script>
     <script src="/pki/js/underscore.js"></script>
     <script src="/pki/js/backbone.js"></script>
     <script src="/pki/js/bootstrap.js"></script>
@@ -376,7 +377,28 @@ $(function() {
         });
     });
 
-    Backbone.history.start();
+    $.i18n.properties({
+        name: 'token-states',
+        language: ' ', // suppress potential 404's due to .i18n.browserLang()
+        path: '/tps/ui/',
+        mode: 'map',
+        callback: function() {
+
+            var key;
+            for (key in $.i18n.map) {
+                var value = $.i18n.prop(key);
+
+                if (key.indexOf('-') < 0) {
+                    TokenStatus[key] = value;
+                } else {
+                    TokenStateTransition[key] = value;
+                }
+            }
+
+            Backbone.history.start();
+        }
+    });
+
 });
     </script>
 </head>
diff --git a/base/tps/shared/webapps/tps/ui/token-states.properties b/base/tps/shared/webapps/tps/ui/token-states.properties
new file mode 100644
index 0000000000000000000000000000000000000000..3d82d8fe53b125de18074a632d15e83511c5960d
--- /dev/null
+++ b/base/tps/shared/webapps/tps/ui/token-states.properties
@@ -0,0 +1,21 @@
+# Token states
+UNINITIALIZED       = Uninitialized
+ACTIVE              = Active
+TEMP_LOST           = Temporarily lost
+PERM_LOST           = Permanently lost
+DAMAGED             = Physically damaged
+TEMP_LOST_PERM_LOST = Temporarily lost then permanently lost
+TERMINATED          = Terminated
+
+# Token state transitions
+UNINITIALIZED-DAMAGED    = This token has been physically damaged.
+UNINITIALIZED-PERM_LOST  = This token has been permanently lost.
+UNINITIALIZED-TEMP_LOST  = This token has been temporarily lost.
+UNINITIALIZED-TERMINATED = This token has been terminated.
+TEMP_LOST-ACTIVE         = This temporarily lost token has been found.
+TEMP_LOST-PERM_LOST      = This temporarily lost token cannot be found (becomes permanently lost).
+TEMP_LOST-TERMINATED     = This temporarily lost token has been terminated.
+ACTIVE-DAMAGED           = This token has been physically damaged.
+ACTIVE-PERM_LOST         = This token has been permanently lost.
+ACTIVE-TEMP_LOST         = This token has been temporarily lost.
+ACTIVE-TERMINATED        = This token has been terminated.
-- 
2.4.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]