From 81250cba158384b40fe32ccf44dc10ccdaa3e80b Mon Sep 17 00:00:00 2001 From: Egil Moeller Date: Thu, 15 Mar 2012 21:07:48 +0100 Subject: [PATCH] Searching for plugins, plus handling async events from the server (progress) --- src/ep.json | 4 +- src/node/hooks/express/adminplugins.js | 51 ++++++----- src/templates/admin/plugins.html | 119 +++++++++++++++++++++---- 3 files changed, 138 insertions(+), 36 deletions(-) diff --git a/src/ep.json b/src/ep.json index a4242890b..6bc777350 100644 --- a/src/ep.json +++ b/src/ep.json @@ -9,6 +9,8 @@ { "name": "importexport", "hooks": { "expressCreateServer": "ep_etherpad-lite/node/hooks/express/importexport:expressCreateServer" } }, { "name": "errorhandling", "hooks": { "expressCreateServer": "ep_etherpad-lite/node/hooks/express/errorhandling:expressCreateServer" } }, { "name": "socketio", "hooks": { "expressCreateServer": "ep_etherpad-lite/node/hooks/express/socketio:expressCreateServer" } }, - { "name": "adminplugins", "hooks": { "expressCreateServer": "ep_etherpad-lite/node/hooks/express/adminplugins:expressCreateServer" } } + { "name": "adminplugins", "hooks": { + "expressCreateServer": "ep_etherpad-lite/node/hooks/express/adminplugins:expressCreateServer", + "socketio": "ep_etherpad-lite/node/hooks/express/adminplugins:socketio" } } ] } diff --git a/src/node/hooks/express/adminplugins.js b/src/node/hooks/express/adminplugins.js index a3fbc2af3..d3884acb2 100644 --- a/src/node/hooks/express/adminplugins.js +++ b/src/node/hooks/express/adminplugins.js @@ -7,28 +7,39 @@ exports.expressCreateServer = function (hook_name, args, cb) { var plugins = require("ep_etherpad-lite/static/js/pluginfw/plugins"); var render_args = { plugins: plugins.plugins, - query: req.query, search_results: {}, errors: [], }; - var render = function () { - res.send(eejs.require( - "ep_etherpad-lite/templates/admin/plugins.html", - render_args), {}); - }; - - if (req.query.search && req.query.search != "") { - installer.search(req.query.search, function (er, data) { - if (er) { - render_args.errors.push(er); - return render(); - } - render_args.search_results = data; - render(); - }); - } else { - render(); - } + res.send(eejs.require( + "ep_etherpad-lite/templates/admin/plugins.html", + render_args), {}); }); -} \ No newline at end of file +} + +exports.socketio = function (hook_name, args, cb) { + var io = args.io.of("/pluginfw/installer"); + io.on('connection', function (socket) { + socket.on("search", function (query) { + socket.emit("progress", {progress:0, message:'Fetching results...'}); + installer.search(query, function (er, data) { + if (er) { + socket.emit("progress", {progress:1, error:er}); + } else { + socket.emit("search-result", {results: data}); + socket.emit("progress", {progress:1, message:'Done.'}); + } + }); + }); + + socket.on("install", function (query) { + }); + + socket.on("uninstall", function (query) { + }); + + + + + }); +} diff --git a/src/templates/admin/plugins.html b/src/templates/admin/plugins.html index 2b40d33c0..f83168574 100644 --- a/src/templates/admin/plugins.html +++ b/src/templates/admin/plugins.html @@ -12,7 +12,90 @@ padding-top: 2px; padding-bottom: 2px; } + .template { + display: none; + } + .dialog { + display: none; + position: absolute; + left: 50%; + top: 50%; + width: 500px; + height: 400px; + margin-left: -250px; + margin-top: -200px; + border: 3px solid #999999; + background: #eeeeee; + } + .dialog .title { + margin: 0; + padding: 2px; + border-bottom: 3px solid #999999; + font-size: 24px; + line-height: 24px; + } + .dialog .title .close { + float: right; + } + .dialog .history { + background: #222222; + color: #eeeeee; + position: absolute; + top: 41px; + bottom: 10px; + left: 10px; + right: 10px; + padding: 2px; + } + + + <% if (errors.length) { %> @@ -54,7 +137,8 @@

Search for plugins to install

- + +
@@ -64,23 +148,28 @@ - - <% for (var plugin_name in search_results) { %> - <% var plugin = search_results[plugin_name]; %> - - - - - - <% } %> + + + + + + + +
<%= plugin.name %><%= plugin.description %> -
- - -
-
+ +
+
+

+ Please wait: + +

+ +
+
+