Skip to content

Commit

Permalink
More error reporting, fix layout of resizable table when some cell is…
Browse files Browse the repository at this point in the history
… empty
  • Loading branch information
Paxa committed Apr 10, 2017
1 parent 8170ed1 commit 3ceb579
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 117 deletions.
20 changes: 13 additions & 7 deletions app/db_screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,14 @@ global.DbScreen = jClass.extend({
}
App.startLoading("Getting table structure...");

this.table.isMatView((isMatView) => {
Model.Table(this.currentSchema, this.currentTable).getStructure((rows) => {
this.table.describe((indexes, error) => {
if (error) console.error(error);
this.table.getConstraints((constraints, error2) => {
if (error2) console.error(error2);
this.table.isMatView((isMatView, error) => {
if (error) errorReporter(error, false);
Model.Table(this.currentSchema, this.currentTable).getStructure((rows, error1) => {
if (error1) errorReporter(error1, false);
this.table.describe((indexes, error2) => {
if (error2) errorReporter(error2, false);
this.table.getConstraints((constraints, error3) => {
if (error3) errorReporter(error3, false);
this.view.structure.renderTab(rows, indexes, constraints, isMatView);
App.stopLoading();
});
Expand Down Expand Up @@ -489,9 +491,13 @@ global.DbScreen = jClass.extend({

App.startLoading("Getting table info...");
table.getSourceSql((code, dumpError) => {
table.diskSummary((relType, estimateCount, diskUsage) => {
table.diskSummary((relType, estimateCount, diskUsage, error) => {
if (dumpError) {
window.alert("Running pg_dump failed:\n" + dumpError);
global.errorReporter(dumpError, false);
}
if (error) {
global.errorReporter(error, false);
}
App.stopLoading();
this.view.info.renderTab(code, relType, estimateCount, diskUsage);
Expand Down
28 changes: 20 additions & 8 deletions app/models/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ global.Model.Table = Model.base.extend({
},

isMatView: function (callback) {
this.getTableType((tableType) => {
callback(tableType == "MATERIALIZED VIEW")
this.getTableType((tableType, error) => {
callback(tableType == "MATERIALIZED VIEW", error);
});
},

Expand Down Expand Up @@ -146,7 +146,11 @@ global.Model.Table = Model.base.extend({
a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum;
`;
this.q(sql, (data) => {
this.q(sql, (data, error) => {
if (error) {
callback(data && data.rows, error);
return;
}
this.hasOID((hasOID) => {
if (hasOID) {
data.rows.unshift({
Expand Down Expand Up @@ -180,10 +184,14 @@ global.Model.Table = Model.base.extend({
where relname = '%s' and attnum >= 1;`;

this.q(sql, this.table, (data, error) => {
data.rows.forEach((row) => {
row.is_nullable = row.attnotnull ? "NO" : "YES";
});
callback(data.rows);
if (data && data.rows) {
data.rows.forEach((row) => {
row.is_nullable = row.attnotnull ? "NO" : "YES";
});
callback(data.rows);
} else {
callback(null, error);
}
});
},

Expand All @@ -195,7 +203,7 @@ global.Model.Table = Model.base.extend({
if (error) {
callback(undefined, error);
} else {
callback(data.rows[0] && data.rows[0].relhasoids);
callback(data && data.rows[0] && data.rows[0].relhasoids);
}
});
},
Expand Down Expand Up @@ -571,6 +579,10 @@ global.Model.Table = Model.base.extend({
`;

this.q(sql, this.schema, this.table, (result, error) => {
if (!result) {
callback("error getting talbe info", '', '', error);
return;
}
var row = result.rows[0];
var type = row.relkind;
// http://www.postgresql.org/docs/9.4/static/catalog-pg-class.html
Expand Down
12 changes: 7 additions & 5 deletions lib/error_reporter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
global.log = require('../app/logger').make('info');

var errorReporter = module.exports = function errorReporter(exception) {
var errorReporter = module.exports = function errorReporter(exception, showError = true) {
setTimeout(function () {
// skip errors while developing
if (process.env.NW_DEV == "true") {
Expand Down Expand Up @@ -76,10 +76,12 @@ var errorReporter = module.exports = function errorReporter(exception) {
console.log(exception.stack);
}

if (exception instanceof Error) {
window.alert(exception.message + "\n" + exception.stack);
} else {
window.alert(exception);
if (showError) {
if (exception instanceof Error) {
window.alert(exception.message + "\n" + exception.stack);
} else {
window.alert(exception);
}
}
return false;
};
Expand Down
3 changes: 2 additions & 1 deletion lib/resizable_columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class ResizableColumns {
th = $(th);
this.columnWidths[i] = th.outerWidth();

th.css('width', th.width());
var w = th.width();
th.css('width', w == 0 ? 0.001 : w);
});

//this.element.css('width', '');
Expand Down
3 changes: 2 additions & 1 deletion run
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/bin/bash

export NW_DEV=true
export PATH=$PATH:node_modules/.bin

if [[ "$OSTYPE" == "darwin"* ]]; then
#/Applications/node-webkit.app/Contents/MacOS/node-webkit .
#/Applications/nwjs.app/Contents/MacOS/nwjs .
#~/Postbird.app/Contents/MacOS/nwjs
./node_modules/.bin/electron .
electron .
elif [[ "$OSTYPE" == "linux-gnu" ]]; then
paths=(
"/lib/x86_64-linux-gnu/libudev.so.1" # Ubuntu, Xubuntu, Mint
Expand Down

0 comments on commit 3ceb579

Please sign in to comment.