archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1304115 - in /archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva: search.js templates/search.html
Date Thu, 22 Mar 2012 22:38:11 GMT
Author: olamy
Date: Thu Mar 22 22:38:11 2012
New Revision: 1304115

URL: http://svn.apache.org/viewvc?rev=1304115&view=rev
Log:
[MRM-1615] Artifact detail view
add link on dependency tree entries.

Modified:
    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/archiva/templates/search.html

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=1304115&r1=1304114&r2=1304115&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
Thu Mar 22 22:38:11 2012
@@ -202,7 +202,7 @@ $(function() {
               mainContent.find("#browse-autocomplete-divider" ).hide();
               mainContent.find("#artifact-details-tabs").on('show', function (e) {
                 if ($(e.target).attr("href")=="#artifact-details-dependency-tree-content")
{
-                  var treeContentDiv=$("#artifact-details-dependency-tree-content" );
+                  var treeContentDiv=mainContent.find("#artifact-details-dependency-tree-content"
);
                   //if( $.trim(treeContentDiv.html()).length<1){
                     treeContentDiv.html(mediumSpinnerImg());
                     var treeDependencyUrl="restServices/archivaServices/browseService/treeEntries/"+encodeURIComponent(groupId);
@@ -212,12 +212,12 @@ $(function() {
                     if (selectedRepo){
                       treeDependencyUrl+="?repositoryId="+encodeURIComponent(selectedRepo);
                     }
-                    var treeDependencyUrl=
                     $.ajax(treeDependencyUrl, {
                       type: "GET",
                       dataType: 'json',
                       success: function(data) {
-                        treeContentDiv.html($("#dependency_tree_tmpl" ).tmpl({treeEntries:
[data[0]]}));
+                        var treeEntries = mapTreeEntries(data);
+                        treeContentDiv.html($("#dependency_tree_tmpl" ).tmpl({treeEntries:
treeEntries}));//[data[0]]
                       }
                     });
                   //}
@@ -234,6 +234,8 @@ $(function() {
       });
     }
 
+
+
     displayGroup=function(groupId){
       var parentBrowseViewModel=new BrowseViewModel(null,null,null);
       displayGroupDetail(groupId,parentBrowseViewModel,null);
@@ -249,7 +251,33 @@ $(function() {
     }
   }
 
+  TreeEntry=function(artifact,childs){
+    this.artifact=artifact;
+    this.childs=childs;
+  }
+
+  mapTreeEntries=function(data){
+    if (data==null){
+      return [];
+    }
+    return $.map(data,function(e) {
+      return new TreeEntry(mapArtifact(e.artifact),mapTreeEntries(e.childs));
+    })
+  }
 
+  dependencyTreeDisplayGroup=function(groupId) {
+    var parentBrowseViewModel=new BrowseViewModel(null,null,null);
+    displayGroupDetail(groupId,parentBrowseViewModel,null);
+  }
+
+  dependencyTreeDisplayArtifactDetailView=function(groupId, artifactId){
+    displayArtifactDetail(groupId, artifactId);
+  }
+
+  dependencyTreeDisplayArtifactVersionDetailViewModel=function(groupId,artifactId,version){
+    var artifactVersionDetailViewModel = new ArtifactVersionDetailViewModel (groupId,artifactId,version)
+    artifactVersionDetailViewModel.display();
+  }
 
   displayArtifactDetail=function(groupId,artifactId,parentBrowseViewModel,restUrl){
     var artifactDetailViewModel=new ArtifactDetailViewModel(groupId,artifactId);
@@ -741,6 +769,9 @@ $(function() {
   Artifact=function(context,url,groupId,artifactId,repositoryId,version,prefix,goals,bundleVersion,bundleSymbolicName,
                     bundleExportPackage,bundleExportService,bundleDescription,bundleName,bundleLicense,bundleDocUrl,
                     bundleImportPackage,bundleRequireBundle,classifier,packaging,fileExtension){
+
+    var self=this;
+
     //private String context;
     this.context=context;
 
@@ -815,6 +846,31 @@ $(function() {
     //file extension of the artifact
     //private String fileExtension;
     this.fileExtension=fileExtension;
+
+    // FIXME it's a copy an paste from Dependency we must extract an "abstract" class with
common fields
+    this.crumbEntries=function(){
+      var splitted = self.groupId.split(".");
+      var breadCrumbEntries=[];
+      var curGroupId="";
+      for (var i=0;i<splitted.length;i++){
+        curGroupId+=splitted[i];
+        breadCrumbEntries.push(new BreadCrumbEntry(curGroupId,splitted[i]));
+        curGroupId+="."
+      }
+      var crumbEntryArtifact=new BreadCrumbEntry(self.groupId,self.artifactId);
+      crumbEntryArtifact.artifactId=self.artifactId;
+      crumbEntryArtifact.artifact=true;
+      breadCrumbEntries.push(crumbEntryArtifact);
+
+      var crumbEntryVersion=new BreadCrumbEntry(self.groupId,self.version);
+      crumbEntryVersion.artifactId=self.artifactId;
+      crumbEntryVersion.artifact=false;
+      crumbEntryVersion.version=self.version;
+      breadCrumbEntries.push(crumbEntryVersion);
+
+      return breadCrumbEntries;
+    }
+
   }
 
   mapArtifacts=function(data){
@@ -825,11 +881,14 @@ $(function() {
   }
 
   mapArtifact=function(data){
+    if(data){
     return new Artifact(data.context,data.url,data.groupId,data.artifactId,data.repositoryId,data.version,data.prefix,
                         data.goals,data.bundleVersion,data.bundleSymbolicName,
                         data.bundleExportPackage,data.bundleExportService,data.bundleDescription,data.bundleName,
                         data.bundleLicense,data.bundleDocUrl,
                         data.bundleImportPackage,data.bundleRequireBundle,data.classifier,data.packaging,data.fileExtension);
+    }
+    return null;
   }
 
   SearchRequest=function(){

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html?rev=1304115&r1=1304114&r2=1304115&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html
Thu Mar 22 22:38:11 2012
@@ -607,7 +607,8 @@
         </table>
   	  </div>
 
-      <div id="artifact-details-dependency-tree-content" class="tab-pane"></div>
+      <div id="artifact-details-dependency-tree-content" class="tab-pane">
+      </div>
 
       <div id="artifact-details-used-by-content" class="tab-pane">
         used by
@@ -677,7 +678,22 @@
 <script id="dependency_tree_tmpl" type="text/html">
   <ul>
   {{each(i,treeEntry) treeEntries}}
-    <li>${treeEntry.artifact.groupId}:${treeEntry.artifact.artifactId}:${treeEntry.artifact.version}</li>
+    <li>
+        {{var entries=treeEntry.artifact.crumbEntries()}}
+        {{each(j,crumbEntry) entries}}
+          {{if j < entries.length - 2}}
+            <a href="#" onclick="dependencyTreeDisplayGroup('${crumbEntry.groupId}')">${crumbEntry.displayValue}</a>
+          {{else j == entries.length - 2}}
+            <a href="#" onclick="dependencyTreeDisplayArtifactDetailView('${crumbEntry.groupId}','${crumbEntry.artifactId}')">${crumbEntry.displayValue}</a>
+          {{else j == entries.length - 1}}
+            &nbsp;|&nbsp;<b>${$.i18n.prop('browse.artifact.version')}:</b>&nbsp;
+             <a href="#" onclick="dependencyTreeDisplayArtifactVersionDetailViewModel('${crumbEntry.groupId}','${crumbEntry.artifactId}','${crumbEntry.version}')">${crumbEntry.version}</a>&nbsp;
+          {{/if}}
+          {{if j < entries.length - 2}}
+             &nbsp;/&nbsp;
+          {{/if}}
+        {{/each}}
+    </li>
     {{if treeEntry.childs.length>0}}
       {{tmpl({treeEntries:treeEntry.childs}) "#dependency_tree_tmpl"}}
     {{/if}}



Mime
View raw message