diff options
author | Clement Ho <clemmakesapps@gmail.com> | 2018-02-16 00:51:41 +0300 |
---|---|---|
committer | Jacob Schatz <jschatz@gitlab.com> | 2018-02-16 00:51:41 +0300 |
commit | f5caabad73e9a2045e76f50df8107dddef39d80d (patch) | |
tree | c2bdd44cb6c09fa12d0f1c7ef013f7ce0c9bcc48 /app/assets/javascripts/importer_status.js | |
parent | 4342e3915c9a3d374f3862b2cfc3ddb07ae56169 (diff) |
Replace $.get with axios in importerStatus
Diffstat (limited to 'app/assets/javascripts/importer_status.js')
-rw-r--r-- | app/assets/javascripts/importer_status.js | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/app/assets/javascripts/importer_status.js b/app/assets/javascripts/importer_status.js index 134a503864e..35094f8e73b 100644 --- a/app/assets/javascripts/importer_status.js +++ b/app/assets/javascripts/importer_status.js @@ -59,29 +59,36 @@ class ImporterStatus { .catch(() => flash(__('An error occurred while importing project'))); } - setAutoUpdate() { - return setInterval(() => $.get(this.jobsUrl, data => $.each(data, (i, job) => { - const jobItem = $(`#project_${job.id}`); - const statusField = jobItem.find('.job-status'); + autoUpdate() { + return axios.get(this.jobsUrl) + .then(({ data = [] }) => { + data.forEach((job) => { + const jobItem = $(`#project_${job.id}`); + const statusField = jobItem.find('.job-status'); + + const spinner = '<i class="fa fa-spinner fa-spin"></i>'; - const spinner = '<i class="fa fa-spinner fa-spin"></i>'; + switch (job.import_status) { + case 'finished': + jobItem.removeClass('active').addClass('success'); + statusField.html('<span><i class="fa fa-check"></i> done</span>'); + break; + case 'scheduled': + statusField.html(`${spinner} scheduled`); + break; + case 'started': + statusField.html(`${spinner} started`); + break; + default: + statusField.html(job.import_status); + break; + } + }); + }); + } - switch (job.import_status) { - case 'finished': - jobItem.removeClass('active').addClass('success'); - statusField.html('<span><i class="fa fa-check"></i> done</span>'); - break; - case 'scheduled': - statusField.html(`${spinner} scheduled`); - break; - case 'started': - statusField.html(`${spinner} started`); - break; - default: - statusField.html(job.import_status); - break; - } - })), 4000); + setAutoUpdate() { + setInterval(this.autoUpdate.bind(this), 4000); } } |