From 11004fa74dbb211a6c5ec7bbff9d3d4e13e7964d Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Thu, 28 Oct 2010 14:53:29 +0000 Subject: [PATCH] SONAR-1643 improve display of widgets to add + administrators can edit the default dashboard --- .../app/controllers/dashboard_controller.rb | 9 +++++--- .../webapp/WEB-INF/app/models/dashboard.rb | 2 +- .../app/views/dashboard/_header.html.erb | 4 +++- .../dashboard/_widget_definition.html.erb | 4 ++-- .../app/views/dashboard/configure.html.erb | 16 +++----------- .../src/main/webapp/stylesheets/dashboard.css | 22 +++++-------------- 6 files changed, 21 insertions(+), 36 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb index b4ff961f126..3fc136ecbc3 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb @@ -28,7 +28,7 @@ class DashboardController < ApplicationController # TODO display error page if no dashboard or no resource load_dashboard() load_resource() - load_widget_definitions() + load_authorized_widget_definitions() end def configure @@ -139,8 +139,7 @@ class DashboardController < ApplicationController @project=@resource # variable name used in old widgets end - # TODO display unauthorized widgets instead of hiding them - def load_widget_definitions() + def load_authorized_widget_definitions() @widget_definitions = java_facade.getWidgets(@resource.scope, @resource.qualifier, @resource.language) @widget_definitions=@widget_definitions.select do |widget| authorized=widget.getUserRoles().size==0 @@ -153,4 +152,8 @@ class DashboardController < ApplicationController authorized end end + + def load_widget_definitions() + @widget_definitions = java_facade.getWidgets() + end end \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/dashboard.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/dashboard.rb index bbcc70ee061..11416159f18 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/dashboard.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/dashboard.rb @@ -37,7 +37,7 @@ class Dashboard < ActiveRecord::Base end def editable_by?(user) - (user && user_id==user.id) || (user_id.nil? && user.has_role?(:admin)) + (user && self.user_id==user.id) || (user_id.nil? && user.has_role?(:admin)) end def owner?(user) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb index dcbb1b32b43..c68cee1a18b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb @@ -1,11 +1,13 @@ -
+
<% if logged_in? %>
    <% if back %>
  • <%= link_to 'Back to dashboard', {:action => 'index', :id => @dashboard.id, :resource => @resource.id } -%>
  • <% else %> + <% if @dashboard.editable_by?(current_user) %>
  • <%= link_to 'Configure widgets', {:action => 'configure', :id => @dashboard.id, :resource => @resource.id } -%>
  • <%= link_to 'Edit layout', {:action => 'edit_layout', :id => @dashboard.id, :resource => @resource.id } -%>
  • + <% end %>
  • <%= link_to 'Manage dashboards', {:controller => 'dashboards', :action => 'index', :resource => @resource.id } -%>
  • <% end %>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definition.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definition.html.erb index ee7ca54dc24..d8b6c9c90d0 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definition.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definition.html.erb @@ -1,7 +1,7 @@
-

<%= h definition.getTitle() -%>

+

<%= h definition.getTitle() -%>

<%= h definition.getDescription() -%>

<%= form_tag :action => 'add_widget', :id => @dashboard.id, :resource => params[:resource], :widget => definition.getId() %> - +
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/configure.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/configure.html.erb index 3765363dcdd..d5d7f315d65 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/configure.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/configure.html.erb @@ -10,7 +10,7 @@ hoverclass: 'block-hover', dashboardstate: 'dashboardstate', toggle: 'block-toggle', - blocklist: 'dashboard-block-carousel', + blocklist: 'widget_defs', highlight_duration: 2, highlight_startcolor: '#ffff99', highlight_endcolor: '#ffffff', @@ -36,21 +36,11 @@
<%= render :partial => 'dashboard/header', :locals => {:back => true} %> - <% diff --git a/sonar-server/src/main/webapp/stylesheets/dashboard.css b/sonar-server/src/main/webapp/stylesheets/dashboard.css index 031e023f582..d61c9e10e73 100644 --- a/sonar-server/src/main/webapp/stylesheets/dashboard.css +++ b/sonar-server/src/main/webapp/stylesheets/dashboard.css @@ -67,27 +67,17 @@ #dashboard #widget_defs { width: 100%; overflow: auto; -} - -#dashboard #widget_defs ul { - list-style-type: none; - margin: 0; white-space: nowrap; - width: 100000px; -} - -#dashboard #widget_defs li { - float: left; - margin: 0; - padding: 2px 7px; - display: inline-block; - width: 200px; + background-color: #FFF6BF; + border: 2px solid #FFD324; } #dashboard .widget_def { - - border: 1px solid #ddd; + border-right: 2px solid #FFD324; padding: 5px; + display: inline-block; + width: 200px; + white-space: normal; } /*OPERATIONS*/ -- 2.39.5