diff options
author | David Gageot <david@gageot.net> | 2012-05-10 13:57:56 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-05-10 14:15:28 +0200 |
commit | 8fbb1e5a79c549755ed11f385d5535b7a96d1eb3 (patch) | |
tree | 66bf3a7c0d83cb1924e68dc855f934fbc6d93b7d | |
parent | 5eb08bb64d7a2047ac0121651e05231fea8a036e (diff) | |
download | sonarqube-8fbb1e5a79c549755ed11f385d5535b7a96d1eb3.tar.gz sonarqube-8fbb1e5a79c549755ed11f385d5535b7a96d1eb3.zip |
SONAR-3462 Separate Global and Project Dashboards
7 files changed, 128 insertions, 121 deletions
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties index 8a0a6b7bf68..97cba6c2cd5 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -530,7 +530,9 @@ dashboard.my_project_dashboards=My project dashboards dashboard.no_dashboard=No dashboard dashboard.do_you_want_to_delete_dashboard=Do you want to delete this dashboard ? dashboard.shared_dashboards=Shared dashboards -dashboard.create_dashboard=Create dashboard +dashboard.create_dashboard=New dashboard +dashboard.create_project_dashboard=Create project dashboard +dashboard.create_global_dashboard=Create global dashboard dashboard.edit_dashboard=Edit dashboard dashboard.update_dashboard=Update dashboard dashboard.error_create_existing_name=A dashboard already exists with the same name diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb index 6df53e1107f..530b2325344 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb @@ -25,10 +25,15 @@ class DashboardsController < ApplicationController before_filter :login_required def index + @global = !params[:resource] + @actives=ActiveDashboard.user_dashboards(current_user) + @actives.reject! { |a| a.global? != @global} + @shared_dashboards=Dashboard.find(:all, :conditions => ['(user_id<>? OR user_id IS NULL) AND shared=?', current_user.id, true], :order => 'name ASC') - active_dashboard_ids=@actives.map { |a| a.dashboard_id } + active_dashboard_ids=@actives.map(&:dashboard_id) @shared_dashboards.reject! { |d| active_dashboard_ids.include?(d.id) } + @shared_dashboards.reject! { |a| a.global != @global} if params[:resource] @resource=Project.by_key(params[:resource]) 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 fad3fe9d7c1..2bce07ee61c 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 @@ -7,7 +7,7 @@ <% 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> + <li class="last"><%= link_to message('dashboard.manage_dashboards'), {:controller => :dashboards, :action => :index, :resource => (@resource.id if @resource) } -%></li> <% end %> </ul> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_create.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_create.html.erb index 6541ca6f3e1..034f8190c26 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_create.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_create.html.erb @@ -13,23 +13,22 @@ <%= message('description') -%>:<br/><input type="text" name="description" size="30" maxlength="1000"> </td> </tr> - <tr> - <td class="left" valign="top"> - <%= message('global') -%>:<br/><input type="checkbox" name="global" value="true"> - </td> - <% if is_admin? %> + <% if is_admin? %> + <tr> <td class="left" valign="top"> <%= message('shared') -%>:<br/><input type="checkbox" name="shared" value="true"> </td> - <% end %> - </tr> + </tr> + <% end %> <tr> <td class="left" valign="top" colspan="2"> - <input type="submit" value="<%= message('dashboard.create_dashboard') -%>" id="submit-create-dashboard"/> + <input type="submit" value="<%= message(@global ? 'dashboard.create_global_dashboard' : 'dashboard.create_project_dashboard') -%>" id="submit-create-dashboard"/> </td> </tr> </tbody> </table> + + <input type="hidden" name="global" value="<%= @global %>" /> </form> <script> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_list.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_list.html.erb deleted file mode 100644 index 7ba92b8cbfc..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_list.html.erb +++ /dev/null @@ -1,63 +0,0 @@ -<h1><%= message(labelKey) -%></h1> - -<table class="data" id="dashboards"> - <thead> - <tr> - <th class="name"><%= message('name') -%></th> - <% if is_admin %> - <th><%= message('shared') -%></th> - <% end %> - <th><%= message('order') -%></th> - <th class="right"><%= message('operations') -%></th> - </tr> - </thead> - <tbody> - <% if active_dashboards.nil? || active_dashboards.empty? %> - <tr class="even"> - <td colspan="4"><%= message('dashboard.no_dashboard') -%></td> - </tr> - <% else %> - <% active_dashboards.each_with_index do |active, index| %> - <tr id="dashboard-<%= u active.name -%>" class="<%= cycle('even', 'odd', :name => group) -%>"> - <td> - <%= link_to active.name(true), {:controller => :dashboard, :action => :index, :did => active.dashboard_id, :id => (params[:resource] unless active.global?)} -%> - <div class="description"><%= h active.dashboard.description -%></div> - </td> - <% if is_admin %> - <td> - <%= boolean_icon(active.dashboard.shared) -%> - </td> - <% end %> - <td> - <% 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 < active_dashboards.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}" %> - <% end %> - </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] 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 active_dashboards.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 %> - <% elsif active_dashboards.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> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/index.html.erb index 4aa7bc4bc44..b46e6e9497c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/index.html.erb @@ -1,51 +1,111 @@ <% is_admin=is_admin? %> -<div id="my_dasboards" class="admin_page"> - <%= render :partial => 'list', :locals => {:active_dashboards => @actives.select(&:global?), :group => 'dashboardsGlobal', :labelKey => 'dashboard.my_global_dashboards', :is_admin => is_admin} %> - <%= render :partial => 'list', :locals => {:active_dashboards => @actives.reject(&:global?), :group => 'dashboardsProject', :labelKey => 'dashboard.my_project_dashboards', :is_admin => is_admin} %> +<div class="admin_page"> + <div id="my_dasboards"> + <h1><%= message(@global ? 'dashboard.my_global_dashboards' : 'dashboard.my_project_dashboards') -%></h1> - <h1><%= message('dashboard.shared_dashboards') -%></h1> - <table class="data" id="shared-dashboards"> - <thead> - <tr> - <th class="name"><%= message('name') -%></th> - <th><%= message('shared_by') -%></th> - <th><%= message('global') -%></th> - <th class="right"><%= message('operations') -%></th> - </tr> - </thead> - <tbody> - <% if @shared_dashboards.nil? || @shared_dashboards.empty? %> - <tr class="even"> - <td colspan="5"><%= message('dashboard.no_dashboard') -%></td> + <table class="data" id="dashboards"> + <thead> + <tr> + <th class="name"><%= message('name') -%></th> + <% if is_admin %> + <th><%= message('shared') -%></th> + <% end %> + <th><%= message('order') -%></th> + <th class="right"><%= message('operations') -%></th> </tr> - <% - else - @shared_dashboards.each do |dashboard| %> - <tr id="shared-dashboard-<%= u dashboard.name -%>" class="<%= cycle('even', 'odd', :name => 'shared') -%>"> - <td> - <%= link_to dashboard.name(true), {:controller => :dashboard, :action => :index, :id => params[:resource], :did => dashboard.id} -%> - <% if dashboard.description.present? %> - <p class="small"><%= h dashboard.description -%></p> + </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-<%= u active.name -%>" class="<%= cycle('even', 'odd', :name => 'dashboard') -%>"> + <td> + <%= link_to active.name(true), {:controller => :dashboard, :action => :index, :did => active.dashboard_id, :id => (params[:resource] unless active.global?)} -%> + <div class="description"><%= h active.dashboard.description -%></div> + </td> + <% if is_admin %> + <td> + <%= boolean_icon(active.dashboard.shared) -%> + </td> <% end %> - </td> - <td> - <%= dashboard.user_name -%> - </td> - <td> - <%= boolean_icon(dashboard.global) -%> - </td> - <td class="thin nowrap right"> - <%= link_to message('follow'), {:action => 'follow', :id => dashboard.id, :resource => params[:resource]}, :method => :post, :id => "follow-#{u dashboard.name}", :class => 'link-action' %> - </td> + <td> + <% 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}" %> + <% end %> + </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] 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 %> + <% elsif @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> + + <h1><%= message('dashboard.shared_dashboards') -%></h1> + + <table class="data" id="shared-dashboards"> + <thead> + <tr> + <th class="name"><%= message('name') -%></th> + <th><%= message('shared_by') -%></th> + <th class="right"><%= message('operations') -%></th> + </tr> + </thead> + <tbody> + <% if @shared_dashboards.nil? || @shared_dashboards.empty? %> + <tr class="even"> + <td colspan="5"><%= message('dashboard.no_dashboard') -%></td> </tr> - <% end - end - %> - </tbody> - </table> -</div> + <% + else + @shared_dashboards.each do |dashboard| %> + <tr id="shared-dashboard-<%= u dashboard.name -%>" class="<%= cycle('even', 'odd', :name => 'shared') -%>"> + <td> + <%= link_to dashboard.name(true), {:controller => :dashboard, :action => :index, :id => params[:resource], :did => dashboard.id} -%> + <% if dashboard.description.present? %> + <p class="small"><%= h dashboard.description -%></p> + <% end %> + </td> + <td> + <%= dashboard.user_name -%> + </td> + <td class="thin nowrap right"> + <%= 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> + </div> -<div id="create_dashboard"> - <%= render :partial => 'dashboards/create' %> + <div id="create_dashboard"> + <%= render :partial => 'dashboards/create' %> + </div> </div> diff --git a/sonar-server/src/main/webapp/stylesheets/dashboard.css b/sonar-server/src/main/webapp/stylesheets/dashboard.css index 9d608988c15..b66fea15d97 100644 --- a/sonar-server/src/main/webapp/stylesheets/dashboard.css +++ b/sonar-server/src/main/webapp/stylesheets/dashboard.css @@ -128,6 +128,10 @@ border: 3px solid #4B9FD5; } +.admin_page { + position: relative; +} + .admin_page table { margin-top: 10px; margin-bottom: 50px; @@ -143,14 +147,14 @@ } #my_dasboards { - margin-right: 260px; + margin-right: 280px; } #create_dashboard { - width: 240px; + width: 235px; position: absolute; - top: 10px; - right: 10px; + top: 0; + right: 28px; } /*OPERATIONS*/ |