mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 02:43:59 +00:00
style
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
const fp = require('lodash/fp');
|
const _ = require('lodash');
|
||||||
const connections = require('./connections');
|
const connections = require('./connections');
|
||||||
const socket = require('../utility/socket');
|
const socket = require('../utility/socket');
|
||||||
const { fork } = require('child_process');
|
const { fork } = require('child_process');
|
||||||
const DatabaseAnalyser = require('../engines/default/DatabaseAnalyser')
|
const DatabaseAnalyser = require('../engines/default/DatabaseAnalyser');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
/** @type {import('../types').OpenedDatabaseConnection[]} */
|
/** @type {import('../types').OpenedDatabaseConnection[]} */
|
||||||
@@ -39,9 +39,12 @@ module.exports = {
|
|||||||
return newOpened;
|
return newOpened;
|
||||||
},
|
},
|
||||||
|
|
||||||
listTables_meta: 'get',
|
listObjects_meta: 'get',
|
||||||
async listTables({ id, database }) {
|
async listObjects({ id, database }) {
|
||||||
const opened = await this.ensureOpened(id, database);
|
const opened = await this.ensureOpened(id, database);
|
||||||
return opened.structure.tables; // .map(fp.pick(['tableName', 'schemaName']));
|
const { tables } = opened.structure;
|
||||||
|
return {
|
||||||
|
tables: _.sortBy(tables, x => `${x.schemaName}.${x.pureName}`),
|
||||||
|
}; // .map(fp.pick(['tableName', 'schemaName']));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
select
|
select
|
||||||
o.name as tableName, s.name as schemaName, o.object_id,
|
o.name as pureName, s.name as schemaName, o.object_id,
|
||||||
o.create_date, o.modify_date
|
o.create_date, o.modify_date
|
||||||
from sys.tables o
|
from sys.tables o
|
||||||
inner join sys.schemas s on o.schema_id = s.schema_id
|
inner join sys.schemas s on o.schema_id = s.schema_id
|
||||||
|
|||||||
@@ -7,17 +7,14 @@ export interface EngineDriver {
|
|||||||
analyseIncremental(pool): Promise<void>;
|
analyseIncremental(pool): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// export interface NameWithSchema {
|
export interface NamedObjectInfo {
|
||||||
// schema: string;
|
pureName: string;
|
||||||
// name: string;
|
|
||||||
// }
|
|
||||||
|
|
||||||
export interface TableInfo {
|
|
||||||
// name: NameWithSchema;
|
|
||||||
tableName: string;
|
|
||||||
schemaName: string;
|
schemaName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TableInfo extends NamedObjectInfo {
|
||||||
|
}
|
||||||
|
|
||||||
export interface DatabaseInfo {
|
export interface DatabaseInfo {
|
||||||
tables: TableInfo[];
|
tables: TableInfo[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ const AppObjectDiv = styled.div`
|
|||||||
background-color: lightblue;
|
background-color: lightblue;
|
||||||
}
|
}
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
white-space: nowrap;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const IconWrap = styled.span`
|
const IconWrap = styled.span`
|
||||||
|
|||||||
29
web/src/appobj/tableAppObject.js
Normal file
29
web/src/appobj/tableAppObject.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { TableIcon } from '../icons';
|
||||||
|
import { DropDownMenuItem } from '../modals/DropDownMenu';
|
||||||
|
import showModal from '../modals/showModal';
|
||||||
|
import ConnectionModal from '../modals/ConnectionModal';
|
||||||
|
import axios from '../utility/axios';
|
||||||
|
|
||||||
|
function Menu({ data, makeAppObj }) {
|
||||||
|
const handleEdit = () => {
|
||||||
|
showModal(modalState => <ConnectionModal modalState={modalState} connection={data} />);
|
||||||
|
};
|
||||||
|
const handleDelete = () => {
|
||||||
|
axios.post('connections/delete', data);
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<DropDownMenuItem onClick={handleEdit}>Edit</DropDownMenuItem>
|
||||||
|
<DropDownMenuItem onClick={handleDelete}>Delete</DropDownMenuItem>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function tableAppObject({ pureName, schemaName }) {
|
||||||
|
const title = schemaName ? `${schemaName}.${pureName}` : pureName;
|
||||||
|
const key = title;
|
||||||
|
const Icon = TableIcon;
|
||||||
|
|
||||||
|
return { title, key, Icon, Menu };
|
||||||
|
}
|
||||||
@@ -8,6 +8,8 @@ import { AppObjectList } from '../appobj/AppObjectList';
|
|||||||
import connectionAppObject from '../appobj/connectionAppObject';
|
import connectionAppObject from '../appobj/connectionAppObject';
|
||||||
import databaseAppObject from '../appobj/databaseAppObject';
|
import databaseAppObject from '../appobj/databaseAppObject';
|
||||||
import { useSetCurrentDatabase, useCurrentDatabase } from '../utility/globalState';
|
import { useSetCurrentDatabase, useCurrentDatabase } from '../utility/globalState';
|
||||||
|
import tableAppObject from '../appobj/tableAppObject';
|
||||||
|
import theme from '../theme';
|
||||||
|
|
||||||
const MainContainer = styled.div`
|
const MainContainer = styled.div`
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -19,6 +21,7 @@ const MainContainer = styled.div`
|
|||||||
const InnerContainer = styled.div`
|
const InnerContainer = styled.div`
|
||||||
flex: 1 0;
|
flex: 1 0;
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
|
width: ${theme.leftPanel.width}px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
function SubDatabaseList({ data }) {
|
function SubDatabaseList({ data }) {
|
||||||
@@ -53,16 +56,14 @@ function ConnectionList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function SqlObjectList({ id, database }) {
|
function SqlObjectList({ id, database }) {
|
||||||
const tables =
|
const objects = useFetch({
|
||||||
useFetch({
|
url: `database-connections/list-objects?id=${id}&database=${database}`,
|
||||||
url: `database-connections/list-tables?id=${id}&database=${database}`,
|
|
||||||
reloadTrigger: `database-structure-changed-${id}-${database}`,
|
reloadTrigger: `database-structure-changed-${id}-${database}`,
|
||||||
}) || [];
|
});
|
||||||
|
const { tables } = objects || {};
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{tables.map(({ tableName, schemaName }) => (
|
<AppObjectList list={tables} makeAppObj={tableAppObject} />
|
||||||
<div key={`${schemaName}.${tableName}`}>{tableName}</div>
|
|
||||||
))}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user