knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smol...@apache.org
Subject [knox] branch master updated: KNOX-2617 - Minor style changes and copy-to-clipboard functionality added for JWT/Passcode tokens and base target UL fields on the Token Generation UI (#454)
Date Fri, 04 Jun 2021 16:50:37 GMT
This is an automated email from the ASF dual-hosted git repository.

smolnar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git


The following commit(s) were added to refs/heads/master by this push:
     new deec67b  KNOX-2617 - Minor style changes and copy-to-clipboard functionality added
for JWT/Passcode tokens and base target UL fields on the Token Generation UI (#454)
deec67b is described below

commit deec67b4476618803f1051b3a40960335602a8bb
Author: Sandor Molnar <smolnar@apache.org>
AuthorDate: Fri Jun 4 18:50:28 2021 +0200

    KNOX-2617 - Minor style changes and copy-to-clipboard functionality added for JWT/Passcode
tokens and base target UL fields on the Token Generation UI (#454)
---
 .../resources/applications/tokengen/app/index.html | 57 ++++++++++++++--------
 .../applications/tokengen/app/js/tokengen.js       | 26 ++++++++++
 2 files changed, 63 insertions(+), 20 deletions(-)

diff --git a/gateway-applications/src/main/resources/applications/tokengen/app/index.html
b/gateway-applications/src/main/resources/applications/tokengen/app/index.html
index a338b3b..ce0ea37 100644
--- a/gateway-applications/src/main/resources/applications/tokengen/app/index.html
+++ b/gateway-applications/src/main/resources/applications/tokengen/app/index.html
@@ -48,10 +48,7 @@
 
     </head>
     <body class="login" style="" onload="setTokenStateServiceStatus()">
-        <!-- Page content
-        ================================================== -->
-
-        <section id="signin-container" style="margin-top: 4.5px;">
+        <div style="margin-left: 1.75%; margin-right: 1.75%; margin-top: 4.5px">
             <form action="" method="get" accept-charset="utf-8">
                 <fieldset>
                     <div class="fields">
@@ -83,27 +80,47 @@
                     <span id="errorBox" class="help-inline" style="color:white;display:none;"><span
class="errorMsg"></span>
                         <i class="icon-warning-sign" style="color:#ae2817;"></i>
                     </span>
-                    <button type="button" class="btn btn-primary btn-block" id="genToken"
tabindex="2" onkeypress="keypressed(event)" onclick="gen();">
-                        Generate Token
-                    </button>
+                    <div style="align-content: center; width: 25%;">
+                        <button type="button" class="btn btn-primary btn-block" id="genToken"
tabindex="2" onkeypress="keypressed(event)" onclick="gen();">
+                            Generate Token
+                        </button>
+                    </div>
                 </fieldset>
             </form>
-        </section>
-        <section id="signin-container" style="margin-top: 4.5px;">
-            <span id="resultBox" class="help-inline" style="color:black;display:none;">
-               <label><i class="icon-copy"></i> JWT Token:</label>
-               <textarea id="accessToken" name="accessToken" rows="5" cols="80"></textarea>
-               <label><i class="icon-copy"></i> Passcode Token:</label>
-               <textarea id="accessPasscode" name="accessPasscode" rows="1" cols="80"></textarea>
+        </div>
+        <div style="margin-left: 1.75%; margin-right: 1.75%; margin-top: 10px">
+            <span id="resultBox" style="color:black; display:none; margin-left: 1.75%;
margin-right: 1.75%;">
+
+               <label id="jwtAccessTokenLabel" onclick="copyAccessTokenToClipBoard();"><i
class="icon-copy"></i> JWT Token:</label>
+               <div class="tokenResultDisplay">
+                   <span id="accessToken" name="accessToken" style="word-wrap: break-word"></span>
+               </div>
+
+               <label id="jwtPasscodeTokenLabel" onclick="copyPasscodeTokenToClipBoard();"><i
class="icon-copy"></i> Passcode Token:</label>
+               <div class="tokenResultDisplay">
+                   <span id="accessPasscode" name="accessPasscode"></span>
+               </div>
+
                <label><i class="icon-info"></i> Expiration:</label>
-               <span id="expiry" name="expiry"><i style="color:#000000;"></i></span>
+               <div class="tokenResultDisplay">
+                   <span id="expiry" name="expiry"></span>
+               </div>
+
                <label><i class="icon-info"></i> User:</label>
-               <span id="user" name="user"><i style="color:#000000;"></i></span>
+               <div class="tokenResultDisplay">
+                   <span id="user" name="user"></span>
+               </div>
+
+               <label id="targetBaseUrlLabel" onclick="copyBaseUrlToClipBoard();"><i
class="icon-copy"></i> Target Base URL:</label>
+               <div class="tokenResultDisplay">
+                   <span id="target_url" name="target_url"></span>
+               </div>
+
                <label><i class="icon-link"></i> Homepage:</label>
-               <div id="homepage_url" name="homepage_url"><i style="color:#000000;"></i></div>
-               <label><i class="icon-info"></i> Target URL:</label>
-               <div id="target_url" name="target_url"><i style="color:#000000;"></i></div>
+               <div class="tokenResultDisplay">
+                   <span id="homepage_url" name="homepage_url"></span>
+               </div>
             </span>
-        </section>
+        </div>
     </body>
 </html>
diff --git a/gateway-applications/src/main/resources/applications/tokengen/app/js/tokengen.js
b/gateway-applications/src/main/resources/applications/tokengen/app/js/tokengen.js
index 2231864..b5b4963 100644
--- a/gateway-applications/src/main/resources/applications/tokengen/app/js/tokengen.js
+++ b/gateway-applications/src/main/resources/applications/tokengen/app/js/tokengen.js
@@ -236,3 +236,29 @@ var gen = function() {
           }
     }
 }
+
+function copyAccessTokenToClipBoard() {
+  var range = document.createRange();
+  range.selectNode(document.getElementById("accessToken"));
+  copyTokenToClipboard(range);
+}
+
+function copyPasscodeTokenToClipBoard() {
+  var range = document.createRange();
+  range.selectNode(document.getElementById("accessPasscode"));
+  copyTokenToClipboard(range);
+}
+
+function copyBaseUrlToClipBoard() {
+  var range = document.createRange();
+  range.selectNode(document.getElementById("target_url"));
+  copyTokenToClipboard(range);
+}
+
+function copyTokenToClipboard(rangeWithSelectedNode) {
+  window.getSelection().removeAllRanges(); // clear current selection
+  window.getSelection().addRange(rangeWithSelectedNode); // to select text
+  document.execCommand("copy");
+  window.getSelection().removeAllRanges();// to deselect
+  swal("Copied to clipboard!", {buttons: false, timer: 1000});
+}
\ No newline at end of file

Mime
View raw message