diff options
author | Adam Kocoloski <adam@cloudant.com> | 2011-08-15 15:45:15 -0400 |
---|---|---|
committer | Adam Kocoloski <adam@cloudant.com> | 2011-08-15 15:45:15 -0400 |
commit | 6ffe1675dd7b004e48891956a6bdbe32899ce80c (patch) | |
tree | 57326d9a498481e65bb0db38c66daf10896801f1 /rel/overlay/share/www/replicator.html | |
parent | 52ff89ff7996e839b9e2f91fd76184d362a8aeb0 (diff) | |
parent | fdd1a5d0bc48b49b0df5c9217beff9574011283c (diff) |
Merge branch '11554-merge-couchdb-1.1'
Diffstat (limited to 'rel/overlay/share/www/replicator.html')
-rw-r--r-- | rel/overlay/share/www/replicator.html | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/rel/overlay/share/www/replicator.html b/rel/overlay/share/www/replicator.html index 70c0a86c..dced6f9c 100644 --- a/rel/overlay/share/www/replicator.html +++ b/rel/overlay/share/www/replicator.html @@ -18,14 +18,18 @@ specific language governing permissions and limitations under the License. <title>Replicator</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <link rel="stylesheet" href="style/layout.css?0.11.0" type="text/css"> + <link rel="stylesheet" href="style/jquery-ui-1.8.11.custom.css" type="text/css"> <script src="script/json2.js"></script> <script src="script/sha1.js"></script> <script src="script/jquery.js?1.4.2"></script> <script src="script/jquery.couch.js?0.11.0"></script> <script src="script/jquery.dialog.js?0.11.0"></script> <script src="script/futon.js?0.11.0"></script> + <script src="script/jquery-ui-1.8.11.custom.min.js"></script> <script> $(document).ready(function() { + var allDatabases; + $("fieldset input[type=radio]").click(function() { var radio = this; var fieldset = $(this).parents("fieldset").get(0); @@ -33,15 +37,17 @@ specific language governing permissions and limitations under the License. this.disabled = radio.value == "local"; if (!this.disabled) this.focus(); }); - $("select", fieldset).each(function() { + $('.local', fieldset).each(function() { this.disabled = radio.value == "remote"; if (!this.disabled) this.focus(); }); }); + var getDatabases = function() { $.couch.allDbs({ success: function(dbs) { - dbs.sort(); + allDatabases = dbs.sort(); + $("fieldset select").each(function() { var select = this; $.each(dbs, function(idx, dbName) { @@ -49,8 +55,12 @@ specific language governing permissions and limitations under the License. }); select.selectedIndex = 0; }); + + $('#to_name').autocomplete({ source: dbs }); } }); + }; + getDatabases(); $("button#swap").click(function() { var fromName = $("#source select").val(); @@ -76,9 +86,20 @@ specific language governing permissions and limitations under the License. $("button#replicate").click(function() { $("#records tbody.content").empty(); + var targetIsLocal = $('#to_local:checked').length > 0; var source = $("#from_local")[0].checked ? $("#from_name").val() : $("#from_url").val(); - var target = $("#to_local")[0].checked ? $("#to_name").val() : $("#to_url").val(); + var target = targetIsLocal ? $("#to_name").val() : $("#to_url").val(); var repOpts = {}; + + if (targetIsLocal && $.inArray(target, allDatabases) < 0) { + if(!confirm('This will create a database named '+target+'. Ok?')) { + return; + } + else { + repOpts.create_target = true; + } + } + if ($("#continuous")[0].checked) { repOpts.continuous = true; } @@ -97,6 +118,10 @@ specific language governing permissions and limitations under the License. }); $("#records tbody tr").removeClass("odd").filter(":odd").addClass("odd"); $("#records tbody.footer td").text("Replication session " + resp.session_id); + + if (repOpts.create_target) { + getDatabases(); + } } } }, repOpts); @@ -115,22 +140,26 @@ specific language governing permissions and limitations under the License. <fieldset id="source"> <legend>Replicate changes from:</legend> <p> - <label><input type="radio" id="from_local" name="from_type" value="local" checked> Local</label> - <label>database: <select id="from_name" name="from_name"></select></label> + <input type="radio" id="from_local" name="from_type" value="local" checked> + <label for="from_local">Local Database: </label> + <select id="from_name" name="from_name" class="local"></select> </p><p> - <label><input type="radio" id="from_to_remote" name="from_type" value="remote"> Remote</label> - <label>database: <input type="text" id="from_url" name="from_url" size="30" value="http://" disabled></label> + <input type="radio" id="from_to_remote" name="from_type" value="remote"> + <label for="from_to_remote">Remote database: </label> + <input type="text" id="from_url" name="from_url" size="30" value="http://" disabled> </p> </fieldset> <p class="swap"><button id="swap" tabindex="99">⇄</button></p> <fieldset id="target"> <legend>to:</legend> <p> - <label><input type="radio" id="to_local" name="to_type" value="local" checked> Local</label> - <label>database: <select id="to_name" name="to_name"></select></label> + <input type="radio" id="to_local" name="to_type" value="local" checked> + <label for="to_local">Local database: </label> + <input type="text" id="to_name" name="to_name" class="local"></select> </p><p> - <label><input type="radio" id="to_remote" name="to_type" value="remote"> Remote</label> - <label>database: <input type="text" id="to_url" name="to_url" size="30" value="http://" disabled></label> + <input type="radio" id="to_remote" name="to_type" value="remote"> + <label for="to_remote">Remote database: </label> + <input type="text" id="to_url" name="to_url" size="30" value="http://" disabled> </p> </fieldset> <p class="actions"> |