syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [1/4] syncope git commit: [SYNCOPE-946] Combining jQuery and AdminLTE to provide the new EncryptedFieldPanel
Date Fri, 30 Sep 2016 15:32:55 GMT
Repository: syncope
Updated Branches:
  refs/heads/2_0_X 9d861564d -> 459cb2e4e
  refs/heads/master 7b9f9758f -> b85e14b85


[SYNCOPE-946] Combining jQuery and AdminLTE to provide the new EncryptedFieldPanel


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/adb56711
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/adb56711
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/adb56711

Branch: refs/heads/2_0_X
Commit: adb567116e9748fb36a236c4c7cad4c05a64ca95
Parents: 9d86156
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Fri Sep 30 17:27:54 2016 +0200
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Fri Sep 30 17:27:54 2016 +0200

----------------------------------------------------------------------
 .../console/rest/AbstractAnyRestClient.java     |  3 +-
 .../markup/html/form/EncryptedFieldPanel.java   | 39 ++++++++++++
 .../client/console/wizards/any/PlainAttrs.java  | 17 ++++--
 .../markup/html/form/AjaxTextFieldPanel.html    | 25 +++-----
 .../markup/html/form/EncryptedFieldPanel.html   | 64 ++++++++++++++++++++
 5 files changed, 127 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/adb56711/client/console/src/main/java/org/apache/syncope/client/console/rest/AbstractAnyRestClient.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/rest/AbstractAnyRestClient.java
b/client/console/src/main/java/org/apache/syncope/client/console/rest/AbstractAnyRestClient.java
index b287029..9d7d1d7 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/rest/AbstractAnyRestClient.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/rest/AbstractAnyRestClient.java
@@ -34,7 +34,6 @@ import org.apache.syncope.common.lib.to.ProvisioningResult;
 import org.apache.syncope.common.lib.types.ResourceAssociationAction;
 import org.apache.syncope.common.lib.types.ResourceDeassociationAction;
 import org.apache.syncope.common.rest.api.service.AnyService;
-import org.apache.syncope.common.rest.api.service.UserService;
 import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
 
 public abstract class AbstractAnyRestClient<TO extends AnyTO, P extends AnyPatch> extends
BaseRestClient {
@@ -63,7 +62,7 @@ public abstract class AbstractAnyRestClient<TO extends AnyTO, P extends
AnyPatch
             result = getService(etag, getAnyServiceClass()).update(patch).
                     readEntity(new GenericType<ProvisioningResult<TO>>() {
                     });
-            resetClient(UserService.class);
+            resetClient(getAnyServiceClass());
         }
         return result;
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/adb56711/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/EncryptedFieldPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/EncryptedFieldPanel.java
b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/EncryptedFieldPanel.java
new file mode 100644
index 0000000..10befa0
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/EncryptedFieldPanel.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.wicket.markup.html.form;
+
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.ResourceModel;
+
+public class EncryptedFieldPanel extends FieldPanel<String> implements Cloneable {
+
+    public EncryptedFieldPanel(final String id, final String name, final IModel<String>
model) {
+        super(id, name, model);
+
+        field = new TextField<String>("encryptedField", model) {
+
+            @Override
+            protected String[] getInputTypes() {
+                return new String[] { "password" };
+            }
+        };
+        add(field.setLabel(new ResourceModel(name, name)).setRequired(false).setOutputMarkupId(true));
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/adb56711/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
index 96d9273..b0429ef 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
@@ -33,6 +33,7 @@ import org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPa
 import org.apache.syncope.client.console.wicket.markup.html.form.BinaryFieldPanel;
 import org.apache.syncope.client.console.wicket.markup.html.form.DateTextFieldPanel;
 import org.apache.syncope.client.console.wicket.markup.html.form.DateTimeFieldPanel;
+import org.apache.syncope.client.console.wicket.markup.html.form.EncryptedFieldPanel;
 import org.apache.syncope.client.console.wicket.markup.html.form.FieldPanel;
 import org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel;
 import org.apache.syncope.client.console.wizards.AjaxWizard;
@@ -266,8 +267,8 @@ public class PlainAttrs extends AbstractAttrs<PlainSchemaTO> {
                 break;
 
             case Long:
-                panel = new AjaxSpinnerFieldPanel.Builder<Long>()
-                        .build("panel", schemaTO.getKey(), Long.class, new Model<Long>());
+                panel = new AjaxSpinnerFieldPanel.Builder<Long>().
+                        build("panel", schemaTO.getKey(), Long.class, new Model<Long>());
 
                 if (required) {
                     panel.addRequiredLabel();
@@ -275,8 +276,8 @@ public class PlainAttrs extends AbstractAttrs<PlainSchemaTO> {
                 break;
 
             case Double:
-                panel = new AjaxSpinnerFieldPanel.Builder<Double>().step(0.1)
-                        .build("panel", schemaTO.getKey(), Double.class, new Model<Double>());
+                panel = new AjaxSpinnerFieldPanel.Builder<Double>().step(0.1).
+                        build("panel", schemaTO.getKey(), Double.class, new Model<Double>());
 
                 if (required) {
                     panel.addRequiredLabel();
@@ -291,6 +292,14 @@ public class PlainAttrs extends AbstractAttrs<PlainSchemaTO> {
                 }
                 break;
 
+            case Encrypted:
+                panel = new EncryptedFieldPanel("panel", schemaTO.getKey(), new Model<String>());
+
+                if (required) {
+                    panel.addRequiredLabel();
+                }
+                break;
+
             default:
                 panel = new AjaxTextFieldPanel("panel", schemaTO.getKey(), new Model<String>(),
false);
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/adb56711/client/console/src/main/resources/org/apache/syncope/client/console/wicket/markup/html/form/AjaxTextFieldPanel.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/wicket/markup/html/form/AjaxTextFieldPanel.html
b/client/console/src/main/resources/org/apache/syncope/client/console/wicket/markup/html/form/AjaxTextFieldPanel.html
index 0b29bba..2c1b7bb 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/wicket/markup/html/form/AjaxTextFieldPanel.html
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/wicket/markup/html/form/AjaxTextFieldPanel.html
@@ -17,19 +17,14 @@ specific language governing permissions and limitations
 under the License.
 -->
 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
-  <head>
-    <title>Ajaxt text field panel</title>
-  </head>
-  <body>
-    <wicket:extend>
-      <wicket:enclosure child="field-label">
-        <label wicket:id="field-label">[LABEL]</label><span wicket:id="required"/>
-        <span wicket:id="jexlInfo" class="glyphicon glyphicon-info-sign" style="cursor:
pointer"></span>
-        <span wicket:id="externalAction"/>
-      </wicket:enclosure>
-      <fieldset class="input-group">
-        <input type="text" class="form-control" wicket:id="textField" placeholder=""/>
-      </fieldset>
-    </wicket:extend>
-  </body>
+  <wicket:extend>
+    <wicket:enclosure child="field-label">
+      <label wicket:id="field-label">[LABEL]</label><span wicket:id="required"/>
+      <span wicket:id="jexlInfo" class="glyphicon glyphicon-info-sign" style="cursor:
pointer"></span>
+      <span wicket:id="externalAction"/>
+    </wicket:enclosure>
+    <fieldset class="input-group">
+      <input type="text" class="form-control" wicket:id="textField" placeholder=""/>
+    </fieldset>
+  </wicket:extend>
 </html>

http://git-wip-us.apache.org/repos/asf/syncope/blob/adb56711/client/console/src/main/resources/org/apache/syncope/client/console/wicket/markup/html/form/EncryptedFieldPanel.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/wicket/markup/html/form/EncryptedFieldPanel.html
b/client/console/src/main/resources/org/apache/syncope/client/console/wicket/markup/html/form/EncryptedFieldPanel.html
new file mode 100644
index 0000000..6a6117f
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/wicket/markup/html/form/EncryptedFieldPanel.html
@@ -0,0 +1,64 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
+  <wicket:extend>
+    <wicket:enclosure child="field-label">
+      <label wicket:id="field-label">[LABEL]</label><span wicket:id="required"/>
+      <span wicket:id="externalAction"/>
+    </wicket:enclosure>
+    <div class="input-group input-group-sm">
+      <span class="input-group-btn">  
+        <button type="button" class="btn btn-warning btn-flat"
+                onclick="var pwd = $(this).parent().next('input');
+                    var children = $(this).children();
+                    if (pwd.is('[readonly]')) {
+                      if (pwd.val() === '') {
+                        pwd.removeAttr('readonly');
+                        children.attr('class', 'fa fa-unlock');
+                      } else {
+                        bootbox.confirm('This will remove the current value. Continue?',
function (result) {
+                          if (result === true) {
+                            pwd.removeAttr('readonly');
+                            pwd.val('');
+                            children.attr('class', 'fa fa-unlock');
+                          }
+                          return true;
+                        });
+                      }
+                    }
+                "><i class="fa fa-lock"></i></button>
+      </span>
+      <input type="password" class="form-control" wicket:id="encryptedField" readonly="true"/>
+      <span class="input-group-btn">  
+        <button type="button" class="btn btn-primary btn-flat"
+                onmousedown="var pwd = $(this).parent().prev('input');
+                    if (!pwd.is('[readonly]')) {
+                      pwd.attr('type', 'text');
+                      $(this).children().attr('class', 'fa fa-eye-slash');
+                    }"
+                onmouseup="var pwd = $(this).parent().prev('input');
+                    if (!pwd.is('[readonly]')) {
+                      pwd.attr('type', 'password');
+                      $(this).children().attr('class', 'fa fa-eye');
+                    }"
+                ><i class="fa fa-eye"></i></button>
+      </span>
+    </div>
+  </wicket:extend>
+</html>


Mime
View raw message