mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 21:26:00 +00:00
changing current DB handler for MySQL #1237
This commit is contained in:
@@ -97,6 +97,12 @@ module.exports = {
|
||||
socket.emit(`session-initialize-file-${jslid}`);
|
||||
},
|
||||
|
||||
handle_changedCurrentDatabase(sesid, props) {
|
||||
const { database } = props;
|
||||
this.dispatchMessage(sesid, `Current database changed to ${database}`);
|
||||
socket.emit(`session-changedb-${sesid}`, { database });
|
||||
},
|
||||
|
||||
handle_ping() {},
|
||||
|
||||
create_meta: true,
|
||||
|
||||
@@ -148,6 +148,7 @@ class StreamHandler {
|
||||
// this.error = this.error.bind(this);
|
||||
this.done = this.done.bind(this);
|
||||
this.info = this.info.bind(this);
|
||||
this.changedCurrentDatabase = this.changedCurrentDatabase.bind(this);
|
||||
|
||||
// use this for cancelling - not implemented
|
||||
// this.stream = null;
|
||||
@@ -166,6 +167,10 @@ class StreamHandler {
|
||||
}
|
||||
}
|
||||
|
||||
changedCurrentDatabase(database) {
|
||||
process.send({ msgtype: 'changedCurrentDatabase', database, sesid: this.sesid });
|
||||
}
|
||||
|
||||
recordset(columns) {
|
||||
if (this.rowsLimitOverflow) {
|
||||
return;
|
||||
|
||||
1
packages/types/engines.d.ts
vendored
1
packages/types/engines.d.ts
vendored
@@ -21,6 +21,7 @@ export interface StreamOptions {
|
||||
error?: (error) => void;
|
||||
done?: (result) => void;
|
||||
info?: (info) => void;
|
||||
changedCurrentDatabase?: (database: string) => void;
|
||||
}
|
||||
|
||||
export type CollectionOperationInfo =
|
||||
|
||||
@@ -265,9 +265,11 @@
|
||||
if (sid) {
|
||||
apiOn(`session-done-${sid}`, handleSessionDone);
|
||||
apiOn(`session-closed-${sid}`, handleSessionClosed);
|
||||
apiOn(`session-changedb-${sid}`, handleChangedDatabase);
|
||||
return () => {
|
||||
apiOff(`session-done-${sid}`, handleSessionDone);
|
||||
apiOff(`session-closed-${sid}`, handleSessionClosed);
|
||||
apiOff(`session-changedb-${sid}`, handleChangedDatabase);
|
||||
};
|
||||
}
|
||||
return () => {};
|
||||
@@ -566,6 +568,17 @@
|
||||
handleSessionDone();
|
||||
};
|
||||
|
||||
const handleChangedDatabase = async props => {
|
||||
changeTab(tabid, tab => ({
|
||||
...tab,
|
||||
props: {
|
||||
...tab.props,
|
||||
conid,
|
||||
database: props.database,
|
||||
},
|
||||
}));
|
||||
};
|
||||
|
||||
const { editorState, editorValue, setEditorData } = useEditorData({
|
||||
tabid,
|
||||
loadFromArgs:
|
||||
|
||||
@@ -130,6 +130,9 @@ const drivers = driverBases.map(driverBase => ({
|
||||
time: new Date(),
|
||||
severity: 'info',
|
||||
});
|
||||
if (row.stateChanges?.schema) {
|
||||
options.changedCurrentDatabase(row.stateChanges.schema);
|
||||
}
|
||||
} else {
|
||||
if (columns) {
|
||||
options.row(zipDataRow(row, columns));
|
||||
|
||||
Reference in New Issue
Block a user