[PATCH conductor] BZ773034, BZ781482: Fix jQuery template on images#show
Tomas Sedovic
tsedovic at redhat.com
Thu Feb 9 13:44:15 UTC 2012
On 02/09/2012 01:42 PM, ifarkas at redhat.com wrote:
> From: Imre Farkas<ifarkas at redhat.com>
>
> The build/push status has disappeared after backbone update and this patch is
> intended to fix this.
>
> Note, that the status in json response needs to capitalized by the controller because in
> the jquery template no javascript function nor rails helper methods can be used.
>
> https://bugzilla.redhat.com/show_bug.cgi?id=773034
> https://bugzilla.redhat.com/show_bug.cgi?id=781482
> ---
> src/app/controllers/images_controller.rb | 3 ++
> src/app/views/images/show.html.haml | 54 +++++++++++++++--------------
> 2 files changed, 31 insertions(+), 26 deletions(-)
>
> diff --git a/src/app/controllers/images_controller.rb b/src/app/controllers/images_controller.rb
> index f634bfa..41108c5 100644
> --- a/src/app/controllers/images_controller.rb
> +++ b/src/app/controllers/images_controller.rb
> @@ -66,6 +66,8 @@ class ImagesController< ApplicationController
> format.json do
> active_builds = @account_groups.keys.inject({}) do |result, driver|
> result[driver] = @builder.find_active_build(@build.id, driver) if @build
> + result[driver].attributes['status'].capitalize! if result[driver]
> +
> result
> end
>
> @@ -73,6 +75,7 @@ class ImagesController< ApplicationController
> timg = @target_images_by_target[driver]
> group[:accounts].each do |account|
> result[account.id] = @builder.find_active_push(timg.id, account.provider.name, account.credentials_hash['username'])
> + result[account.id].attributes['status'].capitalize! if result[account.id]
> end if timg.present?
>
> result
> diff --git a/src/app/views/images/show.html.haml b/src/app/views/images/show.html.haml
> index c83fc6a..e26a720 100644
> --- a/src/app/views/images/show.html.haml
> +++ b/src/app/views/images/show.html.haml
> @@ -101,32 +101,34 @@
> <li>
> <dl>
> <dt>
> -<h3>${groups['type']['name']}</h3>
> - {{if build&& active_builds[driver]}}
> -<label>${active_builds[driver]['status']}</label>
> - {{else target_images_by_target[driver]}}
> - #{path = image_target_image_path('replace_image_id', 'replace_target_image_id')
> - path = path.sub('replace_image_id', '${image[\'uuid\']}')
> - path = path.sub('replace_target_image_id', '${target_images_by_target[driver][\'uuid\']}')
> - button_to(t('images.show.delete'), path, :method => :delete)}
> - {{else build&& build['uuid'] == latest_build_id}}
> - #{path = image_target_images_path('replace_image_id', :target => 'replace_driver', :build_id => 'replace_build_id')
> - path = path.sub('replace_image_id', '${image[\'uuid\']}')
> - path = path.sub('replace_driver', '${driver}')
> - path = path.sub('replace_build_id', '${build[\'uuid\']}')
> - button_to(t('images.show.build'), path, :method => :post)}
> - {{if failed_build_counts[driver]> 1}}
> -<div class="light">
> - #{t('images.show.failed_build_attempts', :count => '${failed_build_counts[driver]}')}
> -</div>
> - {{else failed_build_counts[driver] == 1}}
> -<div class="light">
> - #{t('images.show.failed_build_attempts', :count => 1 )}
> -</div>
> +<div class="build-actions">
> +<h3>${groups['type']['name']}</h3>
> + {{if build&& active_builds[driver]}}
> +<label>${active_builds[driver]['builder']['status']}</label>
> + {{else target_images_by_target[driver]}}
> + #{path = image_target_image_path('replace_image_id', 'replace_target_image_id')
> + path = path.sub('replace_image_id', '${image[\'uuid\']}')
> + path = path.sub('replace_target_image_id', '${target_images_by_target[driver][\'uuid\']}')
> + button_to(t('images.show.delete'), path, :method => :delete)}
> + {{else build&& build['uuid'] == latest_build_id}}
> + #{path = image_target_images_path('replace_image_id', :target => 'replace_driver', :build_id => 'replace_build_id')
> + path = path.sub('replace_image_id', '${image[\'uuid\']}')
> + path = path.sub('replace_driver', '${driver}')
> + path = path.sub('replace_build_id', '${build[\'uuid\']}')
> + button_to(t('images.show.build'), path, :method => :post)}
> + {{if failed_build_counts[driver]> 1}}
> +<div class="light">
> + #{t('images.show.failed_build_attempts', :count => '${failed_build_counts[driver]}')}
> +</div>
> + {{else failed_build_counts[driver] == 1}}
> +<div class="light">
> + #{t('images.show.failed_build_attempts', :count => 1 )}
> +</div>
> + {{/if}}
> + {{else}}
> +
> {{/if}}
> - {{else}}
> -
> - {{/if}}
> +</div>
> </dt>
> <dd>
> <table class="light_table">
> @@ -168,7 +170,7 @@
> </td>
> <td class="image_controls light">
> {{if target_images_by_target[driver]&& active_pushes[account['id']]}}
> -<label>${active_pushes[account['id']]['status']}</label>
> +<label>${active_pushes[account['id']]['builder']['status']}</label>
> {{else target_images_by_target[driver]&& !provider_images[account['id']]&& build&& build['uuid'] == latest_build_id}}
> #{path = image_provider_images_path('replace_image_id', :build_id => 'replace_build_id', :target_image_id => 'replace_target_image_id', :account_id => 'replace_account_id')
> path = path.sub('replace_image_id', '${image[\'uuid\']}')
ACK
More information about the aeolus-devel
mailing list