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
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}/`); return this.http.get(`/api/v2${BASE_URLS[type]}${id}/`);
} }
readEvents(id, jobType = 'job', params = {}) { readEvents(id, type = 'playbook', params = {}) {
let endpoint; let endpoint;
if (jobType === 'job') { if (type === 'playbook') {
endpoint = `${this.baseUrl}${id}/job_events/`; endpoint = `/api/v2${BASE_URLS[type]}${id}/job_events/`;
} else { } else {
endpoint = `${this.baseUrl}${id}/events/`; endpoint = `/api/v2${BASE_URLS[type]}${id}/events/`;
} }
return this.http.get(endpoint, { params }); return this.http.get(endpoint, { params });
} }

View File

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