Permalink
Browse files

Merge pull request #120 from faulkner/uninstall

Added ability to uninstall apps.
2 parents 6d459f7 + f5bfb41 commit 30a7100055ab488c4c93bbf39e2991ef81a216f0 @ctide ctide committed Jul 20, 2011
@@ -145,6 +145,7 @@ ul#servicesList li.current.connector {
font-family: Menlo, Courier, monospace;
}
+#serviceInfo #uninstallButton,
#serviceInfo #installButton {
position: absolute;
top: 16px;
@@ -166,6 +167,7 @@ ul#servicesList li.current.connector {
box-shadow: inset 1px 1px 0px rgba(255, 255, 255, 0.15), inset -1px -1px 0px rgba(0, 0, 0, 0.25);
}
+#serviceInfo #uninstallButton a,
#serviceInfo #installButton a {
display: block;
@@ -183,14 +185,17 @@ ul#servicesList li.current.connector {
cursor: default;
}
+#serviceInfo #uninstallButton:hover,
#serviceInfo #installButton:hover {
background-color: rgba(0, 0, 0, 0.5) !important;
}
+#serviceInfo #uninstallButton:hover a,
#serviceInfo #installButton:hover a {
color: white;
}
+#serviceInfo #uninstallButton:active,
#serviceInfo #installButton:active {
background-color: rgba(0, 0, 0, 0.6) !important;
background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0.35)), to(rgba(0, 0, 0, 0.015)));
@@ -200,6 +205,7 @@ ul#servicesList li.current.connector {
background-image: linear-gradient(top, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.015));
}
+#serviceInfo #uninstallButton:active a,
#serviceInfo #installButton:active a {
color: white;
}
@@ -82,6 +82,17 @@ function unstableServices()
updateServiceMap("",function(){ $("#servicesSection").show();});
}
+function availableIndexForService(service) {
+ var index = -1;
+ for(var i in serviceMap.available) {
+ if(service.handle && serviceMap.available[i].handle === service.handle) {
+ index = i;
+ break;
+ }
+ }
+ return index;
+}
+
function selectService(index) {
var item = serviceMap.available[index];
$("#serviceInfo h1").html(item["title"]);
@@ -92,12 +103,17 @@ function selectService(index) {
$("#connectorInstancesList").children().remove();
$("#installButton a").attr("href", "javascript:installService(" + index + ");");
$("#installButton").show();
+ $("#uninstallButton").hide();
$("#connectorInstancesSection").hide();
- if (item.is == "connector") {
- // $("#addConnectorInstanceButton a").attr("href", "javascript:installService(" + index + ");");
- $.each(serviceMap.installed, function(key, value) {
- if (value["srcdir"] == item["srcdir"]) {
+ $.each(serviceMap.installed, function(key, value) {
+ if (value["srcdir"] == item["srcdir"]) {
+ var index = availableIndexForService(value);
+ if (item.is == "app") {
+ $("#installButton").hide();
+ $("#uninstallButton a").attr("href", "javascript:uninstallService('" + value.id + "', '" + value.title + "', " + index + ");").show();
+ $("#uninstallButton").show();
+ } else if (item.is == "connector") {
var id = value.id;
var abled = 'Dis';
if(value.disabled) {
@@ -118,19 +134,12 @@ function selectService(index) {
$("#connectorInstancesList #id-" + id).click(function(event) {
window.location.replace("#!/app/" + id);
});
- var index = -1;
- for(var i in serviceMap.available) {
- if(value.handle && serviceMap.available[i].handle === value.handle) {
- index = i;
- break;
- }
- }
$("#connectorInstancesList div .uninst-" + id + ' a').attr("href", "javascript:uninstallService('" + id + "', '" + value.title + "', " + index + ");");
$("#connectorInstancesList div .disable-" + id + ' a').attr("href", "javascript:ableService('" + abled + "', '" + id + "', '" + value.title + "', " + index + ");");
}
- });
- $("#connectorInstancesSection").show();
- }
+ }
+ });
+ $("#connectorInstancesSection").toggle(item.is == "connector");
$("#serviceInfo").show();
}
@@ -143,6 +152,8 @@ function installService(i) {
updateServiceMap(previousLocation, function() {
showApp(svc);
});
+ $("#installButton").hide();
+ $("#uninstallButton").show();
} else {
alert('error:' + JSON.string(data));
}
@@ -159,6 +170,8 @@ function uninstallService(svcID, title, index) {
updateServiceMap(previousLocation, function() {
setLocation("services");
selectService(index);
+ $("#installButton").show();
+ $("#uninstallButton").hide();
$("#servicesList li").each(function(index) {
if($(this).html() === title) {
$("#servicesList li").removeClass("current");
@@ -285,7 +298,6 @@ function updateServiceMap(previousLocation, callback) {
}
});
-
$("#appsList").html('');
// Populate Installed Apps List
$.each(serviceMap.installed, function(key, value) {
@@ -84,6 +84,9 @@
<div id="installButton">
<a href="#">Install</a>
</div>
+ <div id="uninstallButton">
+ <a href="#">Uninstall</a>
+ </div>
<section id="connectorInstancesSection">
<ul id="connectorInstancesList">
</ul>

0 comments on commit 30a7100

Please sign in to comment.