Skip to content

Commit

Permalink
added Abort Job button to the top-level Job Details page [BA-5370] (#657
Browse files Browse the repository at this point in the history
)
  • Loading branch information
rsasch authored Jun 25, 2019
1 parent 42a1c33 commit a269f53
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Job Manager Change Log

## v1.2.2 Release Notes

### Added 'Abort Job' button to Job Details page.

## v1.2.1 Release Notes

### Added logic to avoid 500 error on Job Details page when a task does not have a start time.
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/job-details/job-details.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ describe('JobDetailsComponent', () => {
let fixture: ComponentFixture<TestJobDetailsComponent>;
let router: Router;
let fakeJobService: FakeJobManagerService;
let snackBar: MatSnackBar;

const jobId = '123';
function testJob(): JobMetadataResponse {
Expand All @@ -65,7 +64,7 @@ describe('JobDetailsComponent', () => {
beforeEach(async(() => {
fakeJobService = new FakeJobManagerService([testJob()]);
let fakeCapabilitiesService: FakeCapabilitiesService = new FakeCapabilitiesService({});
let authService = new AuthService(null, fakeCapabilitiesService, null, snackBar);
let authService = new AuthService(null, fakeCapabilitiesService, null, null);
let settingsService: SettingsService = new SettingsService(authService, fakeCapabilitiesService, localStorage);

TestBed.configureTestingModule({
Expand Down Expand Up @@ -115,6 +114,7 @@ describe('JobDetailsComponent', () => {
{provide: SettingsService, useValue: settingsService},
{provide: CapabilitiesService, useValue: fakeCapabilitiesService},
{provide: AuthService, useValue: authService},
{provide: MatSnackBar},
JobDetailsResolver
],
}).compileComponents();
Expand Down
7 changes: 7 additions & 0 deletions ui/src/app/job-details/panels/panels.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ p {
height: 2.25rem;
}

button.mat-raised-button {
background-color: #74AE43;
color: #fff;
font-weight: 500;
text-transform: uppercase;
}

.job-id {
margin-bottom: 0.5rem;
}
Expand Down
1 change: 1 addition & 0 deletions ui/src/app/job-details/panels/panels.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</clr-tooltip-content>
</clr-tooltip>
</button>
<button *ngIf="canAbort()" (click)="abortJob()" class="close mat-raised-button">Abort job</button>
<p class="job-id">ID: <b>{{ job.id }}</b></p>
<div *ngIf="hasPrimaryLabels()" class="job-labels">
<span class="label" *ngFor="let l of primaryLabels">
Expand Down
8 changes: 8 additions & 0 deletions ui/src/app/job-details/panels/panels.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
MatCardModule,
MatGridListModule,
MatMenuModule,
MatSnackBar,
MatTabsModule,
MatTableModule
} from '@angular/material';
Expand All @@ -17,6 +18,8 @@ import {JobMetadataResponse} from '../../shared/model/JobMetadataResponse';
import {JobPanelsComponent} from './panels.component';
import {JobFailuresTableComponent} from "../common/failures-table/failures-table.component";
import {JobDebugIconsComponent} from "../common/debug-icons/debug-icons.component";
import {JobManagerService} from "../../core/job-manager.service";
import {FakeJobManagerService} from "../../testing/fake-job-manager.service";

describe('JobPanelsComponent', () => {

Expand All @@ -43,6 +46,7 @@ describe('JobPanelsComponent', () => {
statusDetail: 'success',
}
};
let fakeJobService = new FakeJobManagerService([minimalJob, completeJob]);

beforeEach(async(() => {
TestBed.configureTestingModule({
Expand All @@ -64,6 +68,10 @@ describe('JobPanelsComponent', () => {
MatTableModule,
SharedModule
],
providers: [
{provide: JobManagerService, useValue: fakeJobService},
{provide: MatSnackBar},
]
}).compileComponents();
}));

Expand Down
25 changes: 25 additions & 0 deletions ui/src/app/job-details/panels/panels.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {JobStatus} from '../../shared/model/JobStatus';
import {JobFailuresTableComponent} from "../common/failures-table/failures-table.component";
import {JobStatusIcon} from "../../shared/common";
import {DisplayField} from "../../shared/model/DisplayField";
import {JobManagerService} from "../../core/job-manager.service";
import {MatSnackBar} from "@angular/material";
import {ErrorMessageFormatterPipe} from "../../shared/pipes/error-message-formatter.pipe";

@Component({
selector: 'jm-panels',
Expand All @@ -38,6 +41,10 @@ export class JobPanelsComponent implements OnInit {
numTasks: number = 0;
public readonly numOfErrorsToShow = 4;

constructor(
private readonly snackBar: MatSnackBar,
private readonly jobManagerService: JobManagerService) { }

ngOnInit() {
this.setUpExtensions();
if (this.job.labels) {
Expand Down Expand Up @@ -115,4 +122,22 @@ export class JobPanelsComponent implements OnInit {
getStatusIcon(status: JobStatus): string {
return JobStatusIcon[status];
}

abortJob() {
this.jobManagerService.abortJob(this.job.id)
.then(() => {
window.location.reload();
})
.catch((error) => this.handleError(error));
}

canAbort(): boolean {
return !this.hasParent() && (this.job.status == JobStatus.Submitted || this.job.status == JobStatus.Running);
}

handleError(error: any) {
this.snackBar.open(
new ErrorMessageFormatterPipe().transform(error),
'Dismiss');
}
}

0 comments on commit a269f53

Please sign in to comment.