active_dashboard_ids=@actives.map { |a| a.dashboard_id }
@shared_dashboards.reject! { |d| active_dashboard_ids.include?(d.id) }
- @resource=Project.by_key(params[:resource])
- if @resource.nil?
+ if params[:resource]
+ @resource=Project.by_key(params[:resource])
+ if @resource.nil?
# TODO display error page
- redirect_to home_path
- return false
+ redirect_to home_path
+ return false
+ end
+ access_denied unless has_role?(:user, @resource)
+ @snapshot = @resource.last_snapshot
+ @project=@resource # variable name used in old widgets
end
- access_denied unless has_role?(:user, @resource)
- @snapshot = @resource.last_snapshot
- @project=@resource # variable name used in old widgets
end
def create
add_default_dashboards_if_first_user_dashboard
last_active_dashboard=current_user.active_dashboards.max { |x, y| x.order_index<=>y.order_index }
current_user.active_dashboards.create(:dashboard => @dashboard, :user_id => current_user.id, :order_index => (last_active_dashboard ? last_active_dashboard.order_index+1 : 1))
- redirect_to :controller => 'dashboard', :action => 'configure', :did => @dashboard.id, :id => params[:resource]
+ redirect_to :controller => 'dashboard', :action => 'configure', :did => @dashboard.id, :id => (params[:resource] unless @dashboard.global)
else
flash[:error]=@dashboard.errors.full_messages.join('<br/>')
redirect_to :controller => 'dashboards', :action => 'index', :resource => params[:resource]
def load_dashboard_from_params(dashboard)
dashboard.name=params[:name]
dashboard.description=params[:description]
- dashboard.global=(params[:global].present?)
+ dashboard.is_global=(params[:global].present?)
dashboard.shared=(params[:shared].present? && is_admin?)
dashboard.user_id=current_user.id
dashboard.column_layout=Dashboard::DEFAULT_LAYOUT if !dashboard.column_layout
read_attribute(:shared) || false
end
- def global?
- read_attribute(:is_global) || false
+ def global=(global)
+ write_attribute(:is_global, global)
+ end
+
+ def global
+ read_attribute(:is_global)
end
def layout
<table class="data" id="admin_console">
<thead>
- <tr>
- <th>Name</th>
- <th>Shared by</th>
- <th>Order</th>
- <th class="right">Operations</th>
- </tr>
+ <tr>
+ <th><%= message('name') -%></th>
+ <th><%= message('global') -%></th>
+ <th><%= message('shared_by') -%></th>
+ <th colspan="2" class="right"><%= message('operations') -%></th>
+ </tr>
</thead>
<tbody>
<% if @actives.empty? %>
<br>
<span style="font-size: 85%;font-weight: normal;"><%= active.dashboard.description %></span>
</td>
+ <td>
+ <%= boolean_icon(active.dashboard.global) -%>
+ </td>
<td><%= h(active.dashboard.user.name) if active.dashboard.user %></td>
<td>
<% if index>0 %>
<table class="data" id="shared">
<thead>
<tr>
- <th>Name</th>
- <th>Shared by</th>
- <th colspan="2" class="right">Operations</th>
+ <th><%= message('name') -%></th>
+ <th><%= message('global') -%></th>
+ <th><%= message('shared_by') -%></th>
+ <th colspan="2" class="right"><%= message('operations') -%></th>
</tr>
</thead>
<tbody>
<br>
<span class="small"><%= dashboard.description %></span>
</td>
+ <td>
+ <%= boolean_icon(dashboard.global) -%>
+ </td>
<td><%= h(dashboard.user.name) if dashboard.user %></td>
<td class="thin nowrap right">
<%= link_to 'Add to defaults', {:action => 'add', :id => dashboard.id}, {:method => :post, :id => "add-#{u dashboard.name}", :class => 'link-action'} %>
<li><%= link_to message('dashboard.configure_widgets'), dashboard_action(:configure) -%></li>
<li><%= link_to message('dashboard.edit_layout'), dashboard_action(:edit_layout) -%></li>
<% end %>
- <% if @resource %>
- <li class="last"><%= link_to message('dashboard.manage_dashboards'), {:controller => :dashboards, :action => :index, :resource => @resource.id} -%></li>
- <% end %>
+ <li class="last"><%= link_to message('dashboard.manage_dashboards'), {:controller => :dashboards, :action => :index, :resource => (@resource.id if @resource)} -%></li>
<% end %>
</ul>
<% end %>
<td colspan="2"><h1><%= message('dashboard.create_dashboard') -%></h1></td>
</tr>
<tr>
- <td class="left" valign="top">
+ <td class="left" valign="top" colspan="2">
<%= message('name') -%>:<br/><input type="text" name="name" size="30" maxlength="256">
</td>
</tr>
<tr>
- <td class="left" valign="top">
+ <td class="left" valign="top" colspan="2">
<%= message('description') -%>:<br/><input type="text" name="description" size="30" maxlength="1000">
</td>
</tr>
<td class="left" valign="top">
<%= message('global') -%>:<br/><input type="checkbox" name="global" value="true">
</td>
- </tr>
- <% if is_admin? %>
- <tr>
+ <% if is_admin? %>
<td class="left" valign="top">
<%= message('shared') -%>:<br/><input type="checkbox" name="shared" value="true">
</td>
- </tr>
- <% end %>
+ <% end %>
+ </tr>
<tr>
- <td class="left" valign="top">
+ <td class="left" valign="top" colspan="2">
<input type="submit" value="<%= message('dashboard.create_dashboard') -%>" id="submit-create-dashboard"/>
</td>
</tr>
<td colspan="2"><h1><%= message('dashboard.edit_dashboard') -%></h1></td>
</tr>
<tr>
- <td class="left" valign="top">
+ <td class="left" valign="top" colspan="2">
<%= message('name') -%>:<br/><input type="text" name="name" size="30" maxlength="256" value="<%= @dashboard.name -%>">
</td>
</tr>
<tr>
- <td class="left" valign="top">
+ <td class="left" valign="top" colspan="2">
<%= message('description') -%>:<br/><input type="text" name="description" size="30" maxlength="1000" value="<%= @dashboard.description -%>">
</td>
</tr>
- <% if is_admin? %>
<tr>
<td class="left" valign="top">
- <%= message('shared') -%>:<br/><input type="checkbox" name="shared" value="true" <%= 'checked' if @dashboard.shared -%>>
+ <%= message('global') -%>:<br/><input type="checkbox" name="global" value="true" <%= 'checked' if @dashboard.global -%>>
</td>
+ <% if is_admin? %>
+ <td class="left" valign="top">
+ <%= message('shared') -%>:<br/><input type="checkbox" name="shared" value="true" <%= 'checked' if @dashboard.shared -%>>
+ </td>
</tr>
<% end %>
<tr>
- <td class="left" valign="top">
- <input type="submit" value="<%= message('dashboard.update_dashboard') -%>" id="submit-update-dashboard"/>
- <a href="<%= url_for :action => 'index', :resource => params[:resource] -%>"><%= message('cancel') -%></a>
+ <td class="left" valign="top" colspan="2">
+ <input type="submit" value="<%= message('dashboard.update_dashboard') -%>" id="submit-update-dashboard"/>
+ <a href="<%= url_for :action => 'index', :resource => params[:resource] -%>"><%= message('cancel') -%></a>
</td>
</tr>
</tbody>
</table>
-</form>
\ No newline at end of file
+</form>
@actives.each_with_index do |active, index| %>
<tr id="dashboard-<%= u active.name -%>" class="<%= cycle('even', 'odd', :name => 'dashboards') -%>">
<td>
- <%= link_to active.name(true), {:controller => :dashboard, :action => :index, :did => active.dashboard_id, :id => params[:resource]} -%>
+ <%= link_to active.name(true), {:controller => :dashboard, :action => :index, :did => active.dashboard_id, :id => (params[:resource] unless active.dashboard.global) } -%>
<% if active.dashboard.description.present? %>
<p class="small"><%= h active.dashboard.description -%></p>
<% end %>
</td>
<td>
- <%= boolean_icon(active.dashboard.global?) -%>
+ <%= boolean_icon(active.dashboard.global) -%>
</td>
<% if is_admin %>
<td>
- <%= boolean_icon(active.dashboard.shared?) -%>
+ <%= boolean_icon(active.dashboard.shared) -%>
</td>
<% end %>
<td>
</td>
<td class="thin nowrap right">
<% if active.owner?(current_user) %>
- <%= link_to message('dashboard.configure_widgets'), {:controller => :dashboard, :action => 'configure', :did => active.dashboard_id, :id => params[:resource]},
+ <%= link_to message('dashboard.configure_widgets'), {:controller => :dashboard, :action => 'configure', :did => active.dashboard_id, :id => (params[:resource] unless active.dashboard.global)},
:id => "configure-#{u active.name}", :class => 'link-action' %>
|
<%= link_to_remote message('edit'), {:update => "admin_form", :url => {:action => "edit", :id => active.dashboard_id, :resource => params[:resource]}},
<thead>
<tr>
<th><%= message('name') -%></th>
+ <th><%= message('global') -%></th>
<th><%= message('shared_by') -%></th>
<th><%= message('operations') -%></th>
</tr>
<p class="small"><%= h dashboard.description -%></p>
<% end %>
</td>
+ <td>
+ <%= boolean_icon(dashboard.global) -%>
+ </td>
<td>
<%= dashboard.user_name -%>
</td>
<li class="<%= 'selected' if controller.controller_path=='dependencies' -%>">
<a href="<%= ApplicationController.root_context -%>/dependencies/index"><%= message('dependencies.page') -%></a></li>
- <% ActiveDashboard.user_dashboards(current_user).select { |active_dashboard| active_dashboard.dashboard.global? }.each do |active_dashboard| %>
+ <% ActiveDashboard.user_dashboards(current_user).select { |active_dashboard| active_dashboard.dashboard.global }.each do |active_dashboard| %>
<li class="<%= 'selected' if @dashboard && controller.controller_path=='dashboard' && active_dashboard.dashboard_id==@dashboard.id -%>">
- <a href="<%= ApplicationController.root_context -%>/dashboard/index/?did=<%= active_dashboard.dashboard_id -%>"><%= active_dashboard.dashboard.name(true) -%></a>
+ <a href="<%= ApplicationController.root_context -%>/dashboard/?did=<%= active_dashboard.dashboard_id -%>"><%= active_dashboard.dashboard.name(true) -%></a>
</li>
<% end %>
<% end %>
<% elsif selected_section==Navigation::SECTION_RESOURCE %>
- <% ActiveDashboard.user_dashboards(current_user).select { |active_dashboard| !active_dashboard.dashboard.global? }.each do |active_dashboard| %>
+ <% ActiveDashboard.user_dashboards(current_user).select { |active_dashboard| !active_dashboard.dashboard.global }.each do |active_dashboard| %>
<li class="<%= 'selected' if @dashboard && controller.controller_path=='dashboard' && active_dashboard.dashboard_id==@dashboard.id -%>">
<a href="<%= ApplicationController.root_context -%>/dashboard/index/<%= @project.id -%>?did=<%= active_dashboard.dashboard_id -%><%= "&"+period_param if period_param -%>"><%= active_dashboard.dashboard.name(true) -%></a>
</li>