]> source.dussan.org Git - archiva.git/commitdiff
display artifact info in artifact detail
authorOlivier Lamy <olamy@apache.org>
Sat, 25 Feb 2012 21:15:31 +0000 (21:15 +0000)
committerOlivier Lamy <olamy@apache.org>
Sat, 25 Feb 2012 21:15:31 +0000 (21:15 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1293694 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 58d52c91711a7641449942e33699332029227899..df87ddfaa7a0bbd527292128a8faacb975b7c30b 100644 (file)
@@ -57,15 +57,7 @@ $(function() {
     breadCrumbEntries=function(){
       // root level ?
       if (!self.parentBrowseViewModel) return [];
-      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+="."
-      }
-      return breadCrumbEntries;
+      return calculateBreadCrumbEntries(self.groupId);
     }
 
     displayEntry=function(value){
@@ -76,11 +68,23 @@ $(function() {
     }
   }
 
-
+  calculateBreadCrumbEntries=function(groupId){
+    var splitted = 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+="."
+    }
+    return breadCrumbEntries;
+  }
 
   displayGroupDetail=function(groupId,parentBrowseViewModel,restUrl){
     var mainContent = $("#main-content");
     var browseResult=mainContent.find("#browse_result");
+    browseResult.show();
+    mainContent.find("#browse_artifact" ).hide();
     var browseBreadCrumb=mainContent.find("#browse_breadcrumb");
     mainContent.find("#main_browse_result_content").hide( "slide", {}, 300,
         function(){
@@ -94,36 +98,63 @@ $(function() {
             success: function(data) {
               var browseResultEntries = mapbrowseResultEntries(data);
               var browseViewModel = new BrowseViewModel(browseResultEntries,parentBrowseViewModel,groupId);
-              ko.applyBindings(browseViewModel,mainContent.get(0));
+              ko.applyBindings(browseViewModel,browseBreadCrumb.get(0));
+              ko.applyBindings(browseViewModel,browseResult.get(0));
             }
          });
         }
     );
   }
 
-  ArtifactDetailViewModel=function(){
+  ArtifactDetailViewModel=function(groupId,artifactId){
+    var self=this;
     this.versions=[];
     this.projectVersionMetadata=null;
+    this.groupId=groupId;
+    this.artifactId=artifactId;
+    breadCrumbEntries=function(){
+      var entries = calculateBreadCrumbEntries(self.groupId);
+      entries.push(new BreadCrumbEntry("foo",self.artifactId));
+      return entries;
+    }
+    displayArtifactInfo=function(){
+      if ($("#main-content #artifact-info:visible" ).length>0) {
+        $("#main-content #artifact-info" ).hide();
+      } else {
+        $("#main-content #artifact-info" ).show();
+      }
 
+
+    }
   }
 
   displayArtifactDetail=function(groupId,artifactId,parentBrowseViewModel,restUrl){
     $.log("displayArtifactDetail:"+groupId+":"+artifactId);
-    var artifactDetailViewModel=new ArtifactDetailViewModel();
-    $.ajax("restServices/archivaServices/browseService/projectVersionMetadata/"+groupId+"/"+artifactId, {
-      type: "GET",
-      dataType: 'json',
-      success: function(data) {
-        artifactDetailViewModel.projectVersionMetadata=mapProjectVersionMetadata(data);
-        $.ajax("restServices/archivaServices/browseService/versionsList/"+groupId+"/"+artifactId, {
-          type: "GET",
-          dataType: 'json',
-          success: function(data) {
-            artifactDetailViewModel.versions=mapVersionsList(data);
-          }
-        });
+    var artifactDetailViewModel=new ArtifactDetailViewModel(groupId,artifactId);
+    var mainContent = $("#main-content");
+    mainContent.find("#browse_result").hide();
+    mainContent.find("#main_browse_result_content").hide("slide", {}, 300,function(){
+      mainContent.find("#browse_breadcrumb").html(smallSpinnerImg());
+      mainContent.find("#browse_artifact").show();
+      mainContent.find("#browse_artifact").html(mediumSpinnerImg());
+      mainContent.find("#main_browse_result_content").show();
+      $.ajax("restServices/archivaServices/browseService/projectVersionMetadata/"+groupId+"/"+artifactId, {
+        type: "GET",
+        dataType: 'json',
+        success: function(data) {
+          artifactDetailViewModel.projectVersionMetadata=mapProjectVersionMetadata(data);
+          $.ajax("restServices/archivaServices/browseService/versionsList/"+groupId+"/"+artifactId, {
+            type: "GET",
+            dataType: 'json',
+            success: function(data) {
+              artifactDetailViewModel.versions=mapVersionsList(data);
+              ko.applyBindings(artifactDetailViewModel,mainContent.find("#browse_artifact").get(0));
+              ko.applyBindings(artifactDetailViewModel,mainContent.find("#browse_breadcrumb").get(0));
 
-      }
+             }
+          });
+        }
+      });
     });
   }
 
@@ -146,7 +177,8 @@ $(function() {
           var browseResultEntries = mapbrowseResultEntries(data);
           $.log("size:"+browseResultEntries.length);
           var browseViewModel = new BrowseViewModel(browseResultEntries,null,null);
-          ko.applyBindings(browseViewModel,mainContent.get(0));
+          ko.applyBindings(browseViewModel,mainContent.find("#browse_breadcrumb").get(0));
+          ko.applyBindings(browseViewModel,mainContent.find("#browse_result").get(0));
         }
     });
   }
@@ -183,6 +215,8 @@ $(function() {
   BreadCrumbEntry=function(groupId,displayValue){
     this.groupId=groupId;
     this.displayValue=displayValue;
+    this.artifactId=null;
+    this.artifact=false;
   }
   mapVersionsList=function(data){
     if (data.versionsList){
@@ -195,44 +229,50 @@ $(function() {
     return [];
   }
   mapProjectVersionMetadata=function(data){
-    if (data.projectVersionMetadata){
-      var projectVersionMetadata = new ProjectVersionMetadata(data.id,data.url,data.name,data.description,null,null,null,null,null,
-                                        null,null,data.incomplete);
-      if (data.organization){
-        projectVersionMetadata.organization=new Organization(data.organization.name,data.organization.url);
+    if (data && data.projectVersionMetadata){
+      var projectVersionMetadata =
+          new ProjectVersionMetadata(data.projectVersionMetadata.id,data.projectVersionMetadata.url,
+                                    data.projectVersionMetadata.name,data.projectVersionMetadata.description,
+                                    null,null,null,null,null,null,null,data.projectVersionMetadata.incomplete);
+
+      if (data.projectVersionMetadata.organization){
+        projectVersionMetadata.organization=new Organization(data.projectVersionMetadata.organization.name,data.projectVersionMetadata.organization.url);
       }
-      if (data.issueManagement){
-        projectVersionMetadata.issueManagement=new IssueManagement(data.issueManagement.system,data.issueManagement.url);
+      if (data.projectVersionMetadata.issueManagement){
+        projectVersionMetadata.issueManagement=
+            new IssueManagement(data.projectVersionMetadata.issueManagement.system,data.projectVersionMetadata.issueManagement.url);
       }
-      if (data.scm){
-        projectVersionMetadata.scm=new Scm(data.scm.connection,data.scm.developerConnection,data.scm.url);
+      if (data.projectVersionMetadata.scm){
+        projectVersionMetadata.scm=
+            new Scm(data.projectVersionMetadata.scm.connection,data.projectVersionMetadata.scm.developerConnection,data.projectVersionMetadata.scm.url);
       }
-      if (data.ciManagement){
-        projectVersionMetadata.ciManagement=new CiManagement(data.ciManagement.system,data.ciManagement.url);
+      if (data.projectVersionMetadata.ciManagement){
+        projectVersionMetadata.ciManagement=new CiManagement(data.projectVersionMetadata.ciManagement.system,data.projectVersionMetadata.ciManagement.url);
       }
-      if (data.licenses){
+      if (data.projectVersionMetadata.licenses){
         var licenses =
-        $.isArray(data.licenses) ? $.map(data.licenses,function(item){
+        $.isArray(data.projectVersionMetadata.licenses) ? $.map(data.projectVersionMetadata.licenses,function(item){
               return new License(item.name,item.url);
-          }):[data.licenses];
+          }):[data.projectVersionMetadata.licenses];
         projectVersionMetadata.licenses=licenses;
       }
-      if (data.mailingLists){
+      if (data.projectVersionMetadata.mailingLists){
         var mailingLists =
-        $.isArray(data.mailingLists) ? $.map(data.mailingLists,function(item){
+        $.isArray(data.projectVersionMetadata.mailingLists) ? $.map(data.projectVersionMetadata.mailingLists,function(item){
               return new MailingList(item.mainArchiveUrl,item.otherArchives,item.name,item.postAddress,
                                      item.subscribeAddress,item.unsubscribeAddress);
-          }):[data.mailingLists];
+          }):[data.projectVersionMetadata.mailingLists];
         projectVersionMetadata.mailingLists=mailingLists;
       }
-      if (data.dependencies){
+      if (data.projectVersionMetadata.dependencies){
         var dependencies =
-        $.isArray(data.dependencies) ? $.map(data.dependencies,function(item){
+        $.isArray(data.projectVersionMetadata.dependencies) ? $.map(data.projectVersionMetadata.dependencies,function(item){
               return new Dependency(item.classifier,item.optional,item.scope,item.systemPath,item.type,
                                     item.artifactId,item.groupId,item.version);
-          }):[data.dependencies];
+          }):[data.projectVersionMetadata.dependencies];
         projectVersionMetadata.dependencies=dependencies;
       }
+      $.log("projectVersionMetadata.issueManagement.system:"+(projectVersionMetadata.issueManagement?projectVersionMetadata.issueManagement.system:"null"));
       return projectVersionMetadata;
     }
     return null;
index 4d81fbb3ad1cb82e06e9970f8d83731c7fc10bbb..73f2ec3b9ec4d872a1e1021ab721bdf15c9a3d65 100644 (file)
@@ -78,7 +78,6 @@
           <a href="#" data-bind="click: function(){displayGroupId(breadCrumbEntry.groupId)}">${breadCrumbEntry.displayValue}</a>
         {{/if}}
         {{if i<number-1}}
-          &nbsp;
           <span class="divider">/</span>
         {{/if}}
       </li>
 </script>
 
 <script id="browse-artifact-tmpl" type="text/html">
-        foo
+  <div class="row-fluid">
+    <div>
+      <a href="#" data-bind="click: function(){displayArtifactInfo()}">
+          ${$.i18n.prop('browse.artifact.display.artifactInfo')}
+      </a>
+    </div>
+    <br/>
+    <div id="artifact-info" class="alert alert-info" style="display: none">
+      <div>${$.i18n.prop('browse.artifact.groupId')}:&nbsp;${groupId}</div>
+      <div>${$.i18n.prop('browse.artifact.artifactId')}:&nbsp;${artifactId}</div>
+      <div>${$.i18n.prop('browse.artifact.name')}:&nbsp;${projectVersionMetadata.name}</div>
+      <div>${$.i18n.prop('browse.artifact.organization.name')}:&nbsp;${projectVersionMetadata.organization.name}</div>
+      {{if  projectVersionMetadata.issueManagement}}
+        <div>${$.i18n.prop('browse.artifact.organization.issueManagement')}:&nbsp;
+            <a href="${projectVersionMetadata.issueManagement.url}" target="_blank">${projectVersionMetadata.issueManagement.system}</a>
+        </div>
+      {{/if}}
+    </div>
+
+    <div class="page-header">
+      <h4>${$.i18n.prop('browse.artifact.versions')}</h4>
+    </div>
+
+    <div>
+      <ul>
+      {{each(i,version) versions}}
+        <li>${version}</li>
+      {{/each}}
+      </ul>
+    </div>
+  </div>
 </script>
\ No newline at end of file