mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
feat: schema size in explore bar
This commit is contained in:
@ -187,6 +187,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
|
|
||||||
const tablesArr = [];
|
const tablesArr = [];
|
||||||
const triggersArr = [];
|
const triggersArr = [];
|
||||||
|
let schemaSize = 0;
|
||||||
|
|
||||||
for (const db of filteredDatabases) {
|
for (const db of filteredDatabases) {
|
||||||
if (!schemas.has(db.Database)) continue;
|
if (!schemas.has(db.Database)) continue;
|
||||||
@ -224,6 +225,9 @@ export class MySQLClient extends AntaresCore {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const tableSize = table.Data_length + table.Index_length;
|
||||||
|
schemaSize += tableSize;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: table.Name,
|
name: table.Name,
|
||||||
type: tableType,
|
type: tableType,
|
||||||
@ -232,7 +236,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
updated: table.Update_time,
|
updated: table.Update_time,
|
||||||
engine: table.Engine,
|
engine: table.Engine,
|
||||||
comment: table.Comment,
|
comment: table.Comment,
|
||||||
size: table.Data_length + table.Index_length,
|
size: tableSize,
|
||||||
autoIncrement: table.Auto_increment,
|
autoIncrement: table.Auto_increment,
|
||||||
collation: table.Collation
|
collation: table.Collation
|
||||||
};
|
};
|
||||||
@ -309,6 +313,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
name: db.Database,
|
name: db.Database,
|
||||||
|
size: schemaSize,
|
||||||
tables: remappedTables,
|
tables: remappedTables,
|
||||||
functions: remappedFunctions,
|
functions: remappedFunctions,
|
||||||
procedures: remappedProcedures,
|
procedures: remappedProcedures,
|
||||||
@ -319,6 +324,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
else {
|
else {
|
||||||
return {
|
return {
|
||||||
name: db.Database,
|
name: db.Database,
|
||||||
|
size: 0,
|
||||||
tables: [],
|
tables: [],
|
||||||
functions: [],
|
functions: [],
|
||||||
procedures: [],
|
procedures: [],
|
||||||
|
@ -144,6 +144,7 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
|
|
||||||
const tablesArr = [];
|
const tablesArr = [];
|
||||||
const triggersArr = [];
|
const triggersArr = [];
|
||||||
|
let schemaSize = 0;
|
||||||
|
|
||||||
for (const db of databases) {
|
for (const db of databases) {
|
||||||
if (!schemas.has(db.database)) continue;
|
if (!schemas.has(db.database)) continue;
|
||||||
@ -198,11 +199,14 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
if (schemas.has(db.database)) {
|
if (schemas.has(db.database)) {
|
||||||
// TABLES
|
// TABLES
|
||||||
const remappedTables = tablesArr.filter(table => table.Db === db.database).map(table => {
|
const remappedTables = tablesArr.filter(table => table.Db === db.database).map(table => {
|
||||||
|
const tableSize = +table.data_length + table.index_length;
|
||||||
|
schemaSize += tableSize;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: table.table_name,
|
name: table.table_name,
|
||||||
type: table.table_type === 'VIEW' ? 'view' : 'table',
|
type: table.table_type === 'VIEW' ? 'view' : 'table',
|
||||||
rows: table.reltuples,
|
rows: table.reltuples,
|
||||||
size: +table.data_length + +table.index_length,
|
size: tableSize,
|
||||||
collation: table.Collation,
|
collation: table.Collation,
|
||||||
comment: table.comment,
|
comment: table.comment,
|
||||||
engine: ''
|
engine: ''
|
||||||
@ -250,6 +254,7 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
name: db.database,
|
name: db.database,
|
||||||
|
size: schemaSize,
|
||||||
tables: remappedTables,
|
tables: remappedTables,
|
||||||
functions: remappedFunctions,
|
functions: remappedFunctions,
|
||||||
procedures: remappedProcedures,
|
procedures: remappedProcedures,
|
||||||
@ -261,6 +266,7 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
else {
|
else {
|
||||||
return {
|
return {
|
||||||
name: db.database,
|
name: db.database,
|
||||||
|
size: 0,
|
||||||
tables: [],
|
tables: [],
|
||||||
functions: [],
|
functions: [],
|
||||||
procedures: [],
|
procedures: [],
|
||||||
|
@ -9,7 +9,16 @@
|
|||||||
<div v-if="isLoading" class="icon loading" />
|
<div v-if="isLoading" class="icon loading" />
|
||||||
<i v-else class="icon mdi mdi-18px mdi-chevron-right" />
|
<i v-else class="icon mdi mdi-18px mdi-chevron-right" />
|
||||||
<i class="database-icon mdi mdi-18px mdi-database mr-1" />
|
<i class="database-icon mdi mdi-18px mdi-database mr-1" />
|
||||||
|
<div class="">
|
||||||
<span>{{ database.name }}</span>
|
<span>{{ database.name }}</span>
|
||||||
|
<div
|
||||||
|
v-if="database.size"
|
||||||
|
class="schema-size tooltip tooltip-left mr-1"
|
||||||
|
:data-tooltip="formatBytes(database.size)"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-information-outline pr-2" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</summary>
|
</summary>
|
||||||
<div class="accordion-body">
|
<div class="accordion-body">
|
||||||
<div class="database-tables">
|
<div class="database-tables">
|
||||||
@ -442,6 +451,11 @@ export default {
|
|||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
|
|
||||||
|
.schema-size{
|
||||||
|
visibility: hidden;
|
||||||
|
width: 22.5px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.database-name,
|
.database-name,
|
||||||
@ -487,6 +501,10 @@ export default {
|
|||||||
.misc-name {
|
.misc-name {
|
||||||
&:hover {
|
&:hover {
|
||||||
border-radius: $border-radius;
|
border-radius: $border-radius;
|
||||||
|
|
||||||
|
.schema-size{
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -516,6 +534,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.schema-size,
|
||||||
.table-size,
|
.table-size,
|
||||||
.disabled-indicator {
|
.disabled-indicator {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
Reference in New Issue
Block a user