diff --git a/src/node/hooks/express/adminplugins.js b/src/node/hooks/express/adminplugins.js index 4dad3730d..e85dba28c 100644 --- a/src/node/hooks/express/adminplugins.js +++ b/src/node/hooks/express/adminplugins.js @@ -39,10 +39,12 @@ exports.expressCreateServer = (hookName, args, cb) => { exports.socketio = (hookName, args, cb) => { const io = args.io.of('/pluginfw/installer'); io.on('connection', (socket) => { + console.log('event connection', new Date()) const {session: {user: {is_admin: isAdmin} = {}} = {}} = socket.conn.request; if (!isAdmin) return; socket.on('getInstalled', (query) => { + console.log('message getInstalled', new Date()) // send currently installed plugins const installed = Object.keys(pluginDefs.plugins).map((plugin) => pluginDefs.plugins[plugin].package); @@ -51,6 +53,7 @@ exports.socketio = (hookName, args, cb) => { }); socket.on('checkUpdates', async () => { + console.log('message checkUpdates', new Date()) // Check plugins for updates try { const results = await installer.getAvailablePlugins(/* maxCacheAge:*/ 60 * 10); @@ -64,25 +67,31 @@ exports.socketio = (hookName, args, cb) => { return semver.gt(latestVersion, currentVersion); }).map((plugin) => ({name: plugin, version: results[plugin].version})); + console.log('emit results:updatable', new Date()) socket.emit('results:updatable', {updatable}); } catch (err) { console.warn(err.stack || err.toString()); + console.log('emit results:updatable', new Date()) socket.emit('results:updatable', {updatable: {}}); } }); socket.on('getAvailable', async (query) => { + console.log('message getAvailable', new Date()) try { const results = await installer.getAvailablePlugins(/* maxCacheAge:*/ false); + console.log('emit results:available', new Date()) socket.emit('results:available', results); } catch (er) { console.error(er); + console.log('emit results:available', new Date()) socket.emit('results:available', {}); } }); socket.on('search', async (query) => { + console.log('message search', new Date()) try { const results = await installer.search(query.searchTerm, /* maxCacheAge:*/ 60 * 10); let res = Object.keys(results) @@ -90,18 +99,22 @@ exports.socketio = (hookName, args, cb) => { .filter((plugin) => !pluginDefs.plugins[plugin.name]); res = sortPluginList(res, query.sortBy, query.sortDir) .slice(query.offset, query.offset + query.limit); + console.log('emit results:search', new Date()) socket.emit('results:search', {results: res, query}); } catch (er) { console.error(er); + console.log('emit results:search', new Date()) socket.emit('results:search', {results: {}, query}); } }); socket.on('install', (pluginName, version) => { + console.log('message install', new Date()) installer.install(pluginName, version, (err) => { if (err) console.warn(err.stack || err.toString()); + console.log('emit finished:install', new Date()) socket.emit('finished:install', { plugin: pluginName, code: err ? err.code : null, @@ -111,9 +124,11 @@ exports.socketio = (hookName, args, cb) => { }); socket.on('uninstall', (pluginName) => { + console.log('message uninstall', new Date()) installer.uninstall(pluginName, (err) => { if (err) console.warn(err.stack || err.toString()); + console.log('emit finished:uninstall', new Date()) socket.emit('finished:uninstall', {plugin: pluginName, error: err ? err.message : null}); }); }); diff --git a/src/static/js/admin/plugins.js b/src/static/js/admin/plugins.js index 752d2220f..2682448fd 100644 --- a/src/static/js/admin/plugins.js +++ b/src/static/js/admin/plugins.js @@ -5,6 +5,7 @@ $(document).ready(() => { const socket = socketio.connect('..', '/pluginfw/installer'); socket.on('disconnect', (reason) => { + window.console.log('socket disconnect', new Date()); // The socket.io client will automatically try to reconnect for all reasons other than "io // server disconnect". if (reason === 'io server disconnect') socket.connect(); @@ -133,6 +134,7 @@ $(document).ready(() => { } else { installed.progress.show(plugin, 'Updating'); } + window.console.log('before emit install', new Date()) socket.emit('install', plugin, version); installed.messages.hide('nothing-installed'); }); @@ -141,6 +143,7 @@ $(document).ready(() => { $('.do-uninstall').unbind('click').click((e) => { const $row = $(e.target).closest('tr'); const pluginName = $row.data('plugin'); + window.console.log('before emit uninstall', new Date()) socket.emit('uninstall', pluginName); installed.progress.show(pluginName, 'Uninstalling'); installed.list = installed.list.filter((plugin) => plugin.name !== pluginName); @@ -170,7 +173,7 @@ $(document).ready(() => { search.messages.hide('fetching'); $('#search-query').removeAttr('disabled'); - console.log('got search results', data); + window.console.log('got search results', data); // add to results search.results = search.results.concat(data.results); @@ -198,6 +201,7 @@ $(document).ready(() => { }); socket.on('results:installed', (data) => { + window.console.log('socket results:installed', new Date()); installed.messages.hide('fetching'); installed.messages.hide('nothing-installed'); @@ -214,6 +218,7 @@ $(document).ready(() => { if (installed.list.length > 0) { displayPluginList(installed.list, $('#installed-plugins'), $('#installed-plugin-template')); + window.console.log('before emit checkUpdates', new Date()) socket.emit('checkUpdates'); } else { installed.messages.show('nothing-installed'); @@ -221,6 +226,7 @@ $(document).ready(() => { }); socket.on('results:updatable', (data) => { + window.console.log('socket results:updatable', new Date()); data.updatable.forEach((plugin) => { const {name, version} = plugin; const actions = $(`#installed-plugins > tr.${name} .actions`); @@ -233,6 +239,7 @@ $(document).ready(() => { }); socket.on('finished:install', (data) => { + window.console.log('socket finished:install', new Date()); if (data.error) { if (data.code === 'EPEERINVALID') { alert("This plugin requires that you update Etherpad so it can operate in it's true glory"); @@ -241,6 +248,7 @@ $(document).ready(() => { $(`#installed-plugins .${data.plugin}`).remove(); } + window.console.log('before emit getInstalled', new Date()) socket.emit('getInstalled'); // update search results @@ -250,6 +258,7 @@ $(document).ready(() => { }); socket.on('finished:uninstall', (data) => { + window.console.log('socket finished:uninstall', new Date()); if (data.error) { alert(`An error occurred while uninstalling the ${data.plugin} \n${data.error}`); } @@ -257,6 +266,7 @@ $(document).ready(() => { // remove plugin from installed list $(`#installed-plugins .${data.plugin}`).remove(); + window.console.log('before emit getInstalled', new Date()) socket.emit('getInstalled'); // update search results @@ -266,7 +276,9 @@ $(document).ready(() => { }); socket.on('connect', () => { + window.console.log('socket connect', new Date()); updateHandlers(); + window.console.log('before emit getInstalled', new Date()) socket.emit('getInstalled'); search.searchTerm = null; search($('#search-query').val());