Skip to content

Commit d5455bc

Browse files
committed
debug
1 parent ad15aae commit d5455bc

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/node/hooks/express/adminplugins.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ exports.expressCreateServer = (hookName, args, cb) => {
3939
exports.socketio = (hookName, args, cb) => {
4040
const io = args.io.of('/pluginfw/installer');
4141
io.on('connection', (socket) => {
42+
console.log('event connection', new Date())
4243
const {session: {user: {is_admin: isAdmin} = {}} = {}} = socket.conn.request;
4344
if (!isAdmin) return;
4445

4546
socket.on('getInstalled', (query) => {
47+
console.log('message getInstalled', new Date())
4648
// send currently installed plugins
4749
const installed =
4850
Object.keys(pluginDefs.plugins).map((plugin) => pluginDefs.plugins[plugin].package);
@@ -51,6 +53,7 @@ exports.socketio = (hookName, args, cb) => {
5153
});
5254

5355
socket.on('checkUpdates', async () => {
56+
console.log('message checkUpdates', new Date())
5457
// Check plugins for updates
5558
try {
5659
const results = await installer.getAvailablePlugins(/* maxCacheAge:*/ 60 * 10);
@@ -64,44 +67,54 @@ exports.socketio = (hookName, args, cb) => {
6467
return semver.gt(latestVersion, currentVersion);
6568
}).map((plugin) => ({name: plugin, version: results[plugin].version}));
6669

70+
console.log('emit results:updatable', new Date())
6771
socket.emit('results:updatable', {updatable});
6872
} catch (err) {
6973
console.warn(err.stack || err.toString());
7074

75+
console.log('emit results:updatable', new Date())
7176
socket.emit('results:updatable', {updatable: {}});
7277
}
7378
});
7479

7580
socket.on('getAvailable', async (query) => {
81+
console.log('message getAvailable', new Date())
7682
try {
7783
const results = await installer.getAvailablePlugins(/* maxCacheAge:*/ false);
84+
console.log('emit results:available', new Date())
7885
socket.emit('results:available', results);
7986
} catch (er) {
8087
console.error(er);
88+
console.log('emit results:available', new Date())
8189
socket.emit('results:available', {});
8290
}
8391
});
8492

8593
socket.on('search', async (query) => {
94+
console.log('message search', new Date())
8695
try {
8796
const results = await installer.search(query.searchTerm, /* maxCacheAge:*/ 60 * 10);
8897
let res = Object.keys(results)
8998
.map((pluginName) => results[pluginName])
9099
.filter((plugin) => !pluginDefs.plugins[plugin.name]);
91100
res = sortPluginList(res, query.sortBy, query.sortDir)
92101
.slice(query.offset, query.offset + query.limit);
102+
console.log('emit results:search', new Date())
93103
socket.emit('results:search', {results: res, query});
94104
} catch (er) {
95105
console.error(er);
96106

107+
console.log('emit results:search', new Date())
97108
socket.emit('results:search', {results: {}, query});
98109
}
99110
});
100111

101112
socket.on('install', (pluginName, version) => {
113+
console.log('message install', new Date())
102114
installer.install(pluginName, version, (err) => {
103115
if (err) console.warn(err.stack || err.toString());
104116

117+
console.log('emit finished:install', new Date())
105118
socket.emit('finished:install', {
106119
plugin: pluginName,
107120
code: err ? err.code : null,
@@ -111,9 +124,11 @@ exports.socketio = (hookName, args, cb) => {
111124
});
112125

113126
socket.on('uninstall', (pluginName) => {
127+
console.log('message uninstall', new Date())
114128
installer.uninstall(pluginName, (err) => {
115129
if (err) console.warn(err.stack || err.toString());
116130

131+
console.log('emit finished:uninstall', new Date())
117132
socket.emit('finished:uninstall', {plugin: pluginName, error: err ? err.message : null});
118133
});
119134
});

src/static/js/admin/plugins.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
$(document).ready(() => {
66
const socket = socketio.connect('..', '/pluginfw/installer');
77
socket.on('disconnect', (reason) => {
8+
window.console.log('socket disconnect', new Date());
89
// The socket.io client will automatically try to reconnect for all reasons other than "io
910
// server disconnect".
1011
if (reason === 'io server disconnect') socket.connect();
@@ -133,6 +134,7 @@ $(document).ready(() => {
133134
} else {
134135
installed.progress.show(plugin, 'Updating');
135136
}
137+
window.console.log('before emit install', new Date())
136138
socket.emit('install', plugin, version);
137139
installed.messages.hide('nothing-installed');
138140
});
@@ -141,6 +143,7 @@ $(document).ready(() => {
141143
$('.do-uninstall').unbind('click').click((e) => {
142144
const $row = $(e.target).closest('tr');
143145
const pluginName = $row.data('plugin');
146+
window.console.log('before emit uninstall', new Date())
144147
socket.emit('uninstall', pluginName);
145148
installed.progress.show(pluginName, 'Uninstalling');
146149
installed.list = installed.list.filter((plugin) => plugin.name !== pluginName);
@@ -170,7 +173,7 @@ $(document).ready(() => {
170173
search.messages.hide('fetching');
171174
$('#search-query').removeAttr('disabled');
172175

173-
console.log('got search results', data);
176+
window.console.log('got search results', data);
174177

175178
// add to results
176179
search.results = search.results.concat(data.results);
@@ -198,6 +201,7 @@ $(document).ready(() => {
198201
});
199202

200203
socket.on('results:installed', (data) => {
204+
window.console.log('socket results:installed', new Date());
201205
installed.messages.hide('fetching');
202206
installed.messages.hide('nothing-installed');
203207

@@ -214,13 +218,15 @@ $(document).ready(() => {
214218

215219
if (installed.list.length > 0) {
216220
displayPluginList(installed.list, $('#installed-plugins'), $('#installed-plugin-template'));
221+
window.console.log('before emit checkUpdates', new Date())
217222
socket.emit('checkUpdates');
218223
} else {
219224
installed.messages.show('nothing-installed');
220225
}
221226
});
222227

223228
socket.on('results:updatable', (data) => {
229+
window.console.log('socket results:updatable', new Date());
224230
data.updatable.forEach((plugin) => {
225231
const {name, version} = plugin;
226232
const actions = $(`#installed-plugins > tr.${name} .actions`);
@@ -233,6 +239,7 @@ $(document).ready(() => {
233239
});
234240

235241
socket.on('finished:install', (data) => {
242+
window.console.log('socket finished:install', new Date());
236243
if (data.error) {
237244
if (data.code === 'EPEERINVALID') {
238245
alert("This plugin requires that you update Etherpad so it can operate in it's true glory");
@@ -241,6 +248,7 @@ $(document).ready(() => {
241248
$(`#installed-plugins .${data.plugin}`).remove();
242249
}
243250

251+
window.console.log('before emit getInstalled', new Date())
244252
socket.emit('getInstalled');
245253

246254
// update search results
@@ -250,13 +258,15 @@ $(document).ready(() => {
250258
});
251259

252260
socket.on('finished:uninstall', (data) => {
261+
window.console.log('socket finished:uninstall', new Date());
253262
if (data.error) {
254263
alert(`An error occurred while uninstalling the ${data.plugin} \n${data.error}`);
255264
}
256265

257266
// remove plugin from installed list
258267
$(`#installed-plugins .${data.plugin}`).remove();
259268

269+
window.console.log('before emit getInstalled', new Date())
260270
socket.emit('getInstalled');
261271

262272
// update search results
@@ -266,7 +276,9 @@ $(document).ready(() => {
266276
});
267277

268278
socket.on('connect', () => {
279+
window.console.log('socket connect', new Date());
269280
updateHandlers();
281+
window.console.log('before emit getInstalled', new Date())
270282
socket.emit('getInstalled');
271283
search.searchTerm = null;
272284
search($('#search-query').val());

0 commit comments

Comments
 (0)