configurable event page logo
This commit is contained in:
parent
46c18610e6
commit
2ebe700a9c
|
|
@ -3,7 +3,7 @@ ActiveAdmin.register JamRuby::GenericState, :as => 'GenericState' do
|
|||
|
||||
config.clear_action_items!
|
||||
filter :env
|
||||
permit_params :top_message
|
||||
permit_params :top_message, :event_page_top_logo_url
|
||||
|
||||
actions :all, :except => [:destroy]
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
<%= f.semantic_errors *f.object.errors.keys %>
|
||||
<%= f.inputs do %>
|
||||
<%= f.input(:top_message, :input_html => {:maxlength => 10000, :rows=>10, :class => 'autogrow'}) %>
|
||||
<%= f.input(:event_page_top_logo_url, :input_html => {:maxlength => 200}, :hint => '/assets/logo.png') %>
|
||||
<% end %>
|
||||
<%= f.actions %>
|
||||
<% end %>
|
||||
|
|
@ -53,4 +53,7 @@ ALTER TABLE arses ADD COLUMN port int default 3478;
|
|||
ALTER TABLE generic_state ADD COLUMN top_message VARCHAR(100000);
|
||||
|
||||
ALTER TABLE users ADD COLUMN beta BOOLEAN default FALSE;
|
||||
ALTER TABLE arses ADD COLUMN beta BOOLEAN default FALSE;
|
||||
ALTER TABLE arses ADD COLUMN beta BOOLEAN default FALSE;
|
||||
|
||||
|
||||
ALTER TABLE generic_state ADD COLUMN event_page_top_logo_url VARCHAR(100000) DEFAULT '/assets/event/eventbrite-logo.png';
|
||||
|
|
@ -3,7 +3,7 @@ module JamRuby
|
|||
class GenericState < ActiveRecord::Base
|
||||
|
||||
|
||||
attr_accessible :top_message, as: :admin
|
||||
attr_accessible :top_message, :event_page_top_logo_url, as: :admin
|
||||
|
||||
self.table_name = 'generic_state'
|
||||
|
||||
|
|
@ -38,6 +38,10 @@ module JamRuby
|
|||
GenericState.singleton.top_message
|
||||
end
|
||||
|
||||
def self.event_page_top_logo_url
|
||||
GenericState.singleton.event_page_top_logo_url
|
||||
end
|
||||
|
||||
def self.singleton
|
||||
GenericState.find('default')
|
||||
end
|
||||
|
|
|
|||
|
|
@ -40,4 +40,23 @@
|
|||
body: JSON.stringify(data)
|
||||
})
|
||||
}
|
||||
|
||||
Rest2.getConfigClient = (options) => {
|
||||
if(!options) {
|
||||
options = {}
|
||||
}
|
||||
|
||||
var query = Object.keys(options)
|
||||
.map(k => `${encodeURIComponent(k)}=${encodeURIComponent(params[k])}`)
|
||||
.join('&');
|
||||
|
||||
return fetch('/api/config/client?' + query, {
|
||||
method: 'get',
|
||||
credentials: 'same-origin', // include, *same-origin, omit
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
cache: 'no-cache'
|
||||
})
|
||||
}
|
||||
})(window);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//= require_directory ./react-components/actions
|
||||
//= require ./react-components/stores/EventStore
|
||||
//= require_directory ./react-components
|
||||
//= require ../react-components/actions/ConfigActions
|
||||
//= require ../react-components/stores/ConfigStore
|
||||
//= require_directory ./react-components
|
||||
|
|
|
|||
|
|
@ -1,16 +1,30 @@
|
|||
context = window
|
||||
ConfigStore = context.ConfigStore
|
||||
EventActions = context.EventActions
|
||||
ConfigActions = context.ConfigActions
|
||||
|
||||
context.EventsPage = React.createClass({
|
||||
|
||||
context.EventsPage = React.createClass(
|
||||
{
|
||||
|
||||
mixins: [Reflux.listenTo(ConfigStore, "onConfig")],
|
||||
|
||||
getInitialState: function () {
|
||||
return {submitting: false, error: null}
|
||||
return {submitting: false, error: null, event_page_top_logo_url: null}
|
||||
},
|
||||
|
||||
componentDidMount: function () {
|
||||
EventActions.refresh()
|
||||
ConfigActions.configInit()
|
||||
},
|
||||
|
||||
onConfig: function(configs) {
|
||||
if (configs.event_page_top_logo_url) {
|
||||
this.setState({event_page_top_logo_url: configs.event_page_top_logo_url})
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
authorizeDone: function(response) {
|
||||
this.setState({submitting:false})
|
||||
EventActions.addAuthorization(response)
|
||||
|
|
@ -69,10 +83,14 @@ context.EventsPage = React.createClass({
|
|||
*/
|
||||
|
||||
//tmp
|
||||
top_logo = null
|
||||
if(this.state.event_page_top_logo_url) {
|
||||
top_logo = <img src={this.state.event_page_top_logo_url}/>
|
||||
}
|
||||
listing = null
|
||||
var response = <div className="EventsPage">
|
||||
<div id="header">
|
||||
<div className="logo-holder"><img src="/assets/logo.png"/></div>
|
||||
<div className="logo-holder">{top_logo}</div>
|
||||
</div>
|
||||
<div id="top-container">
|
||||
<div className="header">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
context = window
|
||||
|
||||
@ConfigActions = Reflux.createActions({
|
||||
configInit: {}
|
||||
})
|
||||
|
|
@ -1,31 +1,64 @@
|
|||
$ = jQuery
|
||||
context = window
|
||||
logger = context.JK.logger
|
||||
rest = new context.JK.Rest()
|
||||
if context.JK.Rest
|
||||
rest = new context.JK.Rest()
|
||||
else
|
||||
rest = context.JK.Rest2
|
||||
|
||||
|
||||
@ConfigStore = Reflux.createStore(
|
||||
{
|
||||
top_message: null
|
||||
event_page_top_logo_url: null
|
||||
|
||||
#listenables: @ConfigActions
|
||||
# this path taken on event landing p age
|
||||
listenables: @ConfigActions
|
||||
|
||||
onConfigInit: () ->
|
||||
@fetch(0)
|
||||
|
||||
init: ->
|
||||
this.listenTo(context.AppStore, this.onAppInit)
|
||||
# context.AppStore not available in landing pages. This path below is for the /client view
|
||||
if context.AppStore
|
||||
this.listenTo(context.AppStore, this.onAppInit)
|
||||
|
||||
process: (response) ->
|
||||
@top_message = response.top_message
|
||||
@event_page_top_logo_url = response.event_page_top_logo_url
|
||||
@changed()
|
||||
|
||||
fetch: (wait) ->
|
||||
setTimeout((() =>
|
||||
result = rest.getConfigClient()
|
||||
if result.done
|
||||
result.done((response) =>
|
||||
@process(response)
|
||||
)
|
||||
.fail((jqXHR) =>
|
||||
console.log("failed to fetch config")
|
||||
)
|
||||
else # fetch style
|
||||
result
|
||||
.then((response) =>
|
||||
if !response.ok
|
||||
throw Error(response.statusText)
|
||||
else
|
||||
return response.json()
|
||||
)
|
||||
.then((response) =>
|
||||
@process(response)
|
||||
)
|
||||
.catch((jqXHR) =>
|
||||
console.log("failed to fetch config")
|
||||
)
|
||||
|
||||
), wait)
|
||||
|
||||
onAppInit: (@app) ->
|
||||
setTimeout((() =>
|
||||
rest.getConfigClient()
|
||||
.done((response) =>
|
||||
@top_message = response.top_message
|
||||
@changed()
|
||||
)
|
||||
.fail((jqXHR) =>
|
||||
console.log("failed to fetch config")
|
||||
)
|
||||
), 2000)
|
||||
@fetch(2000)
|
||||
|
||||
changed:() ->
|
||||
@trigger({top_message: @top_message})
|
||||
@trigger({top_message: @top_message, event_page_top_logo_url: @event_page_top_logo_url})
|
||||
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ class ApiConfigsController < ApiController
|
|||
def client
|
||||
configs =
|
||||
{
|
||||
top_message: GenericState.top_message
|
||||
top_message: GenericState.top_message,
|
||||
event_page_top_logo_url: GenericState.event_page_top_logo_url
|
||||
}
|
||||
|
||||
render :json => configs, :status => 200
|
||||
|
|
|
|||
Loading…
Reference in New Issue