this.name=ko.observable(name);
}
+ ManagedRepositoryConnectorView=function(source,targetRepos){
+ this.source=ko.observable(source);
+ this.targetRepos=ko.observableArray(targetRepos);
+ }
+
ProxyConnectorsViewModel=function(){
this.proxyConnectors=ko.observableArray([]);
var self=this;
+ this.uniqueManagedRepos=ko.observableArray([]);
editProxyConnector=function(proxyConnector){
}
- this.displayGrid=function(){
+ this.findUniqueManagedRepos=function(){
var sourcesRepos=[];
//sourceRepoId
for(i=0;i<self.proxyConnectors().length;i++){
var curSrcRepo=self.proxyConnectors()[i].sourceRepoId();
-
var curTarget=self.proxyConnectors()[i].targetRepoId();
var sourceRepo = $.grep(sourcesRepos,
function(srcRepo,idx){
for (j=0;j<sourcesRepos.length;j++){
- if (srcRepo.source==sourcesRepos[j].source){
+ if (srcRepo.source()==curSrcRepo){
return true;
}
}
if (sourceRepo.length>0){
sourceRepo[0].targetRepos.push(curTarget);
} else {
- $.log("sourceRepo==null:"+curSrcRepo);
- sourcesRepos.push({source:curSrcRepo,targetRepos:[curTarget]});
- if (sourceRepo!=null){
- $.log("sourceRepoId:"+curSrcRepo);
- sourcesRepos.push({source:curSrcRepo,targetRepos:[curTarget]});
- } else {
- sourceRepo.targetRepos.push(curTarget);
+ sourcesRepos.push(new ManagedRepositoryConnectorView(curSrcRepo,[curTarget]));
}
}
+ return sourcesRepos;
+ }
+
+ this.displayGrid=function(){
+ self.uniqueManagedRepos(this.findUniqueManagedRepos());
+ $.log("uniqueManagedRepos:"+self.uniqueManagedRepos().length);
+ this.gridViewModel = new ko.simpleGrid.viewModel({
+ data: self.uniqueManagedRepos,
+ pageSize: 5,
+ gridUpdateCallBack: function(){
+ $("#main-content #proxyConnectorsTable [title]").twipsy();
+ }
+ });
+ ko.applyBindings(this,$("#main-content #proxyConnectorsTable").get(0));
+ removeSmallSpinnerImg("#main-content");
+ $("#main-content #proxy-connectors-view-tabs").tabs();
}
}
mapPolicyInformations=function(data){
return $.map(data.policyInformation, function(item) {
- return mapPolicyInformation(item);
- });
+ return mapPolicyInformation(item);
+ });
}
});
\ No newline at end of file
<div class="page-header">
<h2>${$.i18n.prop('proxy-connectors.list')}</h2>
</div>
- <ul id="proxy-connector-view-tabs" class="tabs">
- <li id="network-proxies-view-tabs-li-grid" class="active">
- <a href="#network-proxies-view" id="network-proxies-view-tabs-a-network-proxies-grid">${$.i18n.prop('network-proxies.grid.tab.title')}</a>
+
+ <ul id="proxy-connectors-view-tabs" class="tabs">
+ <li id="proxy-connectors-view-tabs-li-grid" class="active">
+ <a href="#proxy-connectors-view" id="proxy-connectors-view-tabs-a-network-proxies-grid">${$.i18n.prop('proxy-connectors.grid.tab.title')}</a>
</li>
- <li id="network-proxies-view-tabs-li-edit">
- <a href="#network-proxies-edit">${$.i18n.prop('add')}</a>
+ <li id="proxy-connectors-view-tabs-li-edit">
+ <a href="#proxy-connectors-edit">${$.i18n.prop('add')}</a>
</li>
</ul>
- <div id="network-proxies-view-tabs-content" class="tab-content">
- <div id="network-proxies-view" class="active">
- <table class="bordered-table zebra-striped" id="networkProxiesTable"
- data-bind="simpleGrid: gridViewModel,simpleGridTemplate:'ko-network-proxies-grid',pageLinksId:'network-proxiesPagination'">
- </table>
- <div id="network-proxiesPagination"></div>
+ <div id="proxy-connectors-view-tabs-content" class="tab-content">
+ <div id="proxy-connectors-view" class="active">
+ <table class="bordered-table zebra-striped" id="proxyConnectorsTable"
+ data-bind="simpleGrid: gridViewModel,simpleGridTemplate:'ko-proxy-connectors-grid',pageLinksId:'proxy-connectorsPagination'">
+ </table>
+ <div id="proxy-connectorsPagination"></div>
</div>
- <div id="network-proxies-edit" data-bind='template: {name:"network-proxy-edit-tmpl"}'></div>
+ <div id="proxy-connectors-edit" data-bind='template: {name:"proxy-connectors-edit-tmpl"}'></div>
</div>
+
+</script>
+
+<script id='ko-proxy-connectors-grid' type='text/x-jquery-tmpl'>
+ <thead>
+ <tr>
+ <th>${$.i18n.prop('proxy-connectors.grid.managedrepo.title')}</th>
+ <th>${$.i18n.prop('proxy-connectors.grid.remoterepo.title')}</th>
+ </tr>
+ </thead>
+
+ {{each(i, row) itemsOnCurrentPage()}}
+ <tr>
+ <td>${row.source()}</td>
+ <td>
+ {{each(j, targetRepo) row.targetRepos()}}
+ <div>${targetRepo}</div>
+ {{/each}}
+ </td>
+ </tr>
+ {{/each}}
</script>
\ No newline at end of file