[PATCH conductor] BZ#800242 Export events for a single instance display the events of all other instances too.
Jozef Zigmund
jzigmund at redhat.com
Wed May 2 12:55:41 UTC 2012
On Monday 23 April 2012 13:31:14 Tomas Hrcka wrote:
> Added restful submit button, controller action and transtalions to enable
> selection of instances for event exportation.
> ---
> src/app/controllers/instances_controller.rb | 11 +++++++++++
> src/app/views/instances/_list.html.haml | 3 ++-
> src/config/locales/en.yml | 2 ++
> src/config/routes.rb | 1 +
> src/public/javascripts/application.js | 2 +-
> 5 files changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/src/app/controllers/instances_controller.rb
> b/src/app/controllers/instances_controller.rb index 7773d81..6d45b39 100644
> --- a/src/app/controllers/instances_controller.rb
> +++ b/src/app/controllers/instances_controller.rb
> @@ -175,6 +175,17 @@ class InstancesController < ApplicationController
>
> :filename => "export.csv")
>
> end
>
> + def export_selected_events
> + if params[:instance_selected].present?
> +
> send_data(Instance.csv_export(Instance.find(params[:instance_selected] ||
> [])), + :type => 'text/csv; charset=utf-8; header=present',
It could return 404 flash msg when instance is not found. Not need to create
empty csv file.
> + :filename => "export.csv")
> + else
> + flash[:error] = t('instances.none_selected_to_export_events')
> + redirect_to params[:backlink] || pools_path(:view => 'filter',
> :details_tab => 'instances') + end
> + end
> +
> def stop
> if @inaccessible_instances.include?(@instance)
> do_operation(:forced_stop)
> diff --git a/src/app/views/instances/_list.html.haml
> b/src/app/views/instances/_list.html.haml index dac5d69..39276dc 100644
> --- a/src/app/views/instances/_list.html.haml
> +++ b/src/app/views/instances/_list.html.haml
> @@ -1,11 +1,12 @@
> - content_for :form_header do
> %li= restful_submit_tag t('instances.list.stop_selected_instances'),
> 'stop', multi_stop_instances_path, 'GET', :class => 'button', :id =>
> 'stop_selected_instances', 'data-none_selected' =>
> t('instances.none_selected') %li= restful_submit_tag
> t('instances.list.reboot_selected_instances'), 'reboot',
> multi_reboot_instances_path, 'GET', :class => 'button', :id =>
> 'reboot_selected_instances', 'data-none_selected' =>
> t('instances.none_selected_to_reboot') + %li= restful_submit_tag
> t('instances.list.export_events'), 'export',
> export_selected_events_instances_path, 'GET', :class => 'button', :id =>
> 'export_selected_instances_events', 'data-none_selected' =>
> t('instances.none_selected_to_export_events') %li.more_actions
> %span
> = image_tag "more_actions_drop.png"
> %ul
> - %li= link_to "#{t'instances.list.export_events'}",
> export_events_instances_path(:deployment_id => @deployment) + %li=
> link_to "#{t'instances.list.export_all_events'}",
> export_events_instances_path(:deployment_id => @deployment) =
> hidden_field_tag 'backlink', request.url
>
> - content_for :filter_controls do
> diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
> index a3044ad..1154786 100644
> --- a/src/config/locales/en.yml
> +++ b/src/config/locales/en.yml
> @@ -299,12 +299,14 @@ en:
> instance: Instance
> none_selected: "You must select one or more instances to stop."
> none_selected_to_reboot: "You must select one or more instances to
> reboot." + none_selected_to_export_events: "You must select one or more
> instances to export events." tab_captions:
> properties: Properties
> history: History
> permissions: Permissions
> list:
> export_events: Export events
> + export_all_events: Export all events
> stop_selected_instances: Stop selected instances
> reboot_selected_instances: Reboot selected instances
> stopped_instances_hidden: Stopped instances are hidden
> diff --git a/src/config/routes.rb b/src/config/routes.rb
> index a95389f..2199911 100644
> --- a/src/config/routes.rb
> +++ b/src/config/routes.rb
> @@ -115,6 +115,7 @@ Conductor::Application.routes.draw do
> collection do
> get 'multi_stop'
> get 'multi_reboot'
> + get 'export_selected_events'
> get 'remove_failed'
> get 'export_events'
> post 'filter'
> diff --git a/src/public/javascripts/application.js
> b/src/public/javascripts/application.js index f4054fb..6784101 100644
> --- a/src/public/javascripts/application.js
> +++ b/src/public/javascripts/application.js
> @@ -118,7 +118,7 @@ $.extend(Conductor, {
> },
>
> multiActionValidation: function() {
> - $('#delete_button, #revoke_button, #stop_button,
> #stop_selected_instances, #reboot_selected_instances').live('click',
> function(e) { + $('#delete_button, #revoke_button, #stop_button,
> #stop_selected_instances, #reboot_selected_instances,
> #export_selected_instances_events').live('click', function(e) {
>
> var $checkbox_table =
> $(this).closest("form.filterable-data").find("table.checkbox_table"); var
> confirm_message = $checkbox_table.data('confirm');
one inline note and could you write tests for it? otherwise it works well.
More information about the aeolus-devel
mailing list