diff options
Diffstat (limited to 'sonar-server')
10 files changed, 43 insertions, 67 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 5fc5729aba6..958ac6eb0bf 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 @@ -112,7 +112,7 @@ class DashboardController < ApplicationController errors=WidgetProperty.validate_definition(property_def, value) if errors.empty? - widget.set_property(property_def.key(), value) + widget.set_property(property_def.key(), value, property_def.type()) else widget.unset_property(property_def.key()) errors_by_property_key[property_def.key()]=errors 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 8751e4a7c4c..4e0c8146da8 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 @@ -32,6 +32,10 @@ class Dashboard < ActiveRecord::Base read_attribute(:shared) || false
end
+ def layout
+ column_layout
+ end
+
def user_name
user_id ? user.name : nil
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/widget.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/widget.rb index 7cba190ed7f..4cbc5280f80 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/widget.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/widget.rb @@ -42,14 +42,15 @@ class Widget < ActiveRecord::Base (prop ? prop.value : nil) || default_value
end
- def set_property(key, value)
+ def set_property(key, value, value_type)
prop=property(key)
if prop
prop.text_value=value
+ prop.value_type=value_type
else
- self.properties.build(:kee => key, :text_value => value)
+ prop=self.properties.build(:kee => key, :text_value => value, :value_type => value_type)
end
- properties_as_hash[key]=value
+ properties_as_hash[key]=prop.typed_value
end
def unset_property(key)
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/widget_property.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/widget_property.rb index 3909618cde1..3a0706c886b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/widget_property.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/widget_property.rb @@ -36,6 +36,19 @@ class WidgetProperty < ActiveRecord::Base text_value
end
+ def typed_value
+ case value_type
+ when TYPE_INTEGER
+ value.to_i
+ when TYPE_FLOAT
+ Float(value)
+ when TYPE_BOOLEAN
+ value=='true'
+ else
+ value
+ end
+ end
+
def to_hash_json
{:key => key, :value => value.to_s}
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb index ec677b689a8..db775bfe743 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb @@ -10,7 +10,7 @@ <div class="handle" style="//overflow:hidden;//zoom:1;"> <%= definition.getTitle() -%> - <a class="block-remove" onclick="remove_widget(this);return false;">Delete</a> + <a class="block-remove" onclick="portal.deleteWidget(this);return false;">Delete</a> <% if definition.isEditable() %> <a class="block-view-toggle" onclick="portal.editWidget(<%= widget.id -%>);return false;">Edit</a> <% end %> @@ -23,10 +23,6 @@ <tbody> <% definition.getProperties().each do |property_def| value=widget.property_value(property_def.key(), property_def.defaultValue()) - editrow_class="" - if defined?(validation_result) - editrow_class= validation_result[property_def.key()]=="valid" ? "valid-editrow" : "invalid-editrow" - end %> <tr> <td valign="top" nowrap><b><%= property_def.key() -%></b><%= "*" unless property_def.optional()==true -%>: </td> 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 7c0f54e612a..49d3bc131da 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 @@ -24,11 +24,6 @@ <% end %> } Event.observe(window, 'load', init_dashboard, false); - - function remove_widget(link) { - $(link).up('.block').remove(); - portal.saveDashboardsState(); - } //--> </script> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/edit_layout.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/edit_layout.html.erb index 9d906e9b323..5006a908a77 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/edit_layout.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/edit_layout.html.erb @@ -4,24 +4,24 @@ <div id="edit-layout" class="admin"> <p class="note">Click to choose the layout: </p><br/> <!--100%--> - <div class="layout-example-wrapper" style="text-align:center;width: 20%;"> - <%= link_to image_tag('layout100.png'), {:action => 'set_layout', :id => @dashboard.id, :resource => @resource.id, :layout => "100"}, :method => "post" %> + <div class="select-layout <%= 'selected' if @dashboard.layout=='100' -%>" style="text-align:center;width: 20%;"> + <%= link_to image_tag('layout100.png'), {:action => 'set_layout', :id => @dashboard.id, :resource => @resource.id, :layout => "100"}, :method => :post %> </div> <!--50%-50%--> - <div class="layout-example-wrapper" style="text-align:center;width: 20%;"> - <%= link_to image_tag('layout5050.png'), {:action => 'set_layout', :id => @dashboard.id, :resource => @resource.id, :layout => "50-50"}, :method => "post" %> + <div class="select-layout <%= 'selected' if @dashboard.layout=="50-50" -%>" style="text-align:center;width: 20%;"> + <%= link_to image_tag('layout5050.png'), {:action => 'set_layout', :id => @dashboard.id, :resource => @resource.id, :layout => "50-50"}, :method => :post %> </div> <!--30%-70%--> - <div class="layout-example-wrapper" style="text-align:center;width: 20%;"> - <%= link_to image_tag('layout3070.png'), {:action => 'set_layout', :id => @dashboard.id, :resource => @resource.id, :layout => "30-70"}, :method => "post" %> + <div class="select-layout <%= 'selected' if @dashboard.layout=="30-70" -%>" style="text-align:center;width: 20%;"> + <%= link_to image_tag('layout3070.png'), {:action => 'set_layout', :id => @dashboard.id, :resource => @resource.id, :layout => "30-70"}, :method => :post %> </div> <!--70%-30%--> - <div class="layout-example-wrapper" style="text-align:center;width: 20%;"> - <%= link_to image_tag('layout7030.png'), {:action => 'set_layout', :id => @dashboard.id, :resource => @resource.id, :layout => "70-30"}, :method => "post" %> + <div class="select-layout <%= 'selected' if @dashboard.layout=="70-30" -%>" style="text-align:center;width: 20%;"> + <%= link_to image_tag('layout7030.png'), {:action => 'set_layout', :id => @dashboard.id, :resource => @resource.id, :layout => "70-30"}, :method => :post %> </div> <!--33%-33%-33%--> - <div class="layout-example-wrapper" style="text-align:center;width: 19%;"> - <%= link_to image_tag('layout333333.png'), {:action => 'set_layout', :id => @dashboard.id, :resource => @resource.id, :layout => "33-33-33"}, :method => "post" %> + <div class="select-layout <%= 'selected' if @dashboard.layout=="33-33-33" -%>" style="text-align:center;width: 19%;"> + <%= link_to image_tag('layout333333.png'), {:action => 'set_layout', :id => @dashboard.id, :resource => @resource.id, :layout => "33-33-33"}, :method => :post %> </div> <div style="clear:both;"></div> </div> diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/151_create_dashboards.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/151_create_dashboards.rb index 6130b0814a6..80af98ef785 100755 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/151_create_dashboards.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/151_create_dashboards.rb @@ -55,6 +55,7 @@ class CreateDashboards < ActiveRecord::Migration t.column :widget_id, :integer, :null => false t.column :kee, :string, :null => true, :limit => 100 t.column :text_value, :string, :null => true, :limit => 4000 + t.column :value_type, :string, :null => true, :limit => 20 end add_index :widget_properties, [:widget_id], :name => 'widget_properties_widgets' diff --git a/sonar-server/src/main/webapp/javascripts/dashboard.js b/sonar-server/src/main/webapp/javascripts/dashboard.js index 11d99d7c79e..d163d088449 100644 --- a/sonar-server/src/main/webapp/javascripts/dashboard.js +++ b/sonar-server/src/main/webapp/javascripts/dashboard.js @@ -45,14 +45,12 @@ Portal.prototype = { }, highlightWidget: function(widgetId) { - new Effect.Pulsate($('block_' + widgetId), {duration: this.options.highlight_duration}); new Effect.Highlight($('block_' + widgetId), {duration: this.options.highlight_duration, startcolor: this.options.highlight_startcolor, endcolor: this.options.highlight_endcolor}); }, /****************************************************/ - saveDashboardsState: function () { var result = ""; var index = 1; @@ -106,6 +104,10 @@ Portal.prototype = { cancelEditWidget: function(id) { $('widget_' + id).show(); $('widget_props_' + id).hide(); + }, + deleteWidget: function(elt) { + $(elt).up('.block').remove(); + this.saveDashboardsState(); } }; diff --git a/sonar-server/src/main/webapp/stylesheets/dashboard.css b/sonar-server/src/main/webapp/stylesheets/dashboard.css index 1eeae1e2201..a34478cdaa6 100644 --- a/sonar-server/src/main/webapp/stylesheets/dashboard.css +++ b/sonar-server/src/main/webapp/stylesheets/dashboard.css @@ -10,43 +10,19 @@ top: 0; left: 0; background: url('../images/transparent.gif') repeat; + cursor: move; z-index: 1000; } /* CONFIGURE LAYOUT */ -#dashboard .layout-example .transparent { - cursor: pointer; -} - -#dashboard .layout-example-wrapper { +#dashboard .select-layout { text-align: center; float: left; margin: 0; padding: 0; } - -#dashboard .layout-example { - position: relative; - margin: 0 20px 10px 20px; - padding: 0; -} - -#dashboard .layout-example .layout-column-wrapper { - float: left; - margin: 0; - padding: 0; - background-color: #cccccc; -} - -#dashboard .layout-example .layout-column { - margin: 5px 5px 5px 0px; - padding: 0px; - height: 70px; - background-color: #ffffff; -} - -#dashboard .layout-example .first { - margin-left: 5px; +#dashboard .select-layout.selected img { + border: 3px solid #4B9FD5; } /* WIDGETS */ @@ -82,7 +58,7 @@ border-right: 2px solid #FFD324; padding: 5px; display: inline-block; - width: 200px; + width: 180px; white-space: normal; } @@ -179,22 +155,10 @@ text-decoration: underline; } -#dashboard .transparent { - cursor: move; -} - #dashboard .block-hover { border: 3px dashed #ddd; } -#dashboard .valid-editrow { - border: 1px solid #0f0; -} - -#dashboard .invalid-editrow { - border: 1px solid #f00; -} - #dashboard .shadow-block { box-shadow: 8px 8px 8px #ddd; -moz-box-shadow: 8px 8px 8px #ddd; |