/
jobs.ts
99 lines (78 loc) · 2.67 KB
/
jobs.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import { Observable } from 'rxjs/Observable';
import { Page } from '../../shared/model/page';
import { JobExecution } from '../../jobs/model/job-execution.model';
import { StepExecutionResource } from '../../jobs/model/step-execution-resource.model';
import { StepExecutionProgress } from '../../jobs/model/step-execution-progress.model';
export class MockJobsService {
jobsContext = {
sort: 'name',
order: 'ASC',
page: 0,
size: 30,
itemsSelected: []
};
public jobExecutionsPage: Page<JobExecution>;
private _testJobExecutions: JobExecution[];
private _testStepExecutionResource: StepExecutionResource;
private _testStepExecutionProgress: StepExecutionProgress;
get testJobExecutions() {
return this._testJobExecutions;
}
set testJobExecutions(params: any) {
this._testJobExecutions = params;
}
get testStepExecutionResource() {
return this._testStepExecutionResource;
}
set testStepExecutionResource(params: any) {
this._testStepExecutionResource = params;
}
get testStepExecutionProgress() {
return this._testStepExecutionProgress;
}
set testStepExecutionProgress(params: any) {
this._testStepExecutionProgress = params;
}
setJobExecutions(mock) {
let page = new Page<JobExecution>();
if (mock._embedded && mock._embedded.jobExecutionResourceList) {
page = JobExecution.pageFromJSON(mock);
}
this.jobExecutionsPage = page;
}
getStepExecutionProgress(jobid: string, stepid: string): Observable<StepExecutionProgress> {
let stepExecutionProgress: StepExecutionProgress = null;
if (this.testStepExecutionProgress) {
stepExecutionProgress = StepExecutionProgress.fromJSON(this.testStepExecutionProgress);
}
return Observable.of(stepExecutionProgress);
}
getJobExecutions() {
return Observable.of(this.jobExecutionsPage);
}
getJobExecution(id: string) {
let jobExecution = null;
if (this.testJobExecutions) {
const jsonItem = this.testJobExecutions
.find(je => je['executionId'] === +id);
if (!jsonItem) {
return Observable.of(jobExecution);
}
jobExecution = JobExecution.fromJSON(jsonItem);
}
return Observable.of(jobExecution);
}
getStepExecution(jobid: string, stepid: string): Observable<StepExecutionResource> {
let stepExecutionResource: StepExecutionResource = null;
if (this.testStepExecutionResource) {
stepExecutionResource = StepExecutionResource.fromJSON(this.testStepExecutionResource);
}
return Observable.of(stepExecutionResource);
}
stopJob(item: JobExecution) {
return Observable.of({});
}
restartJob(item: JobExecution) {
return Observable.of({});
}
}