mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 08:26:16 -04:00
Searching for plugins, plus handling async events from the server (progress)
This commit is contained in:
parent
51cae02e9d
commit
81250cba15
3 changed files with 138 additions and 36 deletions
|
@ -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), {});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue