Commit e5b5e7d2 authored by Pieterjan Vanhoof's avatar Pieterjan Vanhoof Committed by GitHub

Merge pull request #126 from bokobza/master

added shutdown command for the full node to the UI's unload event
parents 9a583b2a 26c9fc2b
...@@ -48,7 +48,23 @@ function createWindow() { ...@@ -48,7 +48,23 @@ function createWindow() {
// when you should delete the corresponding element. // when you should delete the corresponding element.
mainWindow = null; mainWindow = null;
}); });
// Emitted when the window is going to close.
mainWindow.on('close', function () {
var http = require('http');
const options = {
hostname: 'localhost',
port: 5000,
path: '/api/node/shutdown',
method: 'POST'
};
const req = http.request(options, (res) => {});
req.write('');
req.end();
});
} }
// This method will be called when Electron has finished // This method will be called when Electron has finished
// initialization and is ready to create browser windows. // initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs. // Some APIs can only be used after this event occurs.
......
...@@ -132,4 +132,10 @@ export class ApiService { ...@@ -132,4 +132,10 @@ export class ApiService {
.post(this.webApiUrl + '/wallet/send-transaction/', JSON.stringify(data), {headers: this.headers}) .post(this.webApiUrl + '/wallet/send-transaction/', JSON.stringify(data), {headers: this.headers})
.map((response: Response) => response); .map((response: Response) => response);
} }
shutdownNode(): Observable<any> {
return this.http
.post(this.webApiUrl + '/node/shutdown', '')
.map((response: Response) => response);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment