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)
+ widget_key = params[:id]
+ @widget_definition = java_facade.getWidget(widget_key)
+ @widget=Widget.new(:widget_key => widget_key)
+
+ @widget_definition.getWidgetProperties().each do |property_definition|
+ @widget.properties<<WidgetProperty.new(
+ :kee => property_definition.key(),
+ :value_type => property_definition.type().toString(),
+ :text_value => params[property_definition.key()] || property_definition.defaultValue
+ )
end
+
+ @dashboard_configuration=Api::DashboardConfiguration.new(nil, :period_index => params[:period], :snapshot => @snapshot)
end
end
\ No newline at end of file
-<div class="block" id="block_<%= u @widget.key -%>" style="width: 50px">
- <%= render :partial => 'dashboard/widget', :locals => {:widget => @widget, :definition => @widget_definition} %>
+<div class="<%= @widget_definition.getId() %>" style="height:100%;">
+ <%
+ begin
+ widget_body=render :inline => @widget_definition.getTarget().getTemplate(), :locals => {:widget_properties => @widget.properties_as_hash, :widget => @widget, :dashboard_configuration => @dashboard_configuration}
+ rescue => error
+ logger.error(message('dashboard.cannot_render_widget_x', :params => [@widget_definition.getId(), error]))
+ logger.error(error.backtrace.join("\n"))
+ widget_body=""
+ end
+
+ if widget_body.include?('<')
+ %>
+ <%
+ default_layout=(@widget_definition.getWidgetLayout().name()=='DEFAULT')
+ if default_layout
+ %>
+ <div class="widget">
+ <% end %>
+ <%= widget_body -%>
+ <% if default_layout %>
+ <div class="clear"></div>
+ </div>
+ <% end %>
+ <%
+ end
+ %>
+ <div style="clear: both;"></div>
</div>
\ No newline at end of file