From de4d335725dff5d0399d7e83877013a1a0c91dcd Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 21 May 2012 17:08:18 +0000 Subject: [PATCH] [MRM-1620] add a tab to browse artifact content in artifact detail view pom view ! git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1341111 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/js/archiva/search.js | 48 +++++++++++++++---- .../src/main/webapp/js/archiva/utils.js | 4 ++ .../webapp/js/templates/archiva/search.html | 10 +++- 3 files changed, 51 insertions(+), 11 deletions(-) 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 9a90da8ef..e587ad564 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 @@ -279,15 +279,45 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock $.get(artifactDownloadInfosUrl,function(data){ $("#artifact-details-files-content" ).html($("#artifact-details-files-content_tmpl").tmpl({artifactDownloadInfos:data})); - var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(self.groupId); - entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version); - entriesUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository()); - - $("#main-content #artifact_content_tree").fileTree({ - script: entriesUrl, - root: "" - },function(file) { - }); + mainContent.find("#artifact-content-list-files li" ).on("click",function(){ + var idValue = $(this ).attr("id"); + var classifier=idValue.substringBeforeLast(":"); + var type = idValue.substringAfterLast(":"); + $.log("click:" + idValue + " -> " + classifier + ":" + type ); + if (type=="pom"){ + $.log("show pom"); + var pomContentUrl = "restServices/archivaServices/browseService/artifactContentText/"+encodeURIComponent(self.groupId); + pomContentUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version); + pomContentUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository()); + pomContentUrl+="&t=pom"; + $.ajax({ + url: pomContentUrl, + dataType: "text", + success: function(data) { + $.log("foo"); + $.log("data:"+data); + var text = data.replace(//g,">"); + mainContent.find("#artifact-content-text" ).html(text); + } + }); + return; + } + var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(self.groupId); + entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version); + entriesUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository()); + if(classifier){ + entriesUrl+="&c="+classifier; + } + $("#main-content #artifact_content_tree").fileTree({ + script: entriesUrl, + root: "" + },function(file) { + $.log("file:"+file.substringBeforeLast("/")+',classifier:'+classifier); + } + ); + }); + }); } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js index 5f50407a5..69a575e36 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js @@ -389,6 +389,10 @@ define("utils",["jquery","i18n","jquery.tmpl"], function() { return this.substring(0,this.lastIndexOf(str)); } + String.prototype.substringAfterLast = function(str) { + return this.substring(this.lastIndexOf(str)+1); + } + //----------------------------------------- // extends jquery tmpl to support var def //----------------------------------------- diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html index 19a159cb0..544b90155 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html @@ -810,9 +810,11 @@ \ No newline at end of file -- 2.39.5