Author: olamy
Date: Tue Dec 18 15:54:52 2012
New Revision: 1423489

URL: http://svn.apache.org/viewvc?rev=1423489&view=rev
Log:
[MRM-1726] merge "Artifacts" and "Artifacts Content"

Modified:
    
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
    
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
    
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html

Modified: 
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
URL: 
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js?rev=1423489&r1=1423488&r2=1423489&view=diff
==============================================================================
--- 
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
 (original)
+++ 
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
 Tue Dec 18 15:54:52 2012
@@ -465,32 +465,6 @@ function(jquery,ui,sammy,tmpl,i18n,jquer
           
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;

Modified: 
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
URL: 
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js?rev=1423489&r1=1423488&r2=1423489&view=diff
==============================================================================
--- 
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
 (original)
+++ 
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
 Tue Dec 18 15:54:52 2012
@@ -720,6 +720,80 @@ define("archiva.search",["jquery","i18n"
       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"
         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];
 

Modified: 
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html
URL: 
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html?rev=1423489&r1=1423488&r2=1423489&view=diff
==============================================================================
--- 
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html
 (original)
+++ 
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html
 Tue Dec 18 15:54:52 2012
@@ -515,10 +515,6 @@
        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>
   </li>
@@ -927,13 +923,20 @@
   </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>
@@ -943,24 +946,11 @@
       </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


Reply via email to