Plugin install/uninstall

pull/557/head
Egil Moeller 2012-03-17 18:17:10 +01:00
parent 81250cba15
commit af96509fbb
2 changed files with 41 additions and 19 deletions

View File

@ -32,14 +32,24 @@ exports.socketio = function (hook_name, args, cb) {
}); });
}); });
socket.on("install", function (query) { socket.on("install", function (plugin_name) {
socket.emit("progress", {progress:0, message:'Downloading and installing ' + plugin_name + "..."});
installer.install(plugin_name, function (er) {
if (er)
socket.emit("progress", {progress:1, error:er});
else
socket.emit("progress", {progress:1, message:'Done.'});
});
}); });
socket.on("uninstall", function (query) { socket.on("uninstall", function (plugin_name) {
socket.emit("progress", {progress:0, message:'Uninstalling ' + plugin_name + "..."});
installer.uninstall(plugin_name, function (er) {
if (er)
socket.emit("progress", {progress:1, error:er});
else
socket.emit("progress", {progress:1, message:'Done.'});
});
}); });
}); });
} }

View File

@ -54,14 +54,28 @@
$(document).ready(function () { $(document).ready(function () {
var socket = io.connect().of("/pluginfw/installer"); var socket = io.connect().of("/pluginfw/installer");
$("#progress.dialog .close").click(function () { function updateHandlers() {
$("#progress.dialog").hide(); $("#progress.dialog .close").click(function () {
}); $("#progress.dialog").hide();
});
$("#do-search").click(function () { $("#do-search").click(function () {
if ($("#search-query")[0].value != "") if ($("#search-query")[0].value != "")
socket.emit("search", $("#search-query")[0].value); socket.emit("search", $("#search-query")[0].value);
}); });
$("#do-install").click(function (e) {
var row = $(e.target).closest("tr");
socket.emit("install", row.find(".name").html());
});
$("#do-uninstall").click(function (e) {
var row = $(e.target).closest("tr");
socket.emit("install", row.find(".name").html());
});
}
updateHandlers();
socket.on('progress', function (data) { socket.on('progress', function (data) {
$("#progress.dialog .close").hide(); $("#progress.dialog .close").hide();
@ -93,6 +107,7 @@
} }
$("#search-results").append(row); $("#search-results").append(row);
} }
updateHandlers();
}); });
}); });
</script> </script>
@ -120,13 +135,10 @@
<% for (var plugin_name in plugins) { %> <% for (var plugin_name in plugins) { %>
<% var plugin = plugins[plugin_name]; %> <% var plugin = plugins[plugin_name]; %>
<tr> <tr>
<td><%= plugin.package.name %></td> <td class="name"><%= plugin.package.name %></td>
<td><%= plugin.package.description %></td> <td><%= plugin.package.description %></td>
<td> <td>
<form method="post"> <input type="submit" value="U" class="do-uninstall">
<input type="hidden" name="uninstall_plugin" value="<%= plugin.package.name %>">
<input type="submit" value="U">
</form>
</td> </td>
</tr> </tr>
<% } %> <% } %>
@ -153,7 +165,7 @@
<td class="name"></td> <td class="name"></td>
<td class="description"></td> <td class="description"></td>
<td class="actions"> <td class="actions">
<input type="button" value="I"> <input type="button" value="I" class="do-install">
</td> </td>
</tr> </tr>
</tbody> </tbody>