mirror of https://github.com/apache/archiva.git
[MRM-1620] add a tab to browse artifact content in artifact detail view
add javascript architecture. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1339394 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
34cb0a7608
commit
7633fc863e
|
@ -151,7 +151,7 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ArtifactVersionDetailViewModel=function(groupId,artifactId,version){
|
ArtifactVersionDetailViewModel=function(groupId,artifactId,version,repositoryId){
|
||||||
var mainContent = $("#main-content");
|
var mainContent = $("#main-content");
|
||||||
var self=this;
|
var self=this;
|
||||||
this.groupId=groupId;
|
this.groupId=groupId;
|
||||||
|
@ -159,6 +159,7 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
|
||||||
this.version=version;
|
this.version=version;
|
||||||
this.projectVersionMetadata=null;
|
this.projectVersionMetadata=null;
|
||||||
this.entries=ko.observableArray([]);
|
this.entries=ko.observableArray([]);
|
||||||
|
this.repositoryId=repositoryId;
|
||||||
|
|
||||||
displayGroupId=function(groupId){
|
displayGroupId=function(groupId){
|
||||||
displayGroupDetail(groupId,null);
|
displayGroupDetail(groupId,null);
|
||||||
|
@ -269,9 +270,21 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($(e.target).attr("href")=="#artifact-details-pom-data-content") {
|
if ($(e.target).attr("href")=="#artifact-details-file-content") {
|
||||||
$.log("pom content");
|
$.log("file content:"+self.groupId+":"+self.artifactId+":"+self.version);
|
||||||
|
var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(self.groupId);
|
||||||
|
entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version);
|
||||||
|
entriesUrl+="?repositoryId="+encodeURIComponent(self.repositoryId);
|
||||||
|
$.ajax(entriesUrl,{
|
||||||
|
type: "GET",
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(data) {
|
||||||
|
var artifactContentEntryViewModel=
|
||||||
|
new ArtifactContentEntryViewModel(self.groupId,self.artifactId,self.version,mapArtifactContentEntries(data));
|
||||||
|
$("#artifact-details-file-content").html($("#artifact_content_main_tmpl").tmpl());
|
||||||
|
ko.applyBindings(artifactContentEntryViewModel,mainContent.find("#artifact_file_content_div").get(0));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -373,6 +386,53 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArtifactContentEntry=function(name,file,depth){
|
||||||
|
this.name=name;
|
||||||
|
this.file=file;
|
||||||
|
this.depth=depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
mapArtifactContentEntries=function(data){
|
||||||
|
if(data==null){
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
if ( $.isArray(data)){
|
||||||
|
return $.map(data,function(e){
|
||||||
|
return new ArtifactContentEntry(e.name,e.file,e.depth);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return new ArtifactContentEntry(data.name,data.file,data.depth);
|
||||||
|
}
|
||||||
|
|
||||||
|
ArtifactContentEntryViewModel=function(groupId,artifactId,version,artifactContentEntries){
|
||||||
|
var self=this;
|
||||||
|
this.groupId=groupId;
|
||||||
|
this.artifactId=artifactId;
|
||||||
|
this.version=version;
|
||||||
|
this.artifactContentEntries=ko.observableArray(artifactContentEntries);
|
||||||
|
$.log("size:"+this.artifactContentEntries().length);
|
||||||
|
|
||||||
|
entries=function(){
|
||||||
|
return self.artifactContentEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
displayPath=function(artifactContentEntry){
|
||||||
|
$.log("ArtifactContentEntryViewModel#displayPath:"+artifactContentEntry.name);
|
||||||
|
|
||||||
|
var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(self.groupId);
|
||||||
|
entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version);
|
||||||
|
entriesUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
|
||||||
|
entriesUrl+="&p="+encodeURIComponent(artifactContentEntry.name);
|
||||||
|
$.ajax(entriesUrl,{
|
||||||
|
type: "GET",
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(data) {
|
||||||
|
self.artifactContentEntries(mapArtifactContentEntries(data));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MetadataEntry=function(key,value,editable){
|
MetadataEntry=function(key,value,editable){
|
||||||
var self=this;
|
var self=this;
|
||||||
|
@ -1172,7 +1232,7 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:repositoryId}));
|
mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:repositoryId}));
|
||||||
var artifactVersionDetailViewModel=new ArtifactVersionDetailViewModel(groupId,artifactId,version);
|
var artifactVersionDetailViewModel=new ArtifactVersionDetailViewModel(groupId,artifactId,version,repositoryId);
|
||||||
artifactVersionDetailViewModel.display(true);
|
artifactVersionDetailViewModel.display(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -433,7 +433,7 @@
|
||||||
<a data-toggle="tab" href="#artifact-details-dependency-tree-content">${$.i18n.prop('artifact.detail.tab.header.dependency.tree')}</a>
|
<a data-toggle="tab" href="#artifact-details-dependency-tree-content">${$.i18n.prop('artifact.detail.tab.header.dependency.tree')}</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a data-toggle="tab" href="#artifact-details-pom-data-content">${$.i18n.prop('artifact.detail.tab.header.pom.content')}</a>
|
<a data-toggle="tab" href="#artifact-details-file-content">${$.i18n.prop('artifact.detail.tab.header.file.content')}</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a data-toggle="tab" href="#artifact-details-used-by-content">${$.i18n.prop('artifact.detail.tab.header.used.by')}</a>
|
<a data-toggle="tab" href="#artifact-details-used-by-content">${$.i18n.prop('artifact.detail.tab.header.used.by')}</a>
|
||||||
|
@ -628,7 +628,7 @@
|
||||||
<div id="artifact-details-dependency-tree-content" class="tab-pane">
|
<div id="artifact-details-dependency-tree-content" class="tab-pane">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="artifact-details-pom-data-content" class="tab-pane">
|
<div id="artifact-details-file-content" class="tab-pane">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="artifact-details-used-by-content" class="tab-pane"></div>
|
<div id="artifact-details-used-by-content" class="tab-pane"></div>
|
||||||
|
@ -789,3 +789,18 @@
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script id="artifact_content_main_tmpl" type="text/html">
|
||||||
|
<div id="artifact_file_content_div" data-bind='template:{name:"artifact_content_tmpl"}'>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script id="artifact_content_tmpl" type="text/html">
|
||||||
|
<ul>
|
||||||
|
{{each(i, artifactContentEntry) artifactContentEntries()}}
|
||||||
|
<li data-bind="css: { 'browse-list': artifactContentEntry.file==false }">
|
||||||
|
<a href="#" data-bind="click: function(){displayPath(artifactContentEntry)}">${artifactContentEntry.name}</a>
|
||||||
|
</li>
|
||||||
|
{{/each}}
|
||||||
|
</ul>
|
||||||
|
</script>
|
Loading…
Reference in New Issue