mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
Better plugin admin interface
This commit is contained in:
parent
d6f476312d
commit
4c1d94343f
3 changed files with 54 additions and 11 deletions
|
@ -27,7 +27,7 @@ exports.socketio = function (hook_name, args, cb) {
|
||||||
|
|
||||||
socket.on("search", function (query) {
|
socket.on("search", function (query) {
|
||||||
socket.emit("progress", {progress:0, message:'Fetching results...'});
|
socket.emit("progress", {progress:0, message:'Fetching results...'});
|
||||||
installer.search(query, function (progress) {
|
installer.search(query, true, function (progress) {
|
||||||
if (progress.results)
|
if (progress.results)
|
||||||
socket.emit("search-result", progress);
|
socket.emit("search-result", progress);
|
||||||
socket.emit("progress", progress);
|
socket.emit("progress", progress);
|
||||||
|
|
|
@ -1,18 +1,28 @@
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
var socket = io.connect().of("/pluginfw/installer");
|
var socket = io.connect().of("/pluginfw/installer");
|
||||||
|
|
||||||
|
$('.search-results').data('query', {
|
||||||
|
pattern: '',
|
||||||
|
offset: 0,
|
||||||
|
limit: 4,
|
||||||
|
});
|
||||||
|
|
||||||
var doUpdate = false;
|
var doUpdate = false;
|
||||||
|
|
||||||
|
var search = function () {
|
||||||
|
socket.emit("search", $('.search-results').data('query'));
|
||||||
|
}
|
||||||
|
|
||||||
function updateHandlers() {
|
function updateHandlers() {
|
||||||
$("#progress.dialog .close").unbind('click').click(function () {
|
$("#progress.dialog .close").unbind('click').click(function () {
|
||||||
$("#progress.dialog").hide();
|
$("#progress.dialog").hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#do-search").unbind('click').click(function () {
|
$("#do-search").unbind('click').click(function () {
|
||||||
socket.emit("search", {
|
var query = $('.search-results').data('query');
|
||||||
pattern: $("#search-query")[0].value,
|
query.pattern = $("#search-query")[0].value;
|
||||||
offset: $('#search-results').data('offset') || 0,
|
query.offset = 0;
|
||||||
limit: 4});
|
search();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".do-install").unbind('click').click(function (e) {
|
$(".do-install").unbind('click').click(function (e) {
|
||||||
|
@ -26,12 +36,29 @@ $(document).ready(function () {
|
||||||
doUpdate = true;
|
doUpdate = true;
|
||||||
socket.emit("uninstall", row.find(".name").html());
|
socket.emit("uninstall", row.find(".name").html());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".do-prev-page").unbind('click').click(function (e) {
|
||||||
|
var query = $('.search-results').data('query');
|
||||||
|
query.offset -= query.limit;
|
||||||
|
if (query.offset < 0) {
|
||||||
|
query.offset = 0;
|
||||||
|
}
|
||||||
|
search();
|
||||||
|
});
|
||||||
|
$(".do-next-page").unbind('click').click(function (e) {
|
||||||
|
var query = $('.search-results').data('query');
|
||||||
|
var total = $('.search-results').data('total');
|
||||||
|
if (query.offset + query.limit < total) {
|
||||||
|
query.offset += query.limit;
|
||||||
|
}
|
||||||
|
search();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHandlers();
|
updateHandlers();
|
||||||
|
|
||||||
socket.on('progress', function (data) {
|
socket.on('progress', function (data) {
|
||||||
if ($('#progress.dialog').data('progress') > data.progress) return;
|
if (data.progress > 0 && $('#progress.dialog').data('progress') > data.progress) return;
|
||||||
|
|
||||||
$("#progress.dialog .close").hide();
|
$("#progress.dialog .close").hide();
|
||||||
$("#progress.dialog").show();
|
$("#progress.dialog").show();
|
||||||
|
@ -100,5 +127,6 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.emit("load");
|
socket.emit("load");
|
||||||
|
search();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -55,18 +55,33 @@ exports.install = function(plugin_name, cb) {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.search = function(query, cb) {
|
exports.searchCache = null;
|
||||||
|
|
||||||
|
exports.search = function(query, cache, cb) {
|
||||||
withNpm(
|
withNpm(
|
||||||
function (cb) {
|
function (cb) {
|
||||||
registry.get(
|
var getData = function (cb) {
|
||||||
"/-/all", null, 600, false, true,
|
if (cache && exports.searchCache) {
|
||||||
|
cb(null, exports.searchCache);
|
||||||
|
} else {
|
||||||
|
registry.get(
|
||||||
|
"/-/all", null, 600, false, true,
|
||||||
|
function (er, data) {
|
||||||
|
if (er) return cb(er);
|
||||||
|
exports.searchCache = data;
|
||||||
|
cb(er, data);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getData(
|
||||||
function (er, data) {
|
function (er, data) {
|
||||||
if (er) return cb(er);
|
if (er) return cb(er);
|
||||||
var res = {};
|
var res = {};
|
||||||
var i = 0;
|
var i = 0;
|
||||||
for (key in data) {
|
for (key in data) {
|
||||||
if (/* && key.indexOf(plugins.prefix) == 0 */
|
if ( key.indexOf(plugins.prefix) == 0
|
||||||
key.indexOf(query.pattern) != -1) {
|
&& key.indexOf(query.pattern) != -1) {
|
||||||
i++;
|
i++;
|
||||||
if (i > query.offset
|
if (i > query.offset
|
||||||
&& i <= query.offset + query.limit) {
|
&& i <= query.offset + query.limit) {
|
||||||
|
|
Loading…
Reference in a new issue