Browse Source

Postgres protocol

tags/v0.17.0
Maurizio Carboni 2 years ago
parent
commit
288d29a484
6 changed files with 48 additions and 4 deletions
  1. +11
    -0
      Info.plist
  2. +2
    -2
      mac_build.sh
  3. +28
    -0
      main.js
  4. +2
    -1
      src/Actions.js
  5. +4
    -0
      src/App.js
  6. +1
    -1
      src/Dispatcher.js

+ 11
- 0
Info.plist View File

@@ -21,5 +21,16 @@
<string>SQLDocument</string>
</dict>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>Postgres Database</string>
<key>CFBundleURLSchemes</key>
<array>
<string>postgres</string>
</array>
</dict>
</array>
</dict>
</plist>

+ 2
- 2
mac_build.sh View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash -e
rm -rf .build
mkdir .build
npm install
@@ -13,6 +13,6 @@ cp -r css .build/
cp -r node_modules .build/

cd .build
electron-packager ./ "SQL Tabs" --platform=darwin --arch=x64 --electron-version=1.4.7 --icon logo.icns --asar --prune --extend-info ../Info.plist --extra-resource ../logo_sql.icns
electron-packager ./ "SQL Tabs" --platform=darwin --arch=x64 --electron-version=1.4.7 --icon logo.icns --asar --prune --extend-info ../Info.plist --extra-resource ../logo_sql.icns --protocol postgres ---procol-name postgres
cd ..


+ 28
- 0
main.js View File

@@ -27,6 +27,7 @@ var app = electron.app;
var BrowserWindow = electron.BrowserWindow;

var mainWindow = null;
var urlToOpen = null;
var files2open = [];

var createWindow = function(){
@@ -71,4 +72,31 @@ app.on('ready', function() {
contents.on('did-finish-load', emit_open_file);
}
}
if (urlToOpen) {
mainWindow.webContents.on('did-finish-load', function () {
mainWindow.webContents.send('open-url', urlToOpen);
});
}

if (!app.isDefaultProtocolClient('postgres')) {
electron.dialog.showMessageBox({
type: 'question',
buttons: ['Yes', 'No'],
cancelId: 1,
message: 'Do you want to set SQL Tabs as the default postgres client?'
}, function (button) {
if (button === 0 ) {
app.setAsDefaultProtocolClient('postgres');
}
})
}
});

app.on('open-url', function (ev, url) {
ev.preventDefault();
if (app.isReady()) {
mainWindow.webContents.send('open-url', url);
} else {
urlToOpen = url;
}
});

+ 2
- 1
src/Actions.js View File

@@ -82,11 +82,12 @@ var Actions = {
});
},

newTab: function(script, filename){
newTab: function(script, filename, connstr){
AppDispatcher.dispatch({
eventName: 'select-tab',
key: 0,
script: script,
connstr: connstr,
filename: filename,
});
},

+ 4
- 0
src/App.js View File

@@ -36,6 +36,10 @@ require('electron').ipcRenderer.on('open-file', function(event, path) {
}
})

require('electron').ipcRenderer.on('open-url', function(event, url) {
Actions.newTab(null, null, url);
})

require('./Menu');

var mountNode = document.body;

+ 1
- 1
src/Dispatcher.js View File

@@ -69,7 +69,7 @@ AppDispatcher.register( function(payload) {
switch( payload.eventName ) {
case 'select-tab':
if (payload.key == 0) { // select tab 0 (+) means create a new tab
var tabid = TabsStore.newTab();
var tabid = TabsStore.newTab(payload.connstr);
TabsStore.tmpScript = payload.script;
TabsStore.trigger('change');
if (payload.filename){

Loading…
Cancel
Save