diff --git a/app/mixins/polling.coffee b/app/mixins/polling.coffee index f68d3fa7..acc11490 100644 --- a/app/mixins/polling.coffee +++ b/app/mixins/polling.coffee @@ -1,4 +1,5 @@ `import Ember from 'ember'` +`import config from 'travis/config/environment'` mixin = Ember.Mixin.create polling: Ember.inject.service() @@ -6,11 +7,13 @@ mixin = Ember.Mixin.create didInsertElement: -> @_super.apply(this, arguments) + return unless config.ajaxPolling @startPolling() willDestroyElement: -> @_super.apply(this, arguments) + return unless config.ajaxPolling @stopPolling() pollModelDidChange: (sender, key, value) -> diff --git a/app/services/polling.coffee b/app/services/polling.coffee index f4a3dd1c..1f83afdb 100644 --- a/app/services/polling.coffee +++ b/app/services/polling.coffee @@ -1,4 +1,5 @@ `import Ember from 'ember'` +`import config from 'travis/config/environment'` service = Ember.Service.extend pollingInterval: 30000 @@ -9,6 +10,8 @@ service = Ember.Service.extend @set('watchedModels', []) @set('sources', []) + return unless config.ajaxPolling + interval = setInterval => @poll() , @get('pollingInterval') @@ -18,7 +21,8 @@ service = Ember.Service.extend willDestroy: -> @_super.apply(this, arguments) - clearInterval(@get('interval')) + if interval = @get('interval') + clearInterval(interval) startPollingHook: (source) -> sources = @get('sources') diff --git a/config/environment.js b/config/environment.js index b7104478..abf706be 100644 --- a/config/environment.js +++ b/config/environment.js @@ -31,7 +31,8 @@ module.exports = function(environment) { endpoints: {}, intervals: { updateTimes: 1000 }, statusPageStatusUrl: 'https://pnpcptp8xh9k.statuspage.io/api/v2/status.json', - githubOrgsOauthAccessSettingsUrl: 'https://github.com/settings/connections/applications/f244293c729d5066cf27' + githubOrgsOauthAccessSettingsUrl: 'https://github.com/settings/connections/applications/f244293c729d5066cf27', + ajaxPolling: false }; if (typeof process !== 'undefined') { diff --git a/waiter/config.ru b/waiter/config.ru index b3fd44b5..9aaaf25b 100644 --- a/waiter/config.ru +++ b/waiter/config.ru @@ -71,5 +71,6 @@ run Travis::Web::App.build( code_climate: ENV['CODE_CLIMATE'], code_climate_url: ENV['CODE_CLIMATE_URL'], assets_host: ENV['ASSETS_HOST'], + ajax_polling: ENV['AJAX_POLLING'], github_orgs_oauth_access_settings_url: ENV['GITHUB_ORGS_OAUTH_ACCESS_SETTINGS_URL'] ) diff --git a/waiter/lib/travis/web/app.rb b/waiter/lib/travis/web/app.rb index c7a08323..46c1fb4c 100644 --- a/waiter/lib/travis/web/app.rb +++ b/waiter/lib/travis/web/app.rb @@ -199,6 +199,7 @@ class Travis::Web::App config['codeClimateUrl'] = options[:code_climate_url] if options[:code_climate_url] config['charmKey'] = options[:charm_key] if options[:charm_key] config['githubOrgsOauthAccessSettingsUrl'] = options[:github_orgs_oauth_access_settings_url] + config['ajaxPolling'] = true if options[:ajax_polling] config['endpoints'] = { 'sshKey' => options[:ssh_key_enabled],