]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2771 Allow to render a single widget
authorsimonbrandhof <simon.brandhof@gmail.com>
Tue, 11 Oct 2011 20:19:38 +0000 (22:19 +0200)
committersimonbrandhof <simon.brandhof@gmail.com>
Tue, 11 Oct 2011 20:19:38 +0000 (22:19 +0200)
sonar-server/src/main/webapp/WEB-INF/app/controllers/widget_controller.rb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/app/views/widget/index.html.erb [new file with mode: 0644]

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 (file)
index 0000000..5cf7d90
--- /dev/null
@@ -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 (file)
index 0000000..a00dea3
--- /dev/null
@@ -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