Commit 6e31783a authored by Jeremy Bokobza's avatar Jeremy Bokobza

added shutdown command for the full node to the UI's unload event

parent e201ad10
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, HostListener } from '@angular/core';
import { Router } from '@angular/router';
import { ApiService } from './shared/services/api.service';
......@@ -26,4 +26,23 @@ export class AppComponent implements OnInit {
this.loading = false;
this.router.navigate(['/login']);
}
@HostListener('window:unload')
unloadHandler() {
this.apiService.shutdownNode().subscribe(
response => {},
error => {
if (error.status === 0) {
alert("Error closing application. please close the dotnet process manually.");
} else if (error.status >= 400) {
if (!error.json().errors[0]) {
console.log(error);
}
else {
alert(error.json().errors[0].message);
}
}
}
);
}
}
......@@ -132,4 +132,10 @@ export class ApiService {
.post(this.webApiUrl + '/wallet/send-transaction/', JSON.stringify(data), {headers: this.headers})
.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