From d504118402668872d4acc67c10a40cd03d8f8e99 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 30 Jan 2018 16:33:23 +0000 Subject: Converted job.js to axios --- app/assets/javascripts/job.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'app/assets/javascripts/job.js') diff --git a/app/assets/javascripts/job.js b/app/assets/javascripts/job.js index 9b5092c5e3f..d2cbc9b82b3 100644 --- a/app/assets/javascripts/job.js +++ b/app/assets/javascripts/job.js @@ -1,4 +1,5 @@ import _ from 'underscore'; +import axios from './lib/utils/axios_utils'; import { visitUrl } from './lib/utils/url_utility'; import bp from './breakpoints'; import { numberToHumanSize } from './lib/utils/number_utils'; @@ -171,11 +172,12 @@ export default class Job { } getBuildTrace() { - return $.ajax({ - url: `${this.pagePath}/trace.json`, - data: { state: this.state }, + return axios.get(`${this.pagePath}/trace.json`, { + params: { state: this.state }, }) - .done((log) => { + .then((res) => { + const log = res.data; + setCiStatusFavicon(`${this.pagePath}/status.json`); if (log.state) { @@ -217,7 +219,7 @@ export default class Job { visitUrl(this.pagePath); } }) - .fail(() => { + .catch(() => { this.$buildRefreshAnimation.remove(); }) .then(() => { -- cgit v1.2.1 From 645d635976ef48905c0416bd2a4a25025fef9ee4 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 2 Feb 2018 10:05:37 +0000 Subject: fixed issue with axios_utils not reducing activeVueResources variable when request fails --- app/assets/javascripts/job.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'app/assets/javascripts/job.js') diff --git a/app/assets/javascripts/job.js b/app/assets/javascripts/job.js index d2cbc9b82b3..d0b7ea75082 100644 --- a/app/assets/javascripts/job.js +++ b/app/assets/javascripts/job.js @@ -9,6 +9,7 @@ export default class Job { constructor(options) { this.timeout = null; this.state = null; + this.fetchingStatusFavicon = false; this.options = options || $('.js-build-options').data(); this.pagePath = this.options.pagePath; @@ -178,7 +179,17 @@ export default class Job { .then((res) => { const log = res.data; - setCiStatusFavicon(`${this.pagePath}/status.json`); + if (!this.fetchingStatusFavicon) { + this.fetchingStatusFavicon = true; + + setCiStatusFavicon(`${this.pagePath}/status.json`) + .then(() => { + this.fetchingStatusFavicon = false; + }) + .catch(() => { + this.fetchingStatusFavicon = false; + }); + } if (log.state) { this.state = log.state; -- cgit v1.2.1 From 239d613839eecb68414631e9de4f9a5ac7d18f66 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 7 Feb 2018 12:49:27 +0000 Subject: Clear the timeout in Jobs class after each test --- app/assets/javascripts/job.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/assets/javascripts/job.js') diff --git a/app/assets/javascripts/job.js b/app/assets/javascripts/job.js index d0b7ea75082..f39ae764d3c 100644 --- a/app/assets/javascripts/job.js +++ b/app/assets/javascripts/job.js @@ -217,7 +217,7 @@ export default class Job { } this.isLogComplete = log.complete; - if (!log.complete) { + if (log.complete === false) { this.timeout = setTimeout(() => { this.getBuildTrace(); }, 4000); -- cgit v1.2.1