diff --git a/app/client.js b/app/client.js index c87752b..020b736 100644 --- a/app/client.js +++ b/app/client.js @@ -77,7 +77,11 @@ var updater = new Vue({ event.preventDefault(); } - shell.openExternal(this.releaseURL); + if (window.confirm('You must quit Storj Share to upgrade. Continue?')) { + shell.openExternal(this.releaseURL); + app.quit(); + } + } }, created: function() { @@ -105,50 +109,6 @@ var updater = new Vue({ } }); -/** - * App Settings View - */ -var appSettings = new Vue({ - el:'#app-settings', - data: { - userdata: userdata._parsed - }, - methods: { - changeSettings: function() { - ipc.send('appSettingsChanged', JSON.stringify(userdata.toObject())); - userdata.saveConfig(function(err) { - if (err) { - return window.alert(err.message); - } - }); - } - }, - ready: function() { - var self = this; - //check for OS-specific boot launch option - ipc.send('checkBootSettings'); - ipc.on('checkAutoLaunchOptions', function(ev, isEnabled) { - self.userdata.appSettings.launchOnBoot = isEnabled; - userdata.saveConfig(function(err) { - if (err) { - return window.alert(err.message); - } - }); - }); - //remove default bootstrap UI dropdown close behavior - $('#app-settings > .dropdown-menu input,' + - '#app-settings > .dropdown-menu label') - .on('click', function(e) { - e.stopPropagation(); - } - ); - }, - beforeDestroy: function() { - $('#app-settings > .dropdown-menu input,' + - '#app-settings > .dropdown-menu label').off('click'); - } -}); - /** * Main View */ @@ -262,8 +222,11 @@ var main = new Vue({ var self = this; var current = (index) ? index : this.current; var tab = this.userdata.tabs[current]; + var appSettings = this.userdata.appSettings; var fslogger = new FsLogger(app.getPath('userData'), 'Drive-'+current); + fslogger.setLogLevel(Number(appSettings.logLevel)); + fslogger.on('error', function(err) { console.log(err.message); }); @@ -280,9 +243,9 @@ var main = new Vue({ this.transitioning = true; - tab.telemetry = { enabled: self.userdata.appSettings.reportTelemetry }; + tab.telemetry = { enabled: appSettings.reportTelemetry }; - var logger = new Logger(3); + var logger = new Logger(Number(appSettings.logLevel)); var reporter = new TelemetryReporter( 'https://status.storj.io', storj.KeyPair(tab.key) @@ -291,11 +254,17 @@ var main = new Vue({ keypair: storj.KeyPair(tab.key), payment: { address: tab.address }, storage: tab.storage, - address: '127.0.0.1', - port: 0, - noforward: false, + address: tab.network.hostname, + port: Number(tab.network.port), + noforward: tab.network.nat === 'false', logger: logger, - tunport: 0 + tunport: Number(tab.tunnels.tcpPort), + tunnels: Number(tab.tunnels.numConnections), + gateways: { + min: Number(tab.tunnels.startPort), + max: Number(tab.tunnels.endPort) + }, + seeds: tab.network.seed ? [tab.network.seed] : [] }; var farmer = new storj.FarmerInterface(farmerconf); @@ -333,7 +302,7 @@ var main = new Vue({ self.transitioning = false; if (err) { - return window.alert(err.message); + logger.error(err.message); } }); }); @@ -598,6 +567,65 @@ var main = new Vue({ } }); +/** + * App Settings View + */ +var appSettings = new Vue({ + el:'#settings', + data: { + userdata: userdata._parsed, + current: main.current + }, + methods: { + changeSettings: function() { + ipc.send('appSettingsChanged', JSON.stringify(userdata.toObject())); + userdata.saveConfig(function(err) { + if (err) { + return window.alert(err.message); + } + }); + }, + openLogFolder: function() { + shell.openExternal('file://' + this.userdata.appSettings.logFolder); + }, + selectLogFolder: function() { + ipc.send('selectLogFolder'); + } + }, + ready: function() { + var self = this; + //check for OS-specific boot launch option + ipc.send('checkBootSettings'); + ipc.on('checkAutoLaunchOptions', function(ev, isEnabled) { + self.userdata.appSettings.launchOnBoot = isEnabled; + userdata.saveConfig(function(err) { + if (err) { + return window.alert(err.message); + } + }); + }); + ipc.on('logFolderSelected', function(ev, path) { + self.userdata.appSettings.logFolder = path[0]; + ipc.send('appSettingsChanged', JSON.stringify(userdata.toObject())); + }); + //remove default bootstrap UI dropdown close behavior + $('#app-settings > .dropdown-menu input,' + + '#app-settings > .dropdown-menu label') + .on('click', function(e) { + e.stopPropagation(); + } + ); + }, + beforeDestroy: function() { + $('#app-settings > .dropdown-menu input,' + + '#app-settings > .dropdown-menu label').off('click'); + } +}); + +main.$watch('current', function(val) { + appSettings.current = val; +}); + /** * Footer View */ diff --git a/app/css/style.css b/app/css/style.css index f3abd20..efd6236 100644 --- a/app/css/style.css +++ b/app/css/style.css @@ -81,6 +81,9 @@ header { background-color: #fff; border: 2px solid #ddd; } +.form-control.margin-top { + margin-top: 10px; +} .form-group { margin: 1em auto; @@ -244,12 +247,12 @@ footer a:hover { } } -.modal { +.modal-dialog { top: 5em; } .modal-body { - padding: 2em 1em; + padding: 1em; } .modal-footer { @@ -257,8 +260,8 @@ footer a:hover { } .modal-footer .btn { - margin: 1em !important; - padding: 1em 2em !important; + margin: 1em 0; + padding: 1em 2em; font-size: 14px; } @@ -267,6 +270,11 @@ footer a:hover { margin-bottom: 21px; } +.modal .nav-tabs { + margin-top: 2em; + padding-left: 2em; +} + #modalLogs { top: 0; } diff --git a/app/lib/tab.js b/app/lib/tab.js index c495f4c..c076328 100644 --- a/app/lib/tab.js +++ b/app/lib/tab.js @@ -25,6 +25,8 @@ function Tab(options) { } options = options || {}; options.storage = options.storage || {}; + options.network = options.network || {}; + options.tunnels = options.tunnels || {}; this.key = KeyPair(options.key).getPrivateKey(); this.address = options.addr || ''; @@ -33,6 +35,19 @@ function Tab(options) { size: options.storage.size || 0, unit: options.storage.unit || 'GB' }; + this.network = { + hostname: options.network.hostname || '127.0.0.1', + port: options.network.port || 0, + seed: options.network.seed || '', + nat: options.network.nat || 'true' + }; + this.tunnels = { + numConnections: options.tunnels.numConnections || 3, + tcpPort: options.tunnels.tcpPort || 0, + startPort: options.tunnels.startPort || 0, + endPort: options.tunnels.endPort || 0 + }; + this.id = options.id || this.createID(); this.active = typeof options.active === 'undefined' ? false : options.active; this.wasRunning = options.wasRunning || false; @@ -60,7 +75,9 @@ Tab.prototype.toObject = function() { address: this.address, storage: this.storage, id: this.id, - wasRunning: this.wasRunning + wasRunning: this.wasRunning, + network: this.network, + tunnels: this.tunnels }; }; diff --git a/app/lib/userdata.js b/app/lib/userdata.js index 58bb860..705b03b 100644 --- a/app/lib/userdata.js +++ b/app/lib/userdata.js @@ -20,6 +20,8 @@ function UserData(datadir) { this._path = datadir + '/settings.json'; this._parsed = this._read(); + this._parsed.appSettings.logFolder = this._parsed.appSettings.logFolder || + datadir; } UserData.DEFAULTS = { @@ -28,7 +30,9 @@ UserData.DEFAULTS = { minToTask: true, launchOnBoot: false, runDrivesOnBoot: true, - reportTelemetry: true + reportTelemetry: true, + logFolder: '', + logLevel: 3 } }; /** @@ -53,7 +57,9 @@ UserData.prototype._read = function() { storage: tabdata.storage, id: tabdata.id, active: tabdata.active, - wasRunning: tabdata.wasRunning + wasRunning: tabdata.wasRunning, + network: tabdata.network, + tunnels: tabdata.tunnels }); }); diff --git a/app/main.js b/app/main.js index 049aac1..1101eff 100644 --- a/app/main.js +++ b/app/main.js @@ -48,7 +48,7 @@ app.on('ready', function() { var menu = new ApplicationMenu(); main = new BrowserWindow({ width: 500, - height: PLATFORM === 'mac' ? 600 : 635 + height: PLATFORM === 'mac' ? 712 : 747 }); sysTray = new SysTrayIcon( @@ -69,6 +69,7 @@ app.on('ready', function() { app.on('before-quit', handleBeforeAppQuit); app.on('activate', handleMacActivate); ipc.on('selectStorageDirectory', selectStorageDir); + ipc.on('selectLogFolder', selectLogFolder); ipc.on('checkBootSettings', checkBootSettings); ipc.on('appSettingsChanged', changeAppSettings); }); @@ -102,6 +103,16 @@ function selectStorageDir() { }); } +function selectLogFolder() { + dialog.showOpenDialog( { + properties: ['openDirectory'] + }, function(path) { + if (path) { + main.webContents.send('logFolderSelected', path); + } + }); +} + function changeAppSettings(ev, data) { userDataViewModel = sysTray.userData = JSON.parse(data); if(userDataViewModel.appSettings.launchOnBoot && !isCommandLaunched) { diff --git a/app/package.json b/app/package.json index d08714e..2c1acf3 100644 --- a/app/package.json +++ b/app/package.json @@ -3,7 +3,7 @@ "productName": "Storj Share", "identifier": "com.storj.farmer", "description": "Earn money by sharing your extra hard drive space", - "version": "0.8.9", + "version": "0.9.0", "author": "Storj ", "main": "main.js", "config": { diff --git a/app/storjshare.html b/app/storjshare.html index 41c72bb..0403f2a 100644 --- a/app/storjshare.html +++ b/app/storjshare.html @@ -41,23 +41,9 @@
- -
@@ -176,15 +162,187 @@ - - + + + + + + + @@ -199,11 +357,9 @@ diff --git a/resources/linux/DEBIAN/postinst b/resources/linux/DEBIAN/postinst index ced804a..3880ad8 100755 --- a/resources/linux/DEBIAN/postinst +++ b/resources/linux/DEBIAN/postinst @@ -1,3 +1,9 @@ #!/bin/sh - -ln -s /opt/storjshare/storjshare /usr/local/bin/storjshare +FILE=/usr/local/bin/storjshare +FILE2=/opt/storjshare/storjshare +if [[ -L $FILE ]]; then + echo "File exists and there is a symbolic link" +else + echo "Creating symbolic link between $FILE and $FILE2" + ln -s $FILE2 $FILE +fi