Skip to content

Commit

Permalink
Notification when response finishes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Young committed Dec 16, 2015
1 parent 07b06f6 commit 769f502
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion ch13/electron-quick-start/app/request.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ class Request extends React.Component {

makeRequest() {
request(this.state, (err, res, body) => {
const statusCode = res ? res.statusCode : 'No response';
const result = {
response: res ? `(${res.statusCode})` : '(No response)',
response: `(${statusCode})`,
raw: body ? body : '',
headers: res ? res.headers : [],
error: err ? JSON.stringify(err, null, 2) : ''
};

Events.emit('result', result);

new Notification(`HTTP response finished: ${statusCode}`)
});
}

Expand Down
2 changes: 1 addition & 1 deletion ch13/electron-quick-start/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ input { border: 1px solid #CCCCCC; border-radius: 3px }
input:focus { border: 1px solid #3E8FD6 !important; color: #3E8FD6; outline: none }

.content-container { padding: 0; width: 79%; height: 100%; table-layout: fixed; overflow: hidden; box-sizing: border-box; position: absolute; margin-bottom: -100px; right: 0; left: 30%; background-color: #fff }
.content { padding: 0; width: 100%; height: 100%; background-color: pink }
.content { padding: 0; width: 100%; height: 100%; }

.raw { overflow: scroll; background-color: #fff; font-size: 11px; width: 100%; right: 0; margin: 0; }

Expand Down
7 changes: 5 additions & 2 deletions ch13/electron-quick-start/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19809,14 +19809,17 @@
key: 'makeRequest',
value: function makeRequest() {
request(this.state, function (err, res, body) {
var statusCode = res ? res.statusCode : 'No response';
var result = {
response: res ? '(' + res.statusCode + ')' : '(No response)',
response: '(' + statusCode + ')',
raw: body ? body : '',
headers: res ? res.headers : [],
error: err ? JSON.stringify(err, null, 2) : ''
};

_events2.default.emit('result', result);

new Notification('HTTP response finished: ' + statusCode);
});
}
}, {
Expand Down Expand Up @@ -20490,7 +20493,7 @@
{ className: 'content' },
_react2.default.createElement(
'div',
{ className: 'raw', id: 'headers' },
{ id: 'headers' },
_react2.default.createElement(
'table',
{ className: 'headers' },
Expand Down

0 comments on commit 769f502

Please sign in to comment.