Skip to content

Commit

Permalink
Fix widget_footer
Browse files Browse the repository at this point in the history
Replace one partial call with widget-footer component, move lightbox-panel on same level as notification-app, move last_run and next_run to helper(no duplication of code)
  • Loading branch information
ZitaNemeckova committed Apr 12, 2018
1 parent 67cd442 commit 998735a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
8 changes: 8 additions & 0 deletions app/helpers/dashboard_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@ def ext_auth?(auth_option = nil)
return false unless ::Settings.authentication.mode == 'httpd'
auth_option ? ::Settings.authentication[auth_option] : true
end

def last_next_run(widget)
last_run_on = widget.last_run_on_for_user(current_user)
next_run_on = widget.next_run_on
last_run = last_run_on ? format_timezone(last_run_on, session[:user_tz], "widget_footer") : _('Never')
next_run = next_run_on ? format_timezone(next_run_on, session[:user_tz], "widget_footer") : _('Unknown')
[last_run, next_run]
end
end
11 changes: 5 additions & 6 deletions app/views/dashboard/_widget.html.haml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
%div{:id => "w_#{presenter.widget.id}"}
- last_run_on = presenter.widget.last_run_on_for_user(current_user)
- next_run_on = presenter.widget.next_run_on
%div{:id => "ww_#{presenter.widget.id}"}
- last_run, next_run = last_next_run(presenter.widget)
- widget_blank = presenter.widget.content_type == 'menu' ? false : presenter.widget.contents_for_user(current_user).blank?
%widget-wrapper{"widget-id" => presenter.widget.id,
"widget-type" => presenter.widget.content_type,
"widget-buttons" => presenter.widget_buttons,
"widget-blank" => widget_blank,
"widget-last-run" => last_run_on ? format_timezone(last_run_on, session[:user_tz], "widget_footer") : _('Never'),
"widget-next-run" => next_run_on ? format_timezone(next_run_on, session[:user_tz], "widget_footer") : _('Unknown'),
"widget-last-run" => last_run,
"widget-next-run" => next_run,
"widget-title" => presenter.widget.title}
:javascript
miq_bootstrap("#w_#{presenter.widget.id}");
miq_bootstrap("#ww_#{presenter.widget.id}");
5 changes: 4 additions & 1 deletion app/views/dashboard/_zoomed_chart.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-#
Parameters:
widget -- MiqWidget object
- last_run, next_run = last_next_run(widget)
#zoomed_chart_div
.card-pf
.card-pf-heading
Expand All @@ -11,4 +12,6 @@
%i.fa.fa-close.pull-right
.card-pf-body
= chart_remote('dashboard', :id => 'my_chart', :zoomed => true)
= render :partial => 'widget_footer', :locals => {:widget => widget}
%widget-footer{:id => "zoomed_chart_footer_#{widget.id}", 'widget-last-run' => last_run, 'widget-next-run' => next_run}
:javascript
miq_bootstrap("#zoomed_chart_footer_#{widget.id}");
7 changes: 3 additions & 4 deletions app/views/layouts/_header.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
%li.drawer-pf-trigger.dropdown{"open" => "!hideDrawer"}
%a{:class => "nav-item-iconic drawer-pf-trigger-icon", :title => "{{vm.notificationsIndicatorTooltip}}", "ng-click" => "vm.toggleNotificationsList()"}
%span.fa.fa-bell
%span{"ng-class" => "{'badge badge-pf-bordered': vm.newNotifications}"}
%span{"ng-class" => "{'badge badge-pf-bordered': vm.newNotifications}"}
= ' '
- Menu::Manager.menu(:help) do |menu_section|
- if menu_section.visible?
Expand All @@ -31,12 +31,11 @@
= _(menu_item.name)
= render :partial => "layouts/user_options"
= render :partial => "layouts/spinner"
= render :partial => "layouts/lightbox_panel"
= render :partial => "layouts/notifications_drawer"
= render :partial => "layouts/toast_list"
= render :partial => "layouts/spinner"
= render :partial => "layouts/lightbox_panel"
:javascript
miq_bootstrap('#notification-app', 'miq.notifications');
Expand Down

0 comments on commit 998735a

Please sign in to comment.