Skip to content

Commit

Permalink
Added Player table and scaffolding for Bandshell and hardware integra…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
August committed Apr 18, 2012
1 parent f715a54 commit 0729350
Show file tree
Hide file tree
Showing 18 changed files with 378 additions and 36 deletions.
3 changes: 3 additions & 0 deletions app/assets/javascripts/players.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/players.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Players controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
56 changes: 56 additions & 0 deletions app/assets/stylesheets/scaffolds.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
body {
background-color: #fff;
color: #333;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px; }

p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px; }

pre {
background-color: #eee;
padding: 10px;
font-size: 11px; }

a {
color: #000;
&:visited {
color: #666; }
&:hover {
color: #fff;
background-color: #000; } }

div {
&.field, &.actions {
margin-bottom: 10px; } }

#notice {
color: green; }

.field_with_errors {
padding: 2px;
background-color: red;
display: table; }

#error_explanation {
width: 450px;
border: 2px solid red;
padding: 7px;
padding-bottom: 0;
margin-bottom: 20px;
background-color: #f0f0f0;
h2 {
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px;
margin-bottom: 0px;
background-color: #c00;
color: #fff; }
ul li {
font-size: 12px;
list-style: square; } }
83 changes: 83 additions & 0 deletions app/controllers/players_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
class PlayersController < ApplicationController
# GET /players
# GET /players.json
def index
@players = Player.all

respond_to do |format|
format.html # index.html.erb
format.json { render json: @players }
end
end

# GET /players/1
# GET /players/1.json
def show
@player = Player.find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.json { render json: @player }
end
end

# GET /players/new
# GET /players/new.json
def new
@player = Player.new

respond_to do |format|
format.html # new.html.erb
format.json { render json: @player }
end
end

# GET /players/1/edit
def edit
@player = Player.find(params[:id])
end

# POST /players
# POST /players.json
def create
@player = Player.new(params[:player])

respond_to do |format|
if @player.save
format.html { redirect_to @player, notice: 'Player was successfully created.' }
format.json { render json: @player, status: :created, location: @player }
else
format.html { render action: "new" }
format.json { render json: @player.errors, status: :unprocessable_entity }
end
end
end

# PUT /players/1
# PUT /players/1.json
def update
@player = Player.find(params[:id])

respond_to do |format|
if @player.update_attributes(params[:player])
format.html { redirect_to @player, notice: 'Player was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @player.errors, status: :unprocessable_entity }
end
end
end

# DELETE /players/1
# DELETE /players/1.json
def destroy
@player = Player.find(params[:id])
@player.destroy

respond_to do |format|
format.html { redirect_to players_url }
format.json { head :no_content }
end
end
end
2 changes: 2 additions & 0 deletions app/helpers/players_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module PlayersHelper
end
2 changes: 2 additions & 0 deletions app/models/player.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Player < ActiveRecord::Base
end
33 changes: 33 additions & 0 deletions app/views/players/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<%= form_for(@player) do |f| %>
<% if @player.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@player.errors.count, "error") %> prohibited this player from being saved:</h2>

<ul>
<% @player.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="field">
<%= f.label :secret %><br />
<%= f.text_field :secret %>
</div>
<div class="field">
<%= f.label :ip_address %><br />
<%= f.text_field :ip_address %>
</div>
<div class="field">
<%= f.label :screen_id %><br />
<%= f.number_field :screen_id %>
</div>
<div class="field">
<%= f.label :activated %><br />
<%= f.check_box :activated %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
6 changes: 6 additions & 0 deletions app/views/players/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h1>Editing player</h1>

<%= render 'form' %>
<%= link_to 'Show', @player %> |
<%= link_to 'Back', players_path %>
29 changes: 29 additions & 0 deletions app/views/players/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<h1>Listing players</h1>

<table>
<tr>
<th>Secret</th>
<th>Ip address</th>
<th>Screen</th>
<th>Activated</th>
<th></th>
<th></th>
<th></th>
</tr>

<% @players.each do |player| %>
<tr>
<td><%= player.secret %></td>
<td><%= player.ip_address %></td>
<td><%= player.screen_id %></td>
<td><%= player.activated %></td>
<td><%= link_to 'Show', player %></td>
<td><%= link_to 'Edit', edit_player_path(player) %></td>
<td><%= link_to 'Destroy', player, confirm: 'Are you sure?', method: :delete %></td>
</tr>
<% end %>
</table>

<br />

<%= link_to 'New Player', new_player_path %>
5 changes: 5 additions & 0 deletions app/views/players/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1>New player</h1>

<%= render 'form' %>
<%= link_to 'Back', players_path %>
25 changes: 25 additions & 0 deletions app/views/players/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<p id="notice"><%= notice %></p>

<p>
<b>Secret:</b>
<%= @player.secret %>
</p>

<p>
<b>Ip address:</b>
<%= @player.ip_address %>
</p>

<p>
<b>Screen:</b>
<%= @player.screen_id %>
</p>

<p>
<b>Activated:</b>
<%= @player.activated %>
</p>


<%= link_to 'Edit', edit_player_path(@player) %> |
<%= link_to 'Back', players_path %>
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Concerto::Application.routes.draw do
resources :players

#Custom route for the screen creation/admin form JS
#TODO(bamnet): Clean this up
match "update_owners" => "screens#update_owners"
Expand Down
12 changes: 12 additions & 0 deletions db/migrate/20120418012853_create_players.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CreatePlayers < ActiveRecord::Migration
def change
create_table :players do |t|
t.string :secret
t.string :ip_address
t.integer :screen_id
t.boolean :activated

t.timestamps
end
end
end

4 comments on commit 0729350

@bamnet
Copy link
Member

@bamnet bamnet commented on 0729350 Apr 18, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh! This needs to be an engine if it's going to exist at all as an special bridge between Screens -> Bandshell for the proper linux player so it doesn't turn into /hardware in Concerto 1. We should limit Concerto to code to things required to run the generic system across devices. If this can extend to manage all screens it should be part of the screen model not a separate thing.

Also, it would be useful to see some of the design of this before mode code rolls in....

@augustf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well we don't have any design spec further than this table (which was stubbed so we can make Bandshell start working); we're assuming Andrew has plans for the rest of the hardware stuff. That said, this will probably only be relevant to player hardware, so I'll endeavor to refactor this into an engine...once I find out how to do that...

@asquared
Copy link
Member

@asquared asquared commented on 0729350 Apr 19, 2012 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@augustf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a pain; does no one have a stable distribution and toolset anymore? Mike and I have only gone as far with the hardware management stuff as we need to be able to get a test box to pull content. We'll wait until all the details on the player environment have been hashed out before going any further there.

Please sign in to comment.