lib/services/aws.service.ts
Service and state effects for AWS service calls.
Methods |
constructor(dialog: MatDialog, spinnerService: SpinnerService, nshmpService: NshmpService)
|
||||||||||||
Defined in lib/services/aws.service.ts:23
|
||||||||||||
Parameters :
|
callJobHistoryService | ||||||||||||
callJobHistoryService(serviceUrl: string, idControl: FormControl
|
||||||||||||
Defined in lib/services/aws.service.ts:36
|
||||||||||||
Type parameters :
|
||||||||||||
NGRX effect to call the AWS hazard job history service.
Parameters :
|
callTerminateJobService | ||||||||||||
callTerminateJobService(serviceUrl: string, idControl: FormControl
|
||||||||||||
Defined in lib/services/aws.service.ts:73
|
||||||||||||
NGRX effect to call the AWS hazard terminate job service.
Parameters :
Returns :
any
|
openTerminateDialog | ||||||||||||
openTerminateDialog(jobInfo: Response<JobHistoryRequestData | DynamoDBItem>, onTerminateAction: () => void)
|
||||||||||||
Defined in lib/services/aws.service.ts:57
|
||||||||||||
NGRX effect to open the terminate job dialog.
Parameters :
Returns :
void
|
openTerminateJobDialog | ||||||||
openTerminateJobDialog(data: TerminateJobDialogData)
|
||||||||
Defined in lib/services/aws.service.ts:92
|
||||||||
Open the AWS hazard terminate job dialog.
Parameters :
Returns :
void
|
import {Injectable} from '@angular/core';
import {FormControl} from '@angular/forms';
import {MatDialog} from '@angular/material/dialog';
import {NshmpService} from '@ghsc/nshmp-lib-ng/nshmp';
import {SpinnerService} from '@ghsc/nshmp-template';
import {DynamoDBItem} from '@ghsc/nshmp-utils-ts/libs/aws/run-nshmp-haz';
import {Response} from '@ghsc/nshmp-utils-ts/libs/nshmp-ws-utils';
import {EC2} from 'aws-sdk';
import {Observable} from 'rxjs';
import {map} from 'rxjs/operators';
import {NshmpAwsTerminateJobDialogComponent} from '../components/terminate-job-dialog/terminate-job-dialog.component';
import {JobHistoryRequestData} from '../models/job-history-service.model';
import {TerminateJobRequestData} from '../models/terminate-job.model';
import {TerminateJobDialogData} from '../models/terminate-job-dialog-data.model';
/**
* Service and state effects for AWS service calls.
*/
@Injectable({
providedIn: 'root',
})
export class AwsService {
constructor(
private dialog: MatDialog,
private spinnerService: SpinnerService,
private nshmpService: NshmpService,
) {}
/**
* NGRX effect to call the AWS hazard job history service.
*
* @param serviceUrl The service URL to call
* @param idControl The id form control
*/
callJobHistoryService<U extends DynamoDBItem | DynamoDBItem[]>(
serviceUrl: string,
idControl: FormControl<string>,
): Observable<Response<JobHistoryRequestData, U>> {
const spinnerRef = this.spinnerService.show('Getting job information');
const url = `${serviceUrl}/${idControl.getRawValue()}`;
return this.nshmpService.callService$<Response<JobHistoryRequestData, U>>(url).pipe(
map(response => {
spinnerRef.close();
return response;
}),
);
}
/**
* NGRX effect to open the terminate job dialog.
*
* @param jobInfo The job info
* @param onTerminateAction The callback funciton on terminate
*/
openTerminateDialog(
jobInfo: Response<JobHistoryRequestData, DynamoDBItem>,
onTerminateAction: () => unknown,
) {
this.openTerminateJobDialog({
jobInfo: jobInfo.response,
onTerminateAction,
});
}
/**
* NGRX effect to call the AWS hazard terminate job service.
*
* @param serviceUrl The service URL to call
* @param idControl The id form control
*/
callTerminateJobService(serviceUrl: string, idControl: FormControl<string>) {
const spinnerRef = this.spinnerService.show(`Terminating job ${idControl.getRawValue()}`);
const url = `${serviceUrl}/${idControl.getRawValue()}`;
return this.nshmpService
.callService$<Response<TerminateJobRequestData, EC2.InstanceStateChangeList>>(url)
.pipe(
map(response => {
spinnerRef.close();
return response;
}),
);
}
/**
* Open the AWS hazard terminate job dialog.
*
* @param data The terminate job dialog data
*/
openTerminateJobDialog(data: TerminateJobDialogData) {
this.dialog.open(NshmpAwsTerminateJobDialogComponent, {
data,
});
}
}