Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

generic reusable dialog helper #28

Closed
wants to merge 6 commits into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  app/assets/javascripts/dj_mon/dj_mon.js
@@ -30,7 +30,7 @@ $(function(){
$('a[rel=modal]').live('click', function(){
var template = $($(this).attr('href')).html();
- var output = Mustache.render(template, { content: $(this).data('content') });
+ var output = Mustache.render(template, $(this).data());
$(output).appendTo($('body')).show();
});
View
1  app/controllers/dj_mon/dj_reports_controller.rb
@@ -1,5 +1,6 @@
module DjMon
class DjReportsController < ActionController::Base
+ helper DjMonHelper
respond_to :json, :html
layout 'dj_mon'
View
5 app/helpers/dj_mon/dj_mon_helper.rb
@@ -0,0 +1,5 @@
+module DjMon::DjMonHelper
+ def modal_dialog_template template_name, headline, &block
+ render "dialog", :template_name => template_name, :headline => headline, :content => capture(&block)
+ end
+end
View
11 app/views/dj_mon/dj_reports/_dialog.html.haml
@@ -0,0 +1,11 @@
+%script{ :id => "#{template_name}_template", :type=> "text/x-handlebars-template" }
+ .modal.hide
+ .modal-header
+ %button{ :type => "button", :class => "close", 'data-dismiss' => "modal" }
+ ×
+ %h3
+ = headline
+ .modal-body
+ = content
+ .modal-footer
+ = link_to "Close", '#', :class => 'btn btn-primary', 'data-dismiss' => 'modal'
View
21 app/views/dj_mon/dj_reports/index.html.haml
@@ -48,13 +48,15 @@
.label.label-info
{{queue}}
%td
- <a href="#" data-content="<code class='block'>{{payload}}</code>" rel='popover' title='Payload'> {{id}} </a>
+ %a{:href => "#modal_template", :"data-content" => "{{payload}}", :"data-title" => "Payload", :rel => "modal", :title => "Payload"}
+ {{id}}
%td
{{priority}}
%td
{{attempts}}
%td
- <a href="#last_error_template" data-content="{{last_error}}" rel='modal' title='Last Error'> {{last_error_summary}} </a>
+ %a{:href => "#modal_template", :"data-content" => "{{last_error}}", :"data-title" => "Last Error", :rel => "modal", :title => "Last Error"}
+ {{last_error_summary}}
%td.date
{{run_at}}
%td.date
@@ -73,15 +75,6 @@
{{/.}}
-%script#last_error_template{ :type=> "text/x-handlebars-template" }
- .modal.hide
- .modal-header
- %button{ :type => "button", :class => "close", 'data-dismiss' => "modal" }
- ×
- %h3
- Last Error
- .modal-body
- %code
- {{content}}
- .modal-footer
- = link_to "Close", '#', :class => 'btn btn-primary', 'data-dismiss'=> 'modal'
+= modal_dialog_template "modal", "{{title}}" do
+ %code
+ {{content}}
View
97 app/views/layouts/dj_mon.html.haml
@@ -40,56 +40,47 @@
%span.badge.badge-info
{{all}} all
- %script#dj_settings_template{ :type=> "text/x-handlebars-template" }
- .modal.hide
- .modal-header
- %button{ :type => "button", :class => "close", 'data-dismiss' => "modal" }
- ×
- %h3
- Settings
- .modal-body
- %table.table.table-bordered.table-striped
- %tr
- %td
- Delayed Job version
- %td
- <code>{{content.delayed_job_version}}</code>
- %tr
- %td
- DJ Mon version
- %td
- <code>{{content.dj_mon_version}}</code>
- %tr
- %td
- Destroy failed jobs
- %td
- <code>{{content.destroy_failed_jobs}}</code>
- %tr
- %td
- Sleep delay
- %td
- <code>{{content.sleep_delay}}</code> seconds
- %tr
- %td
- Max attempts
- %td
- <code>{{content.max_attempts}}</code>
- %tr
- %td
- Max run time
- %td
- <code>{{content.max_run_time}}</code> seconds
- %tr
- %td
- Read ahead
- %td
- <code>{{content.read_ahead}}</code>
- %tr
- %td
- Delay Jobs
- %td
- <code>{{content.delay_jobs}}</code>
-
- .modal-footer
- = link_to "Close", '#', :class => 'btn btn-primary', 'data-dismiss'=> 'modal'
-
+ = modal_dialog_template "dj_settings", "Settings" do
+ %table.table.table-bordered.table-striped
+ %tr
+ %td
+ Delayed Job version
+ %td
+ %code {{content.delayed_job_version}}
+ %tr
+ %td
+ DJ Mon version
+ %td
+ %code {{content.dj_mon_version}}
+ %tr
+ %td
+ Destroy failed jobs
+ %td
+ %code {{content.destroy_failed_jobs}}
+ %tr
+ %td
+ Sleep delay
+ %td
+ %code {{content.sleep_delay}}
+ seconds
+ %tr
+ %td
+ Max attempts
+ %td
+ %code {{content.max_attempts}}
+ %tr
+ %td
+ Max run time
+ %td
+ %code {{content.max_run_time}}
+ seconds
+ %tr
+ %td
+ Read ahead
+ %td
+ %code {{content.read_ahead}}
+ %tr
+ %td
+ Delay Jobs
+ %td
+ %code {{content.delay_jobs}}
Something went wrong with that request. Please try again.