]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1615] Artifact detail view
authorOlivier Lamy <olamy@apache.org>
Thu, 22 Mar 2012 22:38:11 +0000 (22:38 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 22 Mar 2012 22:38:11 +0000 (22:38 +0000)
add link on dependency tree entries.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1304115 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/templates/search.html

index fc80868332c08c75c2ecc47c0e783c8e43a71441..cdd056d98d2eecf09e58dc70b9a666798c768e27 100644 (file)
@@ -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(){
index d10ee5dd9c7f37aa88fd7e18e4a280f8a962c9ab..3f153b45cd85408466003637e2acbb7fe76cd4bb 100644 (file)
         </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
 <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}}