fix: Corregir scroll del emulador y serializacion circular de FindCursor en mongosh
This commit is contained in:
@@ -828,8 +828,14 @@ app.post('/api/admin/mongosh', async (req, res) => {
|
|||||||
})();
|
})();
|
||||||
`);
|
`);
|
||||||
|
|
||||||
const result = await evalFn(dbProxy, ObjectId);
|
let finalResult = await evalFn(dbProxy, ObjectId);
|
||||||
res.json({ result });
|
|
||||||
|
// Si el resultado es un cursor de MongoDB (ej. db.collection.find()), lo convertimos a array
|
||||||
|
if (finalResult && typeof finalResult === 'object' && typeof finalResult.toArray === 'function') {
|
||||||
|
finalResult = await finalResult.toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json({ result: finalResult });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
res.status(400).json({ error: err.message || String(err) });
|
res.status(400).json({ error: err.message || String(err) });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ export function SeccionSistema() {
|
|||||||
<CardContent>
|
<CardContent>
|
||||||
<div
|
<div
|
||||||
className="bg-gray-900 text-green-400 font-mono text-sm p-4 rounded-md h-[400px] overflow-y-auto flex flex-col gap-1 relative cursor-text group"
|
className="bg-gray-900 text-green-400 font-mono text-sm p-4 rounded-md h-[400px] overflow-y-auto flex flex-col gap-1 relative cursor-text group"
|
||||||
onClick={() => inputRef.current?.focus()}
|
onClick={() => inputRef.current?.focus({ preventScroll: true })}
|
||||||
>
|
>
|
||||||
{consoleHistory.length === 0 && (
|
{consoleHistory.length === 0 && (
|
||||||
<div className="text-gray-500 italic mb-2">Conectado. Esperando comandos... Ej: db.pacientes.find()</div>
|
<div className="text-gray-500 italic mb-2">Conectado. Esperando comandos... Ej: db.pacientes.find()</div>
|
||||||
@@ -194,7 +194,7 @@ export function SeccionSistema() {
|
|||||||
<input
|
<input
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
type="text"
|
type="text"
|
||||||
className="opacity-0 absolute inset-0 w-full h-full pointer-events-none"
|
className="opacity-0 w-[1px] h-[1px] absolute overflow-hidden p-0 m-0 border-0 pointer-events-none"
|
||||||
value={mongoshCommand}
|
value={mongoshCommand}
|
||||||
onChange={(e) => setMongoshCommand(e.target.value)}
|
onChange={(e) => setMongoshCommand(e.target.value)}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
|
|||||||
Reference in New Issue
Block a user