]> source.dussan.org Git - archiva.git/commitdiff
add sammy route to be able to add repository id in url
authorOlivier Lamy <olamy@apache.org>
Sun, 29 Jul 2012 19:21:42 +0000 (19:21 +0000)
committerOlivier Lamy <olamy@apache.org>
Sun, 29 Jul 2012 19:21:42 +0000 (19:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1366907 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/archiva/search.js

index 0ee7f474ee0209f01b1bb654bca36a29d10c5d9b..66073da59a150e7f5401213bd8a527a6503c609b 100644 (file)
@@ -187,8 +187,8 @@ function() {
         // 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'];
+          var groupId= this.params.groupId;
+          var artifactId= this.params.artifactId;
           $.log("get #artifact:"+groupId+":"+artifactId);
           goToBrowseArtifactDetail(groupId,artifactId);//,null,null);
           return;
@@ -196,10 +196,10 @@ function() {
         });
         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'];
+          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);
@@ -208,13 +208,28 @@ function() {
           }
         });
         this.get('#browse/:groupId',function(context){
-          var groupId = this.params['groupId'];
+          var groupId = this.params.groupId;
           if (groupId){
             displayBrowseGroupId(groupId);
           } else {
             displayBrowse(true);
           }
         });
+        this.get('#browse~:repositoryId/:groupId',function(context){
+          var groupId = this.params.groupId;
+          var repositoryId = this.params.repositoryId;
+          $.log("repositoryId:"+repositoryId);
+          if (groupId){
+            displayBrowseGroupId(groupId);
+          } else {
+            displayBrowse(true);
+          }
+        });
+        this.get('#browse~:repositoryId',function(context){
+          var repositoryId = this.params.repositoryId;
+          $.log("repositoryId:"+repositoryId);
+          displayBrowse(true,repositoryId);
+        });
         this.get('#:folder', function () {
           var folder = this.params.folder;
           self.activeMenuId(folder);
index 5540c2ff23d6c2611353cf5024497c95c424d4a9..40bac1de57f4215fb10c9354ad549b7832b2b3ca 100644 (file)
@@ -637,19 +637,21 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
   }
 
   browseRoot=function(){
-    /*var url="restServices/archivaServices/browseService/rootGroups";
     var selectedRepo=getSelectedBrowsingRepository();
-    if (selectedRepo){
-      url+="?repositoryId="+encodeURIComponent(selectedRepo);
+
+    if(selectedRepo) {
+      window.sammyArchivaApplication.setLocation("#browse~"+selectedRepo);
+    } else {
+      window.sammyArchivaApplication.setLocation("#browse");
     }
-    displayGroupDetail(null,null,url);*/
-    window.sammyArchivaApplication.setLocation("#browse");
   }
 
   /**
    * call from menu entry to display root level
+   * @param freshView redisplay everything
+   * @param repositoryId if any repository selected
    */
-  displayBrowse=function(freshView){
+  displayBrowse=function(freshView,repositoryId){
     screenChange();
     var mainContent = $("#main-content");
     if(freshView){
@@ -663,8 +665,11 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
         type: "GET",
         dataType: 'json',
         success: function(data) {
-          mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:""}));
-          var url="restServices/archivaServices/browseService/rootGroups"
+          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',
@@ -684,8 +689,9 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
 
   changeBrowseRepository=function(){
     var selectedRepository=getSelectedBrowsingRepository();
-    $.log("changeBrowseRepository:"+selectedRepository);
-    displayGroupDetail(null,null,"restServices/archivaServices/browseService/rootGroups?repositoryId="+encodeURIComponent(selectedRepository));
+    //$.log("changeBrowseRepository:"+selectedRepository);
+    //displayGroupDetail(null,null,"restServices/archivaServices/browseService/rootGroups?repositoryId="+encodeURIComponent(selectedRepository));
+    window.sammyArchivaApplication.setLocation("#browse~"+selectedRepository);
   }
 
   getSelectedBrowsingRepository=function(){