diff --git a/ui/src/app/pages/apps-routes/app-actions/app-actions.page.ts b/ui/src/app/pages/apps-routes/app-actions/app-actions.page.ts index af4ce0061..7c5237ca7 100644 --- a/ui/src/app/pages/apps-routes/app-actions/app-actions.page.ts +++ b/ui/src/app/pages/apps-routes/app-actions/app-actions.page.ts @@ -68,27 +68,36 @@ export class AppActionsPage extends Cleanup { } private async executeAction(action: ServiceAction) { - const res = await this.loaderService.displayDuringP( - this.apiService.serviceAction(this.appId, action), - ) - if (isRpcFailure(res)) { - const successAlert = await this.alertCtrl.create({ - header: 'Execution Failed', - message: `Error code ${res.error.code}. ${res.error.message}`, - buttons: ['OK'], - cssClass: 'alert-error-message', - }) - return await successAlert.present() - } - - if (isRpcSuccess(res)) { - const successAlert = await this.alertCtrl.create({ - header: 'Execution Complete', - message: res.result, - buttons: ['OK'], - cssClass: 'alert-success-message', - }) - return await successAlert.present() + try { + const res = await this.loaderService.displayDuringP( + this.apiService.serviceAction(this.appId, action), + ) + + if (isRpcFailure(res)) { + this.presentAlertActionFail(res.error.code, res.error.message) + } + + if (isRpcSuccess(res)) { + const successAlert = await this.alertCtrl.create({ + header: 'Execution Complete', + message: res.result.split('\n').join('

'), + buttons: ['OK'], + cssClass: 'alert-success-message', + }) + return await successAlert.present() + } + } catch (e) { + this.presentAlertActionFail(500, e.message) } } + + private async presentAlertActionFail (code: number, message: string): Promise { + const failureAlert = await this.alertCtrl.create({ + header: 'Execution Failed', + message: `Error code ${code}. ${message}`, + buttons: ['OK'], + cssClass: 'alert-error-message', + }) + return await failureAlert.present() + } } diff --git a/ui/src/app/services/api/live-api.service.ts b/ui/src/app/services/api/live-api.service.ts index c6832e50e..517d4695b 100644 --- a/ui/src/app/services/api/live-api.service.ts +++ b/ui/src/app/services/api/live-api.service.ts @@ -274,7 +274,7 @@ export class LiveApiService extends ApiService { id: uuid.v4(), method: s.id, } - return this.authRequest({ method: Method.POST, url: `/apps/${appId}/actions`, data }) + return this.authRequest({ method: Method.POST, url: `/apps/${appId}/actions`, data, readTimeout: 300000 }) } async refreshLAN(): Promise { diff --git a/ui/src/app/services/api/mock-api.service.ts b/ui/src/app/services/api/mock-api.service.ts index 303a9af75..2f2c75e39 100644 --- a/ui/src/app/services/api/mock-api.service.ts +++ b/ui/src/app/services/api/mock-api.service.ts @@ -235,11 +235,11 @@ export class MockApiService extends ApiService { return { jsonrpc: '2.0', id: '0', - // result: 'Congrats! you did ' + action.name, - error: { - code: 1, - message: 'woooo that was bad bad bad', - }, + result: 'Congrats! you did\na new line: ' + action.name, + // error: { + // code: 1, + // message: 'woooo that was bad bad bad', + // }, } }