$.log("editProxyConnector");
}
- removeProxyConnector=function(managedRepositoryConnectorView,targetRepoId){
- $.log("removeProxyConnector:"+managedRepositoryConnectorView.source()+","+targetRepoId);
- var url="restServices/archivaServices/proxyConnectorService/removeProxyConnector?";
- url += "sourceRepoId="+encodeURIComponent(managedRepositoryConnectorView.source());
- url += "&targetRepoId="+encodeURIComponent(targetRepoId);
+ removeProxyConnector=function(sourceRepoId,targetRepoId){
+ proxyConnector=getProxyConnector(sourceRepoId, targetRepoId);
+ /*var url="restServices/archivaServices/proxyConnectorService/removeProxyConnector?";
+ url += "sourceRepoId="+encodeURIComponent(proxyConnector.sourceRepoId());
+ url += "&targetRepoId="+encodeURIComponent(proxyConnector.targetRepoId());
$.ajax(url,
{
type: "GET",
displayRestError(res);
}
}
- );
+ );*/
+ self.proxyConnectors.remove(proxyConnector);
+ self.displayGrid();
}
this.findUniqueManagedRepos=function(){
- var sourcesRepos=[];
+ var managedRepositoriesIds=[];
//sourceRepoId
for(i=0;i<self.proxyConnectors().length;i++){
- var curSrcRepo=self.proxyConnectors()[i];
- var curSrcRepoId=curSrcRepo.sourceRepoId();
- var curTarget=self.proxyConnectors()[i];
- var sourceRepo = $.grep(sourcesRepos,
- function(srcRepo,idx){
- for (j=0;j<sourcesRepos.length;j++){
- if (srcRepo.source()==curSrcRepoId){
- return true;
- }
- }
- return false;
- }
- );
- if (sourceRepo.length>0){
- sourceRepo[0].targetRepos.push(curTarget);
- } else {
- sourcesRepos.push(new ManagedRepositoryConnectorView(curSrcRepoId,getManagedRepository(curSrcRepoId).name(),[curTarget]));
+ var curSrcRepoId=self.proxyConnectors()[i].sourceRepoId();
+ if ($.inArray(curSrcRepoId,managedRepositoriesIds)<0){
+ managedRepositoriesIds.push(curSrcRepoId)
}
}
- return sourcesRepos;
+ $.log("managedRepositoriesIds:"+managedRepositoriesIds);
+ return managedRepositoriesIds;
}
getManagedRepository=function(id){
return repo.id()==id;
}
);
+ $.log("getRemoteRepository:"+id+":"+remoteRepository);
return ($.isArray(remoteRepository) && remoteRepository.length>0) ? remoteRepository[0]:new RemoteRepository();
}
- this.getProxyConnector=function(sourceRepoId,targetRepoId){
+ // return remote repositories proxied for a managed repository
+ getRemoteRepositories=function(id){
+ $.log("getRemoteRepositories:"+id);
+ var remoteRepositoryIds=$.grep(self.proxyConnectors(),
+ function(repo,idx){
+ return repo.sourceRepoId()==id;
+ }
+ );
+ $.log("remoteRepositoryIds.length:"+remoteRepositoryIds.length);
+ var remoteRepositories=[];
+ for (i=0;i<remoteRepositoryIds.length;i++){
+ remoteRepositories.push(getRemoteRepository(remoteRepositoryIds[i].targetRepoId()));
+ }
+ return remoteRepositories;
+ }
+
+ getProxyConnector=function(sourceRepoId,targetRepoId){
+ $.log("getProxyConnector:"+sourceRepoId+":"+targetRepoId);
var proxyConnector=$.grep(self.proxyConnectors(),
function(proxyConnector,idx){
return proxyConnector.sourceRepoId()==sourceRepoId
&& proxyConnector.targetRepoId==targetRepoId;
}
);
- return ($.isArray(proxyConnector) && proxyConnector.length>0) ? proxyConnector[0]:new ProxyConnector();
+ var res = ($.isArray(proxyConnector) && proxyConnector.length>0) ? proxyConnector[0]:new ProxyConnector();
+ $.log("getProxyConnector res:"+res);
+ return res;
}
showSettings=function(sourceRepoId,targetRepoId){
var targetContent = $("#proxy-connectors-grid-remoterepo-settings-content-"+sourceRepoId+"-"+targetRepoId);
targetContent.html("");
targetContent.append($("#proxy-connectors-remote-settings-popover-tmpl")
- .tmpl(self.getProxyConnector(sourceRepoId,targetRepoId)));
+ .tmpl(getProxyConnector(sourceRepoId,targetRepoId)));
var targetImg = $("#proxy-connectors-grid-remoterepo-settings-edit-"+sourceRepoId+"-"+targetRepoId);
targetImg.attr("data-content",targetContent.html());
</thead>
{{each(i, row) itemsOnCurrentPage()}}
- {{var sourceId = row.source()}}
- <tr data-bind="css:{ 'modified': row.modified()}">
+ <tr>
<td>
<blockquote>
- <p>${row.source()}</p>
- <p>${row.sourceName()}</p>
+ <p>${getManagedRepository(row).id()}</p>
+ <p>${getManagedRepository(row).name()}</p>
</blockquote>
+ </td>
<td>
- {{each(j, targetRepo) row.targetRepos()}}
- {{var targetRepoId = targetRepo.targetRepoId()}}
+ {{each(j, targetRepo) getRemoteRepositories(row)}}
+ {{var targetRepoId = targetRepo.id()}}
<blockquote>
<p>${targetRepoId}</p>
<p>${getRemoteRepository(targetRepoId).name()}</p>
<p>${getRemoteRepository(targetRepoId).url()}</p>
<p>
<a popover-title="${$.i18n.prop('proxy-connectors.grid.remoterepo.settings.popover.title')}"
- data-bind="event: { mouseover: function(){ showSettings(sourceId,targetRepoId)},},click: function(){ editProxyConnector(row)}"
- id="proxy-connectors-grid-remoterepo-settings-edit-${sourceId}-${targetRepoId}" href="#">
+ data-bind="event: { mouseover: function(){ showSettings(row,targetRepoId)},},click: function(){ editProxyConnector(row)}"
+ id="proxy-connectors-grid-remoterepo-settings-edit-${row}-${targetRepoId}" href="#">
${$.i18n.prop('edit')}
</a>
- <a href="#" data-bind="click: function(){ removeProxyConnector(row,targetRepoId) }">
+ <a href="#" data-bind="click: function(){ removeProxyConnector(row,targetRepo)}">
<img src="images/edit-cut.png" title="${$.i18n.prop('delete')}"/>
</a>
<div id="proxy-connectors-grid-remoterepo-settings-content-${val}-${targetRepoId}" style="display:none"></div>
</p>
</blockquote>
- {{/each}}
+ {{/each}}
</td>
</tr>
{{/each}}