archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1366908 - in /archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva: main.js search.js
Date Sun, 29 Jul 2012 19:21:55 GMT
Author: olamy
Date: Sun Jul 29 19:21:55 2012
New Revision: 1366908

URL: http://svn.apache.org/viewvc?rev=1366908&view=rev
Log:
better handling of repositoryId in url while browsing to make it work with history

Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js?rev=1366908&r1=1366907&r2=1366908&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
Sun Jul 29 19:21:55 2012
@@ -220,9 +220,9 @@ function() {
           var repositoryId = this.params.repositoryId;
           $.log("repositoryId:"+repositoryId);
           if (groupId){
-            displayBrowseGroupId(groupId);
+            displayBrowseGroupId(groupId,repositoryId);
           } else {
-            displayBrowse(true);
+            displayBrowse(true,repositoryId);
           }
         });
         this.get('#browse~:repositoryId',function(context){

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js?rev=1366908&r1=1366907&r2=1366908&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
Sun Jul 29 19:21:55 2012
@@ -23,13 +23,19 @@ define("archiva.search",["jquery","i18n"
   // browse part
   //-----------------------------------------
 
-  BrowseViewModel=function(browseResultEntries,parentBrowseViewModel,groupId){
+  BrowseViewModel=function(browseResultEntries,parentBrowseViewModel,groupId,repositoryId){
     var self=this;
     this.browseResultEntries=browseResultEntries;
     this.parentBrowseViewModel=parentBrowseViewModel;
     this.groupId=groupId;
+    this.repositoryId=repositoryId;
     displayGroupId=function(groupId){
-      window.sammyArchivaApplication.setLocation("#browse/"+groupId);
+      $.log("BrowseViewModel#displayGroupId,self.repositoryId:"+self.repositoryId);
+      if(self.repositoryId){
+        window.sammyArchivaApplication.setLocation("#browse~"+self.repositoryId+"/"+groupId);
+      } else {
+        window.sammyArchivaApplication.setLocation("#browse/"+groupId);
+      }
     }
     displayParentGroupId=function(){
       $.log("called displayParentGroupId groupId:"+self.parentBrowseViewModel.groupId);
@@ -86,7 +92,7 @@ define("archiva.search",["jquery","i18n"
     return breadCrumbEntries;
   }
 
-  displayGroupDetail=function(groupId,parentBrowseViewModel,restUrl){
+  displayGroupDetail=function(groupId,parentBrowseViewModel,restUrl,repositoryId){
     var mainContent = $("#main-content");
     mainContent.find("#browse_artifact_detail").hide();
     var browseResult=mainContent.find("#browse_result");
@@ -97,7 +103,7 @@ define("archiva.search",["jquery","i18n"
         function(){
           browseResult.html(mediumSpinnerImg());
           browseBreadCrumb.html(smallSpinnerImg());
-          mainContent.find("#main_browse_result_content" ).show();
+          mainContent.find("#main_browse_result_content").show();
           var url = "";
           if (!restUrl) {
             url="restServices/archivaServices/browseService/browseGroupId/"+encodeURIComponent(groupId);
@@ -105,7 +111,7 @@ define("archiva.search",["jquery","i18n"
             if (selectedRepo){
               url+="?repositoryId="+selectedRepo;
             }
-          }else {
+          } else {
             url=restUrl;
           }
 
@@ -114,7 +120,7 @@ define("archiva.search",["jquery","i18n"
             dataType: 'json',
             success: function(data) {
               var browseResultEntries = mapBrowseResultEntries(data);
-              var browseViewModel = new BrowseViewModel(browseResultEntries,parentBrowseViewModel,groupId);
+              var browseViewModel = new BrowseViewModel(browseResultEntries,parentBrowseViewModel,groupId,repositoryId);
               ko.applyBindings(browseViewModel,browseBreadCrumb.get(0));
               ko.applyBindings(browseViewModel,browseResult.get(0));
               enableAutocompleBrowse(groupId);
@@ -661,36 +667,33 @@ define("archiva.search",["jquery","i18n"
     mainContent.find("#browse_artifact" ).hide();
     mainContent.find("#browse_result").html(mediumSpinnerImg());
 
-    $.ajax("restServices/archivaServices/browseService/userRepositories", {
-        type: "GET",
-        dataType: 'json',
-        success: function(data) {
-          mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:repositoryId}));
-          var url="restServices/archivaServices/browseService/rootGroups";
-          if(repositoryId){
-            url+="?repositoryId="+repositoryId;
-          }
-          $.ajax(url, {
-              type: "GET",
-              dataType: 'json',
-              success: function(data) {
-                var browseResultEntries = mapBrowseResultEntries(data);
-                $.log("size:"+browseResultEntries.length);
-                var browseViewModel = new BrowseViewModel(browseResultEntries,null,null);
-                ko.applyBindings(browseViewModel,mainContent.find("#browse_breadcrumb").get(0));
-                ko.applyBindings(browseViewModel,mainContent.find("#browse_result").get(0));
-                enableAutocompleBrowse();
-              }
-          });
+
+    userRepositoriesCall(
+      function(data) {
+        mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:repositoryId}));
+        var url="restServices/archivaServices/browseService/rootGroups";
+        if(repositoryId){
+          url+="?repositoryId="+repositoryId;
         }
-    });
+        $.ajax(url, {
+            type: "GET",
+            dataType: 'json',
+            success: function(data) {
+              var browseResultEntries = mapBrowseResultEntries(data);
+              $.log("size:"+browseResultEntries.length);
+              var browseViewModel = new BrowseViewModel(browseResultEntries,null,null,repositoryId);
+              ko.applyBindings(browseViewModel,mainContent.find("#browse_breadcrumb").get(0));
+              ko.applyBindings(browseViewModel,mainContent.find("#browse_result").get(0));
+              enableAutocompleBrowse();
+            }
+        });
+      }
+    )
 
   }
 
   changeBrowseRepository=function(){
     var selectedRepository=getSelectedBrowsingRepository();
-    //$.log("changeBrowseRepository:"+selectedRepository);
-    //displayGroupDetail(null,null,"restServices/archivaServices/browseService/rootGroups?repositoryId="+encodeURIComponent(selectedRepository));
     window.sammyArchivaApplication.setLocation("#browse~"+selectedRepository);
   }
 
@@ -827,20 +830,31 @@ define("archiva.search",["jquery","i18n"
    * called if browser url contains queryParam browse=groupId
    * @param groupId
    */
-  displayBrowseGroupId=function(groupId){
+  displayBrowseGroupId=function(groupId,repositoryId){
     clearUserMessages();
-    $.log("displayBrowseGroupId:"+groupId);
-    var mainContent = $("#main-content");
-    mainContent.html($("#browse-tmpl" ).tmpl());
-    mainContent.find("#browse_result").html(mediumSpinnerImg());
-    var parentBrowseViewModel=new BrowseViewModel(null,null,null);
-    displayGroupDetail(groupId,parentBrowseViewModel,null);
+    $.log("displayBrowseGroupId:"+groupId+":"+repositoryId);
+    userRepositoriesCall(
+        function(data){
+          var mainContent = $("#main-content");
+          mainContent.html($("#browse-tmpl" ).tmpl());
+          mainContent.find("#browse_result").html(mediumSpinnerImg());
+          var parentBrowseViewModel=new BrowseViewModel(null,null,null,repositoryId);
+          var url="restServices/archivaServices/browseService/browseGroupId/"+encodeURIComponent(groupId);
+          if (repositoryId){
+            url+="?repositoryId="+repositoryId;
+            mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl"
).tmpl({repositories:data,selected:repositoryId}));
+          }else{
+            mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl"
).tmpl({repositories:data,selected:""}));
+          }
+          displayGroupDetail(groupId,parentBrowseViewModel,url,repositoryId);
+        }
+    );
+
   }
 
   displayBrowseArtifactDetail=function(groupId, artifactId){
     $.log("displayBrowseArtifactDetail");
     window.sammyArchivaApplication.setLocation("#artifact/"+groupId+"/"+artifactId);
-    //displayArtifactDetail(groupId,artifactId,null,null);
   }
 
   goToBrowseArtifactDetail=function(groupId, artifactId){
@@ -1353,13 +1367,23 @@ define("archiva.search",["jquery","i18n"
     mainContent.find("#browse_artifact_detail").html(mediumSpinnerImg());
     mainContent.find("#browse_breadcrumb" ).show();
     mainContent.find("#browse_breadcrumb" ).html(mediumSpinnerImg());
+
+    userRepositoriesCall(
+      function(data) {
+        mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:repositoryId}));
+        var artifactVersionDetailViewModel=new ArtifactVersionDetailViewModel(groupId,artifactId,version,repositoryId);
+        artifactVersionDetailViewModel.display();
+      }
+    );
+
+  }
+
+  userRepositoriesCall=function(successCallbackFn){
     $.ajax("restServices/archivaServices/browseService/userRepositories", {
         type: "GET",
         dataType: 'json',
         success: function(data) {
-          mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:repositoryId}));
-          var artifactVersionDetailViewModel=new ArtifactVersionDetailViewModel(groupId,artifactId,version,repositoryId);
-          artifactVersionDetailViewModel.display();
+          successCallbackFn(data);
         }
     });
   }



Mime
View raw message