Skip to content

Commit

Permalink
apply formatting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudiohbsantos committed Feb 1, 2021
1 parent f881691 commit 41f244f
Show file tree
Hide file tree
Showing 11 changed files with 242 additions and 260 deletions.
64 changes: 21 additions & 43 deletions backend/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,9 @@ let listObj: any;
ipcMain.on('return-db-list', (event, dbName) => {
// DB query to get the database size
let dbSize: string;
db.query(`SELECT pg_size_pretty(pg_database_size('${dbName}'));`).then(
(queryStats) => {
dbSize = queryStats.rows[0].pg_size_pretty;
}
);
db.query(`SELECT pg_size_pretty(pg_database_size('${dbName}'));`).then((queryStats) => {
dbSize = queryStats.rows[0].pg_size_pretty;
});
db.getLists().then((data) => event.sender.send('db-lists', data, dbSize));
});

Expand All @@ -93,15 +91,9 @@ ipcMain.on('upload-file', (event, filePath: string) => {

let dbName: string;
if (process.platform === 'darwin') {
dbName = filePath[0].slice(
filePath[0].lastIndexOf('/') + 1,
filePath[0].lastIndexOf('.')
);
dbName = filePath[0].slice(filePath[0].lastIndexOf('/') + 1, filePath[0].lastIndexOf('.'));
} else {
dbName = filePath[0].slice(
filePath[0].lastIndexOf('\\') + 1,
filePath[0].lastIndexOf('.')
);
dbName = filePath[0].slice(filePath[0].lastIndexOf('\\') + 1, filePath[0].lastIndexOf('.'));
}

const createDB: string = createDBFunc(dbName);
Expand Down Expand Up @@ -134,11 +126,9 @@ ipcMain.on('upload-file', (event, filePath: string) => {
execute(runCmd, sendLists);

// DB query to get the database size
db.query(`SELECT pg_size_pretty(pg_database_size('${dbName}'));`).then(
(queryStats) => {
dbSize = queryStats.rows[0].pg_size_pretty;
}
);
db.query(`SELECT pg_size_pretty(pg_database_size('${dbName}'));`).then((queryStats) => {
dbSize = queryStats.rows[0].pg_size_pretty;
});
};

// Step 3: Import database file from file path into docker container
Expand Down Expand Up @@ -315,19 +305,17 @@ ipcMain.on('execute-query-tracked', (event, data: QueryType) => {
frontendData.queryData = queryData.rows;
if (!queryString.match(/create/i)) {
// Run EXPLAIN (FORMAT JSON, ANALYZE)
db.query('EXPLAIN (FORMAT JSON, ANALYZE) ' + queryString).then(
(queryStats) => {
frontendData.queryStatistics = queryStats.rows;

(async function getListAsync() {
listObj = await db.getLists();
frontendData.lists = listObj;
event.sender.send('db-lists', listObj);
event.sender.send('return-execute-query', frontendData);
event.sender.send('async-complete');
})();
}
);
db.query('EXPLAIN (FORMAT JSON, ANALYZE) ' + queryString).then((queryStats) => {
frontendData.queryStatistics = queryStats.rows;

(async function getListAsync() {
listObj = await db.getLists();
frontendData.lists = listObj;
event.sender.send('db-lists', listObj);
event.sender.send('return-execute-query', frontendData);
event.sender.send('async-complete');
})();
});
} else {
// Handling for tracking a create table query, can't run explain/analyze on create statements
(async function getListAsync() {
Expand Down Expand Up @@ -365,21 +353,11 @@ ipcMain.on('generate-dummy-data', (event: any, data: dummyDataRequest) => {
db.getSchemaLayout().then((result) => {
schemaLayout = result;
// generate the dummy data and save it into matrices associated with table names
tableMatricesArray = generateDummyData(
schemaLayout,
dummyDataRequest,
keyObject
);
tableMatricesArray = generateDummyData(schemaLayout, dummyDataRequest, keyObject);
//iterate through tableMatricesArray to write individual .csv files
for (const tableObject of tableMatricesArray) {
// write all entries in tableMatrix to csv file
writeCSVFile(
tableObject,
schemaLayout,
keyObject,
dummyDataRequest,
event
);
writeCSVFile(tableObject, schemaLayout, keyObject, dummyDataRequest, event);
}
});
});
Expand Down
9 changes: 2 additions & 7 deletions backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ let pruned: boolean = false;
let mainMenu = Menu.buildFromTemplate(require('./mainMenu'));
// Keep a reference for dev mode
let dev = false;
if (
process.env.NODE_ENV !== undefined &&
process.env.NODE_ENV === 'development'
) {
if (process.env.NODE_ENV !== undefined && process.env.NODE_ENV === 'development') {
dev = true;
}

Expand All @@ -51,9 +48,7 @@ function createWindow() {
});

if (process.platform === 'darwin') {
app.dock.setIcon(
path.join(__dirname, '../../frontend/assets/images/seeqr_dock.png')
);
app.dock.setIcon(path.join(__dirname, '../../frontend/assets/images/seeqr_dock.png'));
}

// Load index.html of the app
Expand Down
46 changes: 23 additions & 23 deletions backend/mainMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ module.exports = [
// { role: 'appMenu' }
...(isMac
? [
{
label: app.name,
submenu: [
{ role: 'about' },
{ type: 'separator' },
{ role: 'services' },
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hideothers' },
{ role: 'unhide' },
{ type: 'separator' },
{ role: 'quit' },
],
},
]
{
label: app.name,
submenu: [
{ role: 'about' },
{ type: 'separator' },
{ role: 'services' },
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hideothers' },
{ role: 'unhide' },
{ type: 'separator' },
{ role: 'quit' },
],
},
]
: []),
// { role: 'fileMenu' }
{
Expand All @@ -39,14 +39,14 @@ module.exports = [
{ role: 'paste' },
...(isMac
? [
{ role: 'delete' },
{ role: 'selectAll' },
{ type: 'separator' },
{
label: 'Speech',
submenu: [{ role: 'startspeaking' }, { role: 'stopspeaking' }],
},
]
{ role: 'delete' },
{ role: 'selectAll' },
{ type: 'separator' },
{
label: 'Speech',
submenu: [{ role: 'startspeaking' }, { role: 'stopspeaking' }],
},
]
: [{ role: 'delete' }, { type: 'separator' }, { role: 'selectAll' }]),
],
},
Expand Down
13 changes: 3 additions & 10 deletions backend/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ const getDBNames = () => {
let dbList: any = [];
for (let i = 0; i < databases.rows.length; ++i) {
let curName = databases.rows[i].datname;
if (
curName !== 'postgres' &&
curName !== 'template0' &&
curName !== 'template1'
)
if (curName !== 'postgres' && curName !== 'template0' && curName !== 'template1')
dbList.push(databases.rows[i].datname);
}
resolve(dbList);
Expand Down Expand Up @@ -270,11 +266,8 @@ module.exports = {
let count: number = 0;

for (const fk in keyObject[tableName].foreignKeyColumns) {
let primaryTable: string =
keyObject[tableName].foreignKeyColumns[fk];
let primaryKey: any = Object.keys(
keyObject[primaryTable].primaryKeyColumns
)[0];
let primaryTable: string = keyObject[tableName].foreignKeyColumns[fk];
let primaryKey: any = Object.keys(keyObject[primaryTable].primaryKeyColumns)[0];
if (count > 0) queryString += `, `;
queryString += `ADD CONSTRAINT "${tableName}_fk${count}" FOREIGN KEY ("${fk}") REFERENCES ${primaryTable}("${primaryKey}")`;
count += 1;
Expand Down
11 changes: 5 additions & 6 deletions frontend/components/LoadingModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import ReactLoading from 'react-loading';
// "Loading" pop up renders whenever async functions are called
const LoadingModal = (props) => {
if (props.show) {
return(
return (
<div id="loading-modal" className="modal">
<h3>LOADING...</h3>
<ReactLoading type="cylon" color="#6cbba9"/>
<ReactLoading type="cylon" color="#6cbba9" />
</div>
);
}
else return null;
}
} else return null;
};

export default LoadingModal;
export default LoadingModal;
27 changes: 15 additions & 12 deletions frontend/components/Splash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,22 @@ export class Splash extends Component<SplashProps> {
return (
<div id="splash-page">
<div className="logo"></div>

<h4>Welcome!</h4>
<div className="splash-buttons">
<div id="custom-schema">
<h4>Create custom schema</h4>
<button id="skip_button" onClick={this.props.handleSkipClick}>Create</button>
</div>
<div id="import-schema">
<h4>Import database in .sql or .tar</h4>
<button id="yes_button" onClick={this.props.handleFileClick}>Import</button>
</div>

<h4>Welcome!</h4>
<div className="splash-buttons">
<div id="custom-schema">
<h4>Create custom schema</h4>
<button id="skip_button" onClick={this.props.handleSkipClick}>
Create
</button>
</div>
<div id="import-schema">
<h4>Import database in .sql or .tar</h4>
<button id="yes_button" onClick={this.props.handleFileClick}>
Import
</button>
</div>
</div>
</div>
);
}
Expand Down
9 changes: 3 additions & 6 deletions frontend/components/leftPanel/schemaChildren/Data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type DataProps = {
queries: {
queryString: string;
queryData: {}[];
queryStatistics: any
queryStatistics: any;
querySchema: string;
queryLabel: string;
}[];
Expand All @@ -23,11 +23,8 @@ export class Data extends Component<DataProps> {
return (
<div id="data-panel">
<h3 id="results-title">Data Table</h3>
<div id="data-table">
{queries.length === 0 ? null : <Table queries={queries} />}
</div>

<div id="data-table">{queries.length === 0 ? null : <Table queries={queries} />}</div>
</div>
);
}
}
}
Loading

0 comments on commit 41f244f

Please sign in to comment.