first implementation for flash notification and settings to configure these

This commit is contained in:
Carmine D'Amico
2016-06-05 12:50:15 +02:00
parent c6d91e7ae4
commit 84d3c377b4
3 changed files with 58 additions and 2 deletions

View File

@@ -49,7 +49,10 @@ var SettingsPage = React.createClass({
showTrayIcon: this.state.showTrayIcon,
trayIconTheme: this.state.trayIconTheme,
disablewebsecurity: this.state.disablewebsecurity,
version: settings.version
version: settings.version,
notifications: {
flashWindow: this.state.notifications.flashWindow
}
};
settings.writeFileSync(this.props.configFile, config);
if (process.platform === 'win32' || process.platform === 'linux') {
@@ -96,6 +99,13 @@ var SettingsPage = React.createClass({
});
}
},
handleFlashWindowSetting: function(item) {
this.setState({
notifications: {
flashWindow: item.state
}
});
},
render: function() {
var buttonStyle = {
@@ -136,6 +146,40 @@ var SettingsPage = React.createClass({
</Row>
) : null;
var notificationSettings = [
{
label: 'Never',
state: 0
},
{
label: 'Only when idle (after 10 seconds)',
state: 1
},
{
label: 'Always',
state: 2
}
];
var that = this;
var notificationElements = notificationSettings.map(function(item) {
var boundClick = that.handleFlashWindowSetting.bind(that, item);
return (
<Input key={ "flashWindow" + item.state } name="handleFlashWindow" ref={ "flashWindow" + item.state } type="radio"
label={ item.label } value={ item.state } onChange={ boundClick }
checked={ that.state.notifications.flashWindow == item.state ? "checked" : "" }/>
);
});
var notifications = (
<Row>
<Col md={ 12 }>
<h2>Notifications</h2>
{ notificationElements }
</Col>
</Row>
)
return (
<Grid className="settingsPage">
<Row>
@@ -150,6 +194,10 @@ var SettingsPage = React.createClass({
</Row>
{ teams_row }
{ options_row }
{ notifications }
<div>
<hr />
</div>
<Row>
<Col md={ 12 }>
<Button id="btnCancel" onClick={ this.handleCancel }>Cancel</Button>

View File

@@ -26,7 +26,10 @@ var loadDefault = function(version) {
showTrayIcon: false,
trayIconTheme: '',
disablewebsecurity: true,
version: 1
version: 1,
notifications: {
flashWindow: 0 // 0 = flash never, 1 = only when idle (after 10 seconds), 2 = always
}
};
}
}

View File

@@ -189,6 +189,10 @@ app.on('ready', function() {
title: arg.title,
content: arg.options.body
});
if (config.notifications.flashWindow == 2) {
mainWindow.flashFrame(true);
}
});
// Set overlay icon from dataURL
@@ -209,6 +213,7 @@ app.on('ready', function() {
}
else {
trayIcon.setImage(trayImages.normal);
mainWindow.flashFrame(false);
trayIcon.setToolTip(app.getName());
}
});