[extensions-web: 9/75] Add uninstallation.



commit 4b293faec080a45f0d3df4c793c9750a985156a3
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Sep 13 11:56:39 2011 -0400

    Add uninstallation.

 sweettooth/static/js/extensions.js      |   10 +++++++++-
 sweettooth/static/js/versions/1/main.js |    4 ++++
 2 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/sweettooth/static/js/extensions.js b/sweettooth/static/js/extensions.js
index 93f3cc5..06e208d 100644
--- a/sweettooth/static/js/extensions.js
+++ b/sweettooth/static/js/extensions.js
@@ -118,12 +118,20 @@ function($, messages, dbusProxy) {
         var $container = $(this);
         dbusProxy.ListExtensions().done(function(extensions) {
             $.each(extensions, function(uuid, extension) {
+                function uninstall() {
+                    dbusProxy.UninstallExtension(uuid).done(function(result) {
+                        if (result)
+                            $elem.fadeOut(function() { $elem.detach(); });
+                    });
+                }
+
                 var $elem = $('<div>', {'class': 'extension'}).
                     append($('<div>', {'class': 'switch'})).
                     append($('<img>', {'class': 'icon'})).
                     append($('<h3>').text(extension.name)).
                     append($('<span>', {'class': 'author'})).
-                    append($('<p>', {'class': 'description'}).text(extension.description));
+                    append($('<p>', {'class': 'description'}).text(extension.description)).
+                    append($('<button>', {'class': 'uninstall'}).text("Uninstall").bind('click', uninstall));
 
                 $.ajax({
                     url: "/ajax/d/",
diff --git a/sweettooth/static/js/versions/1/main.js b/sweettooth/static/js/versions/1/main.js
index 580220b..d3110b4 100644
--- a/sweettooth/static/js/versions/1/main.js
+++ b/sweettooth/static/js/versions/1/main.js
@@ -32,6 +32,10 @@ define(['jquery', 'dbus!API'], function($, API) {
             API.installExtension(uuid, server_uuid);
         },
 
+        UninstallExtension: function(uuid) {
+            return _makePromise(API.uninstallExtension(uuid));
+        },
+
         extensionStateChangedHandler: null,
 
         ShellVersion: API.shellVersion



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]