travis-web/assets/scripts/app/controllers.coffee
Mathias Meyer b3fbb5f5cf Add setting for number of concurrent builds.
Includes a little rework of the settings page to fit in an input
field.
2014-06-16 15:45:03 +02:00

86 lines
2.7 KiB
CoffeeScript

require 'helpers'
Travis.Controller = Em.Controller.extend()
Travis.TopController = Em.Controller.extend
needs: ['currentUser']
userBinding: 'controllers.currentUser'
userName: (->
@get('user.name') || @get('user.login')
).property('user.login', 'user.name')
gravatarUrl: (->
"#{location.protocol}//www.gravatar.com/avatar/#{@get('user.gravatarId')}?s=48&d=mm"
).property('user.gravatarId')
signedIn: (->
Travis.get('authState') == 'signed-in'
).property('Travis.authState')
signedOut: (->
Travis.get('authState') == 'signed-out'
).property('Travis.authState')
signingIn: (->
Travis.get('authState') == 'signing-in'
).property('Travis.authState')
Travis.ApplicationController = Em.Controller.extend
templateName: 'layouts/home'
connectLayout: (name) ->
name = "layouts/#{name}"
if @get('templateName') != name
@set('templateName', name)
Travis.MainController = Em.Controller.extend()
Travis.StatsLayoutController = Em.Controller.extend()
Travis.ProfileLayoutController = Em.Controller.extend()
Travis.AuthLayoutController = Em.Controller.extend()
Travis.ProfileInfoController = Em.Controller.extend
needs: ['currentUser', 'repos']
userBinding: 'controllers.currentUser'
Travis.FirstSyncController = Em.Controller.extend
needs: ['currentUser']
user: Ember.computed.alias('controllers.currentUser')
isSyncing: Ember.computed.alias('user.isSyncing')
Travis.IndexErrorController = Em.Controller.extend()
Travis.RepoSettingsTabController = Em.ObjectController.extend()
Travis.RepoSettingsController = Em.ObjectController.extend
needs: ['repoSettingsTab']
tab: Ember.computed.alias('controllers.repoSettingsTab.model.tab')
settings: Ember.computed.alias('model.settings')
settingsChanged: (->
if parseInt(@get('settings.maximum_number_of_builds')) > 0
@get('model').saveSettings(@get('settings')).then null, ->
Travis.flash(error: 'There was an error while saving settings. Please try again.')
else
Travis.flash(error: 'The maximum number of concurrent builds needs to be a number greater than zero.')
).observes('settings.maximum_number_of_builds')
save: ->
@get('model').saveSettings(@get('settings')).then null, ->
Travis.flash(error: 'There was an error while saving settings. Please try again.')
require 'controllers/accounts'
require 'controllers/auth'
require 'controllers/account'
require 'controllers/build'
require 'controllers/builds'
require 'controllers/flash'
require 'controllers/home'
require 'controllers/job'
require 'controllers/profile'
require 'controllers/repos'
require 'controllers/repo'
require 'controllers/stats'
require 'controllers/current_user'
require 'controllers/request'
require 'controllers/requests'