}
NetworkProxiesViewModel=function(){
- this.networkProxies=ko.observableArray([]);//.subscribe(function(val){$.log('subscribe')});
+ this.networkProxies=ko.observableArray([]);
var self=this;
- $.ajax("restServices/archivaServices/networkProxyService/getNetworkProxies", {
- type: "GET",
- dataType: 'json',
- success: function(data) {
+ loadNetworkProxies( function(data) {
networkProxiesViewModel.networkProxies(mapNetworkProxies(data));
- //networkProxiesViewModel.networkProxies.subscribe(function(){$.log("change in networkProxies")});
networkProxiesViewModel.gridViewModel = new ko.simpleGrid.viewModel({
data: networkProxiesViewModel.networkProxies,
columns: [
});
ko.applyBindings(networkProxiesViewModel,$("#main-content #network-proxies-view").get(0));
}
- }
- );
+ )
+ }
+
+ loadNetworkProxies=function(successCallbackFn, errorCallbackFn){
+ $.ajax("restServices/archivaServices/networkProxyService/getNetworkProxies", {
+ type: "GET",
+ dataType: 'json',
+ success: successCallbackFn,
+ error: errorCallbackFn
+ });
}
activateNetworkProxyFormValidation=function(){
this.targetRepos=ko.observableArray(targetRepos);
}
+ ProxyConnectorViewModel=function(proxyConnector,update,proxyConnectorsViewModel){
+ var self=this;
+ this.proxyConnector=ko.observable();
+ this.proxyConnectorsViewModel=proxyConnectorsViewModel;
+ //mappe policies avec policyInformations pour avoir object + plus complexe
+ }
+
ProxyConnectorsViewModel=function(){
var self=this;
this.proxyConnectors=ko.observableArray([]);
this.policyInformations=ko.observableArray([]);
this.managedRepositories=ko.observableArray([]);
this.remoteRepositories=ko.observableArray([]);
+ this.networkProxies=ko.observableArray([]);
+
editProxyConnector=function(proxyConnector){
}
$("#main-content #proxyConnectorsTable [title]").tooltip();
}
});
+ var mainContent = $("#main-content");
this.gridViewModel.getManagedRepository=getManagedRepository;
- ko.applyBindings(this,$("#main-content #proxyConnectorsTable").get(0));
+ ko.applyBindings(this,mainContent.find("#proxyConnectorsTable").get(0));
removeSmallSpinnerImg("#main-content");
- $("#main-content #proxy-connectors-view-tabs a:first").tab('show');
+ this,mainContent.find("#proxy-connectors-view-tabs #proxy-connectors-view-tabs-a-network-proxies-grid").tab('show');
+
+ mainContent.find("#proxy-connectors-view-tabs").on('show', function (e) {
+
+ if ($(e.target).attr("href")=="#proxy-connectors-edit") {
+ var proxyConnectorViewModel=new ProxyConnectorViewModel(new ProxyConnector(),false,self);
+ ko.applyBindings(proxyConnectorViewModel,mainContent.find("#proxy-connectors-edit").get(0));
+
+ }
+ if ($(e.target).attr("href")=="#proxy-connectors-view") {
+ $("#proxy-connectors-view-tabs-a-network-proxies-grid").html($.i18n.prop("add"));
+
+ }
+
+ });
}
}
- // FIXME use various callback to prevent async false !!
-
displayProxyConnectors=function(){
var mainContent = $("#main-content");
mainContent.html($("#proxyConnectorsMain").tmpl());
this.proxyConnectorsViewModel = new ProxyConnectorsViewModel();
var self=this;
- $.ajax("restServices/archivaServices/managedRepositoriesService/getManagedRepositories", {
- type: "GET",
- dataType: 'json',
- async: false,
- success: function(data) {
- self.proxyConnectorsViewModel.managedRepositories(mapManagedRepositories(data));
- }
- });
+ loadManagedRepositories(function(data) {
+ self.proxyConnectorsViewModel.managedRepositories(mapManagedRepositories(data));
+
+ loadRemoteRepositories(function(data) {
+ self.proxyConnectorsViewModel.remoteRepositories(mapRemoteRepositories(data));
+
+ loadNetworkProxies(function(data) {
+ self.proxyConnectorsViewModel.networkProxies(mapNetworkProxies(data));
+
+ loadAllPolicies( function(data) {
+ self.proxyConnectorsViewModel.policyInformations(mapPolicyInformations(data));
+
+ loadAllProxyConnectors( function(data) {
+ self.proxyConnectorsViewModel.proxyConnectors(mapProxyConnectors(data));
+ self.proxyConnectorsViewModel.displayGrid();
+ });
+
+ });
+
+ });
+
+ });
- $.ajax("restServices/archivaServices/remoteRepositoriesService/getRemoteRepositories", {
- type: "GET",
- dataType: 'json',
- async: false,
- success: function(data) {
- self.proxyConnectorsViewModel.remoteRepositories(mapRemoteRepositories(data));
- }
});
+ }
+
+ loadAllPolicies=function(successCallBackFn,errorCallBackFn){
$.ajax("restServices/archivaServices/proxyConnectorService/allPolicies", {
type: "GET",
dataType: 'json',
- async: false,
- success: function(data) {
- self.proxyConnectorsViewModel.policyInformations(mapPolicyInformations(data));
- }
+ success: successCallBackFn,
+ error: errorCallBackFn
}
);
+ }
+ loadAllProxyConnectors=function(successCallBackFn,errorCallBackFn){
$.ajax("restServices/archivaServices/proxyConnectorService/getProxyConnectors", {
- type: "GET",
- dataType: 'json',
- success: function(data) {
- self.proxyConnectorsViewModel.proxyConnectors(mapProxyConnectors(data));
- self.proxyConnectorsViewModel.displayGrid();
- }
- }
- );
-
+ type: "GET",
+ dataType: 'json',
+ success: successCallBackFn,
+ error: errorCallBackFn
+ });
}
mapProxyConnector=function(data){
var policies = data.policies == null ? null: $.each(data.policies,function(item){
return new Entry(item.key, item.value);
});
+ var properties = data.properties == null ? null: $.each(data.properties,function(item){
+ return new Entry(item.key, item.value);
+ });
return new ProxyConnector(data.sourceRepoId,data.targetRepoId,data.proxyId,mapStringArray(data.blackListPatterns),
- mapStringArray(data.whiteListPatterns),policies,data.properties,
+ mapStringArray(data.whiteListPatterns),policies,properties,
data.disabled,data.order);
}
}
activateManagedRepositoriesGridTab=function(){
- $("#main-content #managed-repository-edit-li").removeClass("active");
- $("#main-content #managed-repository-edit").removeClass("active");
+ var mainContent = $("#main-content");
+ mainContent.find("#managed-repository-edit-li").removeClass("active");
+ mainContent.find("#managed-repository-edit").removeClass("active");
- $("#main-content #managed-repositories-view-li").addClass("active");
- $("#main-content #managed-repositories-view").addClass("active");
- $("#main-content #managed-repository-edit-li a").html($.i18n.prop("add"));
+ mainContent.find("#managed-repositories-view-li").addClass("active");
+ mainContent.find("#managed-repositories-view").addClass("active");
+ mainContent.find("#managed-repository-edit-li a").html($.i18n.prop("add"));
}
activateManagedRepositoryEditTab=function(){
- $("#main-content #managed-repositories-view-li").removeClass("active");
- $("#main-content #managed-repositories-view").removeClass("active");
+ var mainContent = $("#main-content");
+ mainContent.find("#managed-repositories-view-li").removeClass("active");
+ mainContent.find("#managed-repositories-view").removeClass("active");
- $("#main-content #managed-repository-edit-li").addClass("active");
- $("#main-content #managed-repository-edit").addClass("active");
+ mainContent.find("#managed-repository-edit-li").addClass("active");
+ mainContent.find("#managed-repository-edit").addClass("active");
}
var managedRepositoriesViewModel = new ManagedRepositoriesViewModel();
var remoteRepositoriesViewModel = new RemoteRepositoriesViewModel();
- $.ajax("restServices/archivaServices/managedRepositoriesService/getManagedRepositories", {
- type: "GET",
- dataType: 'json',
- success: function(data) {
- managedRepositoriesViewModel.managedRepositories(mapManagedRepositories(data));
- managedRepositoriesViewModel.gridViewModel = new ko.simpleGrid.viewModel({
- data: managedRepositoriesViewModel.managedRepositories,
- columns: [
- {
- headerText: $.i18n.prop('identifier'),
- rowText: "id"
- },
- {
- headerText: $.i18n.prop('name'),
- rowText: "name"
- },
- {
- headerText: $.i18n.prop('type'),
- rowText: "getTypeLabel",
- // FIXME i18n
- title: "Repository type (default is Maven 2)"
- }
- ],
- pageSize: 5,
- gridUpdateCallBack: function(){
- $("#main-content #managed-repositories-table").find("[title]").tooltip();
- }
- });
- var mainContent = $("#main-content");
- ko.applyBindings(managedRepositoriesViewModel,mainContent.find("#managed-repositories-view").get(0));
-
- mainContent.find("#managed-repositories-pills #managed-repositories-view-a").tab('show');
- removeMediumSpinnerImg("#main-content #managed-repositories-content");
- activateManagedRepositoriesGridTab();
+ loadManagedRepositories(function(data) {
+ managedRepositoriesViewModel.managedRepositories(mapManagedRepositories(data));
+ managedRepositoriesViewModel.gridViewModel = new ko.simpleGrid.viewModel({
+ data: managedRepositoriesViewModel.managedRepositories,
+ columns: [
+ {
+ headerText: $.i18n.prop('identifier'),
+ rowText: "id"
+ },
+ {
+ headerText: $.i18n.prop('name'),
+ rowText: "name"
+ },
+ {
+ headerText: $.i18n.prop('type'),
+ rowText: "getTypeLabel",
+ // FIXME i18n
+ title: "Repository type (default is Maven 2)"
+ }
+ ],
+ pageSize: 5,
+ gridUpdateCallBack: function(){
+ $("#main-content #managed-repositories-table").find("[title]").tooltip();
}
- }
- );
+ });
+ var mainContent = $("#main-content");
+ ko.applyBindings(managedRepositoriesViewModel,mainContent.find("#managed-repositories-view").get(0));
- $.ajax("restServices/archivaServices/remoteRepositoriesService/getRemoteRepositories", {
- type: "GET",
- dataType: 'json',
- success: function(data) {
- remoteRepositoriesViewModel.remoteRepositories(mapRemoteRepositories(data));
- remoteRepositoriesViewModel.gridViewModel = new ko.simpleGrid.viewModel({
- data: remoteRepositoriesViewModel.remoteRepositories,
- columns: [
- {
- headerText: $.i18n.prop('identifier'),
- rowText: "id"
- },
- {
- headerText: $.i18n.prop('name'),
- rowText: "name"
- },
- {
- headerText: $.i18n.prop('url'),
- rowText: "url"
- },
- {
- headerText: $.i18n.prop('type'),
- rowText: "getTypeLabel",
- // FIXME i18n
- title: "Repository type (default is Maven 2)"
- }
- ],
- pageSize: 5,
- gridUpdateCallBack: function(){
- $("#main-content #remote-repositories-table").find("[title]").tooltip();
- }
- });
- var mainContent = $("#main-content");
- ko.applyBindings(remoteRepositoriesViewModel,mainContent.find("#remote-repositories-table").get(0));
- mainContent.find("#remote-repositories-pills #remote-repositories-view-a").tab('show')
- removeMediumSpinnerImg("#main-content #remote-repositories-content");
+ mainContent.find("#managed-repositories-pills #managed-repositories-view-a").tab('show');
+ removeMediumSpinnerImg("#main-content #managed-repositories-content");
+ activateManagedRepositoriesGridTab();
+ });
+
+ loadRemoteRepositories(function(data) {
+ remoteRepositoriesViewModel.remoteRepositories(mapRemoteRepositories(data));
+ remoteRepositoriesViewModel.gridViewModel = new ko.simpleGrid.viewModel({
+ data: remoteRepositoriesViewModel.remoteRepositories,
+ columns: [
+ {
+ headerText: $.i18n.prop('identifier'),
+ rowText: "id"
+ },
+ {
+ headerText: $.i18n.prop('name'),
+ rowText: "name"
+ },
+ {
+ headerText: $.i18n.prop('url'),
+ rowText: "url"
+ },
+ {
+ headerText: $.i18n.prop('type'),
+ rowText: "getTypeLabel",
+ // FIXME i18n
+ title: "Repository type (default is Maven 2)"
+ }
+ ],
+ pageSize: 5,
+ gridUpdateCallBack: function(){
+ $("#main-content #remote-repositories-table").find("[title]").tooltip();
}
- }
- );
+ });
+ var mainContent = $("#main-content");
+ ko.applyBindings(remoteRepositoriesViewModel,mainContent.find("#remote-repositories-table").get(0));
+ mainContent.find("#remote-repositories-pills #remote-repositories-view-a").tab('show')
+ removeMediumSpinnerImg("#main-content #remote-repositories-content");
+ });
- $("#main-content #managed-repositories-pills").on('show', function (e) {
+ mainContent.find("#managed-repositories-pills").on('show', function (e) {
var mainContent = $("#main-content");
if ($(e.target).attr("href")=="#managed-repository-edit") {
var viewModel = new ManagedRepositoryViewModel(new ManagedRepository(),false,managedRepositoriesViewModel);
});
- $("#main-content #remote-repositories-pills").on('show', function (e) {
+ mainContent.find("#remote-repositories-pills").on('show', function (e) {
if ($(e.target).attr("href")=="#remote-repository-edit") {
$.ajax("restServices/archivaServices/networkProxyService/getNetworkProxies", {
type: "GET",
}
+ loadManagedRepositories=function(successCallBackFn,errorCallBackFn){
+ $.ajax("restServices/archivaServices/managedRepositoriesService/getManagedRepositories", {
+ type: "GET",
+ dataType: 'json',
+ success: successCallBackFn,
+ error: errorCallBackFn
+ });
+ }
+
+ loadRemoteRepositories=function(successCallBackFn,errorCallBackFn){
+ $.ajax("restServices/archivaServices/remoteRepositoriesService/getRemoteRepositories", {
+ type: "GET",
+ dataType: 'json',
+ success: successCallBackFn,
+ error: errorCallBackFn
+ });
+ }
+
});
\ No newline at end of file
<a data-toggle="tab" href="#proxy-connectors-view" id="proxy-connectors-view-tabs-a-network-proxies-grid">${$.i18n.prop('proxy-connectors.grid.tab.title')}</a>
</li>
<li id="proxy-connectors-view-tabs-li-edit">
- <a data-toggle="tab" href="#proxy-connectors-edit">${$.i18n.prop('add')}</a>
+ <a data-toggle="tab" href="#proxy-connectors-edit" id="proxy-connectors-view-tabs-a-edit">${$.i18n.prop('add')}</a>
</li>
</ul>
<div id="proxy-connectors-view-tabs-content" class="tab-content">
</table>
<div id="proxy-connectorsPagination"></div>
</div>
- <div id="proxy-connectors-edit" class="tab-pane" data-bind='template: {name:"proxy-connectors-edit-tmpl"}'></div>
+ <div id="proxy-connectors-edit" class="tab-pane" data-bind='template: {name:"proxy-connector-edit-form-tmpl"}'></div>
</div>
</script>
{{/if}}
<table class="table">
<thead>
- <th colspan="2">Policies</th>
+ <th colspan="2">${$.i18n.prop('proxy-connector.policies')}</th>
</thead>
<tbody>
{{each policies().entry}}
</tbody>
</table>
</div>
+</script>
+
+<script id="proxy-connector-edit-form-tmpl" type='text/x-jquery-tmpl'>
+ <form id="proxy-connector-edit-form" class="form-horizontal">
+ <fieldset id="remote-repository-edit-fieldset">
+ <div class="control-group">
+ <label class="control-label" for="proxyId">${$.i18n.prop('proxy-connector.network-proxy.id')}</label>
+ <div class="controls">
+ <select id="proxyId"
+ data-bind="options: proxyConnectorsViewModel.networkProxies, optionsText: 'id',optionsValue:'id',
+ value: proxyConnector.proxyId, optionsCaption: 'direct connection'"></select>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="proxyId">${$.i18n.prop('proxy-connector.managed.repository.id')}</label>
+ <div class="controls">
+ <select id="sourceRepoId"
+ data-bind="options: proxyConnectorsViewModel.managedRepositories, optionsText: 'id',optionsValue:'id',
+ value: proxyConnector.sourceRepoId"></select>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="proxyId">${$.i18n.prop('proxy-connector.remote.repository.id')}</label>
+ <div class="controls">
+ <select id="targetRepoId"
+ data-bind="options: proxyConnectorsViewModel.remoteRepositories, optionsText: 'id',optionsValue:'id',
+ value: proxyConnector.targetRepoId"></select>
+ </div>
+ </div>
+ <div class="control-group span5">
+ <table class="table">
+ <thead>
+ <th colspan="2">${$.i18n.prop('proxy-connector.policies')}</th>
+ </thead>
+ <tbody>
+ {{each proxyConnector.policies}}
+
+ <tr>
+ <td>${$value.key}</td>
+ <td>${$value.value}</td>
+ </tr>
+ {{/each}}
+ </tbody>
+ </table>
+ </div>
+ </fieldset>
+ </form>
</script>
\ No newline at end of file