add license
[couchdb-futon.git] / plugins.html
index 473531d979921b9bbca66160671928b2e6169f89..7f8da53c208fa4c6a98b357e985e60b03be2d0af 100644 (file)
@@ -33,16 +33,16 @@ specific language governing permissions and limitations under the License.
     <div id="content">
       <div class="row">
         <h2>GeoCouch</h2>
-        <p>Version: <strong>couchdb1.2.x_v0.3.0-11-g4ea0bea</strong></p>
+        <p>Version: <strong>couchdb1.2.x_v0.3.0-11-g66e6219</strong></p>
         <p>Author: Volker Mische</p>
         <p>
           Available Erlang Versions:
           <ul>
-            <li>R15B01</li>
+            <li>CouchDB 1.4.0-XXX R15B01</li>
           </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='{"1.4.0": {"R15B03":"D5QPhrJTAifM42DXqAj4RxzfEtI="}}' data-name="geocouch" data-version="couchdb1.2.x_v0.3.0-16-g66e6219">Install GeoCouch Now</button>
         </p>
       </div>
       <div class="row">
@@ -52,23 +52,41 @@ specific language governing permissions and limitations under the License.
         <p>
           Available Erlang Versions:
           <ul>
-            <li>R15B01</li>
+            <li>CouchDB 1.4.0-XXX R15B01</li>
           </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='{"1.4.0": {"R15B03":"Aj3mjC6M75NA62q5/xkP0tl8Hws="}}' 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. Click to Uninstall');
+          button.data('delete', true);
+        } else {
+          button.html('Other Version Installed: ' + body);
+          button.attr('disabled', true);
+        }
+      });
+    });
+
+    $('.install-plugin').click(function(event) {
+      var button = $(this);
+      var delete_plugin = button.data('delete') || false;
       var plugin_spec = JSON.stringify({
         name: button.data('name'),
         url: button.data('url'),
         version: button.data('version'),
-        checksums: button.data('checksums')
+        checksums: button.data('checksums'),
+        "delete": delete_plugin
       });
       var url = '/_plugins'
       $.ajax({
@@ -79,7 +97,13 @@ specific language governing permissions and limitations under the License.
         dataType: 'json', // expected from the server
         processData: false, // keep our precious JSON
         success: function(data, textStatus, jqXhr) {
-          button.html(textStatus);
+          if(textStatus == "success") {
+            var action = delete_plugin ? 'Uninstalled' : 'Installed';
+            button.html('Sucessfully ' + action);
+            button.attr('disabled', true);
+          } else {
+            button.html(textStatus);
+          }
         },
         beforeSend: function(xhr) {
           xhr.setRequestHeader('Accept', 'application/json');