show notifications even when no async

This commit is contained in:
Radek Stepan 2014-10-27 20:50:24 -06:00
parent 391adb5388
commit 2177cc5087
4 changed files with 69 additions and 49 deletions

View File

@ -1,6 +1,7 @@
#Tasks to do
- [ ] success/warn topbar on milestone page is only shown if we async load data
- [*] success/warn topbar on milestone page is only shown if we async load data
- [ ] why didn't Reset DB load demo data? (Ryan)
- [ ] create notes about how original people can upgrade to burnchart
- [ ] clean up docs, track them on git or using Assembly system?
- [ ] rename repo to burnchart
@ -16,7 +17,6 @@
- [ ] https://github.com/medic/medic-webapp project is overdue and trendline & ideal line end on that date; should max on that date or today's date
- [ ] http://burnchart.io#rails I would expect it to list all the projects for that owner so I can select one of them (Ryan)
- [ ] why didn't Reset DB load demo data? (Ryan)
##Backlog

View File

@ -24,11 +24,16 @@ module.exports = Ractive.extend
'adapt': [ Ractive.adaptors.Ractive ]
cb: ->
@set 'ready', yes
onrender: ->
document.title = 'Burnchart: GitHub Burndown Chart as a Service'
# Quit if we have no projects.
return @set('ready', yes) unless projects.list.length
return do @cb unless projects.list.length
# ---
done = do system.async
@ -69,4 +74,4 @@ module.exports = Ractive.extend
, =>
do done
@set 'ready', yes
do @cb

View File

@ -22,6 +22,40 @@ module.exports = Eventful.extend
'format': format
'ready': no
# Callback when we have data.
cb: (err, data) ->
return @publish '!app/notify', {
'text': do err.toString
'type': 'alert'
'system': yes
'ttl': null
} if err
# No issues?
return @publish '!app/notify', {
'text': 'The milestone has no issues'
'type': 'warn'
'system': yes
'ttl': null
} if data.stats.isEmpty
# Done?
@publish '!app/notify', {
'text': 'The milestone is complete'
'type': 'success'
} if data.stats.isDone
# Overdue?
@publish '!app/notify', {
'text': 'The milestone is overdue'
'type': 'warn'
} if data.stats.isOverdue
# Show the page.
@set
'milestone': data
'ready': yes
onrender: ->
[ owner, name, milestone ] = @get 'route'
@ -33,11 +67,13 @@ module.exports = Eventful.extend
project = projects.find { owner, name }
# Should not happen...
throw 500 unless project
return @cb 'Project not found' unless project
# Do we have this milestone already?
obj = _.find project.milestones, { 'number': milestone }
return @set { 'milestone': obj, 'ready': yes } if obj?
data = _.find project.milestones, { 'number': milestone }
return @cb null, data if data?
# ---
# We are loading the milestones then.
done = do system.async
@ -56,37 +92,9 @@ module.exports = Eventful.extend
fetchIssues
], (err, data) =>
do done
return @publish '!app/notify', {
'text': do err.toString
'type': 'alert'
'system': yes
'ttl': null
} if err
# Save the milestone with issues.
projects.addMilestone project, data
# No issues?
return @publish '!app/notify', {
'text': 'The milestone has no issues'
'type': 'warn'
'system': yes
'ttl': null
} if data.stats.isEmpty
projects.addMilestone project, data unless err
# Done?
@publish '!app/notify', {
'text': 'The milestone is complete'
'type': 'success'
} if data.stats.isDone
# Overdue?
@publish '!app/notify', {
'text': 'The milestone is overdue'
'type': 'warn'
} if data.stats.isOverdue
# Show the page.
@set
'milestone': data
'ready': yes
# Pass to callback.
@cb.apply @, arguments

View File

@ -21,6 +21,17 @@ module.exports = Eventful.extend
'projects': projects
'ready': no
cb: (err) ->
return @publish '!app/notify', {
'text': do err.toString
'type': 'alert'
'system': yes
'ttl': null
} if err
# Say we are ready.
@set 'ready', yes
onrender: ->
[ owner, name ] = @get 'route'
@ -30,7 +41,9 @@ module.exports = Eventful.extend
@set 'project', project = projects.find { owner, name }
# Should not happen...
throw 500 unless project
return @cb 'Project not found' unless project
# ---
# We don't know if we have all milestones, so fetch them.
done = do system.async
@ -64,12 +77,6 @@ module.exports = Eventful.extend
fetchIssues
], (err) =>
do done
return @publish '!app/notify', {
'text': do err.toString
'type': 'alert'
'system': yes
'ttl': null
} if err
# Say we are ready.
@set 'ready', yes
# Pass to callback.
@cb.apply @, arguments