diff options
author | Olivier Lamy <olamy@apache.org> | 2012-02-25 20:46:45 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2012-02-25 20:46:45 +0000 |
commit | b3e4b0439a250658b77883c5260e33e43e7ea49a (patch) | |
tree | f009aa19983858ea920cddfde24608c6d5f66c26 /archiva-modules | |
parent | 3a9e6ca968a0bbe9a22e2981b1faf8db9b951880 (diff) | |
download | archiva-b3e4b0439a250658b77883c5260e33e43e7ea49a.tar.gz archiva-b3e4b0439a250658b77883c5260e33e43e7ea49a.zip |
js bean mapping for displaying artifact entry
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1293686 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules')
2 files changed, 212 insertions, 17 deletions
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js index 0d8526291..58d52c917 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js @@ -50,23 +50,7 @@ $(function() { if (i<values.length-2)groupId+="."; } var artifactId=values[values.length-1]; - $.log("displayProjectEntry:"+id+",groupId:artifactId:"+groupId+":"+artifactId); - - $.ajax("restServices/archivaServices/browseService/projectVersionMetadata/"+groupId+"/"+artifactId, { - type: "GET", - dataType: 'json', - success: function(data) { - - $.ajax("restServices/archivaServices/browseService/versionsList/"+groupId+"/"+artifactId, { - type: "GET", - dataType: 'json', - success: function(data) { - - } - }); - - } - }); + displayArtifactDetail(groupId,artifactId,self); } @@ -117,6 +101,32 @@ $(function() { ); } + ArtifactDetailViewModel=function(){ + this.versions=[]; + this.projectVersionMetadata=null; + + } + + 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); + } + }); + + } + }); + } + browseRoot=function(){ displayGroupDetail(null,null,"restServices/archivaServices/browseService/rootGroups"); } @@ -174,6 +184,186 @@ $(function() { this.groupId=groupId; this.displayValue=displayValue; } + mapVersionsList=function(data){ + if (data.versionsList){ + if (data.versionsList.versions){ + return $.isArray(data.versionsList.versions)? $.map(data.versionsList.versions,function(item){return item}) + :[data.versionsList.versions]; + } + + } + 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.issueManagement){ + projectVersionMetadata.issueManagement=new IssueManagement(data.issueManagement.system,data.issueManagement.url); + } + if (data.scm){ + projectVersionMetadata.scm=new Scm(data.scm.connection,data.scm.developerConnection,data.scm.url); + } + if (data.ciManagement){ + projectVersionMetadata.ciManagement=new CiManagement(data.ciManagement.system,data.ciManagement.url); + } + if (data.licenses){ + var licenses = + $.isArray(data.licenses) ? $.map(data.licenses,function(item){ + return new License(item.name,item.url); + }):[data.licenses]; + projectVersionMetadata.licenses=licenses; + } + if (data.mailingLists){ + var mailingLists = + $.isArray(data.mailingLists) ? $.map(data.mailingLists,function(item){ + return new MailingList(item.mainArchiveUrl,item.otherArchives,item.name,item.postAddress, + item.subscribeAddress,item.unsubscribeAddress); + }):[data.mailingLists]; + projectVersionMetadata.mailingLists=mailingLists; + } + if (data.dependencies){ + var dependencies = + $.isArray(data.dependencies) ? $.map(data.dependencies,function(item){ + return new Dependency(item.classifier,item.optional,item.scope,item.systemPath,item.type, + item.artifactId,item.groupId,item.version); + }):[data.dependencies]; + projectVersionMetadata.dependencies=dependencies; + } + return projectVersionMetadata; + } + return null; + } + + ProjectVersionMetadata=function(id,url,name,description,organization,issueManagement,scm,ciManagement,licenses, + mailingLists,dependencies,incomplete){ + // private String id; + this.id=id; + + // private String url; + this.url=url + + //private String name; + this.name=name; + + //private String description; + this.description=description; + + //private Organization organization; + this.organization=organization; + + //private IssueManagement issueManagement; + this.issueManagement=issueManagement; + + //private Scm scm; + this.scm=scm; + + //private CiManagement ciManagement; + this.ciManagement=ciManagement; + + //private List<License> licenses = new ArrayList<License>(); + this.licenses=licenses; + + //private List<MailingList> mailingLists = new ArrayList<MailingList>(); + this.mailingLists=mailingLists; + + //private List<Dependency> dependencies = new ArrayList<Dependency>(); + this.dependencies=dependencies; + + //private boolean incomplete; + this.incomplete=incomplete; + + } + + Organization=function(name,url){ + //private String name; + this.name=name; + + //private String url; + this.url=url; + } + + IssueManagement=function(system,url) { + //private String system; + this.system=system; + + //private String url; + this.url=url; + } + + Scm=function(connection,developerConnection,url) { + //private String connection; + this.connection=connection; + + //private String developerConnection; + this.developerConnection=developerConnection; + + //private String url; + this.url=url; + } + + CiManagement=function(system,url) { + //private String system; + this.system=system; + + //private String url; + this.url=url; + } + + License=function(name,url){ + this.name=name; + this.url=url; + } + + MailingList=function(mainArchiveUrl,otherArchives,name,postAddress,subscribeAddress,unsubscribeAddress){ + //private String mainArchiveUrl; + this.mainArchiveUrl=mainArchiveUrl; + + //private List<String> otherArchives; + this.otherArchives=otherArchives; + + //private String name; + this.name=name; + + //private String postAddress; + this.postAddress=postAddress; + + //private String subscribeAddress; + this.subscribeAddress=subscribeAddress; + + //private String unsubscribeAddress; + this.unsubscribeAddress=unsubscribeAddress; + } + + Dependency=function(classifier,optional,scope,systemPath,type,artifactId,groupId,version){ + //private String classifier; + this.classifier=classifier; + + //private boolean optional; + this.optional=optional; + + //private String scope; + this.scope=scope; + + //private String systemPath; + this.systemPath=systemPath; + + //private String type; + this.type=type; + + //private String artifactId; + this.artifactId=artifactId; + + //private String groupId; + this.groupId=groupId; + + //private String version; + this.version=version; + + } //----------------------------------------- // search part diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html index 60ea5ec48..4d81fbb3a 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html @@ -27,6 +27,7 @@ <div id="main_browse_result_content" class="well"> <div id="browse_breadcrumb" data-bind='template:{name:"browse-breadcrumb-tmpl"}'></div> <div id="browse_result" class="well" data-bind='template:{name:"browse-groups-tmpl"}'></div> + <div id="browse_artifact" class="well" data-bind='template:{name:"browse-artifact-tmpl"}'></div> </div> </div> </script> @@ -83,4 +84,8 @@ </li> {{/each}} </ul> +</script> + +<script id="browse-artifact-tmpl" type="text/html"> + foo </script>
\ No newline at end of file |