Commit b30870f6 authored by Daniel Nemergut's avatar Daniel Nemergut
Browse files

Merge branch 'ws1257-qa_reject_bad_planes_ui-fixes' into 'release/2.4.1-RC1'

Fixed the UI to work with the manager and added a job status check

See merge request !9
parents ad8325e1 0d1eb94d
<form [formGroup]="planesFormGroup" (ngSubmit)="cachePlanes()" class="mb-2">
<form [formGroup]="planesFormGroup" (ngSubmit)="acceptPlanes()" class="mb-2">
<h4 class="pt-2 border-top">
Planes
</h4>
......@@ -7,7 +7,7 @@
<label><input type="checkbox" [formControlName]="plane" value="{{plane}}" checked/>{{plane}}</label>
</div>
<button type="submit" class="btn btn-sm btn-outline-info bg-light">
Cache Planes
<button type="submit" class="btn btn-success btn-sm">
Accept &amp; Archive Selected Planes
</button>
</form>
......@@ -3,6 +3,7 @@ import {FormControl, FormGroup} from '@angular/forms';
import {AlertService} from '../../../../services/alert.service';
import {JobsService} from '../../../../services/jobs.service';
import {Job} from '../../../../model/job';
import {Observable} from 'rxjs';
@Component({
selector: 'app-execution-detail-planes',
......@@ -12,6 +13,7 @@ import {Job} from '../../../../model/job';
export class ExecutionDetailPlanesComponent implements OnInit, OnDestroy {
@Input() job: Job;
planes: Observable<string>;
planeKeys: string[];
planesFormGroup: FormGroup;
......@@ -25,8 +27,7 @@ export class ExecutionDetailPlanesComponent implements OnInit, OnDestroy {
}
ngOnInit(): void {
// Create a form control for each of the plane checkboxes and add them into the same group
this.getPlaneKeys().forEach(control => this.planesFormGroup.addControl(control, new FormControl(true)));
}
ngOnDestroy(): void {
......@@ -44,7 +45,13 @@ export class ExecutionDetailPlanesComponent implements OnInit, OnDestroy {
// Get the plane names from the spectral window numbers in the planes.json file
this.jobService.getPlanes(this.job.job_id).subscribe(response => {
this.planeKeys = Object.keys(JSON.parse(response));
this.planeKeys = Object.keys(response.body);
// Create a form control for each of the plane checkboxes and add them into the same group
this.planeKeys.forEach(control => this.planesFormGroup.addControl(control, new FormControl(true)));
// Set the planes data here to signal that the controls are done being added and the HTML can finish loading
this.planes = response.body;
},
error => {
this.alertService.error('Could not retrieve planes from planes.json. ' + error);
......@@ -53,9 +60,9 @@ export class ExecutionDetailPlanesComponent implements OnInit, OnDestroy {
return this.planeKeys;
}
// Writes to a file in lustre to flag planes to be cached
cachePlanes(): void {
this.alertService.info('Flagging planes to be cached');
// Writes to a file in lustre to flag planes to be accepted
acceptPlanes(): void {
this.alertService.info('Flagging accepted planes to be cached');
// Collect the selected planes and write their names separated by a newline
let planesText = '';
......
......@@ -44,7 +44,7 @@
</div>
</form>
<app-execution-detail-planes [job]="job" *ngIf="jobDetail.queueName === 'se_coarse_cube_imaging'"></app-execution-detail-planes>
<app-execution-detail-planes [job]="job" *ngIf="jobDetail.queueName === 'se_coarse_cube_imaging' && canAcceptArchive(jobDetail.status, jobDetail.archiveStatus)"></app-execution-detail-planes>
<h4 class="pt-2 border-top">
<fa-icon [icon]="faList"></fa-icon>
......
......@@ -165,7 +165,7 @@ export class JobsService {
// Returns a JSON encoded string of plane information
public getPlanes(id: number): Observable<any> {
return this.http.put(this.configService.config.url + this.endPoint + 'jobs/' + id + '/planes', {}, {observe: 'response'}).pipe(
return this.http.get(this.configService.config.url + this.endPoint + 'jobs/' + id + '/planes', {observe: 'response'}).pipe(
map(response => {
return response;
}));
......@@ -173,7 +173,7 @@ export class JobsService {
// Writes a string of plane names
public writePlanes(id: number, planes: string): Observable<any> {
return this.http.put(this.configService.config.url + this.endPoint + 'jobs/' + id + '/planes?planes=' + planes, {}, {observe: 'response'}).pipe(
return this.http.put(this.configService.config.url + this.endPoint + 'jobs/' + id + '/writePlanes', {planes}, {observe: 'response'}).pipe(
map(response => {
return status;
}));
......
Supports Markdown
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