diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-10-11 22:19:38 +0200 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-10-11 22:19:38 +0200 |
commit | 1157d48769148780ad46699d0bae8ddb349b60bf (patch) | |
tree | 38bbd8f90a4127c7adee2b4bd1661c00e550a2df /sonar-server | |
parent | cb9597afe6f21f4751cfb5a82c8947f467d7b315 (diff) | |
download | sonarqube-1157d48769148780ad46699d0bae8ddb349b60bf.tar.gz sonarqube-1157d48769148780ad46699d0bae8ddb349b60bf.zip |
SONAR-2771 Allow to render a single widget
Diffstat (limited to 'sonar-server')
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/controllers/widget_controller.rb | 52 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/views/widget/index.html.erb | 3 |
2 files changed, 55 insertions, 0 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/widget_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/widget_controller.rb new file mode 100644 index 00000000000..5cf7d9027a8 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/widget_controller.rb @@ -0,0 +1,52 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2011 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# Sonar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# +class WidgetController < ApplicationController + helper :dashboard + + SECTION=Navigation::SECTION_RESOURCE + + def index + begin + load_widget + load_resource + params[:layout]='false' + render :action => 'index' + + rescue Exception => e + render :text => e + end + end + + private + + def load_resource + @resource=Project.by_key(params[:resource]) + return access_denied unless has_role?(:user, @resource) + @snapshot = @resource.last_snapshot + end + + def load_widget + @widget=Widget.find(:first, :conditions => {:widget_key => params[:id]}) + if @widget + @widget_definition = java_facade.getWidget(@widget.key) + @dashboard_configuration=Api::DashboardConfiguration.new(nil, :period_index => params[:period], :snapshot => @snapshot) + end + end +end
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/widget/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/widget/index.html.erb new file mode 100644 index 00000000000..a00dea3781f --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/widget/index.html.erb @@ -0,0 +1,3 @@ +<div class="block" id="block_<%= u @widget.key -%>" style="width: 50px"> + <%= render :partial => 'dashboard/widget', :locals => {:widget => @widget, :definition => @widget_definition} %> +</div>
\ No newline at end of file |