]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1726] merge "Artifacts" and "Artifacts Content"
authorOlivier Lamy <olamy@apache.org>
Tue, 18 Dec 2012 15:54:52 +0000 (15:54 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 18 Dec 2012 15:54:52 +0000 (15:54 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1423489 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
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html

index 1f18d839841bd8b7cf3d1d98dc177895defd5ec5..70caaee491156bdad0a0666222d0f39d562ece96 100644 (file)
@@ -465,32 +465,6 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa
           checkArtifactDetailContent(groupId,artifactId,version,repositoryId,"artifact-details-dependencies-content-a");
         });
 
-        this.get('#artifact-details-files-content/:groupId/:artifactId/:version',function(context){
-
-          var groupId= this.params.groupId;
-          var artifactId= this.params.artifactId;
-          var version= this.params.version;
-
-          checkArtifactDetailContent(groupId,artifactId,version,null,"artifact-details-files-content-a","artifact-details-files-content",
-                                     function(groupId,artifactId,version,artifactVersionDetailViewModel){
-                                       displayArtifactFilesContent(artifactVersionDetailViewModel);
-                                     });
-
-        });
-
-        this.get('#artifact-details-files-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-files-content-a","artifact-details-files-content",
-                                     function(groupId,artifactId,version,artifactVersionDetailViewModel){
-                                       displayArtifactFilesContent(artifactVersionDetailViewModel);
-                                     });
-        });
-
-
         this.get('#artifact-details-download-content/:groupId/:artifactId/:version',function(context){
 
           var repositoryId = this.params.repositoryId;
index 1ae512a97b633906aa284945cbc2ef6154390550..d65d152b6147aeba2bf6c1a6ad85f469c5f37acb 100644 (file)
@@ -720,6 +720,80 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
       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));
+
+
+      mainContent.find("#artifact-download-list-files li img" ).on("click",function(){
+        mainContent.find("#artifact_content_tree").empty();
+        var contentText = mainContent.find("#artifact-content-text" );
+        contentText.empty();
+        var idValue = $(this ).attr("id");
+        var splitted = idValue.split(":");
+
+        var classifier=splitted[0];
+        var version=splitted[1];
+        var type = splitted[2];
+
+        $.log("click:" + idValue + " -> " + classifier + ":" + type + ":" + version);
+        if (type=="pom"){
+          $.log("show pom");
+          var pomContentUrl = "restServices/archivaServices/browseService/artifactContentText/"+encodeURIComponent(artifactVersionDetailViewModel.groupId);
+          pomContentUrl+="/"+encodeURIComponent(artifactVersionDetailViewModel.artifactId)+"/"+encodeURIComponent(version);
+          pomContentUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
+          pomContentUrl+="&t=pom";
+          contentText.html(mediumSpinnerImg());
+          $.ajax({
+                   url: pomContentUrl,
+                   success: function(data) {
+                     var text = data.content.replace(/</g,'&lt;');
+                     text=text.replace(/>/g,"&gt;");
+                     contentText.html(text);
+                     prettyPrint();
+                     // olamy do not move to anchor to not loose nav history
+                     //goToAnchor("artifact-content-text-header");
+                     //window.location.href=window.location+"#artifact-content-text-header";
+                   }
+                 });
+          return;
+        }
+        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);
+        }
+        $("#main-content").find("#artifact_content_tree").fileTree({
+                                                                     script: entriesUrl,
+                                                                     root: ""
+                                                                   },function(file) {
+                                                                     $.log("file:"+file.substringBeforeLast("/")+',classifier:'+classifier);
+                                                                     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);
+                                                                     }
+                                                                     if(classifier){
+                                                                       fileContentUrl+="&c="+encodeURIComponent(classifier);
+                                                                     }
+                                                                     fileContentUrl+="&p="+encodeURIComponent(file.substringBeforeLast("/"));
+                                                                     $.ajax({
+                                                                              url: fileContentUrl,
+                                                                              success: function(data) {
+                                                                                var text = data.content.replace(/</g,'&lt;');
+                                                                                text=text.replace(/>/g,"&gt;");
+                                                                                mainContent.find("#artifact-content-text" ).html(smallSpinnerImg());
+                                                                                mainContent.find("#artifact-content-text" ).html(text);
+                                                                                prettyPrint();
+                                                                                // olamy do not move to anchor to not loose nav history
+                                                                                //goToAnchor("artifact-content-text-header");
+                                                                                //window.location.href=window.location+"#artifact-content-text-header";
+                                                                              }
+                                                                            });
+                                                                   }
+        );
+      });
+
+
     });
     return;
   }
@@ -740,7 +814,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
         var idValue = $(this ).attr("id");
         var splitted = idValue.split(":");
 
-        var classifier=splitted[0];//idValue.substringBeforeLast(":");
+        var classifier=splitted[0];
         var version=splitted[1];
         var type = splitted[2];
 
index c2a0ca1b063fef42bba1c47a8b671905d13bb073..648a8a6a5e8bbd15ab9281850f0bc5d966f97750 100644 (file)
     <a data-toggle="tab" id="artifact-details-dependency-tree-content-a"
        data-target="#artifact-details-dependency-tree-content" href="#artifact-details-dependency-tree-content">${$.i18n.prop('artifact.detail.tab.header.dependency.tree')}</a>
   </li>
-  <li>
-    <a data-toggle="tab" id="artifact-details-files-content-a" data-target="#artifact-details-files-content"
-       href="#artifact-details-files-content">${$.i18n.prop('artifact.detail.tab.header.file.content')}</a>
-  </li>
   <li>
     <a data-toggle="tab" id="artifact-details-download-content-a" data-target="#artifact-details-download-content"
        href="#artifact-details-download-content">${$.i18n.prop('artifact.detail.tab.header.file.download')}</a>
   </ul>
 </script>
 
-<script id="artifact-details-files-content_tmpl" type="text/html">
+<script id="artifact-details-download-content_tmpl" type="text/html">
+
   <div class="row-fluid">
     <div class="span5">
-      <ul id="artifact-content-list-files" class="package-list">
-        {{each artifactDownloadInfos}}
-        <li id="${$value.classifier}:${$value.version}:${$value.packaging}">
-          <a class="cursor-hand">${$value.packaging}:${$value.version}&nbsp;-&nbsp;${$value.size}</a>
+      <ul id="artifact-download-list-files" class="package-list">
+        {{each(i, row) artifacts()}}
+        <li>
+          <img src="images/system-search-16-16.png" class="cursor-hand" id="${row.classifier}:${row.version}:${row.packaging}"/>
+          {{if deleteKarma}}
+          <a href="#" data-bind="click: function(){deleteArtifact(row)}"><img src="images/trash.png"/></a>&nbsp;<a
+                href="${row.url}">${row.packaging}:${row.version}&nbsp;-&nbsp;${row.size}</a>
+          {{else}}
+          <a href="${row.url}">${row.packaging}:${row.version}&nbsp;-&nbsp;${row.size}</a>
+          {{/if}}
         </li>
         {{/each}}
       </ul>
       </div>
     </div>
   </div>
+
   <h4 id="artifact-content-text-header">${$.i18n.prop('browse.artifact.content.header')}</h4>
 
   <div class="source">
     <pre class="prettyprint linenums" id="artifact-content-text"></pre>
   </div>
-</script>
 
-<script id="artifact-details-download-content_tmpl" type="text/html">
-  <ul id="artifact-download-list-files" class="package-list">
-    {{each(i, row) artifacts()}}
-    <li>
-      {{if deleteKarma}}
-      <a href="#" data-bind="click: function(){deleteArtifact(row)}"><img src="images/trash.png"/></a>&nbsp;<a
-            href="${row.url}">${row.packaging}:${row.version}&nbsp;-&nbsp;${row.size}</a>
-      {{else}}
-      <a href="${row.url}">${row.packaging}:${row.version}&nbsp;-&nbsp;${row.size}</a>
-      {{/if}}
-    </li>
-    {{/each}}
-  </ul>
 </script>
\ No newline at end of file