refactor: remap of table data object

This commit is contained in:
Fabio 2020-10-12 18:45:15 +02:00
parent b7c779eef6
commit 936de04cd3
3 changed files with 34 additions and 8 deletions

View File

@ -34,6 +34,7 @@ This is a roadmap with major features will come in near future.
- Users management (add/edit/delete).
- Stored procedures, views, schedulers and trigger support.
- Database tools.
- Improve query suggestions.
- Context menu shortcuts.
- Keyboard shortcuts.
- More secure password storage.
@ -48,7 +49,7 @@ This is a roadmap with major features will come in near future.
### Databases
- [x] MySQL/MariaDB
- [ ] PostrgreSQL
- [ ] PostgreSQL
- [ ] MSSQL
- [ ] SQLite
- [ ] OracleDB

View File

@ -62,9 +62,34 @@ export class MySQLClient extends AntaresCore {
}
return databases.map(db => { // TODO: remap all objects,
const tablesRemapped = tables.filter(table => table.TABLE_SCHEMA === db.Database).map(table => {
let tableType;
switch (table.TABLE_TYPE) {
case 'VIEW':
tableType = 'view';
break;
default:
tableType = 'table';
break;
}
return {
name: table.TABLE_NAME,
type: tableType,
rows: table.TABLE_ROWS,
created: table.CREATE_TIME,
updated: table.UPDATE_TIME,
engine: table.ENGINE,
comment: table.TABLE_COMMENT,
size: table.DATA_LENGTH + table.INDEX_LENGTH,
autoIncrement: table.AUTO_INCREMENT,
collation: table.TABLE_COLLATION
};
});
return {
name: db.Database,
tables: tables.filter(table => table.TABLE_SCHEMA === db.Database),
tables: tablesRemapped,
functions: functions.filter(func => func.Db === db.Database),
procedures: procedures.filter(procedure => procedure.Db === db.Database),
triggers: triggersArr.filter(trigger => trigger.Db === db.Database),

View File

@ -15,15 +15,15 @@
<ul class="menu menu-nav pt-0">
<li
v-for="table of database.tables"
:key="table.TABLE_NAME"
:key="table.name"
class="menu-item"
:class="{'text-bold': breadcrumbs.schema === database.name && breadcrumbs.table === table.TABLE_NAME}"
@click="changeBreadcrumbs({schema: database.name, table: table.TABLE_NAME})"
@contextmenu.prevent="showTableContext($event, table.TABLE_NAME)"
:class="{'text-bold': breadcrumbs.schema === database.name && breadcrumbs.table === table.name}"
@click="changeBreadcrumbs({schema: database.name, table: table.name})"
@contextmenu.prevent="showTableContext($event, table.name)"
>
<a class="table-name">
<i class="table-icon mdi mdi-18px mr-1" :class="table.TABLE_TYPE === 'VIEW' ? 'mdi-table-eye' : 'mdi-table'" />
<span>{{ table.TABLE_NAME }}</span>
<i class="table-icon mdi mdi-18px mr-1" :class="table.type === 'view' ? 'mdi-table-eye' : 'mdi-table'" />
<span>{{ table.name }}</span>
</a>
</li>
</ul>