Эх сурвалжийг харах

[useradmin] "Sync users/groups LDAP" popup submission results in an embedded window

Moved the popup in the page
Fully ported the popup to bootstrap
Refactored a little the urls
Romain Rigaux 13 жил өмнө
parent
commit
1969955c73

+ 17 - 21
apps/useradmin/src/useradmin/templates/list_users.mako

@@ -30,9 +30,9 @@ ${layout.menubar(section='users')}
     <div class="well hueWell">
         <div class="btn-group pull-right">
             %if user.is_superuser == True:
-            <a id="addUserBtn" href="${ url('useradmin.views.edit_user') }" class="btn">Add user</a>
-            <a id="addLdapUserBtn" href="${ url('useradmin.views.add_ldap_user') }" class="btn">Add/sync LDAP user</a>
-            <a id="syncLdapBtn" href="#" class="btn">Sync LDAP users/groups</a>
+            <a href="${ url('useradmin.views.edit_user') }" class="btn">Add user</a>
+            <a href="${ url('useradmin.views.add_ldap_user') }" class="btn">Add/sync LDAP user</a>
+            <a href="#syncLdap" class="btn" data-toggle="modal">Sync LDAP users/groups</a>
             %endif
         </div>
         <form class="form-search">
@@ -77,16 +77,25 @@ ${layout.menubar(section='users')}
         </tbody>
     </table>
 
-    <div id="syncLdap" class="modal hide fade userModal">
+    <div id="syncLdap" class="modal hide fade">
         <div class="modal-header">
-            <a href="#" class="close" data-dismiss="modal">&times;</a>
+            <button type="button" class="close" data-dismiss="modal">&times;</button>
             <h3>Sync LDAP users and groups</h3>
         </div>
-        <div id="syncLdapBody" class="modal-body">
-            <iframe id="syncLdapFrame" class="scroll" frameBorder="0"></iframe>
+        <div class="modal-body">
+            <div class="alert alert-info">
+                This will not import any users or groups that don't already exist in Hue.
+                Only users and groups imported from LDAP can be synced.
+                <br/>
+                All user information and group memberships will be updated based on the LDAP
+                server's current state.
+            </div>
         </div>
         <div class="modal-footer">
-            <button id="syncLdapSaveBtn" class="btn primary">Sync</button>
+            <form action="${ url('useradmin.views.sync_ldap_users_groups') }" method="POST">
+                <a href="#" class="btn" data-dismiss="modal">Cancel</a>
+                <input type="submit" class="btn primary" value="Sync"/>
+             </form>
         </div>
     </div>
 
@@ -102,8 +111,6 @@ ${layout.menubar(section='users')}
         </div>
         </form>
     </div>
-
-
 </div>
 
     <script type="text/javascript" charset="utf-8">
@@ -143,20 +150,9 @@ ${layout.menubar(section='users')}
                     $(value).show(250);
                   }
                 });
-
-            });
-
-            $("#syncLdapBtn").click(function(){
-                $("#syncLdapFrame").css("height","150px").attr("src","${ url('useradmin.views.sync_ldap_users_groups') }");
-                $("#syncLdap").modal("show");
-            });
-
-            $("#syncLdapSaveBtn").click(function(){
-                $("#syncLdapFrame").contents().find('form').submit();
             });
 
 			$("a[data-row-selector='true']").jHueRowSelector();
-
         });
     </script>
 

+ 0 - 37
apps/useradmin/src/useradmin/templates/sync_ldap_users_groups.mako

@@ -1,37 +0,0 @@
-## Licensed to Cloudera, Inc. under one
-## or more contributor license agreements.  See the NOTICE file
-## distributed with this work for additional information
-## regarding copyright ownership.  Cloudera, Inc. 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.
-<%!
-from desktop.views import commonheader_iframe, commonfooter_iframe
-import urllib
-%>
-
-${commonheader_iframe()}
-<form id="editForm" class="form-horizontal" action="${urllib.quote(action)}" method="POST">
-    <div class="alert alert-info">
-        This will not import any users or groups that don't already exist in Hue.
-        Only users and groups imported from LDAP can be synced.
-        <br/>
-        All user information and group memberships will be updated based on the LDAP
-        server's current state.
-    </div>
-</form>
-
-<script type="text/javascript" charset="utf-8">
-	$(document).ready(function(){
-		$("#id_groups").jHueSelector();
-	});
-</script>
-${commonfooter_iframe()}

+ 15 - 15
apps/useradmin/src/useradmin/urls.py

@@ -21,19 +21,19 @@ from desktop.lib.django_util import get_username_re_rule, get_groupname_re_rule
 username_re = get_username_re_rule()
 groupname_re = get_groupname_re_rule()
 
-urlpatterns = patterns('useradmin',
-  url(r'^$', 'views.list_users'),
-  url(r'^users$', 'views.list_users'),
-  url(r'^groups$', 'views.list_groups'),
-  url(r'^permissions$', 'views.list_permissions'),
-  url(r'^users/edit/(?P<username>%s)$' % (username_re,), 'views.edit_user'),
-  url(r'^users/add_ldap_user$', 'views.add_ldap_user'),
-  url(r'^users/add_ldap_group$', 'views.add_ldap_group'),
-  url(r'^users/sync_ldap_users_groups$', 'views.sync_ldap_users_groups'),
-  url(r'^groups/edit/(?P<name>%s)$' % (groupname_re,), 'views.edit_group'),
-  url(r'^permissions/edit/(?P<app>.*)/(?P<priv>.*)$', 'views.edit_permission'),
-  url(r'^users/new$', 'views.edit_user', name="useradmin.new"),
-  url(r'^groups/new$', 'views.edit_group', name="useradmin.new_group"),
-  url(r'^users/delete/(?P<username>%s)$' % (username_re,), 'views.delete_user'),
-  url(r'^groups/delete/(?P<name>%s)$' % (groupname_re,), 'views.delete_group'),
+urlpatterns = patterns('useradmin.views',
+  url(r'^$', 'list_users'),
+  url(r'^users$', 'list_users'),
+  url(r'^groups$', 'list_groups'),
+  url(r'^permissions$', 'list_permissions'),
+  url(r'^users/edit/(?P<username>%s)$' % (username_re,), 'edit_user'),
+  url(r'^users/add_ldap_user$', 'add_ldap_user'),
+  url(r'^users/add_ldap_group$', 'add_ldap_group'),
+  url(r'^users/sync_ldap_users_groups$', 'sync_ldap_users_groups'),
+  url(r'^groups/edit/(?P<name>%s)$' % (groupname_re,), 'edit_group'),
+  url(r'^permissions/edit/(?P<app>.*)/(?P<priv>.*)$', 'edit_permission'),
+  url(r'^users/new$', 'edit_user', name="useradmin.new"),
+  url(r'^groups/new$', 'edit_group', name="useradmin.new_group"),
+  url(r'^users/delete/(?P<username>%s)$' % (username_re,), 'delete_user'),
+  url(r'^groups/delete/(?P<name>%s)$' % (groupname_re,), 'delete_group'),
 )

+ 2 - 2
apps/useradmin/src/useradmin/views.py

@@ -412,9 +412,9 @@ def sync_ldap_users_groups(request):
 
   if request.method == 'POST':
     sync_ldap_users_and_groups()
-    return render("list_users.mako", request, dict(users=User.objects.all()))
+    return redirect(reverse(list_users))
   else:
-    return render('sync_ldap_users_groups.mako', request, dict(action=request.path))
+    raise PopupException("POST request required in order to sync the LDAP users/groups.")
 
 def _check_remove_last_super(user_obj):
   """Raise an error if we're removing the last superuser"""