1
0
mirror of https://gitlab.com/bramw/baserow.git synced 2024-11-21 23:37:55 +00:00
bramw_baserow/web-frontend/modules/core/services/job.js
2024-09-24 09:43:47 +00:00

29 lines
727 B
JavaScript

export default (client) => {
return {
create(jobType, params = {}) {
return client.post(`/jobs/`, {
type: jobType,
...params,
})
},
get(jobId) {
return client.get(`/jobs/${jobId}/`)
},
async cancel(jobId) {
return await client.post(`/jobs/${jobId}/cancel/`)
},
fetchAll(filters = {}) {
const { states, jobIds } = filters
const params = new URLSearchParams()
if (states !== undefined) {
params.append('states', Array.isArray(states) ? states : [states])
}
if (jobIds !== undefined) {
params.append('job_ids', jobIds)
}
const config = { params }
return client.get(`/jobs/`, config)
},
}
}