aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main/webapp
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-10-28 14:53:29 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-10-28 14:53:29 +0000
commit11004fa74dbb211a6c5ec7bbff9d3d4e13e7964d (patch)
tree02373c3a4761ed47860c449f004bc3b7b80e359d /sonar-server/src/main/webapp
parentb918fe7c6647285b0584c5d1682102f9e8835c62 (diff)
downloadsonarqube-11004fa74dbb211a6c5ec7bbff9d3d4e13e7964d.tar.gz
sonarqube-11004fa74dbb211a6c5ec7bbff9d3d4e13e7964d.zip
SONAR-1643 improve display of widgets to add + administrators can edit the default dashboard
Diffstat (limited to 'sonar-server/src/main/webapp')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb9
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/dashboard.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definition.html.erb4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/configure.html.erb16
-rw-r--r--sonar-server/src/main/webapp/stylesheets/dashboard.css22
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 @@
-<div class="line-block" style="position:relative;">
+<div class="line-block">
<% if logged_in? %>
<ul class="operations">
<% if back %>
<li class="last"><%= link_to 'Back to dashboard', {:action => 'index', :id => @dashboard.id, :resource => @resource.id } -%></li>
<% else %>
+ <% if @dashboard.editable_by?(current_user) %>
<li><%= link_to 'Configure widgets', {:action => 'configure', :id => @dashboard.id, :resource => @resource.id } -%></li>
<li><%= link_to 'Edit layout', {:action => 'edit_layout', :id => @dashboard.id, :resource => @resource.id } -%></li>
+ <% end %>
<li class="last"><%= link_to 'Manage dashboards', {:controller => 'dashboards', :action => 'index', :resource => @resource.id } -%></li>
<% end %>
</ul>
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 @@
<div class="widget_def" id="def_<%= definition.getId().tr('_', '') -%>">
-<p><%= h definition.getTitle() -%></p>
+<p><b><%= h definition.getTitle() -%></b></p>
<p><%= h definition.getDescription() -%></p>
<%= form_tag :action => 'add_widget', :id => @dashboard.id, :resource => params[:resource], :widget => definition.getId() %>
- <input type="submit" value="Add" >
+ <input type="submit" value="Add widget" >
</form>
</div> \ 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 @@
<div id="dashboard">
<%= render :partial => 'dashboard/header', :locals => {:back => true} %>
-<div id="dashboard-block-carousel" class="admin marginbottom10">
-
- <div id="dashboard-block-container" class="container">
- <div id="widget_defs">
- <ul>
+ <div id="widget_defs" class="marginbottom10">
<% @widget_definitions.each_with_index do |definition, index| %>
- <li>
- <%= render :partial => 'dashboard/widget_definition', :locals => {:definition => definition} %>
- </li>
+ <%= render :partial => 'dashboard/widget_definition', :locals => {:definition => definition} %>
<% end %>
- </ul>
- </div>
</div>
- <div style="clear: both;"></div>
-</div>
<%
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*/