Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
check if plugins are already installed& better install feedback
  • Loading branch information
janl committed Oct 3, 2013
1 parent 3c7705f commit 4bfd2ff73e7c1463749802a328dd4a68ed514c2d
Showing 1 changed file with 24 additions and 4 deletions.
@@ -42,7 +42,7 @@ <h2>GeoCouch</h2>
</ul>
</p>
<p>
<button href="#" class="install_plugin" data-url="http://people.apache.org/~jan" data-checksums='{"R15B03":"QVKzRsQGKhSdLkLTdHtgUYtr0wU="}' data-name="geocouch" data-version="couchdb1.2.x_v0.3.0-12-g4ea0bea">Install GeoCouch Now</button>
<button href="#" class="install-plugin" data-url="http://people.apache.org/~jan" data-checksums='{"R15B03":"QVKzRsQGKhSdLkLTdHtgUYtr0wU="}' data-name="geocouch" data-version="couchdb1.2.x_v0.3.0-12-g4ea0bea">Install GeoCouch Now</button>
</p>
</div>
<div class="row">
@@ -56,13 +56,28 @@ <h2>CouchPerUser</h2>
</ul>
</p>
<p>
<button href="#" class="install_plugin" data-url="http://people.apache.org/~jan" data-checksums='{"R15B03":"2IvVuihCBAE4SIN3qgjofx23wJs="}' data-name="couchperuser" data-version="1.0.0">Install CouchPerUser Now</button>
<button href="#" class="install-plugin" data-url="http://people.apache.org/~jan" data-checksums='{"R15B03":"2IvVuihCBAE4SIN3qgjofx23wJs="}' data-name="couchperuser" data-version="1.0.0">Install CouchPerUser Now</button>
</p>
</div>
</div>
</div></body>
<script>
$('.install_plugin').click(function(event) {
$('.install-plugin').each(function() {
var button = $(this);
var name = button.data('name');
var version = button.data('version');
$.get("/_config/plugins/" + name + "/", function(body, textStatus) {
body = JSON.parse(body);
if(body == version) {
button.html("Already Installed");
} else {
button.html("Other Version Installed: " + body);
}
button.attr("disabled", true);
});
});

$('.install-plugin').click(function(event) {
var button = $(this);
var plugin_spec = JSON.stringify({
name: button.data('name'),
@@ -79,7 +94,12 @@ <h2>CouchPerUser</h2>
dataType: 'json', // expected from the server
processData: false, // keep our precious JSON
success: function(data, textStatus, jqXhr) {
button.html(textStatus);
if(textStatus == "success") {
button.html("Sucessfully Installed");
button.attr("disabled", true);
} else {
button.html(textStatus);
}
},
beforeSend: function(xhr) {
xhr.setRequestHeader('Accept', 'application/json');

0 comments on commit 4bfd2ff

Please sign in to comment.