private
def load_dashboard
- @active=nil
+ active=nil
+ @dashboard=nil
if logged_in?
if params[:did]
- @active=ActiveDashboard.find(:first, :include => 'dashboard', :conditions => ['active_dashboards.dashboard_id=? AND active_dashboards.user_id=?', params[:did].to_i, current_user.id])
+ @dashboard=Dashboard.find(:first, :conditions => ['id=? AND user_id=?', params[:did].to_i, current_user.id])
elsif params[:name]
- @active=ActiveDashboard.find(:first, :include => 'dashboard', :conditions => ['dashboards.name=? AND active_dashboards.user_id=?', params[:name], current_user.id])
+ @dashboard=Dashboard.find(:first, :conditions => ['name=? AND user_id=?', params[:name], current_user.id])
elsif params[:id]
- @active=ActiveDashboard.user_dashboards(current_user, false).first
+ active=ActiveDashboard.user_dashboards(current_user, false).first
else
- @active=ActiveDashboard.user_dashboards(current_user, true).first
+ active=ActiveDashboard.user_dashboards(current_user, true).first
end
end
- if @active.nil?
+ unless active or @dashboard
# anonymous or not found in user dashboards
if params[:did]
- @active=ActiveDashboard.find(:first, :include => 'dashboard', :conditions => ['active_dashboards.dashboard_id=? AND active_dashboards.user_id IS NULL', params[:did].to_i])
+ @dashboard=Dashboard.find(:first, :conditions => ['id=? AND shared=?', params[:did].to_i, true])
elsif params[:name]
- @active=ActiveDashboard.find(:first, :include => 'dashboard', :conditions => ['dashboards.name=? AND active_dashboards.user_id IS NULL', params[:name]])
+ @dashboard=Dashboard.find(:first, :conditions => ['name=? AND shared=?', params[:name], true])
elsif params[:id]
- @active=ActiveDashboard.user_dashboards(nil, false).first
+ active=ActiveDashboard.user_dashboards(nil, false).first
else
- @active=ActiveDashboard.user_dashboards(nil, true).first
+ active=ActiveDashboard.user_dashboards(nil, true).first
end
end
- @dashboard=(@active ? @active.dashboard : nil)
+
+ unless @dashboard
+ @dashboard=(active ? active.dashboard : nil)
+ end
+
@dashboard_configuration=Api::DashboardConfiguration.new(@dashboard, :period_index => params[:period], :snapshot => @snapshot) if @dashboard && @snapshot
end
<div class="admin_page">
<h1><%= message('dashboard.global_dashboards') -%></h1>
-
<p><%= message('dashboard.global_dashboards.description') -%></p>
<%= render :partial => 'list', :locals => {:active_dashboards => @actives.select(&:global?), :group => 'activeGlobal'} %>
<h1><%= message('dashboard.project_dashboards') -%></h1>
-
<p><%= message('dashboard.project_dashboards.description') -%></p>
<%= render :partial => 'list', :locals => {:active_dashboards => @actives.reject(&:global?), :group => 'activeProject'} %>
<h1><%= message('dashboard.shared_dashboards') -%></h1>
-
<p><%= message('dashboard.shared_dashboards.description') -%></p>
<table class="data" id="shared">
<% if logged_in? %>
<ul class="operations">
<% if back %>
- <li class="last"><%= link_to message('dashboard.back_to_dashboard'), dashboard_action(:index) -%></li>
+ <li><%= link_to message('dashboard.back_to_dashboard'), dashboard_action(:index) -%></li>
<% else %>
<% if @dashboard.editable_by?(current_user) %>
<li><%= link_to message('dashboard.configure_widgets'), dashboard_action(:configure) -%></li>
<% end %>
- <li class="last"><%= link_to message('dashboard.manage_dashboards'), {:controller => :dashboards, :action => :index, :resource => (@resource.id if @resource) } -%></li>
<% end %>
+ <li class="last"><%= link_to message('dashboard.manage_dashboards'), {:controller => :dashboards, :action => :index, :resource => (@resource.id if @resource) } -%></li>
</ul>
<% end %>
--- /dev/null
+<table class="data" id="shared-dashboards">
+ <thead>
+ <tr>
+ <th class="name"><%= message('name') -%></th>
+ <th class="shared"><%= message('shared') -%></th>
+ <th class="owner"><%= message('owner') -%></th>
+ <th class="order"> </th>
+ <th class="operations"><%= message('operations') -%></th>
+ </tr>
+ </thead>
+ <tbody>
+ <% if @shared_dashboards.nil? || @shared_dashboards.empty? %>
+ <tr class="even">
+ <td colspan="5" class="empty"><%= message('dashboard.no_dashboard') -%></td>
+ </tr>
+ <%
+ else
+ @shared_dashboards.each do |dashboard| %>
+ <tr id="dashboard-<%= dashboard.id -%>" class="<%= cycle('even', 'odd', :name => 'shared') -%>">
+ <td>
+ <%= link_to h(dashboard.name(true)), {:controller => :dashboard, :action => :index, :did => dashboard.id, :id => (params[:resource] unless dashboard.global?)},
+ :id => "view-#{u dashboard.name}", :class => 'link-action' %>
+ <div class="description"><%= h dashboard.description -%></div>
+ </td>
+ <td class="shared">
+ <%= boolean_icon(dashboard.shared) -%>
+ </td>
+ <td class="owner">
+ <%= h(dashboard.user_name || message('dashboard.username.default')) -%>
+ </td>
+ <td class="order"> </td>
+ <td class="thin nowrap operations">
+ <% if dashboard.editable_by?(current_user) %>
+ <%= link_to message('dashboard.configure_widgets'), {:controller => :dashboard, :action => :configure, :did => dashboard.id, :id => (params[:resource] unless dashboard.global?)},
+ :id => "configure-#{u dashboard.name}", :class => 'link-action' %>
+ |
+ <%= link_to_remote message('edit'), {:update => "create_dashboard", :url => {:action => :edit, :id => dashboard.id, :resource => params[:resource]}},
+ {:id => "edit-#{u dashboard.name}", :method => :get, :class => 'link-action'} %>
+ |
+ <%= link_to message('delete'), {:action => :delete, :id => dashboard.id, :resource => params[:resource]}, :method => :post,
+ :confirm => message('dashboard.do_you_want_to_delete_dashboard'), :id => "delete-#{u dashboard.name}", :class => 'link-action' %>
+ |
+ <% end %>
+ <%= link_to message('follow'), {:action => :follow, :id => dashboard.id, :resource => params[:resource]}, :method => :post, :id => "follow-#{u dashboard.name}", :class => 'link-action' %>
+ </td>
+ </tr>
+ <% end
+ end
+ %>
+ </tbody>
+</table>
--- /dev/null
+<table class="data" id="dashboards">
+ <thead>
+ <tr>
+ <th class="name"><%= message('name') -%></th>
+ <th class="shared"><%= message('shared') -%></th>
+ <th class="owner"><%= message('owner') -%></th>
+ <th class="order"><%= message('order') -%></th>
+ <th class="operations"><%= message('operations') -%></th>
+ </tr>
+ </thead>
+ <tbody>
+ <% if @actives.nil? || @actives.empty? %>
+ <tr class="even">
+ <td colspan="5" class="empty"><%= message('dashboard.no_dashboard') -%></td>
+ </tr>
+ <% else %>
+ <% @actives.map(&:dashboard).each_with_index do |dashboard, index| %>
+ <tr id="dashboard-<%= dashboard.id -%>" class="<%= cycle('even', 'odd', :name => 'dashboard') -%>">
+ <td>
+ <%= link_to h(dashboard.name(true)), {:controller => :dashboard, :action => :index, :did => dashboard.id, :id => (params[:resource] unless dashboard.global?)},
+ :id => "view-#{u dashboard.name}", :class => 'link-action' %>
+ <div class="description"><%= h dashboard.description -%></div>
+ </td>
+ <td class="shared">
+ <%= boolean_icon(dashboard.shared) -%>
+ </td>
+ <td class="owner">
+ <%= h(dashboard.user_name || message('dashboard.username.default')) -%>
+ </td>
+ <td class="order">
+ <% if index > 0 %>
+ <%= link_to image_tag('blue-up.png'), {:action => :up, :id => dashboard.id, :resource => params[:resource]}, :method => :post, :id => "up-#{u dashboard.name}" %>
+ <% else %>
+ <%= image_tag('transparent_16.gif') %>
+ <% end %>
+ <% if index < @actives.size-1 %>
+ <%= link_to image_tag('blue-down.png'), {:action => :down, :id => dashboard.id, :resource => params[:resource]}, :method => :post, :id => "down-#{u dashboard.name}" %>
+ <% else %>
+ <%= image_tag('transparent_16.gif') %>
+ <% end %>
+ </td>
+ <td class="thin nowrap operations">
+ <% if dashboard.editable_by?(current_user) %>
+ <%= link_to message('dashboard.configure_widgets'), {:controller => :dashboard, :action => :configure, :did => dashboard.id, :id => (params[:resource] unless dashboard.global?)},
+ :id => "configure-#{u dashboard.name}", :class => 'link-action' %>
+ |
+ <%= link_to_remote message('edit'), {:update => "create_dashboard", :url => {:action => :edit, :id => dashboard.id, :resource => params[:resource]}},
+ {:id => "edit-#{u dashboard.name}", :method => :get, :class => 'link-action'} %>
+ <% if @actives.size() > 1 %>
+ |
+ <%= link_to message('delete'), {:action => :delete, :id => dashboard.id, :resource => params[:resource]}, :method => :post,
+ :confirm => message('dashboard.do_you_want_to_delete_dashboard'), :id => "delete-#{u dashboard.name}", :class => 'link-action' %>
+ |
+ <% end %>
+ <% end %>
+ <% if @actives.size() > 1 %>
+ <%= link_to message('unfollow'), {:action => :unfollow, :id => dashboard.id, :resource => params[:resource]}, :method => :post,
+ :id => "unfollow-#{u dashboard.name}", :class => 'link-action' %>
+ <% end %>
+ </td>
+ </tr>
+ <% end
+ end
+ %>
+ </tbody>
+</table>
-<% is_admin=is_admin? %>
-
<div class="admin_page">
<div id="my_dasboards">
<h1><%= message(@global ? 'dashboard.my_global_dashboards' : 'dashboard.my_project_dashboards') -%></h1>
-
- <table class="data" id="dashboards">
- <thead>
- <tr>
- <th class="name"><%= message('name') -%></th>
- <th class="shared"><%= message('shared') -%></th>
- <th class="owner"><%= message('owner') -%></th>
- <th class="order"><%= message('order') -%></th>
- <th class="operations"><%= message('operations') -%></th>
- </tr>
- </thead>
- <tbody>
- <% if @actives.nil? || @actives.empty? %>
- <tr class="even">
- <td colspan="4"><%= message('dashboard.no_dashboard') -%></td>
- </tr>
- <% else %>
- <% @actives.each_with_index do |active, index| %>
- <tr id="dashboard-<%= active.id -%>" class="<%= cycle('even', 'odd', :name => 'dashboard') -%>">
- <td>
- <%= active.name(true) -%>
- <div class="description"><%= h active.dashboard.description -%></div>
- </td>
- <td class="shared">
- <%= boolean_icon(active.dashboard.shared) -%>
- </td>
- <td class="owner">
- <%= h(active.dashboard.user_name || message('dashboard.username.default')) -%>
- </td>
- <td class="order">
- <% if index > 0 %>
- <%= link_to image_tag('blue-up.png'), {:action => :up, :id => active.dashboard_id, :resource => params[:resource]}, :method => :post, :id => "up-#{u active.name}" %>
- <% else %>
- <%= image_tag('transparent_16.gif') %>
- <% end %>
- <% if index < @actives.size-1 %>
- <%= link_to image_tag('blue-down.png'), {:action => :down, :id => active.dashboard_id, :resource => params[:resource]}, :method => :post, :id => "down-#{u active.name}" %>
- <% else %>
- <%= image_tag('transparent_16.gif') %>
- <% end %>
- </td>
- <td class="thin nowrap operations">
- <% if active.editable_by?(current_user) %>
- <%= link_to message('dashboard.configure_widgets'), {:controller => :dashboard, :action => :configure, :did => active.dashboard_id, :id => (params[:resource] unless active.global?)},
- :id => "configure-#{u active.name}", :class => 'link-action' %>
- |
- <%= link_to_remote message('edit'), {:update => "create_dashboard", :url => {:action => :edit, :id => active.dashboard_id, :resource => params[:resource]}},
- {:id => "edit-#{u active.name}", :method => :get, :class => 'link-action'} %>
- <% if @actives.size() > 1 %>
- |
- <%= link_to message('delete'), {:action => :delete, :id => active.dashboard_id, :resource => params[:resource]}, :method => :post,
- :confirm => message('dashboard.do_you_want_to_delete_dashboard'), :id => "delete-#{u active.name}", :class => 'link-action' %>
- |
- <% end %>
- <% end %>
- <% if @actives.size() > 1 %>
- <%= link_to message('unfollow'), {:action => :unfollow, :id => active.dashboard_id, :resource => params[:resource]}, :method => :post,
- :id => "unfollow-#{u active.name}", :class => 'link-action' %>
- <% end %>
- </td>
- </tr>
- <% end
- end
- %>
- </tbody>
- </table>
+ <%= render_partial :partial => 'my_dashboards', :locals => { :is_admin => is_admin? } %>
<h1><%= message('dashboard.available_dashboards') -%></h1>
-
- <table class="data" id="shared-dashboards">
- <thead>
- <tr>
- <th class="name"><%= message('name') -%></th>
- <th class="shared"><%= message('shared') -%></th>
- <th class="owner"><%= message('owner') -%></th>
- <th class="order"> </th>
- <th class="operations"><%= message('operations') -%></th>
- </tr>
- </thead>
- <tbody>
- <% if @shared_dashboards.nil? || @shared_dashboards.empty? %>
- <tr class="even">
- <td colspan="5" class="empty"><%= message('dashboard.no_dashboard') -%></td>
- </tr>
- <%
- else
- @shared_dashboards.each do |dashboard| %>
- <tr id="dashboard-<%= dashboard.id -%>" class="<%= cycle('even', 'odd', :name => 'shared') -%>">
- <td>
- <%= dashboard.name(true) -%>
- <div class="description"><%= h dashboard.description -%></div>
- </td>
- <td class="shared">
- <%= boolean_icon(dashboard.shared) -%>
- </td>
- <td class="owner">
- <%= h(dashboard.user_name || message('dashboard.username.default')) -%>
- </td>
- <td class="order"> </td>
- <td class="thin nowrap operations">
- <% if dashboard.editable_by?(current_user) %>
- <%= link_to_remote message('edit'), {:update => "create_dashboard", :url => {:action => :edit, :id => dashboard.id, :resource => params[:resource]}},
- {:id => "edit-#{u dashboard.name}", :method => :get, :class => 'link-action'} %>
- |
- <%= link_to message('delete'), {:action => :delete, :id => dashboard.id, :resource => params[:resource]}, :method => :post,
- :confirm => message('dashboard.do_you_want_to_delete_dashboard'), :id => "delete-#{u dashboard.name}", :class => 'link-action' %>
- |
- <% end %>
- <%= link_to message('follow'), {:action => :follow, :id => dashboard.id, :resource => params[:resource]}, :method => :post, :id => "follow-#{u dashboard.name}", :class => 'link-action' %>
- </td>
- </tr>
- <% end
- end
- %>
- </tbody>
- </table>
+ <%= render_partial :partial => 'available_dashboards', :locals => { :is_admin => is_admin? } %>
</div>
<div id="create_dashboard">