Skip to content

Commit

Permalink
Update 0.06
Browse files Browse the repository at this point in the history
Fixed a range of recently documented bugs. Also implemented a javascript skeleton to include basic form validation.
  • Loading branch information
ploubser committed Nov 24, 2010
1 parent f7dd2ec commit d64021b
Show file tree
Hide file tree
Showing 21 changed files with 216 additions and 38 deletions.
3 changes: 3 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Bernard Board - version 0.05

Opensource pluggable status board.

CHANGELOG 0.05 Pagination added to board screens
CHANGELOG 0.04 Client and server side form validation.
CHANGELOG 0.03 Complete reimplementation of plugins.
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/boards_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class BoardsController < ApplicationController

def index
@boards = Board.paginate :page => params[:page], :order => 'created_at DESC'
@boards = Board.paginate :page => params[:page], :order => 'created_at DESC'

respond_to do |format|
format.html
Expand All @@ -16,7 +17,6 @@ def index

def show
@board = Board.find(params[:id])

redirect_to :controller => "griditems", :action => :index, :fullscreen => true, :load_board => @board.name
end

Expand Down Expand Up @@ -64,6 +64,7 @@ def update
end

def delete_board

Board.delete_all("name = '#{params[:name]}'")
BoardItem.delete_all("board = '#{params[:name]}'")
render :update do |page|
Expand Down
29 changes: 29 additions & 0 deletions app/controllers/gauge_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class GaugeController < ApplicationController
def redraw_gauge
div = ""
value = ""
if params[:id] =~/item(\d+)/
div = "con#{$1}"
end

@parameters = {}
params[:parameters].split(";").each do |p|
tmp = p.split(/:/, 2)
@parameters[tmp[0]] = tmp[1]
end

unless @parameters["remote"] == "true"
tmp = File.open(@parameters["path"], 'r')
value = tmp.gets()
else
Net::HTTP.start(@parameters["url"]) do |http|
resp = http.get("/#{@parameters["path"]}")
value = resp.body
end
end

render :update do |page|
page << "redrawGauge(#{value}, '#{div}')"
end
end
end
9 changes: 9 additions & 0 deletions app/controllers/griditems_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ class GriditemsController < ApplicationController
rescue_action(exception.original_exception)
end

#######TEMP TEST ACTION! GET RID OF IT BEFORE YOU COMMIT!!!!########
def get_json
@values = ActiveSupport::JSON.encode [Time.now.to_i * 1000 ,rand(10)]

respond_to do |format|
format.json {render :json => @values}
end
end

def index
@fullscreen = params["fullscreen"]
@load_board = params["load_board"]
Expand Down
19 changes: 13 additions & 6 deletions app/views/boards/_board_results.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,22 @@
<td><%=h board.name %></td>
<td><%=h board.width %></td>
<td><%=h board.height %></td>
<td><%= link_to 'Show', board %></td>
<td> <%= link_to_remote "Delete Board",
:url => {:action => "delete_board"},
:html => {:class => "board_item"},
:with => "'name=' + '#{board.name}'" %> </td>
<td><%= button_to 'Show', {:action => "show", :controller => "boards", :id => board.id, :method => "get"},
{:class => "ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only",
:method => "get"} %></td>
<td> <%= button_to_remote "Delete Board",
{:url => {:action => "delete_board", :id =>board.id}, :with => "'name=' + '#{board.name}'"},
:class => "ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
%> </td>
</tr>
<% end %>
</table>
<div id="board_paginate"><%= will_paginate @boards %></div>
</div></center>
<div style="position:absolute;bottom:10%;right:10%;"><%= link_to 'Edit and Create boards', :action => :index, :controller => :griditems %>
<div style="position:absolute;bottom:10%;right:10%;">
<%= button_to 'Edit and Create boards',
{:action => :index, :controller => :griditems},
{:class => "ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only",
:method => "get"}
%></div>

2 changes: 1 addition & 1 deletion app/views/griditems/_item.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


<%= @parameter_list = "" %>
<div class="item" id="item<%= @timestamp%>" style="height:<%= @dimentions[0]%>px;width:<%=@dimentions[1] %>px;border:solid 2px;position:absolute;" onmousemove="if(!'<%=@state%>' == 'view'){enableEvents('item<%= @timestamp%>')};" >
<div class="item" id="item<%= @timestamp%>" style="height:<%= @dimentions[0]%>px;width:<%=@dimentions[1] %>px;border:solid 2px;position:absolute;border-color:#00FF00;" onmousemove="if(!'<%=@state%>' == 'view'){enableEvents('item<%= @timestamp%>')};" >
<%= render :partial => "griditems/plugins/#{@type.downcase}/#{@type.downcase}", :locals => {:parameters => @parameters, :itemid => "item" + @timestamp}%>
<%= form_tag 'index' %>
<% @parameters.each do |p| %>
Expand Down
4 changes: 1 addition & 3 deletions app/views/griditems/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<% javascripts.each do |javascript| %>
<%= javascript_include_tag "#{javascript}" %>
<% end %>
<%= javascript_include_tag "js/highcharts.js" %>

<% stylesheets = get_stylesheets %>
<% stylesheets.each do |stylesheet| %>
Expand All @@ -17,11 +18,8 @@

<div class="ui-widget-header"><center>BernardBoard</center></div>


<div class="container ui-widget-content" id="container">

<div id="progressbar"></div>

<div id="popup" class="popup" >
<a id="popupClose" class="popupClose">x</a>
<h1> Create new item for bernard to consume </h1>
Expand Down
28 changes: 25 additions & 3 deletions app/views/griditems/plugins/calendar/_calendar.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<% id = Time.now.to_i %>
<% size = 0 %>
<div class="ui-widget-header">
<%= @title %>
</div>
Expand All @@ -6,7 +8,27 @@
<%= javascript_tag "alert('Could not create Calendar item. Incorrect username or password.')"%>
<%= javascript_tag "jQuery('##{itemid}').remove();" %>
<% else %>
<% calendar_events.each_with_index do |event, i| %>
<%= event.title %> - <%= event.start_time.strftime("%a %d-%m-%Y %H:%M")%><br>
<% end %>
<div class="calendar">
<table cellspacing="5" >
<% calendar_events.each_with_index do |event, i| %>
<tr id="calevent<%=i%><%=id%>" class="calevent<%=id%>" style="display:none;">
<% unless event.start_time < Time.now() %>
<% size = size + 1 %>
<% background_color = ""%>
<% if (event.start_time - Time.now ) < 86400 %>
<% min = (event.start_time - Time.now) / 60 % 60%>
<% sec = (event.start_time - Time.now) % 60 %>
<% hour = (event.start_time - Time.now) / 60 /60 %>
<td bgcolor="#FF0000"><%= event.title %></td> <td>In <%=hour.to_i%> hours <%= min.to_i%> minutes</td>
<% else %>
<td bgcolor="#33CC00"><%= event.title %></td> <td><%= event.start_time.strftime("%a %d-%m %H:%M")%></td>
<% end %>

<% end %>
</tr>
<% end %>
</table>
</div>
<%= javascript_tag "update_calendar(#{size}, #{id}, #{@parameters["calevents"]})" %>
<%end %>

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
Width : <%= text_field_tag "width", "", :size=>4%><br>
Height: <%= text_field_tag "height", "", :size=>4%><br>
User name: <%= text_field_tag "usrname", "", :size=>24 %><br>
Password : <%= password_field_tag "passwrd" %> <bR>
Password : <%= password_field_tag "passwrd" %> <br>
Events to Display: <%= text_field_tag "calevents","", :size=>2%><br>
Refresh Rate (in seconds): <%= text_field_tag "refresh_rate" %> <br>
<%= submit_to_remote "create_grid_item", "Create", :url => {:action => "create_grid_item", :type => type}, :html => {:class => "create"}, :condition => "validateForm()"%> <br>
<%= submit_to_remote "update_grid_item", "Update", :url => {:action => "update_grid_item", :type => type}, :html => {:class => "update"}, :condition => "validateForm()"%>
Expand Down
2 changes: 1 addition & 1 deletion app/views/griditems/plugins/feed/_feed.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</div>

<% feed.items.each_with_index do |topic,i| %>
<div id="feed<%=i%><%= id%>" class="feed<%=id %>" style="display:none;">
<div id="feed<%=i%><%= id%>" class="feed<%=id %>" style="display:none;color:#00ff00;font-family:'Courier New', 'Courier', 'monospace';">
<div id="feed-header<%=i%>"
<%= image_tag "rss_icon.gif", :html => {"align" => "left"}%>
<%= topic.title %><br>
Expand Down
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
config.action_controller.perform_caching = false

# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
config.action_mailer.raise_delivery_errors = false
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
map.connect 'save_state', :controller => "griditems", :action => "save_state"
map.connect 'get_json', :controller => "griditems", :action => "get_json"
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//Your Javascript goes here
function validate<%= plugin_name.capitalize%>(){
//Your validation goes here
return true;
}
2 changes: 2 additions & 0 deletions public/javascripts/bernard.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ function bindPaginate(){

jQuery(document).ready(function() {

jQuery('.button_to').button();

bindPaginate();
jQuery('.options').draggable({'revert' : false, 'zindex' : 350})
jQuery('.minimise').dblclick(function() {
Expand Down
24 changes: 24 additions & 0 deletions public/javascripts/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,27 @@ function validateCalendar() {
}
return true;
}

function update_calendar(size, id, toShow){
for(i = 0; i < toShow; i++){
jQuery('#calevent' + i + id).show();
}
var currentEvent = 0;
var container = null;
var interval = setInterval(function(){
jQuery('.calevent' + id).hide();
for(i = currentEvent; i < currentEvent + toShow; i++){
jQuery('#calevent' + i + id).show();
}
container = jQuery('#calevent' + currentEvent + id).parent().parent();
if(jQuery(container).attr("id") == null){
clearInterval(interval);
}
if((currentEvent + toShow) < size){
currentEvent++;
}
else{
currentEvent = 0;
}
},5000);
}
8 changes: 7 additions & 1 deletion public/stylesheets/bernard.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
hr {
border-color:#00FF00;
}

.ui-widget-header{
text-align:center;
}
Expand Down Expand Up @@ -58,6 +62,7 @@
.item{
font-style:bold;
overflow:hidden;
border-color:#00FF00;
}

.popup{
Expand Down Expand Up @@ -108,9 +113,10 @@
}

.feed{
background-color:#111111;
background-color:black;
font-style:helvetica impact serif;
font-weight:bold;
color:green;
}

#vmenu{
Expand Down
24 changes: 24 additions & 0 deletions vendor/plugins/bernard_calendar/lib/javascripts/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,27 @@ function validateCalendar() {
}
return true;
}

function update_calendar(size, id, toShow){
for(i = 0; i < toShow; i++){
jQuery('#calevent' + i + id).show();
}
var currentEvent = 0;
var container = null;
var interval = setInterval(function(){
jQuery('.calevent' + id).hide();
for(i = currentEvent; i < currentEvent + toShow; i++){
jQuery('#calevent' + i + id).show();
}
container = jQuery('#calevent' + currentEvent + id).parent().parent();
if(jQuery(container).attr("id") == null){
clearInterval(interval);
}
if((currentEvent + toShow) < size){
currentEvent++;
}
else{
currentEvent = 0;
}
},5000);
}
28 changes: 25 additions & 3 deletions vendor/plugins/bernard_calendar/lib/views/_calendar.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<% id = Time.now.to_i %>
<% size = 0 %>
<div class="ui-widget-header">
<%= @title %>
</div>
Expand All @@ -6,7 +8,27 @@
<%= javascript_tag "alert('Could not create Calendar item. Incorrect username or password.')"%>
<%= javascript_tag "jQuery('##{itemid}').remove();" %>
<% else %>
<% calendar_events.each_with_index do |event, i| %>
<%= event.title %> - <%= event.start_time.strftime("%a %d-%m-%Y %H:%M")%><br>
<% end %>
<div class="calendar">
<table cellspacing="5" >
<% calendar_events.each_with_index do |event, i| %>
<tr id="calevent<%=i%><%=id%>" class="calevent<%=id%>" style="display:none;">
<% unless event.start_time < Time.now() %>
<% size = size + 1 %>
<% background_color = ""%>
<% if (event.start_time - Time.now ) < 86400 %>
<% min = (event.start_time - Time.now) / 60 % 60%>
<% sec = (event.start_time - Time.now) % 60 %>
<% hour = (event.start_time - Time.now) / 60 /60 %>
<td bgcolor="#FF0000"><%= event.title %></td> <td>In <%=hour.to_i%> hours <%= min.to_i%> minutes</td>
<% else %>
<td bgcolor="#33CC00"><%= event.title %></td> <td><%= event.start_time.strftime("%a %d-%m %H:%M")%></td>
<% end %>

<% end %>
</tr>
<% end %>
</table>
</div>
<%= javascript_tag "update_calendar(#{size}, #{id}, #{@parameters["calevents"]})" %>
<%end %>

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
Width : <%= text_field_tag "width", "", :size=>4%><br>
Height: <%= text_field_tag "height", "", :size=>4%><br>
User name: <%= text_field_tag "usrname", "", :size=>24 %><br>
Password : <%= password_field_tag "passwrd" %> <bR>
Password : <%= password_field_tag "passwrd" %> <br>
Events to Display: <%= text_field_tag "calevents","", :size=>2%><br>
Refresh Rate (in seconds): <%= text_field_tag "refresh_rate" %> <br>
<%= submit_to_remote "create_grid_item", "Create", :url => {:action => "create_grid_item", :type => type}, :html => {:class => "create"}, :condition => "validateForm()"%> <br>
<%= submit_to_remote "update_grid_item", "Update", :url => {:action => "update_grid_item", :type => type}, :html => {:class => "update"}, :condition => "validateForm()"%>
Expand Down
2 changes: 1 addition & 1 deletion vendor/plugins/bernard_feed/lib/views/_feed.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</div>

<% feed.items.each_with_index do |topic,i| %>
<div id="feed<%=i%><%= id%>" class="feed<%=id %>" style="display:none;">
<div id="feed<%=i%><%= id%>" class="feed<%=id %>" style="display:none;color:#00ff00;font-family:'Courier New', 'Courier', 'monospace';">
<div id="feed-header<%=i%>"
<%= image_tag "rss_icon.gif", :html => {"align" => "left"}%>
<%= topic.title %><br>
Expand Down
Loading

0 comments on commit d64021b

Please sign in to comment.