Use /jobs/:id/log.txt endpoint for fetching logs

This commit is contained in:
Piotr Sarnacki 2013-01-27 02:46:18 +01:00
parent e9092418a7
commit 5fbf153ed9
5 changed files with 21 additions and 7 deletions

View File

@ -1,10 +1,15 @@
require 'travis/model'
@Travis.Artifact = Travis.Model.extend
@Travis.Artifact = Em.Object.extend
version: 1 # used to refresh log on requeue
body: DS.attr('string')
body: null
isLoaded: false
init: ->
@_super.apply this, arguments
@fetchBody()
@set 'queue', Ember.A([])
@set 'parts', Ember.ArrayProxy.create(content: [])
@ -15,6 +20,14 @@ require 'travis/model'
@set('body', '')
@incrementProperty('version')
fetchBody: ->
self = this
Travis.ajax.ajax "/jobs/#{@get('job.id')}/log.txt", 'GET',
dataType: 'text'
success: (data) ->
self.set 'body', data
self.set 'isLoaded', true
append: (body) ->
if @get('isInitialized')
@get('parts').pushObject body

View File

@ -17,7 +17,9 @@ require 'travis/model'
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')
log: ( ->
Travis.Artifact.create(job: this)
).property()
repoSlug: (->
@get('repositorySlug')

View File

@ -71,6 +71,7 @@ Travis.Store = DS.Store.extend
!!@typeMapFor(type).idToCid[id]
receive: (event, data) ->
console.log event, data
[name, type] = event.split(':')
mappings = @adapter.get('mappings')

View File

@ -4,9 +4,7 @@
{{! this #with + #if is needed because I want to rerender 'pre' when log changes to properly clean it up,
this should probably be refactored to use container view}}
{{#with view.job.log}}
{{#if id}}
{{view Travis.PreView logBinding="view.context.log" logUrlBinding="view.logUrl"}}
{{/if}}
{{/with}}
{{#if sponsor.name}}

View File

@ -21,7 +21,7 @@ jQuery.support.cors = true
options.url = "#{endpoint}#{url}"
options.type = method
options.dataType = 'json'
options.dataType = options.dataType || 'json'
options.contentType = 'application/json; charset=utf-8'
options.context = this