mirror of https://github.com/apache/archiva.git
[MRM-1576] rewrite proxies connector page
refactor to ease edit mode. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1242596 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
66ac3e896c
commit
128af35a7e
|
@ -241,11 +241,11 @@ $(function() {
|
||||||
$.log("editProxyConnector");
|
$.log("editProxyConnector");
|
||||||
}
|
}
|
||||||
|
|
||||||
removeProxyConnector=function(managedRepositoryConnectorView,targetRepoId){
|
removeProxyConnector=function(sourceRepoId,targetRepoId){
|
||||||
$.log("removeProxyConnector:"+managedRepositoryConnectorView.source()+","+targetRepoId);
|
proxyConnector=getProxyConnector(sourceRepoId, targetRepoId);
|
||||||
var url="restServices/archivaServices/proxyConnectorService/removeProxyConnector?";
|
/*var url="restServices/archivaServices/proxyConnectorService/removeProxyConnector?";
|
||||||
url += "sourceRepoId="+encodeURIComponent(managedRepositoryConnectorView.source());
|
url += "sourceRepoId="+encodeURIComponent(proxyConnector.sourceRepoId());
|
||||||
url += "&targetRepoId="+encodeURIComponent(targetRepoId);
|
url += "&targetRepoId="+encodeURIComponent(proxyConnector.targetRepoId());
|
||||||
$.ajax(url,
|
$.ajax(url,
|
||||||
{
|
{
|
||||||
type: "GET",
|
type: "GET",
|
||||||
|
@ -261,33 +261,22 @@ $(function() {
|
||||||
displayRestError(res);
|
displayRestError(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);*/
|
||||||
|
self.proxyConnectors.remove(proxyConnector);
|
||||||
|
self.displayGrid();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.findUniqueManagedRepos=function(){
|
this.findUniqueManagedRepos=function(){
|
||||||
var sourcesRepos=[];
|
var managedRepositoriesIds=[];
|
||||||
//sourceRepoId
|
//sourceRepoId
|
||||||
for(i=0;i<self.proxyConnectors().length;i++){
|
for(i=0;i<self.proxyConnectors().length;i++){
|
||||||
var curSrcRepo=self.proxyConnectors()[i];
|
var curSrcRepoId=self.proxyConnectors()[i].sourceRepoId();
|
||||||
var curSrcRepoId=curSrcRepo.sourceRepoId();
|
if ($.inArray(curSrcRepoId,managedRepositoriesIds)<0){
|
||||||
var curTarget=self.proxyConnectors()[i];
|
managedRepositoriesIds.push(curSrcRepoId)
|
||||||
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]));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sourcesRepos;
|
$.log("managedRepositoriesIds:"+managedRepositoriesIds);
|
||||||
|
return managedRepositoriesIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
getManagedRepository=function(id){
|
getManagedRepository=function(id){
|
||||||
|
@ -305,24 +294,44 @@ $(function() {
|
||||||
return repo.id()==id;
|
return repo.id()==id;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
$.log("getRemoteRepository:"+id+":"+remoteRepository);
|
||||||
return ($.isArray(remoteRepository) && remoteRepository.length>0) ? remoteRepository[0]:new 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(),
|
var proxyConnector=$.grep(self.proxyConnectors(),
|
||||||
function(proxyConnector,idx){
|
function(proxyConnector,idx){
|
||||||
return proxyConnector.sourceRepoId()==sourceRepoId
|
return proxyConnector.sourceRepoId()==sourceRepoId
|
||||||
&& proxyConnector.targetRepoId==targetRepoId;
|
&& 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){
|
showSettings=function(sourceRepoId,targetRepoId){
|
||||||
var targetContent = $("#proxy-connectors-grid-remoterepo-settings-content-"+sourceRepoId+"-"+targetRepoId);
|
var targetContent = $("#proxy-connectors-grid-remoterepo-settings-content-"+sourceRepoId+"-"+targetRepoId);
|
||||||
targetContent.html("");
|
targetContent.html("");
|
||||||
targetContent.append($("#proxy-connectors-remote-settings-popover-tmpl")
|
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);
|
var targetImg = $("#proxy-connectors-grid-remoterepo-settings-edit-"+sourceRepoId+"-"+targetRepoId);
|
||||||
targetImg.attr("data-content",targetContent.html());
|
targetImg.attr("data-content",targetContent.html());
|
||||||
|
|
|
@ -54,33 +54,33 @@
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
{{each(i, row) itemsOnCurrentPage()}}
|
{{each(i, row) itemsOnCurrentPage()}}
|
||||||
{{var sourceId = row.source()}}
|
<tr>
|
||||||
<tr data-bind="css:{ 'modified': row.modified()}">
|
|
||||||
<td>
|
<td>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p>${row.source()}</p>
|
<p>${getManagedRepository(row).id()}</p>
|
||||||
<p>${row.sourceName()}</p>
|
<p>${getManagedRepository(row).name()}</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{each(j, targetRepo) row.targetRepos()}}
|
{{each(j, targetRepo) getRemoteRepositories(row)}}
|
||||||
{{var targetRepoId = targetRepo.targetRepoId()}}
|
{{var targetRepoId = targetRepo.id()}}
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p>${targetRepoId}</p>
|
<p>${targetRepoId}</p>
|
||||||
<p>${getRemoteRepository(targetRepoId).name()}</p>
|
<p>${getRemoteRepository(targetRepoId).name()}</p>
|
||||||
<p>${getRemoteRepository(targetRepoId).url()}</p>
|
<p>${getRemoteRepository(targetRepoId).url()}</p>
|
||||||
<p>
|
<p>
|
||||||
<a popover-title="${$.i18n.prop('proxy-connectors.grid.remoterepo.settings.popover.title')}"
|
<a popover-title="${$.i18n.prop('proxy-connectors.grid.remoterepo.settings.popover.title')}"
|
||||||
data-bind="event: { mouseover: function(){ showSettings(sourceId,targetRepoId)},},click: function(){ editProxyConnector(row)}"
|
data-bind="event: { mouseover: function(){ showSettings(row,targetRepoId)},},click: function(){ editProxyConnector(row)}"
|
||||||
id="proxy-connectors-grid-remoterepo-settings-edit-${sourceId}-${targetRepoId}" href="#">
|
id="proxy-connectors-grid-remoterepo-settings-edit-${row}-${targetRepoId}" href="#">
|
||||||
${$.i18n.prop('edit')}
|
${$.i18n.prop('edit')}
|
||||||
</a>
|
</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')}"/>
|
<img src="images/edit-cut.png" title="${$.i18n.prop('delete')}"/>
|
||||||
</a>
|
</a>
|
||||||
<div id="proxy-connectors-grid-remoterepo-settings-content-${val}-${targetRepoId}" style="display:none"></div>
|
<div id="proxy-connectors-grid-remoterepo-settings-content-${val}-${targetRepoId}" style="display:none"></div>
|
||||||
</p>
|
</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
|
@ -64,8 +64,12 @@
|
||||||
|
|
||||||
// Render the page links
|
// Render the page links
|
||||||
var pageLinksContainer = $("#"+allBindings.pageLinksId).get(0);
|
var pageLinksContainer = $("#"+allBindings.pageLinksId).get(0);
|
||||||
ko.renderTemplate(pageLinksTemplateName, viewModel, { templateEngine: templateEngine }, pageLinksContainer, "replaceNode")
|
if (viewModel.pageLinksUpdateCallBack){
|
||||||
|
ko.renderTemplate(pageLinksTemplateName, viewModel, { templateEngine: templateEngine }, pageLinksContainer, "replaceNode")
|
||||||
.subscribe(viewModel.pageLinksUpdateCallBack?viewModel.pageLinksUpdateCallBack:function(){});
|
.subscribe(viewModel.pageLinksUpdateCallBack?viewModel.pageLinksUpdateCallBack:function(){});
|
||||||
|
} else {
|
||||||
|
ko.renderTemplate(pageLinksTemplateName, viewModel, { templateEngine: templateEngine }, pageLinksContainer, "replaceNode");
|
||||||
|
}
|
||||||
if (viewModel.pageLinksUpdateCallBack) viewModel.pageLinksUpdateCallBack();
|
if (viewModel.pageLinksUpdateCallBack) viewModel.pageLinksUpdateCallBack();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue