Merge branch 'master' of github.com:travis-ci/travis-web
This commit is contained in:
commit
aa129f6e3b
|
@ -26,7 +26,7 @@ Travis.ReposController = Ember.ArrayController.extend
|
|||
@set('content', content)
|
||||
|
||||
viewOwned: ->
|
||||
@set('content', Travis.Repo.ownedBy(Travis.app.get('currentUser.login')))
|
||||
@set('content', Travis.Repo.accessibleBy(Travis.app.get('currentUser.login')))
|
||||
|
||||
viewSearch: (params) ->
|
||||
@set('content', Travis.Repo.search(params.search))
|
||||
|
|
|
@ -15,31 +15,12 @@ Travis.reopen
|
|||
groups = {}
|
||||
for worker in content.toArray()
|
||||
host = worker.get('host')
|
||||
groups[host] = Em.ArrayProxy.create(content: []) unless groups[host]
|
||||
groups[host].pushObject(worker)
|
||||
|
||||
prepareForSort = (str) ->
|
||||
match = str.match /(.*?)-(\d+)/
|
||||
name = match[1]
|
||||
id = match[2].toString()
|
||||
if id.length < 2
|
||||
id = "00#{id}"
|
||||
else if id.length < 3
|
||||
id = "0#{id}"
|
||||
|
||||
"#{name}-#{id}"
|
||||
|
||||
for own host, workers of groups
|
||||
groups[host] = workers.toArray().sort (a, b) ->
|
||||
a = prepareForSort a.get('name')
|
||||
b = prepareForSort b.get('name')
|
||||
|
||||
if a < b
|
||||
-1
|
||||
else if b < a
|
||||
1
|
||||
else
|
||||
0
|
||||
unless groups[host]
|
||||
groups[host] = Em.ArrayProxy.create(Em.SortableMixin,
|
||||
content: [],
|
||||
sortProperties: ['nameForSort']
|
||||
)
|
||||
groups[host].addObject(worker)
|
||||
|
||||
$.values(groups)
|
||||
).property('length')
|
||||
|
|
|
@ -31,5 +31,8 @@ Ember.registerBoundHelper 'formatConfig', (config, options) ->
|
|||
safe Travis.Helpers.formatConfig(config)
|
||||
|
||||
Ember.registerBoundHelper 'formatLog', (log, options) ->
|
||||
Travis.Helpers.formatLog(log) || ''
|
||||
parentView = @get 'parentView'
|
||||
repo = parentView.get(options.repo)
|
||||
item = parentView.get(options.item)
|
||||
Travis.Helpers.formatLog(log, repo, item) || ''
|
||||
|
||||
|
|
|
@ -31,8 +31,15 @@ require 'config/emoij'
|
|||
message = message.split(/\n/)[0] if options.short
|
||||
@_emojize(@_escape(message)).replace /\n/g, '<br/>'
|
||||
|
||||
formatLog: (log) ->
|
||||
Travis.Log.filter(log)
|
||||
formatLog: (log, repo, item) ->
|
||||
event = if item.constructor == Travis.Build
|
||||
'showBuild'
|
||||
else
|
||||
'showJob'
|
||||
|
||||
url = Travis.app.get('router').urlForEvent(event, repo, item)
|
||||
|
||||
Travis.Log.filter(log, url)
|
||||
|
||||
pathFrom: (url) ->
|
||||
(url || '').split('/').pop()
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'travis/model'
|
|||
|
||||
@Travis.Build = Travis.Model.extend Travis.DurationCalculations,
|
||||
eventType: DS.attr('string')
|
||||
repoId: DS.attr('number')
|
||||
repoId: DS.attr('number', key: 'repository_id')
|
||||
commitId: DS.attr('number')
|
||||
|
||||
state: DS.attr('string')
|
||||
|
@ -14,7 +14,7 @@ require 'travis/model'
|
|||
startedAt: DS.attr('string', key: 'started_at')
|
||||
finishedAt: DS.attr('string', key: 'finished_at')
|
||||
|
||||
repo: DS.belongsTo('Travis.Repo')
|
||||
repo: DS.belongsTo('Travis.Repo', key: 'repository_id')
|
||||
commit: DS.belongsTo('Travis.Commit')
|
||||
jobs: DS.hasMany('Travis.Job', key: 'job_ids')
|
||||
|
||||
|
|
|
@ -79,6 +79,9 @@ require 'travis/model'
|
|||
ownedBy: (login) ->
|
||||
@find(owner_name: login, orderBy: 'name')
|
||||
|
||||
accessibleBy: (login) ->
|
||||
@find(member: login, orderBy: 'name')
|
||||
|
||||
search: (query) ->
|
||||
@find(search: query, orderBy: 'name')
|
||||
|
||||
|
|
|
@ -29,3 +29,17 @@ require 'travis/model'
|
|||
job: (->
|
||||
Travis.Job.find @get('job_id')
|
||||
).property('job_id')
|
||||
|
||||
nameForSort: (->
|
||||
if name = @get('name')
|
||||
match = name.match /(.*?)-(\d+)/
|
||||
if match
|
||||
name = match[1]
|
||||
id = match[2].toString()
|
||||
if id.length < 2
|
||||
id = "00#{id}"
|
||||
else if id.length < 3
|
||||
id = "0#{id}"
|
||||
|
||||
"#{name}-#{id}"
|
||||
).property('name')
|
||||
|
|
|
@ -7,6 +7,9 @@ defaultRoute = Ember.Route.extend
|
|||
lineNumberRoute = Ember.Route.extend
|
||||
route: '#L:number'
|
||||
index: 1
|
||||
connectOutlets: (router) ->
|
||||
router.saveLineNumberHash()
|
||||
|
||||
routeMatcher: Ember.computed(->
|
||||
if route = @get 'route'
|
||||
Ember._RouteMatcher.create
|
||||
|
@ -127,6 +130,12 @@ Travis.Router = Ember.Router.extend
|
|||
showAccount: Ember.Route.transitionTo('root.profile.account')
|
||||
showUserProfile: Ember.Route.transitionTo('root.profile.account.profile')
|
||||
|
||||
saveLineNumberHash: (path) ->
|
||||
Ember.run.next this, ->
|
||||
path = path || @get('location').getURL()
|
||||
if match = path.match(/#L\d+$/)
|
||||
@set 'repoController.lineNumberHash', match[0]
|
||||
|
||||
reload: ->
|
||||
url = @get('location').getURL()
|
||||
@transitionTo 'loading'
|
||||
|
@ -143,8 +152,7 @@ Travis.Router = Ember.Router.extend
|
|||
|
||||
loading: Ember.Route.extend
|
||||
routePath: (router, path) ->
|
||||
if match = path.match(/#.*$/)
|
||||
router.set 'lineNumberHash', match[0]
|
||||
router.saveLineNumberHash(path)
|
||||
|
||||
sessionStorage.setItem('travis.path', path)
|
||||
if router.needsAuth(path)
|
||||
|
@ -348,16 +356,20 @@ Travis.Router = Ember.Router.extend
|
|||
# record.
|
||||
# TODO: find out why it happens
|
||||
build = Travis.Build.find params.build_id
|
||||
deferred = $.Deferred()
|
||||
|
||||
observer = ->
|
||||
if build.get 'id'
|
||||
build.removeObserver 'id', observer
|
||||
deferred.resolve build
|
||||
if build.get 'id'
|
||||
build
|
||||
else
|
||||
deferred = $.Deferred()
|
||||
|
||||
build.addObserver 'id', observer
|
||||
observer = ->
|
||||
if build.get 'id'
|
||||
build.removeObserver 'id', observer
|
||||
deferred.resolve build
|
||||
|
||||
deferred.promise()
|
||||
build.addObserver 'id', observer
|
||||
|
||||
deferred.promise()
|
||||
|
||||
# TODO: this is not dry, but for some weird
|
||||
# reason Mixins don't play nice with Ember.Route
|
||||
|
@ -394,14 +406,18 @@ Travis.Router = Ember.Router.extend
|
|||
|
||||
deserialize: (router, params) ->
|
||||
job = Travis.Job.find params.job_id
|
||||
deferred = $.Deferred()
|
||||
|
||||
observer = ->
|
||||
if job.get 'id'
|
||||
job.removeObserver 'id', observer
|
||||
deferred.resolve job
|
||||
job.addObserver 'id', observer
|
||||
deferred.promise()
|
||||
if job.get 'id'
|
||||
job
|
||||
else
|
||||
deferred = $.Deferred()
|
||||
|
||||
observer = ->
|
||||
if job.get 'id'
|
||||
job.removeObserver 'id', observer
|
||||
deferred.resolve job
|
||||
job.addObserver 'id', observer
|
||||
deferred.promise()
|
||||
|
||||
initialState: 'default'
|
||||
default: defaultRoute
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<td class="number">
|
||||
<span class="status"></span>
|
||||
{{#if id}}
|
||||
<a {{action showBuild this href=true}}>
|
||||
<a {{action showBuild repo this href=true}}>
|
||||
{{number}}
|
||||
</a>
|
||||
{{/if}}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<dd class="number">
|
||||
<span class="status"></span>
|
||||
{{#if build.id}}
|
||||
<a {{action showBuild build href=true}}>{{build.number}}</a>
|
||||
<a {{action showBuild repo build href=true}}>{{build.number}}</a>
|
||||
{{/if}}
|
||||
</dd>
|
||||
<dt class="finished_at_label">{{t builds.finished_at}}</dt>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<pre id="log" class="ansi"><a href="#" id="tail" {{action toggleTailing target="view"}}>
|
||||
<span class="status"></span>
|
||||
<label>Follow logs</label>
|
||||
</a>{{{formatLog log.body}}}</pre>
|
||||
</a>{{{formatLog log.body repo="repository" item="parentView.currentItem"}}}</pre>
|
||||
|
||||
{{#if sponsor.name}}
|
||||
<p class="sponsor">
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<li id="tab_build" {{bindAttr class="view.classBuild"}}>
|
||||
<h5>
|
||||
{{#if view.build.id}}
|
||||
<a {{action showBuild view.build href=true}}>
|
||||
<a {{action showBuild view.repo view.build href=true}}>
|
||||
{{t repositories.tabs.build}} #{{view.build.number}}
|
||||
</a>
|
||||
{{/if}}
|
||||
|
@ -47,7 +47,7 @@
|
|||
<li id="tab_job" {{bindAttr class="view.classJob"}}>
|
||||
<h5>
|
||||
{{#if view.job.id}}
|
||||
<a {{action showBuild view.job href=true}}>
|
||||
<a {{action showJob view.repo view.job href=true}}>
|
||||
{{t repositories.tabs.job}} #{{view.job.number}}
|
||||
</a>
|
||||
{{/if}}
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
buildBinding: 'controller.build'
|
||||
commitBinding: 'build.commit'
|
||||
|
||||
currentItemBinding: 'build'
|
||||
|
||||
loading: (->
|
||||
!@get('build.isLoaded')
|
||||
).property('build.isLoaded')
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
jobBinding: 'controller.job'
|
||||
commitBinding: 'job.commit'
|
||||
|
||||
currentItemBinding: 'job'
|
||||
|
||||
color: (->
|
||||
Travis.Helpers.colorForResult(@get('job.result'))
|
||||
).property('job.result')
|
||||
|
@ -50,12 +52,14 @@
|
|||
|
||||
scrollTo: (hash) ->
|
||||
$('body').scrollTop $(hash).offset().top
|
||||
Travis.app.router.set 'lineNumberHash', null
|
||||
@set 'controller.lineNumberHash', null
|
||||
|
||||
didInsertElement: ->
|
||||
@_super.apply this, arguments
|
||||
lineNumberHashDidChange: (->
|
||||
@tryScrollingToHashLineNumber()
|
||||
).observes('controller.lineNumberHash')
|
||||
|
||||
if hash = Travis.app.router.get 'lineNumberHash'
|
||||
tryScrollingToHashLineNumber: ->
|
||||
if hash = @get 'controller.lineNumberHash'
|
||||
self = this
|
||||
|
||||
checker = ->
|
||||
|
@ -68,8 +72,21 @@
|
|||
|
||||
checker()
|
||||
|
||||
didInsertElement: ->
|
||||
@_super.apply this, arguments
|
||||
|
||||
@tryScrollingToHashLineNumber()
|
||||
|
||||
click: (event) ->
|
||||
$(event.target).closest('.fold').toggleClass('open')
|
||||
target = $(event.target)
|
||||
|
||||
target.closest('.fold').toggleClass('open')
|
||||
|
||||
if target.is('.log-line-number')
|
||||
path = target.attr 'href'
|
||||
Travis.app.get('router').route(path)
|
||||
event.stopPropagation()
|
||||
return false
|
||||
|
||||
toTop: () ->
|
||||
$(window).scrollTop(0)
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
bundle: /(<p.*?\/a>\$ bundle install.*<\/p>\n(<p.*?\/a>(Updating|Using|Installing|Fetching|remote:|Receiving|Resolving).*?<\/p>\n|<p.*?\/a><\/p>\n)*)/g
|
||||
exec: /(<p.*?\/a>[\/\w]*.rvm\/rubies\/[\S]*?\/(ruby|rbx|jruby) .*?<\/p>)/g
|
||||
|
||||
filter: (log) ->
|
||||
filter: (log, path) ->
|
||||
log = @escape(log)
|
||||
log = @deansi(log)
|
||||
log = log.replace(/\r/g, '')
|
||||
log = @number(log)
|
||||
log = @number(log, path)
|
||||
log = @fold(log)
|
||||
log = log.replace(/\n/g, '')
|
||||
log
|
||||
|
@ -23,12 +23,13 @@
|
|||
escapeRuby: (log) ->
|
||||
log.replace /#<(\w+.*?)>/, '#<$1>'
|
||||
|
||||
number: (log) ->
|
||||
number: (log, path) ->
|
||||
path = "#{path}/"
|
||||
result = ''
|
||||
$.each log.trim().split('\n'), (ix, line) ->
|
||||
number = ix + 1
|
||||
path = Travis.Log.location().substr(1).replace(/L\d+/, '') + 'L' + number
|
||||
result += '<p><a href=\'#%@\' id=\'%@\' name=\'L%@\'>%@</a>%@</p>\n'.fmt(path, path, number, number, line)
|
||||
pathWithNumber = "#{path}#L#{number}"
|
||||
result += '<p><a href="%@" id="L%@" class="log-line-number" name="L%@">%@</a>%@</p>\n'.fmt(pathWithNumber, number, number, number, line)
|
||||
result.trim()
|
||||
|
||||
deansi: (log) ->
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
f480d531
|
||||
82ce45cb
|
Loading…
Reference in New Issue
Block a user