Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #268 from aleitner/advanced-settings
Browse files Browse the repository at this point in the history
v0.9.0
  • Loading branch information
bookchin authored Jul 8, 2016
2 parents 2a04237 + 7f18d10 commit 4700462
Show file tree
Hide file tree
Showing 8 changed files with 319 additions and 87 deletions.
132 changes: 80 additions & 52 deletions app/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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);
});
Expand All @@ -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)
Expand All @@ -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);

Expand Down Expand Up @@ -333,7 +302,7 @@ var main = new Vue({
self.transitioning = false;

if (err) {
return window.alert(err.message);
logger.error(err.message);
}
});
});
Expand Down Expand Up @@ -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
*/
Expand Down
16 changes: 12 additions & 4 deletions app/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ header {
background-color: #fff;
border: 2px solid #ddd;
}
.form-control.margin-top {
margin-top: 10px;
}

.form-group {
margin: 1em auto;
Expand Down Expand Up @@ -244,21 +247,21 @@ footer a:hover {
}
}

.modal {
.modal-dialog {
top: 5em;
}

.modal-body {
padding: 2em 1em;
padding: 1em;
}

.modal-footer {
text-align: center;
}

.modal-footer .btn {
margin: 1em !important;
padding: 1em 2em !important;
margin: 1em 0;
padding: 1em 2em;
font-size: 14px;
}

Expand All @@ -267,6 +270,11 @@ footer a:hover {
margin-bottom: 21px;
}

.modal .nav-tabs {
margin-top: 2em;
padding-left: 2em;
}

#modalLogs {
top: 0;
}
Expand Down
19 changes: 18 additions & 1 deletion app/lib/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || '';
Expand All @@ -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;
Expand Down Expand Up @@ -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
};
};

Expand Down
10 changes: 8 additions & 2 deletions app/lib/userdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -28,7 +30,9 @@ UserData.DEFAULTS = {
minToTask: true,
launchOnBoot: false,
runDrivesOnBoot: true,
reportTelemetry: true
reportTelemetry: true,
logFolder: '',
logLevel: 3
}
};
/**
Expand All @@ -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
});
});

Expand Down
13 changes: 12 additions & 1 deletion app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
});
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>",
"main": "main.js",
"config": {
Expand Down
Loading

0 comments on commit 4700462

Please sign in to comment.