diff --git a/assets/scripts/app/models/build.coffee b/assets/scripts/app/models/build.coffee index 438a1771..fd37e623 100644 --- a/assets/scripts/app/models/build.coffee +++ b/assets/scripts/app/models/build.coffee @@ -14,9 +14,9 @@ require 'travis/model' startedAt: DS.attr('string', key: 'started_at') finishedAt: DS.attr('string', key: 'finished_at') - repo: DS.belongsTo('Travis.Repo', key: 'repository_id') - commit: DS.belongsTo('Travis.Commit') - jobs: DS.hasMany('Travis.Job', key: 'job_ids') + repo: DS.belongsTo('Travis.Repo', key: 'repository_id') + commit: DS.belongsTo('Travis.Commit') + jobs: DS.hasMany('Travis.Job', key: 'job_ids') config: (-> Travis.Helpers.compact(@get('data.config')) @@ -49,6 +49,14 @@ require 'travis/model' $.map(headers.concat(keys), (key) -> return $.camelize(key)) ).property('config') + canCancel: (-> + @get('state') == 'created' # TODO + ).property('state') + + cancel: (-> + Travis.ajax.post "/builds/#{@get('id')}", _method: 'delete' + ) + requeue: -> Travis.ajax.post '/requests', build_id: @get('id') diff --git a/assets/scripts/app/models/job.coffee b/assets/scripts/app/models/job.coffee index 613e4d84..349e3ff2 100644 --- a/assets/scripts/app/models/job.coffee +++ b/assets/scripts/app/models/job.coffee @@ -15,11 +15,10 @@ require 'travis/model' allowFailure: DS.attr('boolean', key: 'allow_failure') repositorySlug: DS.attr('string') - - repo: DS.belongsTo('Travis.Repo', key: 'repository_id') - build: DS.belongsTo('Travis.Build', key: 'build_id') - commit: DS.belongsTo('Travis.Commit', key: 'commit_id') - log: DS.belongsTo('Travis.Artifact', key: 'log_id') + repo: DS.belongsTo('Travis.Repo', key: 'repository_id') + build: DS.belongsTo('Travis.Build', key: 'build_id') + commit: DS.belongsTo('Travis.Commit', key: 'commit_id') + log: DS.belongsTo('Travis.Artifact', key: 'log_id') repoSlug: (-> @get('repositorySlug') @@ -59,6 +58,14 @@ require 'travis/model' [] ).property('config') + canCancel: (-> + @get('state') == 'created' || @get('state') == 'queued' # TODO + ).property('state') + + cancel: (-> + Travis.ajax.post "/jobs/#{@get('id')}", _method: 'delete' + ) + requeue: -> Travis.ajax.post '/requests', job_id: @get('id') diff --git a/assets/scripts/app/templates/repos/show/tools.hbs b/assets/scripts/app/templates/repos/show/tools.hbs index cd8ea082..e2441476 100644 --- a/assets/scripts/app/templates/repos/show/tools.hbs +++ b/assets/scripts/app/templates/repos/show/tools.hbs @@ -4,6 +4,16 @@