From e75ddd592ea787fcf900960170e008716ba6b1ca Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sun, 29 Jul 2012 19:21:42 +0000 Subject: [PATCH] add sammy route to be able to add repository id in url git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1366907 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/js/archiva/main.js | 29 ++++++++++++++----- .../src/main/webapp/js/archiva/search.js | 26 ++++++++++------- 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js index 0ee7f474e..66073da59 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js @@ -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); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js index 5540c2ff2..40bac1de5 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js @@ -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(){ -- 2.39.5