Build correct job_event url for different job types

This commit is contained in:
Jake McDermott 2019-10-03 15:11:58 -04:00
parent bdd28bcb3b
commit 731982c736
No known key found for this signature in database
GPG Key ID: 0E56ED990CDFCB4F
2 changed files with 8 additions and 8 deletions

View File

@ -20,12 +20,12 @@ class Jobs extends RelaunchMixin(Base) {
return this.http.get(`/api/v2${BASE_URLS[type]}${id}/`);
}
readEvents(id, jobType = 'job', params = {}) {
readEvents(id, type = 'playbook', params = {}) {
let endpoint;
if (jobType === 'job') {
endpoint = `${this.baseUrl}${id}/job_events/`;
if (type === 'playbook') {
endpoint = `/api/v2${BASE_URLS[type]}${id}/job_events/`;
} else {
endpoint = `${this.baseUrl}${id}/events/`;
endpoint = `/api/v2${BASE_URLS[type]}${id}/events/`;
}
return this.http.get(endpoint, { params });
}

View File

@ -112,7 +112,7 @@ class JobOutput extends Component {
}
async loadJobEvents() {
const { job } = this.props;
const { job, type } = this.props;
const loadRange = range(1, 50);
this._isMounted &&
@ -123,7 +123,7 @@ class JobOutput extends Component {
try {
const {
data: { results: newResults = [], count },
} = await JobsAPI.readEvents(job.id, job.type, {
} = await JobsAPI.readEvents(job.id, type, {
page_size: 50,
order_by: 'start_line',
});
@ -220,7 +220,7 @@ class JobOutput extends Component {
if (startIndex === 0 && stopIndex === 0) {
return Promise.resolve(null);
}
const { job } = this.props;
const { job, type } = this.props;
const loadRange = range(startIndex, stopIndex);
this._isMounted &&
@ -233,7 +233,7 @@ class JobOutput extends Component {
order_by: 'start_line',
};
return JobsAPI.readEvents(job.id, job.type, params).then(response => {
return JobsAPI.readEvents(job.id, type, params).then(response => {
this._isMounted &&
this.setState(({ results, currentlyLoading }) => {
response.data.results.forEach(jobEvent => {