mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 22:57:11 -04:00
Added vite react admin ui.
This commit is contained in:
parent
d34b964cc2
commit
6f440a13cd
27 changed files with 969 additions and 11 deletions
|
@ -18,9 +18,12 @@ exports.expressCreateServer = (hookName:string, {app}:any) => {
|
|||
|
||||
exports.socketio = (hookName:string, {io}:any) => {
|
||||
io.of('/settings').on('connection', (socket: any ) => {
|
||||
console.log('Admin connected to /admin/settings')
|
||||
// @ts-ignore
|
||||
const {session: {user: {is_admin: isAdmin} = {}} = {}} = socket.conn.request;
|
||||
console.log('isAdmin', isAdmin)
|
||||
if (!isAdmin) return;
|
||||
console.log('Admin authenticated')
|
||||
|
||||
socket.on('load', async (query:string):Promise<any> => {
|
||||
let data;
|
||||
|
@ -38,6 +41,7 @@ exports.socketio = (hookName:string, {io}:any) => {
|
|||
});
|
||||
|
||||
socket.on('saveSettings', async (newSettings:string) => {
|
||||
console.log('Admin request to save settings through a socket on /admin/settings');
|
||||
await fsp.writeFile(settings.settingsFilename, newSettings);
|
||||
socket.emit('saveprogress', 'saved');
|
||||
});
|
||||
|
|
|
@ -76,10 +76,12 @@ export const expressCreateServer = (hookName:string, args:ArgsExpressType, cb:Fu
|
|||
maxHttpBufferSize: settings.socketIo.maxHttpBufferSize,
|
||||
})
|
||||
|
||||
io.on('connection', (socket:any) => {
|
||||
|
||||
const handleConnection = (socket:Socket) => {
|
||||
sockets.add(socket);
|
||||
socketsEvents.emit('updated');
|
||||
// https://socket.io/docs/v3/faq/index.html
|
||||
// @ts-ignore
|
||||
const session = socket.request.session;
|
||||
session.connections++;
|
||||
session.save();
|
||||
|
@ -87,15 +89,9 @@ export const expressCreateServer = (hookName:string, args:ArgsExpressType, cb:Fu
|
|||
sockets.delete(socket);
|
||||
socketsEvents.emit('updated');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
io.use(socketSessionMiddleware(args));
|
||||
|
||||
// Temporary workaround so all clients go through middleware and handle connection
|
||||
io.of('/pluginfw/installer').use(socketSessionMiddleware(args))
|
||||
io.of('/settings').use(socketSessionMiddleware(args))
|
||||
|
||||
io.use((socket:any, next:Function) => {
|
||||
const renewSession = (socket:any, next:Function) => {
|
||||
socket.conn.on('packet', (packet:string) => {
|
||||
// Tell express-session that the session is still active. The session store can use these
|
||||
// touch events to defer automatic session cleanup, and if express-session is configured with
|
||||
|
@ -106,7 +102,24 @@ export const expressCreateServer = (hookName:string, args:ArgsExpressType, cb:Fu
|
|||
if (socket.request.session != null) socket.request.session.touch();
|
||||
});
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
io.on('connection', handleConnection);
|
||||
|
||||
io.use(socketSessionMiddleware(args));
|
||||
|
||||
// Temporary workaround so all clients go through middleware and handle connection
|
||||
io.of('/pluginfw/installer')
|
||||
.on('connection',handleConnection)
|
||||
.use(socketSessionMiddleware(args))
|
||||
.use(renewSession)
|
||||
io.of('/settings')
|
||||
.on('connection',handleConnection)
|
||||
.use(socketSessionMiddleware(args))
|
||||
.use(renewSession)
|
||||
|
||||
io.use(renewSession);
|
||||
|
||||
// var socketIOLogger = log4js.getLogger("socket.io");
|
||||
// Debug logging now has to be set at an environment level, this is stupid.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue