summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2017-04-03 18:58:04 +0300
committerFatih Acet <acetfatih@gmail.com>2017-04-03 22:22:09 +0300
commit06613b09b2dabdfc5222c47503e6e9fdbbbe0c6a (patch)
treeed1a3ed1ca2107ed6b5068e0cd937febe15e7e76
parentab78aa406cc4f7eb93c301c88154998e73e7da1f (diff)
downloadgitlab-ce-06613b09b2dabdfc5222c47503e6e9fdbbbe0c6a.tar.gz
MRWidget: Implement polling for deployments.
-rw-r--r--app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js35
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,