add broadcasts
This commit is contained in:
parent
03595db5fa
commit
90fb2c3b78
|
@ -1,8 +1,38 @@
|
|||
Travis.FlashController = Ember.ArrayController.extend
|
||||
broadcastBinding: 'Travis.app.currentUser.broadcasts'
|
||||
|
||||
init: ->
|
||||
@_super.apply this, arguments
|
||||
@set('content', Ember.A())
|
||||
|
||||
pushObjects: (objects) ->
|
||||
Ember.run.later(this, (-> @removeObjects(objects)), 10000)
|
||||
@_super(objects)
|
||||
broadcasts: (->
|
||||
Travis.Broadcast.find() if Travis.app.get('currentUser')
|
||||
).property('Travis.app.currentUser')
|
||||
|
||||
broadcastsObserver: (->
|
||||
if broadcasts = @get('broadcasts')
|
||||
broadcasts.forEach (msg) => @pushObject(msg.toObject()) unless @isSeenBroadcast(msg)
|
||||
).observes('broadcasts.length')
|
||||
|
||||
loadFlashes: (msgs) ->
|
||||
for msg in msgs
|
||||
type = Ember.keys(msg)[0]
|
||||
msg = { type: type, message: msg[type] }
|
||||
@pushObject(msg)
|
||||
Ember.run.later(this, (-> @removeObject(msg)), 15000)
|
||||
|
||||
close: (msg) ->
|
||||
@storeSeenBroadcast(msg) if msg.type == 'broadcast'
|
||||
@removeObject(msg)
|
||||
|
||||
isSeenBroadcast: (msg) ->
|
||||
msg.get('id') in @seenBroadcasts()
|
||||
|
||||
seenBroadcasts: ->
|
||||
seen = localStorage.getItem('travis.seen_broadcasts')
|
||||
if seen then JSON.parse(seen) else []
|
||||
|
||||
storeSeenBroadcast: (msg) ->
|
||||
seen = @seenBroadcasts()
|
||||
seen.push(msg.id)
|
||||
localStorage.setItem('travis.seen_broadcasts', JSON.stringify(seen))
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
require 'models/extensions'
|
||||
require 'models/account'
|
||||
require 'models/artifact'
|
||||
require 'models/broadcast'
|
||||
require 'models/branch'
|
||||
require 'models/build'
|
||||
require 'models/commit'
|
||||
|
|
11
assets/scripts/app/models/broadcast.coffee
Normal file
11
assets/scripts/app/models/broadcast.coffee
Normal file
|
@ -0,0 +1,11 @@
|
|||
require 'travis/model'
|
||||
|
||||
@Travis.Broadcast = Travis.Model.extend
|
||||
message: DS.attr('string')
|
||||
|
||||
toObject: ->
|
||||
{ type: 'broadcast', id: @get('id'), message: @get('message') }
|
||||
|
||||
@Travis.Broadcast.reopenClass
|
||||
# TODO fix or monkey-patch the adapter's url and key lookup/generation crap
|
||||
# url: 'users/broadcasts'
|
|
@ -3,6 +3,7 @@ require 'models'
|
|||
|
||||
@Travis.RestAdapter = DS.RESTAdapter.extend
|
||||
mappings:
|
||||
broadcasts: Travis.Broadcast
|
||||
repositories: Travis.Repo
|
||||
repository: Travis.Repo
|
||||
repos: Travis.Repo
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{#each flash in controller}}
|
||||
{{#view Travis.FlashItemView flashBinding="flash"}}
|
||||
<p>{{view.message}}</p>
|
||||
<p>{{{flash.message}}}</p>
|
||||
<a class="close" {{action close target="view"}}></a>
|
||||
{{/view}}
|
||||
{{/each}}
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
templateName: 'application'
|
||||
classNames: ['application']
|
||||
|
||||
popup: (event) ->
|
||||
console.log event
|
||||
# popup: (event) ->
|
||||
# console.log event
|
||||
|
||||
localeDidChange: (->
|
||||
if locale = Travis.app.get('auth.user.locale')
|
||||
Travis.setLocale(locale)
|
||||
|
|
|
@ -6,15 +6,7 @@
|
|||
|
||||
FlashItemView: Travis.View.extend
|
||||
tagName: 'li'
|
||||
classNameBindings: ['type']
|
||||
|
||||
type: (->
|
||||
@get('flash') && Ember.keys(@get('flash'))[0]
|
||||
).property('flash')
|
||||
|
||||
message: (->
|
||||
@get('flash') && @get('flash')[@get('type')]
|
||||
).property('flash')
|
||||
classNameBindings: ['flash.type']
|
||||
|
||||
close: (event) ->
|
||||
@get('controller').removeObject(@get('flash'))
|
||||
@get('controller').close(@get('flash'))
|
||||
|
|
|
@ -30,7 +30,7 @@ jQuery.support.cors = true
|
|||
|
||||
success = options.success || (->)
|
||||
options.success = (data) =>
|
||||
Travis.app.router.flashController.pushObjects(data.flash) if Travis.app?.router && data.flash
|
||||
Travis.app.router.flashController.loadFlashes(data.flash) if Travis.app?.router && data.flash
|
||||
delete data.flash
|
||||
success.call(this, data)
|
||||
|
||||
|
|
|
@ -103,6 +103,11 @@ $color-bg-list-info: $yellow-light-2
|
|||
$color-text-list-info: $slate-yellow-1
|
||||
$color-shadow-list-info: $slate-yellow-2
|
||||
|
||||
$color-bg-flash-success: #ebfcc2
|
||||
$color-bg-flash-notice: lightGoldenrodYellow
|
||||
$color-bg-flash-error: #f5d7d3
|
||||
$color-bg-flash-broadcast: #efefef
|
||||
|
||||
|
||||
#colors
|
||||
.black
|
||||
|
|
|
@ -11,14 +11,20 @@
|
|||
@include box-shadow(transparent 0 0 0 0, $color-border-normal 0 1px 6px 0, transparent 0 0 0 0, transparent 0 0 0 0)
|
||||
border-bottom: 1px solid $color-border-light
|
||||
|
||||
a
|
||||
text-decoration: underline
|
||||
|
||||
.success
|
||||
background-color: #ebfcc2
|
||||
background-color: $color-bg-flash-success
|
||||
|
||||
.notice
|
||||
background-color: lightGoldenrodYellow
|
||||
background-color: $color-bg-flash-notice
|
||||
|
||||
.error
|
||||
background-color: #f5d7d3
|
||||
background-color: $color-bg-flash-error
|
||||
|
||||
.broadcast
|
||||
background-color: $color-bg-flash-broadcast
|
||||
|
||||
p
|
||||
margin: 0
|
||||
|
|
|
@ -94,8 +94,8 @@ class Travis::Web::App
|
|||
end
|
||||
|
||||
def set_config(string)
|
||||
string.gsub! %r(<meta (rel|name)="(travis\.[^"]*)" (href|value)="([^"]*)"[^>]*>) do
|
||||
%(<meta #{$1}="#{$2}" #{$3}="#{options[$2.to_sym] || $4}">)
|
||||
string.gsub! %r(<meta (rel|name)="travis\.([^"]*)" (href|value)="([^"]*)"[^>]*>) do
|
||||
%(<meta #{$1}="travis.#{$2}" #{$3}="#{options[$2.to_sym] || $4}">)
|
||||
end
|
||||
|
||||
string.gsub! %r{(src|href)="(\/?)((styles|scripts)\/[^"]*)"} do
|
||||
|
@ -113,4 +113,4 @@ class Travis::Web::App
|
|||
builder.run router
|
||||
builder
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -1 +1 @@
|
|||
6d938637
|
||||
63abb082
|
|
@ -4,5 +4,5 @@ cd "$(dirname "$0")/.."
|
|||
[ $RACK_ENV ] || RACK_ENV=development
|
||||
|
||||
cmd="ruby -I lib -S bundle exec ruby -I lib -S unicorn -p $PORT -c ./config/unicorn.rb"
|
||||
[[ $RACK_ENV == "development" ]] && exec rerun "$cmd -o 127.0.0.1"
|
||||
[[ $RACK_ENV == "development" ]] && exec rerun "$cmd -o 127.0.0.1" -p '{lib,public}/**/*'
|
||||
exec $cmd
|
||||
|
|
Loading…
Reference in New Issue
Block a user