mirror of
https://github.com/skot/ESP-Miner.git
synced 2025-03-19 14:22:04 +01:00
fix: Better restart feedback & attempt to fix CORS
This commit is contained in:
parent
08367a6135
commit
b7eee35ce4
@ -132,10 +132,16 @@ export class SwarmComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
public restart(axe: any) {
|
||||
this.systemService.restart(`http://${axe.IP}`).subscribe(res => {
|
||||
|
||||
this.systemService.restart(`http://${axe.IP}`).pipe(
|
||||
catchError(error => {
|
||||
this.toastr.error('Failed to restart device', 'Error');
|
||||
return of(null);
|
||||
})
|
||||
).subscribe(res => {
|
||||
if (res !== null) {
|
||||
this.toastr.success('Bitaxe restarted', 'Success');
|
||||
}
|
||||
});
|
||||
this.toastr.success('Success!', 'Bitaxe restarted');
|
||||
}
|
||||
|
||||
public remove(axeOs: any) {
|
||||
|
@ -320,6 +320,12 @@ static esp_err_t PATCH_update_settings(httpd_req_t * req)
|
||||
|
||||
static esp_err_t POST_restart(httpd_req_t * req)
|
||||
{
|
||||
// Set CORS headers
|
||||
if (set_cors_headers(req) != ESP_OK) {
|
||||
httpd_resp_send_500(req);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Restarting System because of API Request");
|
||||
|
||||
// Send HTTP response before restarting
|
||||
@ -710,6 +716,10 @@ esp_err_t start_rest_server(void * pvParameters)
|
||||
.uri = "/api/system/restart", .method = HTTP_POST, .handler = POST_restart, .user_ctx = rest_context};
|
||||
httpd_register_uri_handler(server, &system_restart_uri);
|
||||
|
||||
httpd_uri_t system_restart_options_uri = {
|
||||
.uri = "/api/system/restart", .method = HTTP_OPTIONS, .handler = handle_options_request, .user_ctx = NULL};
|
||||
httpd_register_uri_handler(server, &system_restart_options_uri);
|
||||
|
||||
httpd_uri_t update_system_settings_uri = {
|
||||
.uri = "/api/system", .method = HTTP_PATCH, .handler = PATCH_update_settings, .user_ctx = rest_context};
|
||||
httpd_register_uri_handler(server, &update_system_settings_uri);
|
||||
|
Loading…
x
Reference in New Issue
Block a user