You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by de...@apache.org on 2013/09/23 21:30:04 UTC

git commit: updated refs/heads/replicator-redesign to 464f8bc

Updated Branches:
  refs/heads/replicator-redesign 26b334146 -> 464f8bc80


Added Authentication fields. hooking up interactions


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/464f8bc8
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/464f8bc8
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/464f8bc8

Branch: refs/heads/replicator-redesign
Commit: 464f8bc808d7f0b6c631345a95a731e20eb7aeb0
Parents: 26b3341
Author: suelockwood <de...@gmail.com>
Authored: Mon Sep 23 15:29:20 2013 -0400
Committer: suelockwood <de...@gmail.com>
Committed: Mon Sep 23 15:29:56 2013 -0400

----------------------------------------------------------------------
 .../replication/assets/less/replication.less    |  9 ++++
 src/fauxton/app/addons/replication/resources.js |  2 +
 .../replication/templates/authfields.html       | 16 +++++++
 .../app/addons/replication/templates/form.html  | 17 +++++---
 src/fauxton/app/addons/replication/views.js     | 45 +++++++++++++++++---
 5 files changed, 77 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/464f8bc8/src/fauxton/app/addons/replication/assets/less/replication.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/replication/assets/less/replication.less b/src/fauxton/app/addons/replication/assets/less/replication.less
index 881f830..d903b7a 100644
--- a/src/fauxton/app/addons/replication/assets/less/replication.less
+++ b/src/fauxton/app/addons/replication/assets/less/replication.less
@@ -24,6 +24,15 @@ form#replication {
 	position: relative;
 	max-width: none;
 	width: auto;
+
+	#from_name {
+		margin-right: 20px;
+	}
+	.authArea_source_local {
+		display: inline-block;
+		vertical-align: top;
+	}
+	
 	.span12{
 		margin-left: 0;
 		padding-bottom: 20px;

http://git-wip-us.apache.org/repos/asf/couchdb/blob/464f8bc8/src/fauxton/app/addons/replication/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/replication/resources.js b/src/fauxton/app/addons/replication/resources.js
index 38ae139..bf70302 100644
--- a/src/fauxton/app/addons/replication/resources.js
+++ b/src/fauxton/app/addons/replication/resources.js
@@ -64,5 +64,7 @@ function (app, FauxtonAPI, ActiveTasks) {
     }
   });
 
+
+
   return Replication;
 });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/464f8bc8/src/fauxton/app/addons/replication/templates/authfields.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/replication/templates/authfields.html b/src/fauxton/app/addons/replication/templates/authfields.html
new file mode 100644
index 0000000..7aac5d2
--- /dev/null
+++ b/src/fauxton/app/addons/replication/templates/authfields.html
@@ -0,0 +1,16 @@
+<!--
+Licensed under the Apache License, Version 2.0 (the "License"); you may not
+use this file except in compliance with the License. You may obtain a copy of
+the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+License for the specific language governing permissions and limitations under
+the License.
+-->
+<p>Authorize the use of this database for replication.</p>
+<input class="input-medium" type="text" name="user_<%=type%>" size="30" placeholder="Username">
+<input class="input-medium" type="password" name="password_<%=type%>" size="30" placeholder="Password">

http://git-wip-us.apache.org/repos/asf/couchdb/blob/464f8bc8/src/fauxton/app/addons/replication/templates/form.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/replication/templates/form.html b/src/fauxton/app/addons/replication/templates/form.html
index 1d56972..b3001e2 100644
--- a/src/fauxton/app/addons/replication/templates/form.html
+++ b/src/fauxton/app/addons/replication/templates/form.html
@@ -11,7 +11,7 @@ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 License for the specific language governing permissions and limitations under
 the License.
 -->
-
+<span id="clickme">Hey guys</span>
 <form id="replication" class="form-horizontal">
 	<!-- SOURCE -->
 	<div class="row span12" id="step1">
@@ -31,17 +31,18 @@ the License.
 
 			<div class="tab-content small-tabs">
 				<div class="tab-pane active" id="source_local">
-					<select id="from_name" name="source">
+					<select id="from_name" name="source" data-auth-selector="source_local" class="permission">
 							<option value="">Select a database</option>
-						<% _.each( databases, function( db, i ){ %>
-						  <option value="<%=db.name%>" <% if(selectedDB == db.name){%>selected<%}%> ><%=db.name%></option>
-						<% }); %>
+							<% _.each( databases, function( db, i ){ %>
+							  <option value="<%=db.name%>" <% if(selectedDB == db.name){%>selected<%}%> ><%=db.name%></option>
+							<% }); %>
 					</select>
+					<div class="authArea_source_local"></div>
 				</div>
 
 				<div class="tab-pane" id="source_remote">
 					<input type="text" id="from_url" name="source" size="30" value="http://">
-					<small>e.g. http://username:password@user.cloudant.com/database</small>
+					<small>e.g. http://username:password@user.cloudant.com/database.</small>
 				</div>
 			</div>
 			<div id="options-here">
@@ -80,12 +81,14 @@ the License.
 
 			<div class="tab-content small-tabs">
 				<div class="tab-pane active" id="target_local">
-						<input type="text" id="to_name" name="target" size="30" placeholder="Select a target database">
+					<input type="text" id="to_name" name="target" size="30" placeholder="Select a target database"  data-auth-selector="target_local" class="permission">
+					<div class="authArea_target_local"></div>
 				</div>
 
 				<div class="tab-pane" id="target_remote">
 					<input type="text" id="to_url" name="target" size="30" value="http://">
 					<small>e.g. http://username:password@user.cloudant.com/database</small>
+					<div class="authArea_target_remote"></div>
 				</div>
 			</div>
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/464f8bc8/src/fauxton/app/addons/replication/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/replication/views.js b/src/fauxton/app/addons/replication/views.js
index 337fd5c..8e366c6 100644
--- a/src/fauxton/app/addons/replication/views.js
+++ b/src/fauxton/app/addons/replication/views.js
@@ -48,13 +48,15 @@ function(app, FauxtonAPI, Components, replication) {
       "submit #replication": "validate",
       "click .options": "toggleAdvancedOptions",
       "click .nav-tabs a": "tabs",
-      "change #from_name": "showAdvancedOptions"
+      "change .permission": "showMore",
+      "click #create_target button": "createTarget"
     },
     initialize: function(options){
       this.status = options.status;
       this.selectedDB = options.selectedDB;
       this.newRepModel = new replication.Replicate({});
     },
+
     afterRender: function(){
       this.dbSearchTypeahead = new Components.DbSearchTypeahead({
         dbLimit: 30,
@@ -71,6 +73,14 @@ function(app, FauxtonAPI, Components, replication) {
     cleanup: function(){
       clearInterval(pollingInfo.intervalId);
     },
+    createTarget: function(e){
+      var $currentTarget = this.$(e.currentTarget);
+      checked = $currentTarget.attr('value')=="true";
+      
+      this.$('[name="create_target"]').prop("checked",checked);
+      $currentTarget.parents("#create_target").find('.active').removeClass('active');
+      $currentTarget.addClass('active');
+    },
     enableFields: function(){
       this.$el.find('input','select').attr('disabled',false);
     },
@@ -119,8 +129,21 @@ function(app, FauxtonAPI, Components, replication) {
       };
     },
     showAdvancedOptions:  function(e){
-      var thisview = this.insertView("#options-here", new View.AdvancedOptions({}));
-      thisview.render();
+      if (this.advancedOptions){ this.advancedOptions.remove();}
+      this.advancedOptions = this.insertView("#options-here", new View.AdvancedOptions({}));
+      this.advancedOptions.render();
+    },
+    showAuthFields: function(e){
+      var dataAuthSelector = this.$(e.currentTarget).attr('data-auth-selector'),
+          autharea = ".authArea_"+dataAuthSelector;
+      this.authfields = this.insertView(autharea, new View.AuthFields({type:dataAuthSelector}));
+      this.authfields.render();
+    },
+    showMore: function(e){
+      if (this.$(e.currentTarget).attr('data-auth-selector') === "source_local"){
+        this.showAdvancedOptions(e);
+      }
+      this.showAuthFields(e);
     },
     startReplication: function(json){
       var that = this;
@@ -158,8 +181,8 @@ function(app, FauxtonAPI, Components, replication) {
       $(getTabID).addClass('active');
     },	
     toggleAdvancedOptions:  function(e){
-      $(e.currentTarget).toggleClass("off");
-      $('.advancedOptions').toggle("hidden").find('input').removeAttr('disabled');
+      this.$(e.currentTarget).toggleClass("off");
+      this.$('.advancedOptions').toggle("hidden").find('input').removeAttr('disabled');
     },
     updateButtonText: function(wait){
       var $button = this.$('#replication button[type=submit]');
@@ -184,9 +207,21 @@ function(app, FauxtonAPI, Components, replication) {
   });
 
   View.AdvancedOptions = FauxtonAPI.View.extend({
+    className: "authenticate",
     template: "addons/replication/templates/options"
   });
 
+  View.AuthFields = FauxtonAPI.View.extend({
+    template: "addons/replication/templates/authfields",
+    initialize: function(options){
+      this.type = options.type;
+    },
+    serialize: function(){
+      return {
+        type: this.type
+      };
+    }
+  });
 
   View.ReplicationList = FauxtonAPI.View.extend({
     tagName: "ul",