]> source.dussan.org Git - archiva.git/commitdiff
fix admin create box call
authorOlivier Lamy <olamy@apache.org>
Wed, 11 Jul 2012 22:03:04 +0000 (22:03 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 11 Jul 2012 22:03:04 +0000 (22:03 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1360437 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js

index 4b7167314cf35e490511c76e8520bee8723c096c..a220541ee4d516a87005a5c284cdaef4d005564e 100644 (file)
@@ -129,45 +129,6 @@ function() {
     $.log("hideElementWithKarma");
   }
 
-  userLoggedCallbackFn=function(user){
-    $.log("userLoggedCallbackFn:"+ (user?user.username:null));
-
-    if (!user) {
-      $("#login-link").show();
-      $("#register-link").show();
-      $("#change-password-link").hide();
-      checkUrlParams();
-    } else {
-      $("#change-password-link").show();
-      $("#logout-link").show();
-      $("#register-link").hide();
-      $("#login-link").hide();
-      decorateMenuWithKarma(user);
-    }
-  }
-
-  checkSecurityLinks=function(){
-    userLogged(userLoggedCallbackFn);
-  }
-
-  checkCreateAdminLink=function(){
-    $.ajax("restServices/redbackServices/userService/isAdminUserExists", {
-      type: "GET",
-      dataType: 'json',
-      success: function(data) {
-        var adminExists = data;
-        if (adminExists == false) {
-          $("#create-admin-link").show();
-          $("#login-link").hide();
-          $("#register-link").hide();
-        } else {
-          $("#create-admin-link").hide();
-        }
-        $.log("adminExists:"+adminExists);
-      }
-    });
-  }
-
   //------------------------------------//
   // Change UI with appearance settings //
   //------------------------------------//
@@ -235,58 +196,101 @@ function() {
       this.activeMenuId = ko.observable();
           
       window.sammyArchivaApplication = Sammy(function () {
-                // #artifact-(optionnal repositoryId)
-                // format groupId:artifactId org.apache.maven.plugins:maven-jar-plugin
-                // or  groupId:artifactId:version org.apache.maven.plugins:maven-jar-plugin:2.3.1
-                this.get('#artifact/:groupId/:artifactId',function(context){
-                  var groupId= this.params['groupId'];
-                  var artifactId= this.params['artifactId'];
-                  $.log("get #artifact:"+groupId+":"+artifactId);
-                  goToBrowseArtifactDetail(groupId,artifactId);//,null,null);
-                  return;
-
-                });
-                this.get('#artifact:repositoryId/:groupId/:artifactId/:version',function(context){
-
-                  var repositoryId = this.params['repositoryId'];
-                  var groupId= this.params['groupId'];
-                  var artifactId= this.params['artifactId'];
-                  var version= this.params['version'];
-
-                  if(!version){
-                    displayBrowseArtifactDetail(splitted[0],splitted[1]);//,null,null);
-                  } else {
-                    generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId);
-                  }
-                });
-                this.get('#browse/:groupId',function(context){
-                  var groupId = this.params['groupId'];
-                  if (groupId){
-                    displayBrowseGroupId(groupId);
-                  } else {
-                    displayBrowse(true);
-                  }
-                });
-                this.get('#:folder', function () {
-                    self.activeMenuId(this.params.folder);
-                    var baseItems = self.artifactMenuItems?self.artifactMenuItems:[];
-                    ko.utils.arrayFirst(baseItems.concat(self.usersMenuItems, self.administrationMenuItems), function(p) {
-                        if ( p.href == "#"+self.activeMenuId()) {
-                          p.func();
-                          return;
-                        }
-                    });
-                    
-                });
-                this.get('#open-admin-create-box',function(){
-                  $.log("#open-admin-create-box");
-                  adminCreateBox();
-                });
-                //this.get('', function () { this.app.runRoute('get', '#search') });
-          } );
+        this.get('#open-admin-create-box',function(){
+          $.log("#open-admin-create-box");
+          adminCreateBox();
+        });
+
+        // #artifact-(optionnal repositoryId)
+        // format groupId:artifactId org.apache.maven.plugins:maven-jar-plugin
+        // or  groupId:artifactId:version org.apache.maven.plugins:maven-jar-plugin:2.3.1
+        this.get('#artifact/:groupId/:artifactId',function(context){
+          var groupId= this.params['groupId'];
+          var artifactId= this.params['artifactId'];
+          $.log("get #artifact:"+groupId+":"+artifactId);
+          goToBrowseArtifactDetail(groupId,artifactId);//,null,null);
+          return;
+
+        });
+        this.get('#artifact:repositoryId/:groupId/:artifactId/:version',function(context){
+
+          var repositoryId = this.params['repositoryId'];
+          var groupId= this.params['groupId'];
+          var artifactId= this.params['artifactId'];
+          var version= this.params['version'];
+
+          if(!version){
+            displayBrowseArtifactDetail(splitted[0],splitted[1]);//,null,null);
+          } else {
+            generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId);
+          }
+        });
+        this.get('#browse/:groupId',function(context){
+          var groupId = this.params['groupId'];
+          if (groupId){
+            displayBrowseGroupId(groupId);
+          } else {
+            displayBrowse(true);
+          }
+        });
+        this.get('#:folder', function () {
+          var folder = this.params.folder;
+          self.activeMenuId(folder);
+          var baseItems = self.artifactMenuItems?self.artifactMenuItems:[];
+          ko.utils.arrayFirst(baseItems.concat(self.usersMenuItems, self.administrationMenuItems), function(p) {
+            if ( p.href == "#"+self.activeMenuId()) {
+              p.func();
+              return;
+            }
+          });
+        });
+        //this.get('', function () { this.app.runRoute('get', '#search') });
+      });
       sammyArchivaApplication.run();
   }
 
+  userLoggedCallbackFn=function(user){
+    $.log("userLoggedCallbackFn:"+ (user?user.username:null));
+
+    if (!user) {
+      $("#login-link").show();
+      $("#register-link").show();
+      $("#change-password-link").hide();
+      checkUrlParams();
+    } else {
+      $("#change-password-link").show();
+      $("#logout-link").show();
+      $("#register-link").hide();
+      $("#login-link").hide();
+      decorateMenuWithKarma(user);
+    }
+  }
+
+  checkSecurityLinks=function(){
+    userLogged(userLoggedCallbackFn);
+  }
+
+  checkCreateAdminLink=function(callbackFn){
+    $.ajax("restServices/redbackServices/userService/isAdminUserExists", {
+      type: "GET",
+      dataType: 'json',
+      success: function(data) {
+        var adminExists = data;
+        if (adminExists == false) {
+          $("#create-admin-link").show();
+          $("#login-link").hide();
+          $("#register-link").hide();
+        } else {
+          $("#create-admin-link").hide();
+        }
+        if(callbackFn){
+          callbackFn()
+        }
+        $.log("adminExists:"+adminExists);
+      }
+    });
+  }
+
   startArchivaApplication=function(){
 
     $.log("startArchivaApplication");
index d91bd4dcd2ed18c3d87d649eec47f7cdb48a9c34..ea11fa92b23a4a3f767ff883ffcbb500a049351e 100644 (file)
@@ -296,10 +296,11 @@ define("redback.user",["jquery","utils","i18n","jquery.validate","knockout","kno
    * open a modal box to create admin user
    */
   adminCreateBox=function() {
+    $.log("adminCreateBox");
     window.redbackModel.createUser=true;
     $("#main-content").attr("data-bind",'template: {name:"redback/user-edit-tmpl",data: user}');
     var viewModel = new AdminUserViewModel();
-    ko.applyBindings(viewModel);
+    ko.applyBindings(viewModel,$("#main-content" ).get(0));
     $("#user-create").validate({
       rules: {
         confirmPassword: {