You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2012/02/10 00:08:43 UTC
svn commit: r1242598 - in
/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js:
archiva/proxy-connectors.js archiva/templates/network-proxies.html
archiva/templates/proxy-connectors.html archiva/utils.js
knockout.simpleGrid.js
Author: olamy
Date: Thu Feb 9 23:08:43 2012
New Revision: 1242598
URL: http://svn.apache.org/viewvc?rev=1242598&view=rev
Log:
[MRM-1576] rewrite proxies connector page
cleanup grid and forms for add.
Modified:
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/network-proxies.html
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/proxy-connectors.html
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js
Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js?rev=1242598&r1=1242597&r2=1242598&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js Thu Feb 9 23:08:43 2012
@@ -87,6 +87,29 @@ $(function() {
this.modified=ko.observable(false);
this.modified.subscribe(function(newValue){$.log("ProxyConnector modified:"+newValue)});
+
+ this.policiesEntries=[];
+ this.propertiesEntries=[];
+
+ this.deleteProperty=function(key){
+ $.log("delete property key:"+key());
+ for(i=0;i<self.properties().length;i++){
+ var entry=self.properties()[i];
+ if (entry.key()==key()){
+ self.properties.remove(entry);
+ }
+ }
+
+ }
+
+ this.addProperty=function(){
+ var mainContent=$("#main-content");
+ var key=mainContent.find("#property-key").val();
+ var value=mainContent.find("#property-value").val();
+ var oldTab = self.properties();
+ oldTab.push(new Entry(key,value));
+ self.properties(oldTab);
+ }
}
PolicyInformation=function(options,defaultOption,id,name){
@@ -111,18 +134,6 @@ $(function() {
this.name.subscribe(function(newValue){self.modified(true)});
}
-
- ManagedRepositoryConnectorView=function(source,sourceName,targetRepos){
- var self=this;
- this.modified=ko.observable(false);
- //this.proxyConnector=ko.observable(proxyConnector);
- //$.log("new ManagedRepositoryConnectorView:"+proxyConnector.id);
- this.source=ko.observable(source);
- this.sourceName=ko.observable(sourceName);
- //$.log("new ManagedRepositoryConnectorView source id:"+this.source.id);
- this.targetRepos=ko.observableArray(targetRepos);
- }
-
ProxyConnectorViewModel=function(proxyConnector,update,proxyConnectorsViewModel){
var self=this;
this.proxyConnector=proxyConnector;
@@ -152,25 +163,7 @@ $(function() {
}
}
- deleteProperty=function(key){
- $.log("delete property key:"+key());
- for(i=0;i<self.proxyConnector.properties().length;i++){
- var entry=self.proxyConnector.properties()[i];
- if (entry.key()==key()){
- self.proxyConnector.properties.remove(entry);
- }
- }
- }
-
- addProperty=function(){
- var mainContent=$("#main-content");
- var key=mainContent.find("#property-key").val();
- var value=mainContent.find("#property-value").val();
- var oldTab = self.proxyConnector.properties();
- oldTab.push(new Entry(key,value));
- self.proxyConnector.properties(oldTab);
- }
addBlacklistPattern=function(){
var pattern = $("#main-content #blacklist-value").val();
@@ -198,10 +191,15 @@ $(function() {
save=function(){
//FIXME data controls !!!
-
+ clearUserMessages();
if (this.update){
} else {
+ self.proxyConnector.policiesEntries=self.proxyConnector.policies();
+ self.proxyConnector.propertiesEntries=self.proxyConnector.properties();
+ var json = $.toJSON(ko.toJS(self.proxyConnector));
+ $.log("toJSON:"+json);
+
$.ajax("restServices/archivaServices/proxyConnectorService/addProxyConnector",
{
type: "POST",
@@ -212,6 +210,7 @@ $(function() {
displaySuccessMessage($.i18n.prop('proxyconnector.added'));
activateProxyConnectorsGridTab();
self.proxyConnector.modified(false);
+ self.proxyConnectorsViewModel.proxyConnectors.push(self.proxyConnector);
},
error: function(data) {
var res = $.parseJSON(data.responseText);
@@ -231,7 +230,6 @@ $(function() {
ProxyConnectorsViewModel=function(){
var self=this;
this.proxyConnectors=ko.observableArray([]);
- this.managedRepositoryConnectorViews=ko.observableArray([]);
this.policyInformations=ko.observableArray([]);
this.managedRepositories=ko.observableArray([]);
this.remoteRepositories=ko.observableArray([]);
@@ -240,10 +238,9 @@ $(function() {
editProxyConnector=function(managedRepositoryConnectorView){
$.log("editProxyConnector");
}
-
- removeProxyConnector=function(sourceRepoId,targetRepoId){
- proxyConnector=getProxyConnector(sourceRepoId, targetRepoId);
- /*var url="restServices/archivaServices/proxyConnectorService/removeProxyConnector?";
+ deleteProxyConnector=function(proxyConnector){
+ clearUserMessages();
+ var url="restServices/archivaServices/proxyConnectorService/removeProxyConnector?";
url += "sourceRepoId="+encodeURIComponent(proxyConnector.sourceRepoId());
url += "&targetRepoId="+encodeURIComponent(proxyConnector.targetRepoId());
$.ajax(url,
@@ -251,9 +248,8 @@ $(function() {
type: "GET",
contentType: 'application/json',
success: function(data) {
- clearUserMessages();
displaySuccessMessage($.i18n.prop('proxyconnector.removed'));
- //self.proxyConnectors.remove ProxyConnector=function(sourceRepoId,targetRepoId
+ self.proxyConnectors.remove(proxyConnector);
self.displayGrid();
},
error: function(data) {
@@ -261,24 +257,11 @@ $(function() {
displayRestError(res);
}
}
- );*/
- self.proxyConnectors.remove(proxyConnector);
- self.displayGrid();
- }
+ );
- this.findUniqueManagedRepos=function(){
- var managedRepositoriesIds=[];
- //sourceRepoId
- for(i=0;i<self.proxyConnectors().length;i++){
- var curSrcRepoId=self.proxyConnectors()[i].sourceRepoId();
- if ($.inArray(curSrcRepoId,managedRepositoriesIds)<0){
- managedRepositoriesIds.push(curSrcRepoId)
- }
- }
- $.log("managedRepositoriesIds:"+managedRepositoriesIds);
- return managedRepositoriesIds;
}
+
getManagedRepository=function(id){
var managedRepository=$.grep(self.managedRepositories(),
function(repo,idx){
@@ -298,22 +281,6 @@ $(function() {
return ($.isArray(remoteRepository) && remoteRepository.length>0) ? remoteRepository[0]:new RemoteRepository();
}
- // 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(),
@@ -327,13 +294,16 @@ $(function() {
return res;
}
- showSettings=function(sourceRepoId,targetRepoId){
- var targetContent = $("#proxy-connectors-grid-remoterepo-settings-content-"+sourceRepoId+"-"+targetRepoId);
+ showSettings=function(proxyConnector){
+ //proxyConnector=getProxyConnector(proxyConnector.sourceRepoId(),proxyConnector.targetRepoId());
+ var targetContent = $("#proxy-connectors-grid-remoterepo-settings-content-"
+ +proxyConnector.sourceRepoId()+"-"+proxyConnector.targetRepoId());
targetContent.html("");
targetContent.append($("#proxy-connectors-remote-settings-popover-tmpl")
- .tmpl(getProxyConnector(sourceRepoId,targetRepoId)));
+ .tmpl(proxyConnector));
- var targetImg = $("#proxy-connectors-grid-remoterepo-settings-edit-"+sourceRepoId+"-"+targetRepoId);
+ var targetImg = $("#proxy-connectors-grid-remoterepo-settings-edit-"+proxyConnector.sourceRepoId()
+ +"-"+proxyConnector.targetRepoId());
targetImg.attr("data-content",targetContent.html());
targetImg.popover(
{
@@ -345,12 +315,13 @@ $(function() {
targetImg.popover('show');
+ $.log("showSettings:"+proxyConnector.policies().length);
+
}
this.displayGrid=function(){
- self.managedRepositoryConnectorViews(this.findUniqueManagedRepos());
this.gridViewModel = new ko.simpleGrid.viewModel({
- data: self.managedRepositoryConnectorViews,
+ data: self.proxyConnectors,
pageSize: 5,
gridUpdateCallBack: function(){
$("#main-content #proxyConnectorsTable [title]").tooltip();
@@ -465,7 +436,8 @@ $(function() {
if (data==null){
return null;
}
- var policies = data.policies == null ? []: $.each(data.policies,function(item){
+ var policies = (data.policies == null || data.policies.entry == null ) ? []: $.each(data.policies.entry,function(item){
+ $.log("each policies:");
return new Entry(item.key, item.value);
});
if (!$.isArray(policies)){
Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/network-proxies.html
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/network-proxies.html?rev=1242598&r1=1242597&r2=1242598&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/network-proxies.html (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/network-proxies.html Thu Feb 9 23:08:43 2012
@@ -69,15 +69,15 @@
{{else}}
<td></td>
{{/if}}
- <td>${row.useNtlm()}</td>
- <td>
+ <td>${row.useNtlm()}</td>
+ <td>
<a href="#" data-bind="click: function(){ editNetworkProxy(row) }">${$.i18n.prop('edit')}</a>
- </td>
- <td>
+ </td>
+ <td>
<a href="#" data-bind="click: function(){ removeNetworkProxy(row) }">
<img src="images/edit-cut.png" title="${$.i18n.prop('delete')}"/>
</a>
- </td>
+ </td>
{{if row.modified()}}
<td>
<a href="#" data-bind="click: function(){ updateNetworkProxy(row) }">${$.i18n.prop('save')}</a>
Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/proxy-connectors.html
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/proxy-connectors.html?rev=1242598&r1=1242597&r2=1242598&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/proxy-connectors.html (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/proxy-connectors.html Thu Feb 9 23:08:43 2012
@@ -42,48 +42,45 @@
</script>
<script id='ko-proxy-connectors-grid' type='text/x-jquery-tmpl'>
- <thead>
- <tr>
- <th title="${$.i18n.prop('proxy-connectors.grid.managedrepo.title')}">
- ${$.i18n.prop('proxy-connectors.grid.managedrepo.grid.header')}
- </th>
- <th title="${$.i18n.prop('proxy-connectors.grid.remoterepo.title')}">
- ${$.i18n.prop('proxy-connectors.grid.remoterepo.grid.header')}
- </th>
- </tr>
- </thead>
-
- {{each(i, row) itemsOnCurrentPage()}}
+ <thead>
+ <tr>
+ <th title="${$.i18n.prop('proxy-connectors.grid.managedrepo.title')}">
+ ${$.i18n.prop('proxy-connectors.grid.managedrepo.grid.header')}
+ </th>
+ <th title="${$.i18n.prop('proxy-connectors.grid.remoterepo.title')}">
+ ${$.i18n.prop('proxy-connectors.grid.remoterepo.grid.header')}
+ </th>
+ <th>
+ ${$.i18n.prop('edit')}
+ </th>
+ <th>
+ ${$.i18n.prop('delete')}
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ {{each(i, row) itemsOnCurrentPage()}}
<tr>
+ <td>${row.sourceRepoId()}</td>
+ <td>${row.targetRepoId()}</td>
<td>
- <blockquote>
- <p>${getManagedRepository(row).id()}</p>
- <p>${getManagedRepository(row).name()}</p>
- </blockquote>
+ <a popover-title="${$.i18n.prop('proxy-connectors.grid.remoterepo.settings.popover.title')}"
+ data-bind="event: { mouseover: function(){ showSettings(row)},},click: function(){ editProxyConnector(row)}"
+ id="proxy-connectors-grid-remoterepo-settings-edit-${row.sourceRepoId()}-${row.targetRepoId()}" href="#">
+ ${$.i18n.prop('edit')}
+ </a>
+ <div id="proxy-connectors-grid-remoterepo-settings-content-${row.sourceRepoId()}-${row.targetRepoId()}"
+ style="display:none"></div>
</td>
<td>
- {{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(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,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}}
+ <a href="#" data-bind="click: function(){ deleteProxyConnector(row)}">
+ <img src="images/edit-cut.png" title="${$.i18n.prop('delete')}"/>
+ </a>
</td>
</tr>
- {{/each}}
+ {{/each}}
+ </tbody>
+ <div id="proxy-connectors-grid-remoterepo-settings-content-${val}-${targetRepoId}" style="display:none"></div>
</script>
<script id='proxy-connectors-remote-settings-popover-tmpl' type='text/x-jquery-tmpl'>
@@ -98,7 +95,7 @@
<th colspan="2">${$.i18n.prop('proxy-connector.policies')}</th>
</thead>
<tbody>
- {{each policies().entry}}
+ {{each policies()}}
<tr>
<td>${$value.key}</td>
<td>${$value.value}</td>
@@ -159,7 +156,7 @@
<thead>
<th><input type="text" id="property-key"/></th>
<th><input type="text" id="property-value"/></th>
- <th><a href="#" data-bind="click: function(){ addProperty() }">${$.i18n.prop('add')}</a></th>
+ <th><a href="#" data-bind="click: function(){ proxyConnector.addProperty() }">${$.i18n.prop('add')}</a></th>
</thead>
<tbody data-bind="foreach: proxyConnector.properties">
<tr>
Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js?rev=1242598&r1=1242597&r2=1242598&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js Thu Feb 9 23:08:43 2012
@@ -312,11 +312,10 @@ appendTemplateUrl=function(){
*/
Entry=function(key,value){
var self=this;
- this.modified=ko.observable(false);
this.key=ko.observable(key);
- this.key.subscribe(function(newValue){self.modified(true)});
+ //this.key.subscribe(function(newValue){self.modified(true)});
this.value=ko.observable(value);
- this.value.subscribe(function(newValue){self.modified(true)});
+ //this.value.subscribe(function(newValue){self.modified(true)});
}
// extends jquery tmpl to support var def
Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js?rev=1242598&r1=1242597&r2=1242598&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js Thu Feb 9 23:08:43 2012
@@ -66,7 +66,7 @@
var pageLinksContainer = $("#"+allBindings.pageLinksId).get(0);
if (viewModel.pageLinksUpdateCallBack){
ko.renderTemplate(pageLinksTemplateName, viewModel, { templateEngine: templateEngine }, pageLinksContainer, "replaceNode")
- .subscribe(viewModel.pageLinksUpdateCallBack?viewModel.pageLinksUpdateCallBack:function(){});
+ .subscribe(viewModel.pageLinksUpdateCallBack);
} else {
ko.renderTemplate(pageLinksTemplateName, viewModel, { templateEngine: templateEngine }, pageLinksContainer, "replaceNode");
}