make last 5 builds work
This commit is contained in:
parent
6d0067bdb0
commit
5326821990
|
@ -9,7 +9,7 @@ BranchRowComponent = Ember.Component.extend
|
||||||
tagName: 'li'
|
tagName: 'li'
|
||||||
classNameBindings: ['build.last_build.state']
|
classNameBindings: ['build.last_build.state']
|
||||||
classNames: ['branch-row']
|
classNames: ['branch-row']
|
||||||
isLoading: true
|
isLoading: false
|
||||||
|
|
||||||
urlGithubCommit: (->
|
urlGithubCommit: (->
|
||||||
githubCommitUrl(@get('build.repository.slug'), @get('build.last_build.commit.sha'))
|
githubCommitUrl(@get('build.repository.slug'), @get('build.last_build.commit.sha'))
|
||||||
|
@ -17,25 +17,37 @@ BranchRowComponent = Ember.Component.extend
|
||||||
|
|
||||||
getLast5Builds: (->
|
getLast5Builds: (->
|
||||||
|
|
||||||
array = [{}, {}, {}, {}, {}]
|
lastBuilds = Ember.ArrayProxy.create(
|
||||||
|
content: [{}, {}, {}, {}, {}]
|
||||||
|
isLoading: true,
|
||||||
|
count: 0
|
||||||
|
)
|
||||||
|
|
||||||
if @get('build.last_build') == null
|
if !@get('build.last_build')
|
||||||
@set('isLoading', false)
|
lastBuilds.set('isLoading', false)
|
||||||
array
|
|
||||||
else
|
else
|
||||||
array
|
apiEndpoint = config.apiEndpoint
|
||||||
|
repoId = @get('build.repository.id')
|
||||||
|
branchName = @get('build.name')
|
||||||
|
|
||||||
# apiEndpoint = config.apiEndpoint
|
options = {}
|
||||||
# repoId = @get('build.repository.id')
|
if @get('auth.signedIn')
|
||||||
|
options.headers = { Authorization: "token #{@auth.token()}" }
|
||||||
|
|
||||||
# options = {}
|
$.ajax("#{apiEndpoint}/v3/repo/#{repoId}/builds?branch.name=#{branchName}&limit=5&offset=1", options).then (response) ->
|
||||||
# if @get('auth.signedIn')
|
array = response.builds.map( (build) ->
|
||||||
# options.headers = { Authorization: "token #{@auth.token()}" }
|
Ember.Object.create(build)
|
||||||
|
)
|
||||||
|
if array.length < 5
|
||||||
|
for i in [1..5 - array.length] by 1
|
||||||
|
array.push({})
|
||||||
|
|
||||||
# $.ajax("#{apiEndpoint}/v3/repo/269284/builds?branch.name=master&limit=5", options).then (response) ->
|
lastBuilds.set('count', response['@pagination'].count)
|
||||||
# console.log(response)
|
lastBuilds.set('content', array)
|
||||||
# @set('isLoading', false)
|
lastBuilds.set('isLoading', false)
|
||||||
).property('build')
|
|
||||||
|
lastBuilds
|
||||||
|
).property()
|
||||||
|
|
||||||
actions:
|
actions:
|
||||||
tiggerBuild: (branch) ->
|
tiggerBuild: (branch) ->
|
||||||
|
|
|
@ -4,22 +4,25 @@ RequestIconComponent = Ember.Component.extend
|
||||||
|
|
||||||
tagName: 'span'
|
tagName: 'span'
|
||||||
classNames: ['icon-request']
|
classNames: ['icon-request']
|
||||||
classNameBindings: ['build.last_build.state']
|
classNameBindings: ['build.last_build.state', 'build.state']
|
||||||
|
|
||||||
isPush: (->
|
isPush: (->
|
||||||
@get('build.last_build.event_type') == 'push'
|
@get('build.last_build.event_type') == 'push' ||
|
||||||
|
@get('build.event_type') == 'push'
|
||||||
).property('build.last_build')
|
).property('build.last_build')
|
||||||
|
|
||||||
isPR: (->
|
isPR: (->
|
||||||
@get('build.last_build.event_type') == 'pull_request'
|
@get('build.last_build.event_type') == 'pull_request' ||
|
||||||
|
@get('build.event_type') == 'pull_request'
|
||||||
).property('build.last_build')
|
).property('build.last_build')
|
||||||
|
|
||||||
isAPI: (->
|
isAPI: (->
|
||||||
@get('build.last_build.event_type') == 'api'
|
@get('build.last_build.event_type') == 'api' ||
|
||||||
|
@get('build.event_type') == 'api'
|
||||||
).property('build.last_build')
|
).property('build.last_build')
|
||||||
|
|
||||||
isEmpty: (->
|
isEmpty: (->
|
||||||
true if @get('build.last_build') == null
|
true if @get('build.last_build') == null || @get('build') == null
|
||||||
).property('build.last_build')
|
).property('build.last_build')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,31 +7,44 @@ StatusIconComponent = Ember.Component.extend
|
||||||
classNameBindings: ['build.last_build.state']
|
classNameBindings: ['build.last_build.state']
|
||||||
|
|
||||||
hasPassed: (->
|
hasPassed: (->
|
||||||
@get('build.last_build.state') == 'passed'
|
@get('build.last_build.state') == 'passed' ||
|
||||||
).property('build.last_build.state')
|
@get('build.state') == 'passed'
|
||||||
|
).property('build')
|
||||||
|
|
||||||
hasFailed: (->
|
hasFailed: (->
|
||||||
@get('build.last_build.state') == 'failed'
|
@get('build.last_build.state') == 'failed' ||
|
||||||
).property('build.last_build.state')
|
@get('build.state') == 'failed'
|
||||||
|
).property('build')
|
||||||
|
|
||||||
hasErrored: (->
|
hasErrored: (->
|
||||||
@get('build.last_build.state') == 'errored'
|
@get('build.last_build.state') == 'errored' ||
|
||||||
).property('build.last_build.state')
|
@get('build.state') == 'errored'
|
||||||
|
).property('build')
|
||||||
|
|
||||||
wasCanceled: (->
|
wasCanceled: (->
|
||||||
@get('build.last_build.state') == 'canceled'
|
@get('build.last_build.state') == 'canceled' ||
|
||||||
).property('build.last_build.state')
|
@get('build.state') == 'canceled'
|
||||||
|
).property('build')
|
||||||
|
|
||||||
isRunning: (->
|
isRunning: (->
|
||||||
@get('build.last_build.state') == 'started' ||
|
@get('build.last_build.state') == 'started' ||
|
||||||
@get('build.last_build.state') == 'queued' ||
|
@get('build.last_build.state') == 'queued' ||
|
||||||
@get('build.last_build.state') == 'booting' ||
|
@get('build.last_build.state') == 'booting' ||
|
||||||
@get('build.last_build.state') == 'received' ||
|
@get('build.last_build.state') == 'received' ||
|
||||||
@get('build.last_build.state') == 'created'
|
@get('build.last_build.state') == 'created' ||
|
||||||
).property('build.last_build.state')
|
@get('build.state') == 'started' ||
|
||||||
|
@get('build.state') == 'queued' ||
|
||||||
|
@get('build.state') == 'booting' ||
|
||||||
|
@get('build.state') == 'received' ||
|
||||||
|
@get('build.state') == 'created'
|
||||||
|
).property('build')
|
||||||
|
|
||||||
isEmpty: (->
|
isEmpty: (->
|
||||||
true if @get('build.last_build') == null
|
if @get('build.@type') == 'branch'
|
||||||
).property('build.last_build')
|
true if @get('build.last_build.state') == null
|
||||||
|
else if @get('build.@type') == 'build'
|
||||||
|
false if @get('build.state') != ''
|
||||||
|
|
||||||
|
).property('build')
|
||||||
|
|
||||||
`export default StatusIconComponent`
|
`export default StatusIconComponent`
|
||||||
|
|
|
@ -14,6 +14,9 @@ BranchesController = Ember.Controller.extend
|
||||||
repos = @get('model')
|
repos = @get('model')
|
||||||
repos = repos.filter (item, index) ->
|
repos = repos.filter (item, index) ->
|
||||||
item if item.exists_on_github == true
|
item if item.exists_on_github == true
|
||||||
|
.sort (a, b) ->
|
||||||
|
return 0
|
||||||
|
|
||||||
).property('model')
|
).property('model')
|
||||||
|
|
||||||
inactiveBranches: (->
|
inactiveBranches: (->
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
display: inline-block
|
display: inline-block
|
||||||
height: 100%
|
height: 100%
|
||||||
width: 18.8%
|
width: 18.8%
|
||||||
|
background-color: #F7F7F7
|
||||||
.status-icon
|
.status-icon
|
||||||
position: absolute
|
position: absolute
|
||||||
top: 0
|
top: 0
|
||||||
|
@ -36,7 +37,7 @@
|
||||||
left: 0
|
left: 0
|
||||||
width: 2rem
|
width: 2rem
|
||||||
height: 2rem
|
height: 2rem
|
||||||
margin: auto
|
margin: auto !important
|
||||||
background-color: transparent
|
background-color: transparent
|
||||||
.is-rotating
|
.is-rotating
|
||||||
width: 100%
|
width: 100%
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
color: $grey-dark
|
color: $grey-dark
|
||||||
background: linear-gradient(to right, #CACECE 0%, #CACECE 9px, white 10px, white 100%) no-repeat
|
background: linear-gradient(to right, #CACECE 0%, #CACECE 9px, white 10px, white 100%) no-repeat
|
||||||
|
|
||||||
span
|
span[class*="icon"]
|
||||||
width: 1.3em
|
width: 1.3em
|
||||||
height: 1.3em
|
height: 1.3em
|
||||||
margin-right: .2em
|
margin-right: .2em
|
||||||
|
|
|
@ -6,27 +6,27 @@
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
{{#if activeBranches}}
|
||||||
<h2 class="small-title">Active Branches</h2>
|
<section>
|
||||||
<ul class="blank-list">
|
<h2 class="small-title">Active Branches</h2>
|
||||||
{{#each branch in activeBranches}}
|
<ul class="blank-list">
|
||||||
{{branch-row build=branch}}
|
{{#each branch in activeBranches}}
|
||||||
{{else}}
|
{{branch-row build=branch}}
|
||||||
<li>There are no active branches</li>
|
{{/each}}
|
||||||
{{/each}}
|
</ul>
|
||||||
</ul>
|
</section>
|
||||||
</section>
|
{{/if}}
|
||||||
|
|
||||||
<section>
|
{{#if inactiveBranches}}
|
||||||
<h2 class="small-title">Inactive Branches</h2>
|
<section>
|
||||||
<ul class="blank-list">
|
<h2 class="small-title">Inactive Branches</h2>
|
||||||
{{#each branch in inactiveBranches}}
|
<ul class="blank-list">
|
||||||
{{branch-row build=branch}}
|
{{#each branch in inactiveBranches}}
|
||||||
{{else}}
|
{{branch-row build=branch}}
|
||||||
<li>There are no inactive branches</li>
|
{{/each}}
|
||||||
{{/each}}
|
</ul>
|
||||||
</ul>
|
</section>
|
||||||
</section>
|
{{/if}}
|
||||||
|
|
||||||
|
|
||||||
{{!-- {{#if content.isLoaded}} --}}
|
{{!-- {{#if content.isLoaded}} --}}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<h2 class="row-item">{{status-icon build=build}}{{build.name}}</h2>
|
<h2 class="row-item">{{status-icon build=build}}{{build.name}}</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="branch-builds">
|
<div class="branch-builds">
|
||||||
<div class="row-item"><a href="#">
|
<div class="row-item">
|
||||||
<span class="icon-line-build">
|
<span class="icon-line-build">
|
||||||
<svg x="0px" y="0px" viewBox="0 0 20 20" xml:space="preserve" enable-background="new 0 0 20 20">
|
<svg x="0px" y="0px" viewBox="0 0 20 20" xml:space="preserve" enable-background="new 0 0 20 20">
|
||||||
<g id="Build">
|
<g id="Build">
|
||||||
|
@ -20,11 +20,15 @@
|
||||||
</g>
|
</g>
|
||||||
</svg></span>
|
</svg></span>
|
||||||
{{#if build.last_build}}
|
{{#if build.last_build}}
|
||||||
~ builds
|
{{#if getLast5Builds.isLoading}}
|
||||||
|
{{loading-indicator inline=true}}
|
||||||
|
{{else}}
|
||||||
|
{{getLast5Builds.count}} builds
|
||||||
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
0 builds
|
0 builds
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</a></div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="two-line">
|
<div class="two-line">
|
||||||
|
@ -42,7 +46,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="branch-calendar">
|
<div class="branch-calendar">
|
||||||
<div class="row-item" title="{{pretty-date build.last_build.finished_at}}">
|
<div class="row-item" title="{{pretty-date build.last_build.finished_at}}">
|
||||||
<span class="">
|
<span class="icon">
|
||||||
<svg viewBox="0 0 20 20">
|
<svg viewBox="0 0 20 20">
|
||||||
<g id="Cal">
|
<g id="Cal">
|
||||||
<path fill="#A7AEAE" d="M16.7,2.5H3.3C3,2.5,2.8,2.7,2.8,3V17c0,0.3,0.2,0.5,0.5,0.5h13.4c0.3,0,0.5-0.2,0.5-0.5V3
|
<path fill="#A7AEAE" d="M16.7,2.5H3.3C3,2.5,2.8,2.7,2.8,3V17c0,0.3,0.2,0.5,0.5,0.5h13.4c0.3,0,0.5-0.2,0.5-0.5V3
|
||||||
|
@ -70,7 +74,7 @@
|
||||||
<div class="branch-commit">
|
<div class="branch-commit">
|
||||||
<div class="row-item">
|
<div class="row-item">
|
||||||
<a href="{{urlGithubCommit}}" title="commit on GitHub">
|
<a href="{{urlGithubCommit}}" title="commit on GitHub">
|
||||||
<span class="">
|
<span class="icon">
|
||||||
<svg x="0px" y="0px" viewBox="2 0 20 20" xml:space="preserve">
|
<svg x="0px" y="0px" viewBox="2 0 20 20" xml:space="preserve">
|
||||||
<g id="Commit">
|
<g id="Commit">
|
||||||
<path fill="#A7AEAE" d="M7.8,17.5c-0.3,0-0.5-0.2-0.5-0.5l0-1c-0.4,0-1,0.1-1.4-0.1c-0.4-0.1-1.3-0.5-1.8-1.7
|
<path fill="#A7AEAE" d="M7.8,17.5c-0.3,0-0.5-0.2-0.5-0.5l0-1c-0.4,0-1,0.1-1.4-0.1c-0.4-0.1-1.3-0.5-1.8-1.7
|
||||||
|
@ -163,8 +167,12 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="one-line">
|
<div class="one-line">
|
||||||
<ul class="build-tiles">
|
<ul class="build-tiles">
|
||||||
{{#each buildTile in getLast5Builds}}
|
{{#if getLast5Builds.isLoading}}
|
||||||
|
{{loading-indicator center=true}}
|
||||||
|
{{else}}
|
||||||
|
{{#each buildTile in getLast5Builds.content}}
|
||||||
{{build-tile build=buildTile}}
|
{{build-tile build=buildTile}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
{{/if}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
{{#unless build}}
|
{{#if build.number}}
|
||||||
<a href="#" class="dropup-trigger">
|
{{#link-to "build" build.repository.slug build.id class="dropup-trigger"}}
|
||||||
{{status-icon build=build}}
|
{{status-icon build=build}}
|
||||||
<div class="dropup--status">
|
<div class="dropup--status">
|
||||||
{{request-icon build=build}} #{{build.number}}
|
{{request-icon build=build}} #{{build.number}}
|
||||||
</div>
|
</div>
|
||||||
</a>
|
{{/link-to}}
|
||||||
{{/unless}}
|
{{/if}}
|
Loading…
Reference in New Issue
Block a user