Skip to content
Snippets Groups Projects
Commit 2b0aaa4c authored by Clayton, Brandon Scott's avatar Clayton, Brandon Scott
Browse files

add spinner ref

parent 1924cc5c
No related branches found
No related tags found
1 merge request!572AWS Updates
...@@ -2,6 +2,7 @@ import {Location as LocationService} from '@angular/common'; ...@@ -2,6 +2,7 @@ import {Location as LocationService} from '@angular/common';
import {HttpParams} from '@angular/common/http'; import {HttpParams} from '@angular/common/http';
import {computed, Injectable, Signal, signal} from '@angular/core'; import {computed, Injectable, Signal, signal} from '@angular/core';
import {AbstractControl, FormBuilder, Validators} from '@angular/forms'; import {AbstractControl, FormBuilder, Validators} from '@angular/forms';
import {MatDialogRef} from '@angular/material/dialog';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
import { import {
AwsService, AwsService,
...@@ -9,7 +10,11 @@ import { ...@@ -9,7 +10,11 @@ import {
JobStatus, JobStatus,
TerminateJobRequestData, TerminateJobRequestData,
} from '@ghsc/nshmp-lib-ng/aws'; } from '@ghsc/nshmp-lib-ng/aws';
import {NshmpService, SpinnerService} from '@ghsc/nshmp-lib-ng/nshmp'; import {
NshmpLibNgSpinnerComponent,
NshmpService,
SpinnerService,
} from '@ghsc/nshmp-lib-ng/nshmp';
import {DynamoDBItem} from '@ghsc/nshmp-utils-ts/libs/aws/run-nshmp-haz'; import {DynamoDBItem} from '@ghsc/nshmp-utils-ts/libs/aws/run-nshmp-haz';
import {Response} from '@ghsc/nshmp-utils-ts/libs/nshmp-ws-utils'; import {Response} from '@ghsc/nshmp-utils-ts/libs/nshmp-ws-utils';
import {EC2} from 'aws-sdk'; import {EC2} from 'aws-sdk';
...@@ -126,9 +131,10 @@ export class AppService implements AppServiceModel<AppState, ControlForm> { ...@@ -126,9 +131,10 @@ export class AppService implements AppServiceModel<AppState, ControlForm> {
*/ */
callService(showSpinner = true): void { callService(showSpinner = true): void {
const {id} = this.formGroup.getRawValue(); const {id} = this.formGroup.getRawValue();
let spinnerRef: MatDialogRef<NshmpLibNgSpinnerComponent> = undefined;
if (showSpinner) { if (showSpinner) {
this.spinnerService.show(`Getting logs for job ${id}`); spinnerRef = this.spinnerService.show(`Getting logs for job ${id}`);
} }
const url = `${this.baseUrl}${this.hazardLogsService}/${id}`; const url = `${this.baseUrl}${this.hazardLogsService}/${id}`;
...@@ -139,9 +145,10 @@ export class AppService implements AppServiceModel<AppState, ControlForm> { ...@@ -139,9 +145,10 @@ export class AppService implements AppServiceModel<AppState, ControlForm> {
this.nshmpService this.nshmpService
.callService$<Response<GetLogsRequestData, GetLogsResponseData>>(url) .callService$<Response<GetLogsRequestData, GetLogsResponseData>>(url)
.pipe(catchError((error: Error) => this.nshmpService.throwError$(error))) .pipe(catchError((error: Error) => this.nshmpService.throwError$(error)))
.subscribe(serviceResponse => .subscribe(serviceResponse => {
this.handleServiceResponse(serviceResponse, showSpinner), this.handleServiceResponse(serviceResponse);
); spinnerRef?.close();
});
} }
defaultFormValues(): ControlForm { defaultFormValues(): ControlForm {
...@@ -212,7 +219,6 @@ export class AppService implements AppServiceModel<AppState, ControlForm> { ...@@ -212,7 +219,6 @@ export class AppService implements AppServiceModel<AppState, ControlForm> {
*/ */
private handleServiceResponse( private handleServiceResponse(
serviceResponse: Response<GetLogsRequestData, GetLogsResponseData>, serviceResponse: Response<GetLogsRequestData, GetLogsResponseData>,
showSpinner: boolean,
): void { ): void {
const {autoRefresh} = this.formGroup.getRawValue(); const {autoRefresh} = this.formGroup.getRawValue();
const status = serviceResponse.response.jobStatus; const status = serviceResponse.response.jobStatus;
...@@ -224,11 +230,6 @@ export class AppService implements AppServiceModel<AppState, ControlForm> { ...@@ -224,11 +230,6 @@ export class AppService implements AppServiceModel<AppState, ControlForm> {
setTimeout(() => this.callService(false), 3000); setTimeout(() => this.callService(false), 3000);
} }
if (showSpinner) {
this.spinnerService.remove();
}
this.spinnerService.remove();
this.updateState({ this.updateState({
serviceLoading: false, serviceLoading: false,
serviceResponse, serviceResponse,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment