diff options
author | Fatih Acet <acetfatih@gmail.com> | 2017-04-03 18:58:04 +0300 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2017-04-03 22:22:09 +0300 |
commit | 06613b09b2dabdfc5222c47503e6e9fdbbbe0c6a (patch) | |
tree | ed1a3ed1ca2107ed6b5068e0cd937febe15e7e76 | |
parent | ab78aa406cc4f7eb93c301c88154998e73e7da1f (diff) | |
download | gitlab-ce-06613b09b2dabdfc5222c47503e6e9fdbbbe0c6a.tar.gz |
MRWidget: Implement polling for deployments.
-rw-r--r-- | app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js b/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js index 9a641861293..c7d9aade121 100644 --- a/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js +++ b/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js @@ -69,14 +69,24 @@ export default { }, initCIPolling() { this.ciStatusInterval = new gl.SmartInterval({ - callback: this.getCIStatus, + callback: this.fetchCIStatus, startingInterval: 10000, maxInterval: 30000, hiddenInterval: 120000, incrementByFactorOf: 5000, }); }, - getCIStatus() { + initDeploymentsPolling() { + this.deploymentsInterval = new gl.SmartInterval({ + callback: this.fetchDeployments, + startingInterval: 30000, + maxInterval: 120000, + hiddenInterval: 240000, + incrementByFactorOf: 15000, + immediateExecution: true, + }); + }, + fetchCIStatus() { // TODO: Error handling this.service.ciStatusResorce.get() .then(res => res.json()) @@ -86,6 +96,15 @@ export default { } }); }, + fetchDeployments() { + this.service.fetchDeployments() + .then(res => res.json()) + .then((res) => { + if (res.length) { + this.mr.deployments = res; + } + }); + }, }, created() { eventHub.$on('MRWidgetUpdateRequested', (cb) => { @@ -104,20 +123,12 @@ export default { }, mounted() { this.checkStatus(); - this.getCIStatus(); - - // TODO: Error handling - this.service.fetchDeployments() - .then(res => res.json()) - .then((res) => { - if (res.length) { - this.mr.deployments = res; - } - }); + this.fetchCIStatus(); if (this.mr.hasCI) { this.initCIPolling(); } + this.initDeploymentsPolling(); }, components: { 'mr-widget-header': WidgetHeader, |