]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1620] add a tab to browse artifact content in artifact detail view
authorOlivier Lamy <olamy@apache.org>
Mon, 21 May 2012 17:08:18 +0000 (17:08 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 21 May 2012 17:08:18 +0000 (17:08 +0000)
pom view !

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1341111 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html

index 9a90da8ef135af47f04805933023dab7c7806814..e587ad56486ee9c085f9317c4f34fbd6f20b262f 100644 (file)
@@ -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,'&lt;');
+                            text=text.replace(/>/g,"&gt;");
+                            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);
+                                 }
+                      );
+                    });
+
                   });
 
                 }
index 5f50407a5dfd7e9d0a3d32936e4d39ba8f103f0f..69a575e36a044aa3da3da1a620248cfb7e87d4bd 100644 (file)
@@ -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
   //-----------------------------------------
index 19a159cb0ed63cb105cbd3dd281579484f8b1b79..544b90155dfb759e0c04f8d9453dfc91fc7411e2 100644 (file)
 <script id="artifact-details-files-content_tmpl" type="text/html">
       <div class="row">
         <div class="span4">
-           <ul>
+           <ul id="artifact-content-list-files">
            {{each artifactDownloadInfos}}
-             <li>${$value.type}:${$value.classifier}</li>
+             <li id="${$value.classifier}:${$value.type}">
+               <a href="#">${$value.type}</a>
+             </li>
            {{/each}}
            </ul>
         </div>
           </div>
         </div>
       </div>
+      <h4>Content</h4>
+      <div>
+         <pre id="artifact-content-text"></pre>
+      </div>
 </script>
\ No newline at end of file