Skip to content

Commit

Permalink
Merge pull request #127 from sasha-alias/s-firebase
Browse files Browse the repository at this point in the history
S firebase
  • Loading branch information
Sasha Aliashkevich authored Mar 30, 2019
2 parents bffddd9 + 773bfa0 commit f8586ed
Show file tree
Hide file tree
Showing 15 changed files with 8,848 additions and 3,048 deletions.
5 changes: 5 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ if (process.platform == 'linux'){
var electron = require('electron');
var config = require('./build/Config');

require('electron-reload')(__dirname);

var app = electron.app;
var BrowserWindow = electron.BrowserWindow;

Expand All @@ -37,6 +39,9 @@ var createWindow = function(){
width: 800,
height: 600,
title: 'SQL Tabs',
webPreferences: {
nodeIntegration: true,
},
});
mainWindow.maximize();
mainWindow.loadURL('file://' + __dirname + '/index.html');
Expand Down
11,292 changes: 8,293 additions & 2,999 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
"dependencies": {
"alasql": "^0.3.9",
"async": "^1.4.2",
"bootstrap": "3.3.2",
"bootstrap": "^3.3.2",
"brace": "^0.11.1",
"c3": "^0.4.0",
"cassandra-driver": "^3.1.1",
"cassandra-map": "~0.1.7",
"firebase": "^5.9.1",
"firebase-admin": "^7.1.1",
"flux": "2.0.1",
"jquery": "^3.3.1",
"lowdb": "0.7.2",
Expand All @@ -39,11 +41,12 @@
"tunnel-ssh": "^4.1.4"
},
"devDependencies": {
"babel-cli": "^6.23.0",
"babel-plugin-transform-react-jsx": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-cli": "^6.26.0",
"babel-plugin-transform-react-jsx": "^6.24.1",
"babel-preset-env": "^1.7.0",
"electron": "^4.1.0",
"electron-packager": "^13.1.1",
"electron-reload": "^1.4.0",
"uglify-es": "^3.3.9"
},
"optionalDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion src/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,11 @@ var Actions = {
});
},

setPassword: function(password){
setPassword: function(password, savePassword){
AppDispatcher.dispatch({
eventName: 'set-password',
password: password,
savePassword: savePassword,
callback: QueryCallback,
err_callback: ErrorCallback,
});
Expand Down
18 changes: 18 additions & 0 deletions src/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,24 @@ var Conf = {
return config.auto_completion;
},

saveSecret: function(connstr, secret){
if (typeof config.secrets == 'undefined'){
config.secrets = {};
}
if (secret != null){
config.secrets[connstr] = secret;
} else {
delete config.secrets[connstr];
}
this.saveSync();
},

getSecret: function(connstr){
if (typeof config.secrets != undefined){
return config.secrets[connstr];
}
},

getSharingServer: function(){
if (config.sharing_server == "sqltabs.com" || config.sharing_server == "www.sqltabs.com"){
return "share.sqltabs.com";
Expand Down
6 changes: 3 additions & 3 deletions src/Dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ AppDispatcher.register( function(payload) {

case 'set-connection':
TabsStore.setConnection(payload.key, payload.value);
TabsStore.setPassword(payload.key, null);
TabsStore.resetPassword(payload.key);
Config.saveConnHistory(TabsStore.connectionHistory);
TabsStore.trigger('change');
Executor.testConnection(
Expand All @@ -195,7 +195,7 @@ AppDispatcher.register( function(payload) {
break;

case 'set-password':
TabsStore.setPassword(TabsStore.selectedTab, payload.password);
TabsStore.setPassword(TabsStore.selectedTab, payload.password, payload.savePassword);
Executor.testConnection(
TabsStore.selectedTab,
TabsStore.getConnstr(TabsStore.selectedTab),
Expand All @@ -210,9 +210,9 @@ AppDispatcher.register( function(payload) {
case 'run-query':
connstr = TabsStore.getConnstr(payload.key);
password = TabsStore.getPassword(payload.key);
Executor.runQuery(payload.key, connstr, password, payload.query, payload.callback, payload.err_callback);
History.push(payload.query);
TabsStore.trigger('query-started-'+payload.key);
Executor.runQuery(payload.key, connstr, password, payload.query, payload.callback, payload.err_callback);
break;

case 'run-all-blocks':
Expand Down
9 changes: 8 additions & 1 deletion src/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var History = require('./History');
var fs = require('fs');

require('brace/mode/pgsql');
require('brace/mode/javascript');
require('brace/theme/chrome');
require('brace/theme/idle_fingers');
require('brace/keybinding/vim');
Expand All @@ -51,9 +52,15 @@ var Editor = React.createClass({

componentDidMount: function(){
this.editor = Ace.edit(this.props.name);
this.editor.getSession().setMode('ace/mode/pgsql');
this.editor.setTheme('ace/theme/' + this.state.theme);
this.editor.setKeyboardHandler(this.state.mode);

if (TabsStore.tabs[TabsStore.selectedTab].connector_type == 'firebase'){
this.editor.getSession().setMode('ace/mode/javascript');
} else {
this.editor.getSession().setMode('ace/mode/pgsql');
}

TabsStore.bind('change', this.changeHandler);
TabsStore.bind('editor-resize', this.resize);
TabsStore.bind('change-theme', this.changeHandler);
Expand Down
13 changes: 8 additions & 5 deletions src/Executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var cassandra = require('./connectors/cassandra/Database.js');
var mysql = require('./connectors/mysql/Database.js');
var mssql = require('./connectors/mssql/Database.js');
var alasql = require('./connectors/alasql/Database.js');
var firebase = require('./connectors/firebase/Database.js');
var url = require('url');
var path = require('path');
var tunnel = require('tunnel-ssh');
Expand Down Expand Up @@ -48,12 +49,12 @@ var Executor = {
if (connstr_list.length > 1 && connstr_list[0].startsWith('ssh://')){
this.createTunnel(id, connstr, connstr_list, callback, err_callback);
} else {
callback(this._getConnector(connstr));
callback(this.getConnector(connstr));
}

},

_getConnector: function(connstr){
getConnector: function(connstr){
if (connstr == '' || connstr == null || connstr.indexOf('alasql://') == 0){
var db = alasql;
} else if (connstr.indexOf('cassandra://') == 0){
Expand All @@ -62,6 +63,8 @@ var Executor = {
var db = mysql;
} else if (connstr.indexOf('mssql://') == 0){
var db = mssql;
} else if (connstr.indexOf('https://') == 0){
var db = firebase;
} else if (connstr.indexOf('redshift://') == 0){
var db = postgres;
db.redshift = true;
Expand Down Expand Up @@ -89,7 +92,7 @@ var Executor = {
var db_url = url.parse(connstr_list[1]);

if (db_url.port == null){
db_url.port = self._getConnector(connstr_list[1]).DEFAULT_PORT;
db_url.port = self.getConnector(connstr_list[1]).DEFAULT_PORT;
}

if (db_url.auth == null){
Expand Down Expand Up @@ -125,7 +128,7 @@ var Executor = {
console.log('reuse tunnel: '+id);
var port = TunnelPorts[id];
var mapped_db_url = db_url.protocol+'//'+auth+'localhost:'+port+url_path;
return callback(self._getConnector(mapped_db_url));
return callback(self.getConnector(mapped_db_url));
} else {
console.log('create tunnel: '+id);
PortSequence = PortSequence + 1;
Expand Down Expand Up @@ -163,7 +166,7 @@ var Executor = {
TunnelPorts[id] = PortSequence;

self.testSSH(id, ssh_config, function(){
return callback(self._getConnector(mapped_db_url));
return callback(self.getConnector(mapped_db_url));
}, function(err){
console.log(err);
err_callback(id, "ssh tunnel error: "+err);
Expand Down
10 changes: 9 additions & 1 deletion src/ObjectInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ require('brace/keybinding/vim');
var Cassandra = require('./connectors/cassandra/Renderer.js');
var Mysql = require('./connectors/mysql/Renderer.js');
var MSsql = require('./connectors/mssql/Renderer.js');
var Firebase = require('./connectors/Firebase/Renderer.js');

var ObjectInfo = React.createClass({

Expand Down Expand Up @@ -308,6 +309,11 @@ var ObjectInfo = React.createClass({
else {relkind = ""}

var edit = null;
var script = `SELECT *
FROM `+info.object_name+`
WHERE true
LIMIT 100;`;
var view = <a href="#" onClick={function(){Actions.newTab(script);}}><span className="glyphicon glyphicon-new-window" title="view"/></a>
columns = [];
columns.push(
<tr key="object_info_column_header">
Expand Down Expand Up @@ -501,7 +507,7 @@ var ObjectInfo = React.createClass({
<div>{relkind}&nbsp;
<span className="object-info-name">
<a href="#" onClick={function(){self.getInfo(info.object.schema+'.');}}>{info.object.schema}</a>.{info.object.relname}
&nbsp; {edit}
&nbsp; {edit} &nbsp; {view}
</span>
<hr/>
</div>
Expand Down Expand Up @@ -529,6 +535,8 @@ var ObjectInfo = React.createClass({
return Mysql.info(this.props.eventKey, info, this.getInfo);
} else if (info.connector == 'mssql'){
return MSsql.info(this.props.eventKey, info, this.getInfo);
} else if (info.connector == 'firebase'){
return Firebase.info(this.props.eventKey, info, this.getInfo);
} else {

if (info.object_type == 'function'){
Expand Down
Loading

0 comments on commit f8586ed

Please sign in to comment.