diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2049b36..86124f0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,108 +1,109 @@ module ApplicationHelper # Custom helper for better display of big numbers # @example number_by_magnitude(4242) # "4.2K" # # @param number[Numeric] # @return [String] human friendly respresentation def number_by_magnitude(number) number_to_human(number, units: { thousand: :K, million: :M, billion: :G }) end # Creates a bootstrap form-group div with an additional 'Add' button next to the select field # # @param object[ActiveRecord::Object] the form's subject # @param resource[Symbol] the objects class # @param attr[Symbol] the select box's attribute # @param attr_name[String] the attribute's display name # @param options[Array] the select box options # @param path[String] the add button's path def select_with_errors_and_button(object, resource, attr, attr_name, options, path) has_errors = object.errors[attr].present? content_tag(:div, class: "form-group #{' has-error' if has_errors }") do attr_label = label(resource, attr, attr_name, class: 'control-label col-xs-5 required') select_div = content_tag(:div, class: 'col-xs-5') do select_part = select_tag([resource, attr].join('_').to_sym, options, + include_blank: true, name: "#{resource}[#{attr}]", class: 'form-control' ) if has_errors select_part.concat(content_tag(:span, class: 'help-block') { object.errors[attr].first }) end select_part end button_part = content_tag(:div, class: 'col-xs-1') do link_to path do content_tag(:span, class: 'glyphicon glyphicon-plus text-success') {} end end attr_label.concat(select_div).concat(button_part) end end # Returns a style class depending on the given parameter # # @param status[Char] def success_class(status) case status when 'T' then 'success' when 'E' then 'danger' when 'f' then 'fatal' end end # Fetches the html class for a given path # # @param path[String] the path to check for # @param partial[Boolean] forces a left partial match # # @return [Hash] { class: 'active' } if the given path is the current page def active_class(path, partial = false) if current_page?(path) || (partial && request.path.starts_with?(path)) { class: 'active' } else {} end end # Constructs a breadcrumb out the given options # # @param options[Hash] a hash containing the breadcrumb links in name: path sets # @return an html ol breadcrumb def breadcrumb_with(options) content_tag(:ol, class: 'breadcrumb') do options.map { |name, path| content_tag(:li, active_class(path)) do link_to_if !current_page?(path), name, path end }.inject { |result, element| result.concat(element) } end end # Constructs a list with the given array elements # # @example: # inline_list([:foo, :bar]) # # # # @param arr[Array] # @return an html ul list def inline_list(arr) content_tag(:ul, class: 'list-inline') do arr.map { |element| content_tag(:li) do content_tag(:span, class: 'label label-default') do element end end }.inject { |result, element| result.concat(element) } end end end diff --git a/app/views/jobs/_fileset.html.erb b/app/views/jobs/_fileset.html.erb index ec4150d..a33c495 100644 --- a/app/views/jobs/_fileset.html.erb +++ b/app/views/jobs/_fileset.html.erb @@ -1,6 +1,9 @@ -
-

Fileset "<%= fileset.name %>"

-
-
+
+
+

Fileset "<%= fileset.name %>"

+
+
+
 <%= fileset.to_bacula_config_array.join("\n") %>
-
+
+ diff --git a/app/views/jobs/_schedule.html.erb b/app/views/jobs/_schedule.html.erb index 33fd25e..efe5fda 100644 --- a/app/views/jobs/_schedule.html.erb +++ b/app/views/jobs/_schedule.html.erb @@ -1,6 +1,8 @@ -
-

Schedule "<%= schedule.name %>"

+
+
+

Schedule "<%= schedule.name %>"

+
+
+  <%= schedule.to_bacula_config_array.join("\n") %>
+  
-
-<%= schedule.to_bacula_config_array.join("\n") %>
-
diff --git a/app/views/jobs/edit.html.erb b/app/views/jobs/edit.html.erb index b6113c7..5d8b988 100644 --- a/app/views/jobs/edit.html.erb +++ b/app/views/jobs/edit.html.erb @@ -1,36 +1,32 @@

Edit Job Template <%= @job.name %>

Job Attributes


<%= render 'form' %>
-
-
- <% fileset = @fileset || @job.fileset %> - <%= render partial: 'fileset', locals: { fileset: fileset } if fileset %> -
+
+ <% fileset = @fileset || @job.fileset %> + <%= render partial: 'fileset', locals: { fileset: fileset } if fileset %>
-
-
- <% schedule = @schedule || @job.schedule %> - <%= render partial: 'schedule', locals: { schedule: schedule } if schedule %> -
+
+ <% schedule = @schedule || @job.schedule %> + <%= render partial: 'schedule', locals: { schedule: schedule } if schedule %>

<%= link_to 'Cancel', host_job_path(@host, @job), class: 'btn btn-danger', role: 'button' %>
diff --git a/app/views/jobs/new.html.erb b/app/views/jobs/new.html.erb index 357cb8c..5b822f8 100644 --- a/app/views/jobs/new.html.erb +++ b/app/views/jobs/new.html.erb @@ -1,18 +1,27 @@

New Job Template

-
-
-

Job Attributes

+
+
+
+

Job Attributes

+
+
+ <%= render 'form' %>
-
-
+
+
+
+
+
+
+
<%= link_to 'Cancel', host_path(@job.host), class: 'btn btn-danger', role: 'button' %>