From 7a447503fd53bb2a14777d8fcc0ae99a513cb6cc Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 28 Aug 2012 09:08:01 +0000 Subject: [PATCH] browsing download artifacts content is now navigable git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1378030 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/js/archiva/main.js | 26 ++++++++++ .../src/main/webapp/js/archiva/search.js | 49 ++++++++++++------- 2 files changed, 56 insertions(+), 19 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 b55de7d8d..16e18e79c 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 @@ -393,6 +393,32 @@ function(jquery,ui,sammy,tmpl) { }); + this.get('#artifact-details-download-content/: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; + + checkArtifactDetailContent(groupId,artifactId,version,null,"artifact-details-download-content-a","artifact-details-download-content", + function(groupId,artifactId,version,artifactVersionDetailViewModel){ + displayArtifactDownloadContent(artifactVersionDetailViewModel); + }); + + }); + + this.get('#artifact-details-download-content~: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; + checkArtifactDetailContent(groupId,artifactId,version,repositoryId,"artifact-details-download-content-a","artifact-details-download-content", + function(groupId,artifactId,version,artifactVersionDetailViewModel){ + displayArtifactDownloadContent(artifactVersionDetailViewModel); + }); + }); + this.get('#artifact-dependency-tree/:groupId/:artifactId/:version',function(context){ 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 880b12a89..cc19e38d7 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 @@ -329,19 +329,16 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno } if ($(e.target).attr("href")=="#artifact-details-download-content") { - mainContent.find("#artifact-details-download-content" ).html(smallSpinnerImg()); - var artifactDownloadInfosUrl = "restServices/archivaServices/browseService/artifactDownloadInfos/"+encodeURIComponent(self.groupId); - artifactDownloadInfosUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version); - artifactDownloadInfosUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository()); - $.get(artifactDownloadInfosUrl,function(data){ - var artifactDetailsDownloadViewModel = new ArtifactDetailsDownloadViewModel(mapArtifacts(data),self); - mainContent.find("#artifact-details-download-content" ).attr("data-bind",'template:{name:"artifact-details-download-content_tmpl"}'); - ko.applyBindings(artifactDetailsDownloadViewModel,mainContent.find("#artifact-details-download-content" ).get(0)); - }); + var location ="#artifact-details-download-content"; + if (self.repositoryId){ + location+="~"+self.repositoryId; + } + location+="/"+self.groupId+"/"+self.artifactId+"/"+self.version; + + window.sammyArchivaApplication.setLocation(location); return; } if ($(e.target).attr("href")=="#artifact-details-files-content") { - //displayArtifactFilesContent(self); var location ="#artifact-details-files-content"; if (self.repositoryId){ location+="~"+self.repositoryId; @@ -520,11 +517,25 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno } - displayArtifactFilesContent=function(self){ + displayArtifactDownloadContent=function(artifactVersionDetailViewModel){ + var mainContent=$("#main-content"); + mainContent.find("#artifact-details-download-content" ).html(smallSpinnerImg()); + var artifactDownloadInfosUrl = "restServices/archivaServices/browseService/artifactDownloadInfos/"+encodeURIComponent(artifactVersionDetailViewModel.groupId); + artifactDownloadInfosUrl+="/"+encodeURIComponent(artifactVersionDetailViewModel.artifactId)+"/"+encodeURIComponent(artifactVersionDetailViewModel.version); + artifactDownloadInfosUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository()); + $.get(artifactDownloadInfosUrl,function(data){ + var artifactDetailsDownloadViewModel = new ArtifactDetailsDownloadViewModel(mapArtifacts(data),artifactVersionDetailViewModel); + mainContent.find("#artifact-details-download-content" ).attr("data-bind",'template:{name:"artifact-details-download-content_tmpl"}'); + ko.applyBindings(artifactDetailsDownloadViewModel,mainContent.find("#artifact-details-download-content" ).get(0)); + }); + return; + } + + displayArtifactFilesContent=function(artifactVersionDetailViewModel){ var mainContent = $("#main-content"); mainContent.find("#artifact-details-files-content" ).html(smallSpinnerImg()); - var artifactDownloadInfosUrl = "restServices/archivaServices/browseService/artifactDownloadInfos/"+encodeURIComponent(self.groupId); - artifactDownloadInfosUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version); + var artifactDownloadInfosUrl = "restServices/archivaServices/browseService/artifactDownloadInfos/"+encodeURIComponent(artifactVersionDetailViewModel.groupId); + artifactDownloadInfosUrl+="/"+encodeURIComponent(artifactVersionDetailViewModel.artifactId)+"/"+encodeURIComponent(artifactVersionDetailViewModel.version); artifactDownloadInfosUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository()); $.get(artifactDownloadInfosUrl,function(data){ @@ -542,8 +553,8 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno $.log("click:" + idValue + " -> " + classifier + ":" + type + ":" + version); if (type=="pom"){ $.log("show pom"); - var pomContentUrl = "restServices/archivaServices/browseService/artifactContentText/"+encodeURIComponent(self.groupId); - pomContentUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(version); + var pomContentUrl = "restServices/archivaServices/browseService/artifactContentText/"+encodeURIComponent(artifactVersionDetailViewModel.groupId); + pomContentUrl+="/"+encodeURIComponent(artifactVersionDetailViewModel.artifactId)+"/"+encodeURIComponent(version); pomContentUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository()); pomContentUrl+="&t=pom"; mainContent.find("#artifact-content-text" ).html(smallSpinnerImg()); @@ -559,8 +570,8 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno }); return; } - var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(self.groupId); - entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(version); + var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(artifactVersionDetailViewModel.groupId); + entriesUrl+="/"+encodeURIComponent(artifactVersionDetailViewModel.artifactId)+"/"+encodeURIComponent(version); entriesUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository()); if(classifier){ entriesUrl+="&c="+encodeURIComponent(classifier); @@ -570,8 +581,8 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno root: "" },function(file) { $.log("file:"+file.substringBeforeLast("/")+',classifier:'+classifier); - var fileContentUrl = "restServices/archivaServices/browseService/artifactContentText/"+encodeURIComponent(self.groupId); - fileContentUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(version); + var fileContentUrl = "restServices/archivaServices/browseService/artifactContentText/"+encodeURIComponent(artifactVersionDetailViewModel.groupId); + fileContentUrl+="/"+encodeURIComponent(artifactVersionDetailViewModel.artifactId)+"/"+encodeURIComponent(version); fileContentUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository()); if(type){ fileContentUrl+="&t="+encodeURIComponent(type);