From 0fa041345bcbfd6755df26e3126d0f770ce3fad0 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 11:36:02 +0100 Subject: [PATCH 01/59] Fix(Hosts index): Move to datatables usage --- Gemfile | 3 ++ Gemfile.lock | 2 + app/assets/javascripts/application.js | 7 ++-- app/assets/javascripts/datatables.js | 33 +++++++++++++++ app/assets/javascripts/filter_table.js | 54 ------------------------- app/assets/javascripts/sort_table.js | 8 ---- app/assets/stylesheets/application.scss | 24 +++++++++-- app/assets/stylesheets/requests.scss | 4 -- app/views/application/_footer.html.erb | 10 ----- app/views/hosts/index.html.erb | 37 ++++++++--------- 10 files changed, 79 insertions(+), 103 deletions(-) create mode 100644 app/assets/javascripts/datatables.js delete mode 100644 app/assets/javascripts/filter_table.js delete mode 100644 app/assets/javascripts/sort_table.js diff --git a/Gemfile b/Gemfile index 2a607980..f41c8896 100644 --- a/Gemfile +++ b/Gemfile @@ -49,6 +49,9 @@ gem 'bootstrap', '~> 4.3.1' gem 'devise-bootstrap-views', '~> 1.0' gem 'devise-i18n' gem 'jquery-rails' +# Jquery datatables ruby gems for assets pipeline, https://datatables.net/ +# https://github.com/mkhairi/jquery-datatables +gem 'jquery-datatables' # Ruby interface to the VMware vSphere API # https://github.com/vmware/rbvmomi diff --git a/Gemfile.lock b/Gemfile.lock index 1703f752..50b667cf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -172,6 +172,7 @@ GEM jbuilder (2.8.0) activesupport (>= 4.2.0) multi_json (>= 1.2) + jquery-datatables (1.10.19.1) jquery-rails (4.3.3) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -435,6 +436,7 @@ DEPENDENCIES git guard jbuilder (~> 2.5) + jquery-datatables jquery-rails listen (>= 3.0.5, < 3.2) mina diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 274b05dc..50073a3d 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -17,12 +17,13 @@ //= require popper //= require bootstrap //= require doughnut_chart -//= require filter_table -//= require sort_table //= require prevent_anchor_reload -//= require_tree . //= require select2 //= require clipboard +// Contains code for initializing and configuring datatables +// app/assets/javascripts/datatables.js +//= require datatables +//= require_tree . // With Turbolinks, jQuery $(document).ready events fire only in response // to the initial page load, not after any subsequent page changes diff --git a/app/assets/javascripts/datatables.js b/app/assets/javascripts/datatables.js new file mode 100644 index 00000000..0eedfd58 --- /dev/null +++ b/app/assets/javascripts/datatables.js @@ -0,0 +1,33 @@ +//= require datatables/jquery.dataTables +//= require datatables/dataTables.bootstrap4 + +// Global settings and initializer for all datatables +$.extend( $.fn.dataTable.defaults, { + // https://datatables.net/reference/option/responsive + responsive: true, + // https://datatables.net/reference/option/pagingType + pagingType: 'simple_numbers' + // https://datatables.net/reference/option/dom + //dom: + // "<'row'<'col-sm-4 text-left'f><'right-action col-sm-8 text-right'<'buttons'B> <'select-info'> >>" + + // "<'row'<'dttb col-12 px-0'tr>>" + + // "<'row'<'col-sm-12 table-footer'lip>>" +}); + +// Initialization on turbolinks load +$(document).on('turbolinks:load', function() { + if (!$.fn.DataTable.isDataTable('table[data-toggle="datatable"]')) { + $('table[data-toggle="datatable"]').DataTable(); + } +}); + +// Turbolinks cache fix +$(document).on('turbolinks:before-cache', function() { + var dataTable = $($.fn.dataTable.tables(true)).DataTable(); + if (dataTable !== null) { + dataTable.clear(); + dataTable.destroy(); + return dataTable = null; + } +}); + diff --git a/app/assets/javascripts/filter_table.js b/app/assets/javascripts/filter_table.js deleted file mode 100644 index da3a4fe5..00000000 --- a/app/assets/javascripts/filter_table.js +++ /dev/null @@ -1,54 +0,0 @@ -function hide(htmlElm) { - htmlElm.style.display = 'none'; -} - -function unhide(htmlElm) { - htmlElm.style.display = ''; -} - -function someCellInRowContains(row, searchTexts) { - let remainingFilters = searchTexts.filter(searchText => - !Array.prototype.some.call(row, cell => { - let txtValue = (cell.dataset && cell.dataset.filterValue) || cell.textContent || cell.innerText; - return txtValue.toUpperCase().includes(searchText); - }) - ); - return remainingFilters.length === 0; -} - - -function filterTable(inputId, tableId) { - const input = document.getElementById(inputId); - const table = document.getElementById(tableId); - if (!table || !input) { - return; - } - - const filters = input.value.toUpperCase().split(/[ ,]+/); - const rows = table.getElementsByTagName('tr'); - let invisible = 0; - - // Loop through all table rows, and hide those who don't match the search query ignoring the headline - for (let i = 1; i < rows.length; i++) { - const cells = rows[i].getElementsByTagName('td'); - - if (someCellInRowContains(cells, filters)) { - unhide(rows[i]); - } else { - hide(rows[i]); - invisible++; - } - } - - if (invisible === rows.length - 1) { - hide(table); - } else { - unhide(table); - } -} - -function filterTables(inputId, tableIds) { - for (const tableID of tableIds) { - filterTable(inputId, tableID) - } -} \ No newline at end of file diff --git a/app/assets/javascripts/sort_table.js b/app/assets/javascripts/sort_table.js deleted file mode 100644 index d615733c..00000000 --- a/app/assets/javascripts/sort_table.js +++ /dev/null @@ -1,8 +0,0 @@ -function sortWithoutHTML(a, b) { - function stripHTML(html) { - let tmp = document.createElement("DIV"); - tmp.innerHTML = html; - return tmp.textContent || tmp.innerText || ""; - } - return stripHTML(a).localeCompare(stripHTML(b)) -} \ No newline at end of file diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 72123cee..7acc50b2 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -9,18 +9,35 @@ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS * files in this directory. Styles in this file should be added after the last require_* statement. * It is generally better to create a new file per style scope. - + *= require font-awesome *= require_self *= require_tree . */ - + $primary: #0C415F; $danger: #a80833; $primary-active: #1f6993; $primary-hover: #1a5b82; +// https://github.com/twbs/bootstrap-rubygem#a-ruby-on-rails +// Custom bootstrap variables must be set or imported *before* bootstrap. @import "bootstrap"; +// Bootstrap styling for datatables +// https://github.com/mkhairi/jquery-datatables#stylesheets +@import 'datatables/dataTables.bootstrap4'; +// optional datatables styles for extensions, include when used +//@import 'datatables/extensions/AutoFill/autoFill.bootstrap4'; +//@import 'datatables/extensions/Buttons/buttons.bootstrap4'; +//@import 'datatables/extensions/ColReorder/colReorder.bootstrap4'; +//@import 'datatables/extensions/FixedColumns/fixedColumns.bootstrap4'; +//@import 'datatables/extensions/FixedHeader/fixedHeader.bootstrap4'; +//@import 'datatables/extensions/KeyTable/keyTable.bootstrap4'; +//@import 'datatables/extensions/Responsive/responsive.bootstrap4'; +//@import 'datatables/extensions/RowGroup/rowGroup.bootstrap4'; +//@import 'datatables/extensions/RowReorder/rowReorder.bootstrap4'; +//@import 'datatables/extensions/Scroller/scroller.bootstrap4'; +//@import 'datatables/extensions/Select/select.bootstrap4'; th { @extend .text-white; @@ -34,7 +51,7 @@ html, body { } .page-container { - margin: 50px 0 0 50px; + margin: 25px 0 0 50px; width: calc(100% - 100px); } @@ -114,3 +131,4 @@ body { padding-top: 3px; } + diff --git a/app/assets/stylesheets/requests.scss b/app/assets/stylesheets/requests.scss index bd36f34a..252bdaf6 100644 --- a/app/assets/stylesheets/requests.scss +++ b/app/assets/stylesheets/requests.scss @@ -30,10 +30,6 @@ label { margin-right: 5px; } -h1{ - margin-bottom: 1em; -} - /* Selected items on top */ .select2-selection__choice { background-color: #0C415F !important; diff --git a/app/views/application/_footer.html.erb b/app/views/application/_footer.html.erb index 7d49a634..71df46c9 100644 --- a/app/views/application/_footer.html.erb +++ b/app/views/application/_footer.html.erb @@ -15,13 +15,3 @@ - - - - - - \ No newline at end of file diff --git a/app/views/hosts/index.html.erb b/app/views/hosts/index.html.erb index 72a5a738..2878d620 100644 --- a/app/views/hosts/index.html.erb +++ b/app/views/hosts/index.html.erb @@ -1,31 +1,26 @@ -

Hosts

+

Hosts

- - - +
- - - - - - + + + + + + <% @hosts.each do |host| %> - - - - + + + - <% end %> + <% end %> <%# @hosts.each %>
NameVendorModelStatus
NameVendorModelStatus
- <%= link_to host.name, {controller: :hosts, action: 'show', id: host.name}, method: :get %> - <%= host.vendor %><%= host.model %> -
-
+
<%= link_to host.name, host_path(host.name) %><%= host.vendor %><%= host.model %> + <%= content_tag(:div, nil, + title: host.connection_state, + class: ["round", "#{host.connection_state == 'connected' ? 'bg-success' : 'bg-warning'}"]) %>
\ No newline at end of file From b06ffbe4af16ccc19e37ad483a96cebe0575dc6e Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 11:40:34 +0100 Subject: [PATCH 02/59] Chore(Application.scss): Whitespace --- app/assets/stylesheets/application.scss | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 7acc50b2..97d62e63 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -9,12 +9,12 @@ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS * files in this directory. Styles in this file should be added after the last require_* statement. * It is generally better to create a new file per style scope. - + *= require font-awesome *= require_self *= require_tree . */ - + $primary: #0C415F; $danger: #a80833; $primary-active: #1f6993; @@ -131,4 +131,3 @@ body { padding-top: 3px; } - From e66b27190f6c13a94423dadb0b181a9325822936 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 14:47:50 +0100 Subject: [PATCH 03/59] Fix(Projects index): Use datatables --- app/views/projects/_list.html.erb | 22 --------------------- app/views/projects/index.html.erb | 32 +++++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 28 deletions(-) delete mode 100644 app/views/projects/_list.html.erb diff --git a/app/views/projects/_list.html.erb b/app/views/projects/_list.html.erb deleted file mode 100644 index acfe18f2..00000000 --- a/app/views/projects/_list.html.erb +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - <% projects.each do |project| %> - - - - - - <% end %> - -
<%= User.human_attribute_name('name') %><%= User.human_attribute_name('description') %><%= User.human_attribute_name('responsible_users') %>
<%= link_to project.name, project_path(project) %><%= project.description %> -
    - <% project.responsible_users.each do |user| %> -
  • <%= user.name %>
  • - <% end %> -
-
diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index 375bc5e1..0a1bde07 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -1,4 +1,4 @@ -

Projects

+

Projects

<% if current_user.employee_or_admin? %> @@ -9,8 +9,28 @@ <% end %>
-<%= render 'list', projects: @projects %> - -<% if @projects.length == 0 %> -

No projects created yet

-<% end %> + + + + + + + + + + <% @projects.each do |project| %> + + + + + + <% end %> <%# @projects.each %> + +
<%= User.human_attribute_name('name') %><%= User.human_attribute_name('description') %><%= User.human_attribute_name('responsible_users') %>
<%= link_to project.name, project_path(project) %><%= truncate(project.description, length: 100) %> + <%# https://getbootstrap.com/docs/4.0/content/typography/#inline %> +
    + <% project.responsible_users.each do |user| %> +
  • <%= user.name %>
  • + <% end %> +
+
From cc7b3a89aa297b9059bf44cbb258c1d189e5629a Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 14:57:37 +0100 Subject: [PATCH 04/59] Fix(Servers index): Use datatables --- app/views/servers/index.html.erb | 37 +++++++++++++++----------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/app/views/servers/index.html.erb b/app/views/servers/index.html.erb index db1345e2..7e7b3b97 100644 --- a/app/views/servers/index.html.erb +++ b/app/views/servers/index.html.erb @@ -1,32 +1,29 @@ -

Servers

+

Servers

- -
- <% if current_user.admin? %> - <%= link_to fa_icon('plus'), new_server_path, - title: 'Create new server', - :data => { toggle: 'tooltip', placement: 'left' }, - class: "btn btn-primary float-right" %> - <% end %> -
+<% if current_user.admin? %> + <%= link_to fa_icon('plus'), new_server_path, + title: 'Create new server', + :data => { toggle: 'tooltip', placement: 'left' }, + class: "btn btn-primary float-right" %> +<% end %> - +
- - - - + + + + <% @servers.each do |server| %> - - - - + + + + - <% end %> + <% end %> <%# @servers.each %>
NameVendorModelResponsibleNameVendorModelResponsible
<%= link_to server.name, server %><%= server.vendor %><%= server.model %><%= server.responsible&.name %><%= link_to server.name, server_path(server) %><%= server.vendor %><%= server.model %><%= server.responsible.name %>
\ No newline at end of file From ae816563f3b8bdd1843d32cef48d167d35baa42d Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 15:23:26 +0100 Subject: [PATCH 05/59] Fix(Users index: Use datatables. Cleanup. Show role instead of disabled buttons when no change right exist. --- app/views/users/index.html.erb | 58 +++++++++++++--------------------- 1 file changed, 22 insertions(+), 36 deletions(-) diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index c43be934..2c0dd903 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,47 +1,33 @@ -

Users

+

Users

- - - +
- - - - + + + + <% @users.each do |user| %> - <% end %> From 39fc489b49b949c3e7d47cee74512eb148865441 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 15:29:10 +0100 Subject: [PATCH 06/59] Fix(Users index): Display date nicely. --- app/views/users/index.html.erb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 2c0dd903..f3002515 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -28,7 +28,9 @@ <%= user.role.capitalize %> <% end %> - + <% end %> From 0ab8ea0337981d1b6af04f0b1cb04c12db302621 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 15:58:13 +0100 Subject: [PATCH 07/59] Fix(OS index): Use datatables --- app/views/operating_systems/index.html.erb | 35 ++++++++++++---------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/app/views/operating_systems/index.html.erb b/app/views/operating_systems/index.html.erb index 52c64e2e..3a1dbda8 100644 --- a/app/views/operating_systems/index.html.erb +++ b/app/views/operating_systems/index.html.erb @@ -1,29 +1,32 @@

Operating Systems

-
<%= User.human_attribute_name('name') %><%= User.human_attribute_name('email') %><%= User.human_attribute_name('role') %><%= User.human_attribute_name('last_sign_in_at') %><%= User.human_attribute_name('name') %><%= User.human_attribute_name('email') %><%= User.human_attribute_name('role') %><%= User.human_attribute_name('last_sign_in_at') %>
<%= link_to user.name, user_path(user) %> <%= user.email %> - -

<%= user.role %>

-
- <% User.roles.map(&:first).each do |role| %> - <% if editable_for user %> - <%= link_to role.capitalize, - update_role_user_path(user, role: role), - method: :patch, - id: "btn-#{role}-#{user.id}", - class: "btn - btn-#{if user.role == role then 'primary' else 'light' end}" - %> - <% else %> - - <% end %> - <% end %> -
+ <%# https://datatables.net/manual/data/orthogonal-data#HTML-5 %> +
+ <% if editable_for user %> +
+ <% User.roles.map(&:first).each do |role| %> + <%= link_to role.capitalize, + update_role_user_path(user, role: role), + method: :patch, + class: "btn btn-#{if user.role == role then 'primary' else 'light' end}" %> + <% end %> + <% else %> + <%= user.role.capitalize %> + <% end %> +
<%= user.current_sign_in_at %>
<%= user.current_sign_in_at %> + <%= I18n.l(user.current_sign_in_at, format: :long) %> +
- - - -
- <%=link_to(fa_icon('plus'), - {controller: :operating_systems, action: 'new'}, - method: :get, class: 'btn btn-primary', id: 'createNewProjectButton') %> -
+<%= link_to fa_icon('plus'), new_operating_system_path, + title: 'Add new OS', + :data => { toggle: 'tooltip', placement: 'left' }, + class: 'btn btn-primary float-right' %> - + +
- + <%# https://datatables.net/reference/option/columns.orderable %> + - - <% @operating_systems.each do |operating_system| %> + <% @operating_systems.each do |os| %> - - - + + <% end %> From 94dd42bd7b98c3c37461da51054425f0a3d15479 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 16:59:16 +0100 Subject: [PATCH 08/59] Fix(Requests index): Use datatables --- app/assets/javascripts/datatables.js | 1 + app/views/hosts/index.html.erb | 6 +- app/views/operating_systems/index.html.erb | 2 +- app/views/requests/index.html.erb | 119 ++++++++++----------- 4 files changed, 63 insertions(+), 65 deletions(-) diff --git a/app/assets/javascripts/datatables.js b/app/assets/javascripts/datatables.js index 0eedfd58..89ffa0b1 100644 --- a/app/assets/javascripts/datatables.js +++ b/app/assets/javascripts/datatables.js @@ -21,6 +21,7 @@ $(document).on('turbolinks:load', function() { } }); +// https://stackoverflow.com/questions/41070556/how-can-i-prevent-duplicate-wrappers-on-a-jquery-datatable-when-navigating-back // Turbolinks cache fix $(document).on('turbolinks:before-cache', function() { var dataTable = $($.fn.dataTable.tables(true)).DataTable(); diff --git a/app/views/hosts/index.html.erb b/app/views/hosts/index.html.erb index 2878d620..9c04be02 100644 --- a/app/views/hosts/index.html.erb +++ b/app/views/hosts/index.html.erb @@ -15,10 +15,10 @@ - <% end %> <%# @hosts.each %> diff --git a/app/views/operating_systems/index.html.erb b/app/views/operating_systems/index.html.erb index 3a1dbda8..16bd474f 100644 --- a/app/views/operating_systems/index.html.erb +++ b/app/views/operating_systems/index.html.erb @@ -6,7 +6,7 @@ class: 'btn btn-primary float-right' %> -
NameActions
<%= operating_system.name %><%= link_to 'Edit', edit_operating_system_path(operating_system), class: "btn btn-primary" %><%= link_to 'Delete', operating_system, method: :delete, data: { confirm: 'Are you sure?' }, class: "btn btn-danger" %><%= os.name %> + <%= link_to fa_icon('pencil'), edit_operating_system_path(os), + title: 'Edit', + class: "btn btn-sm btn-primary" %> + <%= link_to fa_icon('trash'), os, method: :delete, + title: 'Delete', + data: { confirm: "Are you sure you want to delete '#{os.name}'?" }, + class: "btn btn-sm btn-danger" %> +
<%= link_to host.name, host_path(host.name) %> <%= host.vendor %> <%= host.model %> - <%= content_tag(:div, nil, + + <%= content_tag :div, nil, title: host.connection_state, - class: ["round", "#{host.connection_state == 'connected' ? 'bg-success' : 'bg-warning'}"]) %> + class: "round #{host.connection_state == 'connected' ? 'bg-success' : 'bg-warning'}" %>
+
diff --git a/app/views/requests/index.html.erb b/app/views/requests/index.html.erb index 373869f4..795a0dbb 100644 --- a/app/views/requests/index.html.erb +++ b/app/views/requests/index.html.erb @@ -4,86 +4,83 @@ method: :get, class: "btn btn-primary float-right mt-3" %> <% if current_user.admin? %> - <%= button_to "Templates", request_templates_path, - method: :get, - class: "btn btn-primary float-right mt-3 mr-3" %> - <%= button_to 'Operating Systems', operating_systems_path, - method: :get, - class: 'btn btn-primary float-right mt-3 mr-3' %> + <%= button_to "Templates", request_templates_path, + method: :get, + class: "btn btn-primary float-right mt-3 mr-3" %> + <%= button_to 'Operating Systems', operating_systems_path, + method: :get, + class: 'btn btn-primary float-right mt-3 mr-3' %> <% end %> -<%= link_to "Pending requests (#{@pending_requests&.size}) ".html_safe, '#pending' %>
-<%= link_to "Resolved requests (#{@resolved_requests&.size}) ".html_safe, '#resolved' %>
-

Pending requests

- - -
Name
+
- - - - - - - - + + + + + + + + - <% @pending_requests&.each do |request| %> - - - - - - - - - - - <% end %> + <% @pending_requests&.each do |request| %> + + + + + + + + + + + <% end %>
VM NameCPU CoresRAMHDDOSPortApplication NameCommentVM NameCPU CoresRAMHDDOSPortApplication NameComment
<%= link_to request.name, request_path(request) %><%= request.cpu_cores %><%= request.ram_gb %> GB<%= request.storage_gb %> GB<%= request.operating_system %><%= request.port %><%= request.application_name %><%= request.comment %>
<%= link_to request.name, request_path(request) %><%= request.cpu_cores %><%= request.ram_gb %> GB<%= request.storage_gb %> GB<%= request.operating_system %><%= request.port %><%= request.application_name %><%= request.comment %>
-

Resolved requests

- - +

Resolved requests

- +
- - - - - - - - - + + + + + + + + + + - <% @resolved_requests&.each do |request| %> - - - - - - - - - - + + + + + + + + + <%# https://datatables.net/manual/data/orthogonal-data#HTML-5 %> + + - <% end %> + <% end %> <%# @resolved_requests&.each %>
VM NameCPU CoresRAMHDDOSPortApplication NameCommentStatusVM NameCPU CoresRAMHDDOSPortApplication NameCommentStatusActions
<%= link_to request.name, request_path(request) %><%= request.cpu_cores %><%= request.ram_gb %> GB<%= request.storage_gb %> GB<%= request.operating_system %><%= request.port %><%= request.application_name %><%= request.comment %> -
-
+ <% @resolved_requests&.each do |request| %> +
<%= link_to request.name, request_path(request) %><%= request.cpu_cores %><%= request.ram_gb %> GB<%= request.storage_gb %> GB<%= request.operating_system %><%= request.port %><%= request.application_name %><%= request.comment %> + <%= content_tag :div, nil, + title: request.status, + class: "round #{request.accepted? ? 'bg-success' : 'bg-warning'}" %> + <% if request.accepted? %> - > + >
\ No newline at end of file From 50bfa6f5e4704e2d4c1c692bbd277e41ced20b65 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 17:03:05 +0100 Subject: [PATCH 09/59] Fix(Users index): handle nil in current_sign_in_at --- app/views/users/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index f3002515..67229d64 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -29,7 +29,7 @@ <% end %> - <%= I18n.l(user.current_sign_in_at, format: :long) %> + <%= I18n.l(user.current_sign_in_at, format: :long) if user.current_sign_in_at %> <% end %> From 152c5ef110b4557f945d5cfa460a53e069e950f9 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 17:30:49 +0100 Subject: [PATCH 10/59] Fix(Requests index): Top navigation buttons --- app/views/requests/index.html.erb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/requests/index.html.erb b/app/views/requests/index.html.erb index 795a0dbb..5f447711 100644 --- a/app/views/requests/index.html.erb +++ b/app/views/requests/index.html.erb @@ -1,14 +1,14 @@ +

Requests

+
-

Requests

<%= link_to fa_icon('plus'), new_request_path, - method: :get, + title: 'New VM request', + :data => { toggle: 'tooltip', placement: 'bottom' }, class: "btn btn-primary float-right mt-3" %> <% if current_user.admin? %> - <%= button_to "Templates", request_templates_path, - method: :get, + <%= link_to "Templates", request_templates_path, class: "btn btn-primary float-right mt-3 mr-3" %> - <%= button_to 'Operating Systems', operating_systems_path, - method: :get, + <%= link_to 'Operating Systems', operating_systems_path, class: 'btn btn-primary float-right mt-3 mr-3' %> <% end %>
From 0a8c43d3de83e4ae266ffc96c57d624c8eaf6160 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 17:31:32 +0100 Subject: [PATCH 11/59] Fix(Requests index): Use datatables. Cleanup. --- app/views/request_templates/index.html.erb | 73 ++++++++++------------ 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/app/views/request_templates/index.html.erb b/app/views/request_templates/index.html.erb index 426800f1..aec51bc7 100644 --- a/app/views/request_templates/index.html.erb +++ b/app/views/request_templates/index.html.erb @@ -1,58 +1,53 @@ -

Request Templates

+

Request Templates

- - - - - - - -
- <%=link_to(fa_icon('plus'), - new_request_template_path, class: 'btn btn-primary') %> - - <%= link_to 'Requests', requests_path, class: 'btn btn-primary' %> -
+
+ <%= link_to fa_icon('plus'), new_request_template_path, + title: 'Add request template', + :data => { toggle: 'tooltip', placement: 'bottom' }, + class: "btn btn-primary float-right mt-3" %> + + <% if current_user.admin? %> + <%= link_to "Requests", requests_path, + class: "btn btn-primary float-right mt-3 mr-3" %> + <%= link_to 'Operating Systems', operating_systems_path, + class: 'btn btn-primary float-right mt-3 mr-3' %> + <% end %> +
- +
- - - + + + + <% @request_templates.each do |request_template| %> - <% if current_user.admin? %> - - <% else %> - - <% end %> + - - + + - <% if current_user.admin? %> - - <% end %> + <% end %>
Template name CPU coresRAM in GBStorage in GBOperating systemRAMStorageOperating systemActions
<%= link_to request_template.name, edit_request_template_path(request_template) %><%= request_template.name %><%= request_template.name %> <%= request_template.cpu_cores %><%= request_template.ram_gb %><%= request_template.storage_gb %><%= request_template.ram_gb %> GB<%= request_template.storage_gb %> GB <%= request_template.operating_system %> - <%= link_to 'Delete', - request_template, - method: :delete, - data: { confirm: 'Are you sure?' }, - id: "deleteRequestTemplateButton-#{request_template.id}", - class: 'btn btn-danger' - %> - + <% if current_user.admin? %> + <%= link_to fa_icon('pencil'), edit_request_template_path(request_template), + title: 'Edit', + class: "btn btn-sm btn-primary" %> + <%= link_to fa_icon('trash'), request_template, method: :delete, + title: 'Delete', + data: { confirm: "Are you sure you want to delete '#{request_template.name}'?" }, + id: "deleteRequestTemplateButton-#{request_template.id}", + class: "btn btn-sm btn-danger" %> + <% end %> +
-<% if @request_templates.length == 0 %> -

No templates created yet

-<% end %> From 95782df38ec75855386de92c32e3d986ac6ea76d Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 17:42:40 +0100 Subject: [PATCH 12/59] Fix(projects table): Readd table partial. It's used in Users#show --- app/views/projects/_table.html.erb | 25 ++++++++++++++++++ app/views/projects/index.html.erb | 41 ++++++------------------------ app/views/users/show.html.erb | 18 +++++-------- 3 files changed, 40 insertions(+), 44 deletions(-) create mode 100644 app/views/projects/_table.html.erb diff --git a/app/views/projects/_table.html.erb b/app/views/projects/_table.html.erb new file mode 100644 index 00000000..d886e3fd --- /dev/null +++ b/app/views/projects/_table.html.erb @@ -0,0 +1,25 @@ + + + + + + + + + + <% projects.each do |project| %> + + + + + + <% end %> <%# projects.each %> + +
<%= User.human_attribute_name('name') %><%= User.human_attribute_name('description') %><%= User.human_attribute_name('responsible_users') %>
<%= link_to project.name, project_path(project) %><%= truncate(project.description, length: 100) %> + <%# https://getbootstrap.com/docs/4.0/content/typography/#inline %> +
    + <% project.responsible_users.each do |user| %> +
  • <%= user.name %>
  • + <% end %> +
+
\ No newline at end of file diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index 0a1bde07..4f7df0b9 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -1,36 +1,11 @@

Projects

-
- <% if current_user.employee_or_admin? %> - <%= link_to(fa_icon('plus'), new_project_path, - title: 'Create new project', - :data => { toggle: 'tooltip', placement: 'left' }, - class: 'btn btn-primary float-right', id: 'createNewProjectButton') %> - <% end %> -
+<% if current_user.employee_or_admin? %> + <%= link_to(fa_icon('plus'), new_project_path, + title: 'Create new project', + :data => { toggle: 'tooltip', placement: 'left' }, + class: 'btn btn-primary float-right', id: 'createNewProjectButton') %> +<% end %> + +<%= render 'table', projects: @projects %> - - - - - - - - - - <% @projects.each do |project| %> - - - - - - <% end %> <%# @projects.each %> - -
<%= User.human_attribute_name('name') %><%= User.human_attribute_name('description') %><%= User.human_attribute_name('responsible_users') %>
<%= link_to project.name, project_path(project) %><%= truncate(project.description, length: 100) %> - <%# https://getbootstrap.com/docs/4.0/content/typography/#inline %> -
    - <% project.responsible_users.each do |user| %> -
  • <%= user.name %>
  • - <% end %> -
-
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index dbca4887..fac0bd94 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -9,8 +9,6 @@ <% end %> -
- @@ -44,17 +42,15 @@ <% end %> -

+ <% if @user == current_user %> -
- - Add to Slack - -
+ + Add to Slack + <% end %> -

-

Projects

+ +

<%= "#{@user.first_name.capitalize}'s projects" %>

<% if @user.responsible_projects.empty? %> <% if @user == current_user %>

You are not part of any projects. All your projects will be shown here.

@@ -62,5 +58,5 @@

This user is not part of any projects. All his projects will be shown here.

<% end %> <% else %> - <%= render 'projects/list', projects: @user.responsible_projects %> + <%= render 'projects/table', projects: @user.responsible_projects %> <% end %> From 7603e38df591db46440811f7bc71a2dd0b9e8158 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 18:00:07 +0100 Subject: [PATCH 13/59] Fix(Users index): Readd HTML ids used for testing --- app/views/users/index.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 67229d64..92f945b9 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -21,6 +21,7 @@ <% User.roles.map(&:first).each do |role| %> <%= link_to role.capitalize, update_role_user_path(user, role: role), + id: "btn-#{role}-#{user.id}", method: :patch, class: "btn btn-#{if user.role == role then 'primary' else 'light' end}" %> <% end %> From ed30074eb93424f38e5cba9e75e4bef0b8e54451 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 18:00:27 +0100 Subject: [PATCH 14/59] Fix(Projects index): USe of parenthesis --- app/views/projects/index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index 4f7df0b9..33213660 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -1,10 +1,10 @@

Projects

<% if current_user.employee_or_admin? %> - <%= link_to(fa_icon('plus'), new_project_path, + <%= link_to fa_icon('plus'), new_project_path, title: 'Create new project', :data => { toggle: 'tooltip', placement: 'left' }, - class: 'btn btn-primary float-right', id: 'createNewProjectButton') %> + class: 'btn btn-primary float-right', id: 'createNewProjectButton' %> <% end %> <%= render 'table', projects: @projects %> From 2a12a17ce97d91e1e8860532b109ca5ed23603e3 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 18:55:47 +0100 Subject: [PATCH 15/59] Fix(VMs index): Use datatables. --- app/views/vms/_table.erb | 88 +++++++++++++++++------------------- app/views/vms/index.html.erb | 1 - 2 files changed, 41 insertions(+), 48 deletions(-) diff --git a/app/views/vms/_table.erb b/app/views/vms/_table.erb index 7a149503..840a8915 100644 --- a/app/views/vms/_table.erb +++ b/app/views/vms/_table.erb @@ -1,57 +1,51 @@ -<%# https://getbootstrap.com/docs/4.0/content/tables/ %> -> +
> - - - - + + + + <% unless buttons.nil? %> - + <% end %> - <%# Element hidden, used for search %> - - <% vms.each do |vm| %> - - - - - - <% unless buttons.nil? %> - + + <%# Allow searching for description %> + - <% end %> - <%# Element hidden, used for search %> - - - <% end %> + + + <% unless buttons.nil? %> + + <% end %> + + <% end %> <%# vms.each %>
StatusNameProjectResponsibleStatusNameProjectResponsibleActionsActionsDescription
-

<%= vm.status %>

-
-
-
- <%= link_to vm.name, {controller: :vms, action: 'show', id: vm.name}, method: :get %> - - <% if vm.project.nil? %> - No project found! - <% else %> - <%= link_to vm.project.name, vm.project %> - <% end %> - - <% if vm.responsible_users.empty? %> - No responsible users found! - <% else %> - <%# https://getbootstrap.com/docs/4.0/content/typography/#inline %> -
    - <% vm.responsible_users.each do |user| %> -
  • <%= link_to user.name, user %>
  • - <% end %> -
- <% end %> -
- <%= render buttons.to_s, vm: vm %> + <% vms.each do |vm| %> +
+ <%= content_tag :div, nil, + title: vm.status, + :data => { toggle: 'tooltip', placement: 'right' }, + class: "round #{vm.archived? ? 'bg-secondary' : (vm.powered_on? ? 'bg-success' : 'bg-danger')}" %> + + <%= link_to vm.name, vm_path(vm.name) %> <%= vm.config&.description %>
+ <% if vm.project.nil? %> + No project found! + <% else %> + <%= link_to vm.project.name, project_path(vm.project) %> + <% end %> + + <% if vm.responsible_users.empty? %> + No responsible users found! + <% else %> + <%# https://getbootstrap.com/docs/4.0/content/typography/#inline %> +
    + <% vm.responsible_users.each do |user| %> +
  • <%= link_to user.name, user_path(user) %>
  • + <% end %> +
+ <% end %> +
<%= render buttons.to_s, vm: vm %>
\ No newline at end of file diff --git a/app/views/vms/index.html.erb b/app/views/vms/index.html.erb index 1b9af43f..3c1c40e0 100644 --- a/app/views/vms/index.html.erb +++ b/app/views/vms/index.html.erb @@ -1,6 +1,5 @@

Virtual Machines

-
<% if current_user.employee_or_admin? %> <%= link_to fa_icon('plus'), new_request_path, From 2fc242e6738a1543e854c445596a9ce68c8c8e62 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 18:56:13 +0100 Subject: [PATCH 16/59] Fix(Index): Tooltips for status --- app/views/hosts/index.html.erb | 1 + app/views/requests/index.html.erb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/views/hosts/index.html.erb b/app/views/hosts/index.html.erb index 9c04be02..ec47168e 100644 --- a/app/views/hosts/index.html.erb +++ b/app/views/hosts/index.html.erb @@ -18,6 +18,7 @@ <%= content_tag :div, nil, title: host.connection_state, + :data => { toggle: 'tooltip', placement: 'right' }, class: "round #{host.connection_state == 'connected' ? 'bg-success' : 'bg-warning'}" %> diff --git a/app/views/requests/index.html.erb b/app/views/requests/index.html.erb index 5f447711..5282a29b 100644 --- a/app/views/requests/index.html.erb +++ b/app/views/requests/index.html.erb @@ -76,6 +76,7 @@ <%= content_tag :div, nil, title: request.status, + :data => { toggle: 'tooltip', placement: 'right' }, class: "round #{request.accepted? ? 'bg-success' : 'bg-warning'}" %> From 79254760679a29008b5fdcc01b028e46f40fe1a4 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 21:38:20 +0100 Subject: [PATCH 17/59] Fix(VMs index): refactor buttons. Add tooltips. --- app/views/vms/_archive_buttons.erb | 14 ++++++++------ app/views/vms/_revive_buttons.erb | 14 ++++++++------ app/views/vms/_running_vm_buttons.erb | 14 ++++++++------ app/views/vms/_to_revive_buttons.erb | 7 ++++--- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/app/views/vms/_archive_buttons.erb b/app/views/vms/_archive_buttons.erb index 2198700d..29ccc8bd 100644 --- a/app/views/vms/_archive_buttons.erb +++ b/app/views/vms/_archive_buttons.erb @@ -1,14 +1,16 @@ <%if current_user.admin? && vm.archivable? %> - <%= link_to '', + <%= link_to fa_icon('archive'), {controller: :vms, action: 'archive_vm', id: vm.name}, method: :post, - data: { confirm: "Are you sure you want to archive '#{vm.name}'?" }, + data: { confirm: "Are you sure you want to archive '#{vm.name}'?", + toggle: 'tooltip', placement: 'top' }, title: "Archive VM", - class: "btn btn-primary btn-sm fa fa-archive" %> + class: "btn btn-primary btn-sm" %> <% end %> -<%= link_to '', +<%= link_to fa_icon('arrow-circle-up'), {controller: :vms, action: 'revive_vm', id: vm.name}, method: :post, - data: { confirm: "Are you sure you want to revive '#{vm.name}'?" }, + data: { confirm: "Are you sure you want to revive '#{vm.name}'?", + toggle: 'tooltip', placement: 'top' }, title: "Revive VM", - class: "btn btn-primary btn-sm fa fa-arrow-circle-up" %> \ No newline at end of file + class: "btn btn-primary btn-sm" %> \ No newline at end of file diff --git a/app/views/vms/_revive_buttons.erb b/app/views/vms/_revive_buttons.erb index f19b3f13..9f1c7c55 100644 --- a/app/views/vms/_revive_buttons.erb +++ b/app/views/vms/_revive_buttons.erb @@ -1,15 +1,17 @@ <% if current_user.admin? %> - <%= link_to '', + <%= link_to fa_icon('arrow-circle-up'), {controller: :vms, action: 'revive_vm', id: vm.name}, method: :post, - data: { confirm: "Are you sure you want to revive '#{vm.name}'?" }, + data: { confirm: "Are you sure you want to revive '#{vm.name}'?", + toggle: 'tooltip', placement: 'top' }, title: "Revive VM", - class: "btn btn-primary btn-sm fa fa-arrow-circle-up" %> + class: "btn btn-primary btn-sm" %> <% else %> - <%= link_to '', + <%= link_to fa_icon('arrow-circle-up'), {controller: :vms, action: 'request_vm_revive', id: vm.name}, method: :post, - data: { confirm: "Are you sure you want to request revival of '#{vm.name}'?" }, + data: { confirm: "Are you sure you want to request revival of '#{vm.name}'?", + toggle: 'tooltip', placement: 'top' }, title: "Request revival", - class: "btn btn-primary btn-sm fa fa-arrow-circle-up" %> + class: "btn btn-primary btn-sm" %> <% end %> \ No newline at end of file diff --git a/app/views/vms/_running_vm_buttons.erb b/app/views/vms/_running_vm_buttons.erb index 94e4842f..ababec5f 100644 --- a/app/views/vms/_running_vm_buttons.erb +++ b/app/views/vms/_running_vm_buttons.erb @@ -1,19 +1,21 @@ <% if current_user.admin? || vm.sudo_users.include?(current_user) %> <% if vm.vm_ware_tools? %> <% vm_powered_on = vm.powered_on? %> - <%= link_to '', + <%= link_to (vm_powered_on ? fa_icon('stop') : fa_icon('play')), {controller: :vms, action: 'change_power_state', id: vm.name}, method: :post, - data: {confirm: "Are you sure you want to #{ vm_powered_on ? 'stop' : 'start' } '#{vm.name}'?"}, + data: { confirm: "Are you sure you want to #{ vm_powered_on ? 'stop' : 'start' } '#{vm.name}'?", + toggle: 'tooltip', placement: 'top' }, title: "#{ vm_powered_on ? 'Stop' : 'Start' } VM", - class: "btn btn-primary btn-sm fa #{ vm_powered_on ? 'fa-stop' : 'fa-play' }" %> + class: "btn btn-primary btn-sm" %> <% if vm.powered_on? %> - <%= link_to '', + <%= link_to fa_icon('repeat'), {controller: :vms, action: 'reboot_guest_os', id: vm.name}, method: :post, - data: {confirm: "Are you sure you want to reboot the guest OS of '#{vm.name}'?"}, + data: { confirm: "Are you sure you want to reboot the guest OS of '#{vm.name}'?", + toggle: 'tooltip', placement: 'top' }, title: 'Reboot VM', - class: "btn btn-primary btn-sm fa fa-repeat" %> + class: "btn btn-primary btn-sm" %> <% end %> <% end %> <% end %> \ No newline at end of file diff --git a/app/views/vms/_to_revive_buttons.erb b/app/views/vms/_to_revive_buttons.erb index 797f3e85..c4a4c580 100644 --- a/app/views/vms/_to_revive_buttons.erb +++ b/app/views/vms/_to_revive_buttons.erb @@ -1,8 +1,9 @@ <%if current_user.admin? && vm.archivable? %> - <%= link_to '', + <%= link_to fa_icon('arrow-circle-up'), {controller: :vms, action: 'revive_vm', id: vm.name}, method: :post, - data: { confirm: "Are you sure you want to revive '#{vm.name}'?" }, + data: { confirm: "Are you sure you want to revive '#{vm.name}'?", + toggle: 'tooltip', placement: 'top' }, title: "Revive VM", - class: "btn btn-primary btn-sm fa fa-arrow-circle-up" %> + class: "btn btn-primary btn-sm" %> <% end %> \ No newline at end of file From f6cc88703c54b28954f046f7d5512f26e705a10c Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 21:38:51 +0100 Subject: [PATCH 18/59] Fix(VMs index): Handle searching for descriptions --- app/views/vms/_table.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/vms/_table.erb b/app/views/vms/_table.erb index 840a8915..f636050a 100644 --- a/app/views/vms/_table.erb +++ b/app/views/vms/_table.erb @@ -19,8 +19,8 @@ :data => { toggle: 'tooltip', placement: 'right' }, class: "round #{vm.archived? ? 'bg-secondary' : (vm.powered_on? ? 'bg-success' : 'bg-danger')}" %> - <%# Allow searching for description %> - + <%# Allow also searching for description %> + <%= link_to vm.name, vm_path(vm.name) %> From 128e9cc79372cc50acb30f95500916fbca5cb212 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 21:52:21 +0100 Subject: [PATCH 19/59] Chore(CSS): Remove unused class --- app/assets/stylesheets/vms.scss | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/assets/stylesheets/vms.scss b/app/assets/stylesheets/vms.scss index dec2f161..d7c7bf8a 100644 --- a/app/assets/stylesheets/vms.scss +++ b/app/assets/stylesheets/vms.scss @@ -34,7 +34,3 @@ margin-right: 0.5rem; display: inline-block; } - -.script-doc::before { - content: "\1F4CE"; -} \ No newline at end of file From b4f5f87f2ebf6e64aeaaa692a0e442415ab9cffd Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 21:53:53 +0100 Subject: [PATCH 20/59] Chore(CSS): Remove unused 'table-bar' class --- app/assets/stylesheets/application.scss | 10 ---------- app/assets/stylesheets/vms.scss | 10 ---------- 2 files changed, 20 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 97d62e63..23353862 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -105,16 +105,6 @@ body { padding-top: 1.2em; } -.table-bar { - width: auto; - border: 0; - margin: 1.5em 0 1em; - - td { - padding-right: 20px; - } -} - .table-flex-width { width: auto; } diff --git a/app/assets/stylesheets/vms.scss b/app/assets/stylesheets/vms.scss index d7c7bf8a..130b2a5e 100644 --- a/app/assets/stylesheets/vms.scss +++ b/app/assets/stylesheets/vms.scss @@ -7,16 +7,6 @@ flex: 1; } -.table-bar { - width: auto; - border: 0; - margin: 1.5em 0 1em; - - td { - padding-right: 20px; - } -} - .create-form { width: auto; padding-bottom: 1.5em; From 2d44b86e07cf68ecd8ffc4d24eb8a4089714e8d7 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 22:04:36 +0100 Subject: [PATCH 21/59] Chore(Request teamplate CSS): Remove classes --- app/assets/stylesheets/vms.scss | 9 ----- app/views/request_templates/_form.html.erb | 47 ++++++++++------------ 2 files changed, 21 insertions(+), 35 deletions(-) diff --git a/app/assets/stylesheets/vms.scss b/app/assets/stylesheets/vms.scss index 130b2a5e..493ccb7c 100644 --- a/app/assets/stylesheets/vms.scss +++ b/app/assets/stylesheets/vms.scss @@ -7,15 +7,6 @@ flex: 1; } -.create-form { - width: auto; - padding-bottom: 1.5em; -} - -.login-form-group { - padding-bottom: 1.5em; -} - .round { height: 1rem; width: 1rem; diff --git a/app/views/request_templates/_form.html.erb b/app/views/request_templates/_form.html.erb index c1f87388..c1a88bb7 100644 --- a/app/views/request_templates/_form.html.erb +++ b/app/views/request_templates/_form.html.erb @@ -11,33 +11,28 @@
<% end %> -
-
- <%= form.label 'Template name' %> - <%= form.text_field :name, class: 'form-control' %> -
- -
- <%= form.label :cpu_cores, "CPU cores" %> - <%= form.number_field :cpu_cores, min: 0, class: 'form-control' %> -
- -
- <%= form.label :ram_gb, "RAM in GB" %> - <%= form.number_field :ram_gb, min: 0, class: 'form-control' %> -
- -
- <%= form.label :storage_gb, "Storage in GB" %> - <%= form.number_field :storage_gb, min: 0, class: 'form-control' %> -
- -
- <%= form.label :operating_system, "Operating System" %> - <%= form.select :operating_system, operating_system_options, {}, {class: 'form-control'}%> -
+
+ <%= form.label 'Template name' %> + <%= form.text_field :name, class: 'form-control' %> +
+
+ <%= form.label :cpu_cores, "CPU cores" %> + <%= form.number_field :cpu_cores, min: 0, class: 'form-control' %> +
+
+ <%= form.label :ram_gb, "RAM in GB" %> + <%= form.number_field :ram_gb, min: 0, class: 'form-control' %>
-
+
+ <%= form.label :storage_gb, "Storage in GB" %> + <%= form.number_field :storage_gb, min: 0, class: 'form-control' %> +
+
+ <%= form.label :operating_system, "Operating System" %> + <%= form.select :operating_system, operating_system_options, {}, {class: 'form-control'}%> +
+ +
<%= form.submit class: "btn btn-primary" %>
<% end %> From 333c377ea547117177e3eaf8b4aaaf71e631c664 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 22:12:30 +0100 Subject: [PATCH 22/59] Fix(Requests show): Remove CSS classes --- app/assets/stylesheets/application.scss | 9 --------- app/views/requests/show.html.erb | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 23353862..3fd365a8 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -100,15 +100,6 @@ body { width: auto; } -.empty-table-label { - text-align: center; - padding-top: 1.2em; -} - -.table-flex-width { - width: auto; -} - .unread { background-color: #e6f3ff; } diff --git a/app/views/requests/show.html.erb b/app/views/requests/show.html.erb index c140f0e1..99487255 100644 --- a/app/views/requests/show.html.erb +++ b/app/views/requests/show.html.erb @@ -1,6 +1,6 @@

Request Information

- +
From e20fa82dee26c574664af242754d839ca32b642d Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 22:15:21 +0100 Subject: [PATCH 23/59] Fix(projects show): Remove CSS classes. --- app/assets/stylesheets/application.scss | 4 ---- app/views/projects/show.html.erb | 5 +++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 3fd365a8..ad2d92f0 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -104,10 +104,6 @@ body { background-color: #e6f3ff; } -.bulletless { - list-style-type: none; -} - #menu-profile-dropdown { padding-top: 3px; } diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index caf0a3c7..b57eee30 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -13,9 +13,10 @@ From ef5638c2781abaae2022281c4d7110914fdd58f3 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 22:22:33 +0100 Subject: [PATCH 24/59] Chore(CSS): Remove empty SCSS files --- app/assets/stylesheets/app_settings.scss | 3 --- app/assets/stylesheets/dashboard.scss | 3 --- app/assets/stylesheets/landing.scss | 3 --- app/assets/stylesheets/request_templates.scss | 3 --- app/assets/stylesheets/servers.scss | 3 --- app/assets/stylesheets/slack.scss | 3 --- app/assets/stylesheets/users.scss | 3 --- 7 files changed, 21 deletions(-) delete mode 100644 app/assets/stylesheets/app_settings.scss delete mode 100644 app/assets/stylesheets/dashboard.scss delete mode 100644 app/assets/stylesheets/landing.scss delete mode 100644 app/assets/stylesheets/request_templates.scss delete mode 100644 app/assets/stylesheets/servers.scss delete mode 100644 app/assets/stylesheets/slack.scss delete mode 100644 app/assets/stylesheets/users.scss diff --git a/app/assets/stylesheets/app_settings.scss b/app/assets/stylesheets/app_settings.scss deleted file mode 100644 index e0b8a156..00000000 --- a/app/assets/stylesheets/app_settings.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the AppSettings controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/dashboard.scss b/app/assets/stylesheets/dashboard.scss deleted file mode 100644 index 3a51a8cf..00000000 --- a/app/assets/stylesheets/dashboard.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the dashboard controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/landing.scss b/app/assets/stylesheets/landing.scss deleted file mode 100644 index c4fe6e75..00000000 --- a/app/assets/stylesheets/landing.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the Landing controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ \ No newline at end of file diff --git a/app/assets/stylesheets/request_templates.scss b/app/assets/stylesheets/request_templates.scss deleted file mode 100644 index ee80308f..00000000 --- a/app/assets/stylesheets/request_templates.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the RequestTemplates controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/servers.scss b/app/assets/stylesheets/servers.scss deleted file mode 100644 index 4710386b..00000000 --- a/app/assets/stylesheets/servers.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the servers controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/slack.scss b/app/assets/stylesheets/slack.scss deleted file mode 100644 index 57bf03be..00000000 --- a/app/assets/stylesheets/slack.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the slack controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/users.scss b/app/assets/stylesheets/users.scss deleted file mode 100644 index 31a2eacb..00000000 --- a/app/assets/stylesheets/users.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the Users controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ From 3b218c1d89ccdfd52ec383a3cbff59f70343f262 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 22:27:19 +0100 Subject: [PATCH 25/59] Chore(JS): Remove empty coffee files --- app/assets/javascripts/app_settings.coffee | 3 --- app/assets/javascripts/dashboard.coffee | 3 --- app/assets/javascripts/landing.coffee | 3 --- app/assets/javascripts/operating_systems.coffee | 3 --- app/assets/javascripts/request_templates.coffee | 3 --- app/assets/javascripts/requests.coffee | 3 --- app/assets/javascripts/servers.coffee | 3 --- app/assets/javascripts/slack.coffee | 3 --- app/assets/javascripts/users.coffee | 3 --- app/assets/javascripts/vms.coffee | 3 --- 10 files changed, 30 deletions(-) delete mode 100644 app/assets/javascripts/app_settings.coffee delete mode 100644 app/assets/javascripts/dashboard.coffee delete mode 100644 app/assets/javascripts/landing.coffee delete mode 100644 app/assets/javascripts/operating_systems.coffee delete mode 100644 app/assets/javascripts/request_templates.coffee delete mode 100644 app/assets/javascripts/requests.coffee delete mode 100644 app/assets/javascripts/servers.coffee delete mode 100644 app/assets/javascripts/slack.coffee delete mode 100644 app/assets/javascripts/users.coffee delete mode 100644 app/assets/javascripts/vms.coffee diff --git a/app/assets/javascripts/app_settings.coffee b/app/assets/javascripts/app_settings.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/assets/javascripts/app_settings.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/dashboard.coffee b/app/assets/javascripts/dashboard.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/assets/javascripts/dashboard.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/landing.coffee b/app/assets/javascripts/landing.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/assets/javascripts/landing.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/operating_systems.coffee b/app/assets/javascripts/operating_systems.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/assets/javascripts/operating_systems.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/request_templates.coffee b/app/assets/javascripts/request_templates.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/assets/javascripts/request_templates.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/requests.coffee b/app/assets/javascripts/requests.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/assets/javascripts/requests.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/servers.coffee b/app/assets/javascripts/servers.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/assets/javascripts/servers.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/slack.coffee b/app/assets/javascripts/slack.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/assets/javascripts/slack.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/users.coffee b/app/assets/javascripts/users.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/assets/javascripts/users.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/vms.coffee b/app/assets/javascripts/vms.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/assets/javascripts/vms.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ From 2aa12272a42323a14a2fba66d25bf94a1ae46739 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 22:50:19 +0100 Subject: [PATCH 26/59] Fix(dashboard): Remove markup --- app/views/dashboard/_widget.erb | 4 +--- app/views/dashboard/index.html.erb | 14 ++++---------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/app/views/dashboard/_widget.erb b/app/views/dashboard/_widget.erb index 21655314..a31f7b5a 100644 --- a/app/views/dashboard/_widget.erb +++ b/app/views/dashboard/_widget.erb @@ -2,9 +2,7 @@
<%= link_to vms_path, method: :get, class: "dashboard-header-link" do %>
-
-

<%= header %>

-
+

<%= header %>

<% end %>
diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index 85968f7e..8286c074 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -1,20 +1,14 @@ -
-
-

Dashboard

-
-
+

Dashboard

+
+ <%# left column - VMs %>
<%= render 'widget', {vms: @vms.slice(0...max_shown_vms), id: 'vms_active', header: 'Active VMs', buttons: nil} %> <%= render 'widget', {vms: @archivable.slice(0...max_shown_vms), id: 'vms_to_be_archived', header: 'Archivable VMs', buttons: nil} %> <%= render 'widget', {vms: @revivable.slice(0...max_shown_vms), id: 'vms_to_be_revived', header: 'Revivable VMs', buttons: nil} %>
- - - - - + <%# right column - notifications %>
<%= link_to notifications_path, method: :get, class: "dashboard-header-link" do %> From dd8da9d97619ee6f19cfc203c92493f218d325db Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 23:15:13 +0100 Subject: [PATCH 27/59] Fix(dashboard): Don't show datatables controls --- app/views/dashboard/_widget.erb | 3 ++- app/views/vms/_section.erb | 2 +- app/views/vms/_table.erb | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/dashboard/_widget.erb b/app/views/dashboard/_widget.erb index 21655314..b3e4d250 100644 --- a/app/views/dashboard/_widget.erb +++ b/app/views/dashboard/_widget.erb @@ -8,7 +8,8 @@
<% end %>
- <%= render 'vms/table', {vms: vms, id: id, buttons: buttons} %> + <%= render 'vms/table', {vms: vms, id: id, buttons: buttons, + datatable_options: {searching: false, paging: false, info:false}} %>
<% end %> \ No newline at end of file diff --git a/app/views/vms/_section.erb b/app/views/vms/_section.erb index 4c9245f0..2eb3a4a8 100644 --- a/app/views/vms/_section.erb +++ b/app/views/vms/_section.erb @@ -1,6 +1,6 @@ <% if should_be_shown vms %>

><%= header %>

- <%= render 'table', {id: 'vms_' + id, vms: vms, buttons: buttons} %> + <%= render 'table', {id: 'vms_' + id, vms: vms, buttons: buttons, datatable_options: {}} %> <% end %> \ No newline at end of file diff --git a/app/views/vms/_table.erb b/app/views/vms/_table.erb index f636050a..52c9897d 100644 --- a/app/views/vms/_table.erb +++ b/app/views/vms/_table.erb @@ -1,4 +1,4 @@ -
VM Name
<%= Project.human_attribute_name('responsible_users') %> -
    + <%# https://getbootstrap.com/docs/4.0/content/typography/#inline %> +
      <% @project.responsible_users.each do |user| %> -
    • <%= user.name %>
    • +
    • <%= user.name %>
    • <% end %>
> +
<%= datatable_options.map{ |k,v| "data-#{k}=#{v}" }.join(' ') %>> From 41de9643ad618d6f952f64f98593a359be983ba0 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Fri, 22 Mar 2019 23:19:12 +0100 Subject: [PATCH 28/59] Fix(dashboard): Spacing between tables --- app/assets/stylesheets/application.scss | 1 - app/views/vms/_section.erb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index ad2d92f0..88eac47b 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -57,7 +57,6 @@ html, body { h1 { color: $primary; - margin-bottom: .5em; } .dashboard-header-link { diff --git a/app/views/vms/_section.erb b/app/views/vms/_section.erb index 2eb3a4a8..f92fa53c 100644 --- a/app/views/vms/_section.erb +++ b/app/views/vms/_section.erb @@ -1,5 +1,5 @@ <% if should_be_shown vms %> -

><%= header %>

+

><%= header %>

<%= render 'table', {id: 'vms_' + id, vms: vms, buttons: buttons, datatable_options: {}} %> From e9cd2ba0ffa6f08052cade834116d2f3127188db Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sat, 23 Mar 2019 09:11:23 +0100 Subject: [PATCH 29/59] Fix(Users index): Return to prev. role display. Tests depend on it, --- app/views/users/index.html.erb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 92f945b9..21b8f2c3 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -14,19 +14,22 @@
<%# https://datatables.net/manual/data/orthogonal-data#HTML-5 %>
Status<%= user.email %> - <% if editable_for user %> -
- <% User.roles.map(&:first).each do |role| %> +
+ <% User.roles.map(&:first).each do |role| %> + <% if editable_for user %> <%= link_to role.capitalize, update_role_user_path(user, role: role), - id: "btn-#{role}-#{user.id}", method: :patch, + id: "btn-#{role}-#{user.id}", class: "btn btn-#{if user.role == role then 'primary' else 'light' end}" %> + <% else %> + + <%= role.capitalize %> + <% end %> - <% else %> - <%= user.role.capitalize %> <% end %>
From ec09c3afd28849f1f8d4047b26628f60492e4fc1 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sat, 23 Mar 2019 10:09:35 +0100 Subject: [PATCH 30/59] Fix(VMs index spec): adapt to changed HTML --- spec/views/vms/index.html.erb_spec.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/views/vms/index.html.erb_spec.rb b/spec/views/vms/index.html.erb_spec.rb index 73dab380..7fdeabc8 100644 --- a/spec/views/vms/index.html.erb_spec.rb +++ b/spec/views/vms/index.html.erb_spec.rb @@ -51,7 +51,7 @@ end it 'shows correct power on / off button' do - expect(rendered).to have_css('a.fa-play') + expect(rendered).to have_css 'i.fa-play', count: 1 end it 'demands confirmation on shutdown' do @@ -65,16 +65,16 @@ it 'shows no power buttons' do rendered = render - expect(rendered).not_to have_css('a.fa-play') - expect(rendered).not_to have_css('a.fa-stop') + expect(rendered).not_to have_css 'i.fa-play' + expect(rendered).not_to have_css 'i.fa-play' end end end context 'when the user is not a root user for the vms' do it 'does not show any manage buttons' do - expect(rendered).not_to have_css('a.fa-play') - expect(rendered).not_to have_css('a.fa-stop') + expect(rendered).not_to have_css 'i.fa-play' + expect(rendered).not_to have_css 'i.fa-play' end end @@ -98,7 +98,7 @@ let(:current_user) { FactoryBot.create :admin } it 'shows correct power on / off button' do - expect(rendered).to have_css('a.fa-play') + expect(rendered).to have_css 'i.fa-play', count: 1 end it 'demands confirmation on shutdown and reboot' do @@ -108,8 +108,8 @@ it 'shows no power buttons when vmwaretools are not installed' do assign(:vms, mock_vms_without_tools) rendered = render - expect(rendered).not_to have_css('a.fa-play') - expect(rendered).not_to have_css('a.fa-stop') + expect(rendered).not_to have_css 'i.fa-play' + expect(rendered).not_to have_css 'i.fa-play' end it 'links to new vm page' do From e55e61696021b3cf128a008b73786dfc44732361 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sat, 23 Mar 2019 17:05:22 +0100 Subject: [PATCH 31/59] Test(Request template index): Fixes. Use factory. --- .../request_templates/index.html.erb_spec.rb | 29 +++++-------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/spec/views/request_templates/index.html.erb_spec.rb b/spec/views/request_templates/index.html.erb_spec.rb index 19740d17..f831b0a4 100644 --- a/spec/views/request_templates/index.html.erb_spec.rb +++ b/spec/views/request_templates/index.html.erb_spec.rb @@ -4,22 +4,7 @@ RSpec.describe 'request_templates/index', type: :view do let(:request_templates) do - [ - RequestTemplate.create!( - name: 'string', - cpu_cores: 2, - ram_gb: 3, - storage_gb: 4, - operating_system: 'Operating System' - ), - RequestTemplate.create!( - name: 'string', - cpu_cores: 2, - ram_gb: 3, - storage_gb: 4, - operating_system: 'Operating System' - ) - ] + FactoryBot.create_list(:request_template, 2) end let(:current_user) { FactoryBot.create :user } @@ -30,12 +15,12 @@ render end - it 'renders a list of request_templates' do - assert_select 'tr>td', text: 'string'.to_s, count: 2 - assert_select 'tr>td', text: 2.to_s, count: 2 - assert_select 'tr>td', text: 3.to_s, count: 2 - assert_select 'tr>td', text: 4.to_s, count: 2 - assert_select 'tr>td', text: 'Operating System'.to_s, count: 2 + it 'renders a list of request_templates in a table' do + expect(rendered).to have_css("tbody>tr", count: request_templates.size) + end + + it 'renders a request template names' do + expect(rendered).to have_css("td", text: request_templates.first.name, count: request_templates.size) end context 'when the user is an user' do From 884097f619df597b004c4044f5d26a5579cd5cc7 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sat, 23 Mar 2019 18:38:10 +0100 Subject: [PATCH 32/59] Fix(notification index): Styling and links --- app/assets/stylesheets/application.scss | 2 +- app/assets/stylesheets/notifications.scss | 15 ----------- app/views/dashboard/index.html.erb | 12 ++++----- app/views/notifications/_list.html.erb | 33 +++++++++++++---------- 4 files changed, 25 insertions(+), 37 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 72123cee..88655a0f 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -102,7 +102,7 @@ body { width: auto; } -.unread { +.bg-primary-light { background-color: #e6f3ff; } diff --git a/app/assets/stylesheets/notifications.scss b/app/assets/stylesheets/notifications.scss index 27c3a957..d8daaa78 100644 --- a/app/assets/stylesheets/notifications.scss +++ b/app/assets/stylesheets/notifications.scss @@ -2,21 +2,6 @@ // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ -.unread { - background-color: #e6f3ff; -} - -.big-icon { - font-size: 20px; -} - -.icon-link { - margin-left: 5px; - &:hover { - text-decoration: none; - } -} - .notification-bell { #notification-alert { margin-top: -0.4em; diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index 85968f7e..3c3b2314 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -17,13 +17,11 @@
- <%= link_to notifications_path, method: :get, class: "dashboard-header-link" do %> -
-
-

Notifications

-
-
- <% end %> +
+ <%= link_to notifications_path, class: "dashboard-header-link text-white" do %> +

<%= fa_icon('bell') %> Notifications

+ <% end %> +
<%= render 'notifications/list' %>
diff --git a/app/views/notifications/_list.html.erb b/app/views/notifications/_list.html.erb index a77e18e9..ef8603b0 100644 --- a/app/views/notifications/_list.html.erb +++ b/app/views/notifications/_list.html.erb @@ -1,21 +1,26 @@ <% unless @notifications.empty? %> <% @notifications.each do |notification| %> - <% class_names = notification.read ? "card mb-3 notification" : "card unread mb-3 notification" %> -
+
">
- <%= link_to destroy_and_redirect_notification_path(notification), {controller: notification, action: 'destroy_and_redirect', method: :delete} do %> -
- <%= notification.title %> -
- <%= simple_format(notification.message).html_safe%> - <% end %> - -
- <%= link_to notification, method: :delete, data: { confirm: 'Are you sure you want to delete this notification?' }, class: 'icon-link delete' do %> - <%= fa_icon('trash', class: 'big-icon') %> - <% end %> -
+ <%= link_to fa_icon('trash lg'), notification, + method: :delete, + title: 'Delete', + data: { toggle: 'tooltip', placement: 'top', + confirm: 'Are you sure you want to delete this notification?' }, + class: "float-right" %> + <%= link_to fa_icon('check lg'), mark_as_read_notification_path(notification), + title: 'Mark as read', + data: { toggle: 'tooltip', placement: 'top'}, + class: "float-right mr-2" unless notification.read %> +
+ <%= link_to notification.title, notification.link %> +
+ + <%= I18n.l notification.created_at,format: :short%> (<%= time_ago_in_words notification.created_at %> ago) + +
+ <%= simple_format(notification.message).html_safe %>
<% end %> From 56d07f6129bba351dd710a3dbe35e8d8ad05b3fd Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sat, 23 Mar 2019 20:27:21 +0100 Subject: [PATCH 33/59] Fix(Dashboard spec): Deletion of notifications --- app/views/notifications/_list.html.erb | 2 +- spec/features/dashboard/dashboard_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/notifications/_list.html.erb b/app/views/notifications/_list.html.erb index ef8603b0..991bc882 100644 --- a/app/views/notifications/_list.html.erb +++ b/app/views/notifications/_list.html.erb @@ -3,7 +3,7 @@ <% @notifications.each do |notification| %>
">
- <%= link_to fa_icon('trash lg'), notification, + <%= link_to fa_icon('trash lg'), notification_path(notification), method: :delete, title: 'Delete', data: { toggle: 'tooltip', placement: 'top', diff --git a/spec/features/dashboard/dashboard_spec.rb b/spec/features/dashboard/dashboard_spec.rb index 5be370f2..012fc25b 100644 --- a/spec/features/dashboard/dashboard_spec.rb +++ b/spec/features/dashboard/dashboard_spec.rb @@ -38,7 +38,7 @@ it 'does not redirect after deleting notification' do visit dashboard_path - all(:css, '.delete.icon-link').first.click + all(:css, "a[data-method='delete']").first.click expect(current_path).to eql(dashboard_path) end From 89a3807c6f6b2bff0d0524d459474df51559371d Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sat, 23 Mar 2019 20:40:27 +0100 Subject: [PATCH 34/59] Fix(Dashboard spec): First element is hidden due max display --- spec/features/dashboard/dashboard_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/dashboard/dashboard_spec.rb b/spec/features/dashboard/dashboard_spec.rb index 012fc25b..e9bca23c 100644 --- a/spec/features/dashboard/dashboard_spec.rb +++ b/spec/features/dashboard/dashboard_spec.rb @@ -38,7 +38,7 @@ it 'does not redirect after deleting notification' do visit dashboard_path - all(:css, "a[data-method='delete']").first.click + find(:css, "a[data-method='delete'][href='#{notification_path(@notifications.second)}']").click expect(current_path).to eql(dashboard_path) end From 87330e87ecff578485f7bd5ecb70943e2ece79ed Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sat, 23 Mar 2019 20:55:44 +0100 Subject: [PATCH 35/59] Fix(Notifications): Mark as read when clicking --- app/controllers/notifications_controller.rb | 16 ++++++---------- app/views/notifications/_list.html.erb | 2 +- config/routes.rb | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index c30c2e4e..3c58b9e2 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -40,16 +40,12 @@ def destroy end end - def destroy_and_redirect - link = @notification.link - @notification.destroy - respond_to do |format| - if link.nil? || link.empty? - format.html { redirect_back fallback_location: notifications_url } - else - format.html { redirect_to link } - end - format.json { head :no_content } + def mark_as_read_and_redirect + @notification.update(read: true) + if @notification.link.present? + redirect_to @notification.link + else + redirect_back fallback_location: notifications_url end end diff --git a/app/views/notifications/_list.html.erb b/app/views/notifications/_list.html.erb index 991bc882..28a644c5 100644 --- a/app/views/notifications/_list.html.erb +++ b/app/views/notifications/_list.html.erb @@ -14,7 +14,7 @@ data: { toggle: 'tooltip', placement: 'top'}, class: "float-right mr-2" unless notification.read %>
- <%= link_to notification.title, notification.link %> + <%= link_to notification.title, mark_as_read_and_redirect_notification_path(notification) %>
<%= I18n.l notification.created_at,format: :short%> (<%= time_ago_in_words notification.created_at %> ago) diff --git a/config/routes.rb b/config/routes.rb index d4ecc7ca..232e7d63 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -21,7 +21,7 @@ resources :notifications, only: %i[index new create destroy] do member do get :mark_as_read - delete :destroy_and_redirect + delete :mark_as_read_and_redirect end get :has_any, on: :collection, to: 'notifications#any?' end From ab3a7b0acf2d25f8442a9d11d956c4de2e9d06ff Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sat, 23 Mar 2019 21:10:20 +0100 Subject: [PATCH 36/59] Fix(Notification controller): mark as read and redirect route --- app/controllers/notifications_controller.rb | 4 ++-- config/routes.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 3c58b9e2..e3c993c5 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class NotificationsController < ApplicationController - before_action :set_notification, only: %i[show edit update destroy mark_as_read destroy_and_redirect] + before_action :set_notification, only: %i[show edit update destroy mark_as_read mark_as_read_and_redirect] # GET /notifications # GET /notifications.json @@ -41,7 +41,7 @@ def destroy end def mark_as_read_and_redirect - @notification.update(read: true) + @notification.update(read: true) unless @notification.read if @notification.link.present? redirect_to @notification.link else diff --git a/config/routes.rb b/config/routes.rb index 232e7d63..3417f550 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -21,7 +21,7 @@ resources :notifications, only: %i[index new create destroy] do member do get :mark_as_read - delete :mark_as_read_and_redirect + get :mark_as_read_and_redirect end get :has_any, on: :collection, to: 'notifications#any?' end From 0af0847b474fa761d92841bd0cb95ee5a3920214 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sat, 23 Mar 2019 21:54:26 +0100 Subject: [PATCH 37/59] Test(Notifications controller): Refactor --- .../notifications_controller_spec.rb | 31 ++++++------------- spec/factories/notifications.rb | 1 + 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb index b1567a35..a2d02aa4 100644 --- a/spec/controllers/notifications_controller_spec.rb +++ b/spec/controllers/notifications_controller_spec.rb @@ -3,18 +3,8 @@ require 'rails_helper' RSpec.describe NotificationsController, type: :controller do - let(:user) { FactoryBot.create :user } - let(:valid_attributes) do - { - title: 'title', - message: 'message', - link: 'https://www.google.com', - user: user - } - end - - # use let! instead of let otherwise the value will be lazily-instantiated - let!(:notification) { Notification.create!(valid_attributes) } + let(:notification) { FactoryBot.create :notification } + let(:user) { notification.user } before do sign_in user @@ -28,24 +18,23 @@ end end - describe 'POST #destroy_and_redirect' do - it 'destroys the notification' do - expect do - delete :destroy_and_redirect, params: { id: notification.to_param } - end.to change(Notification, :count).by(-1) + describe 'GET #mark_as_read_and_redirect' do + it 'marks the notification as read' do + expect { + get :mark_as_read_and_redirect, params: { id: notification.to_param } + }.to change{notification.reload.read}.from(false).to(true) end it 'redirects to the notification link' do - link = notification.link - delete :destroy_and_redirect, params: { id: notification.to_param } - expect(response).to redirect_to(link) + get :mark_as_read_and_redirect, params: { id: notification.to_param } + expect(response).to redirect_to(notification.link) end it 'redirects back if no link is provided' do notification.update!(link: '') redirect_url = 'https://www.google.com/' from redirect_url - delete :destroy_and_redirect, params: { id: notification.to_param } + get :mark_as_read_and_redirect, params: { id: notification.to_param } expect(response).to redirect_to(redirect_url) end end diff --git a/spec/factories/notifications.rb b/spec/factories/notifications.rb index 4e3c84b8..7f8d11f6 100644 --- a/spec/factories/notifications.rb +++ b/spec/factories/notifications.rb @@ -6,5 +6,6 @@ title { 'Test Notification' } message { 'This is a test' } read { false } + link { 'https://example.com' } end end From 7c552fb995c0182d9ef8ec4b6a4c75fcd950af2b Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sat, 23 Mar 2019 22:40:21 +0100 Subject: [PATCH 38/59] Fix(Datatables JS): Refactor turbolinks cache fix --- app/assets/javascripts/datatables.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/datatables.js b/app/assets/javascripts/datatables.js index 89ffa0b1..c46ce658 100644 --- a/app/assets/javascripts/datatables.js +++ b/app/assets/javascripts/datatables.js @@ -21,14 +21,12 @@ $(document).on('turbolinks:load', function() { } }); -// https://stackoverflow.com/questions/41070556/how-can-i-prevent-duplicate-wrappers-on-a-jquery-datatable-when-navigating-back // Turbolinks cache fix +// https://stackoverflow.com/questions/41070556 $(document).on('turbolinks:before-cache', function() { - var dataTable = $($.fn.dataTable.tables(true)).DataTable(); - if (dataTable !== null) { - dataTable.clear(); - dataTable.destroy(); - return dataTable = null; + var tables = $.fn.dataTable.tables(true); + if (tables.length > 0) { + $(tables).DataTable().destroy(); } }); From 7510afa63846adaa09e74dc00f9cd2f49de06d57 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sat, 23 Mar 2019 22:44:39 +0100 Subject: [PATCH 39/59] Fix(Datatable JS): Further refactoring of cache fix --- app/assets/javascripts/datatables.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/assets/javascripts/datatables.js b/app/assets/javascripts/datatables.js index c46ce658..6889b74f 100644 --- a/app/assets/javascripts/datatables.js +++ b/app/assets/javascripts/datatables.js @@ -24,9 +24,6 @@ $(document).on('turbolinks:load', function() { // Turbolinks cache fix // https://stackoverflow.com/questions/41070556 $(document).on('turbolinks:before-cache', function() { - var tables = $.fn.dataTable.tables(true); - if (tables.length > 0) { - $(tables).DataTable().destroy(); - } + $($.fn.dataTable.tables(true)).DataTable().destroy(); }); From 2e26c87adf81684b6a5e2e680858ac34a3384912 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sat, 23 Mar 2019 23:10:01 +0100 Subject: [PATCH 40/59] Fix(dashboard): Only show unread notifications --- app/controllers/dashboard_controller.rb | 2 +- app/views/notifications/_list.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index b80552e1..d03d8ae9 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -12,7 +12,7 @@ def index redirect_to '/users/sign_in' if current_user.nil? initialize_vm_categories filter_vm_categories current_user unless current_user.admin? - @notifications = Notification.where(user: current_user).slice(0, number_of_notifications) + @notifications = Notification.where(user: current_user, read: false).slice(0, number_of_notifications) end private diff --git a/app/views/notifications/_list.html.erb b/app/views/notifications/_list.html.erb index 28a644c5..7c2879fa 100644 --- a/app/views/notifications/_list.html.erb +++ b/app/views/notifications/_list.html.erb @@ -26,5 +26,5 @@ <% end %> <% else %> -

You don't have any notifications at the moment.

+
No unread notifications
<% end %> From 90c9a9af13ec630899acc0532b0158f619f7d1b2 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sat, 23 Mar 2019 23:33:00 +0100 Subject: [PATCH 41/59] Fix(Dashboard spec): Adapt to changed HTML --- app/views/notifications/_list.html.erb | 2 +- spec/features/dashboard/dashboard_spec.rb | 2 +- spec/features/notifications/notifications_spec.rb | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/views/notifications/_list.html.erb b/app/views/notifications/_list.html.erb index 7c2879fa..8434f7ef 100644 --- a/app/views/notifications/_list.html.erb +++ b/app/views/notifications/_list.html.erb @@ -26,5 +26,5 @@ <% end %> <% else %> -
No unread notifications
+
No unread notifications
<% end %> diff --git a/spec/features/dashboard/dashboard_spec.rb b/spec/features/dashboard/dashboard_spec.rb index e9bca23c..ac84982e 100644 --- a/spec/features/dashboard/dashboard_spec.rb +++ b/spec/features/dashboard/dashboard_spec.rb @@ -51,7 +51,7 @@ context 'without notifications' do it 'informs about no notifications' do visit dashboard_path - expect(page).to have_text('You don\'t have any notifications at the moment.') + expect(page).to have_css('#no-notifications', count: 1) end end end diff --git a/spec/features/notifications/notifications_spec.rb b/spec/features/notifications/notifications_spec.rb index c9a225ff..50af97c1 100644 --- a/spec/features/notifications/notifications_spec.rb +++ b/spec/features/notifications/notifications_spec.rb @@ -37,8 +37,7 @@ it 'informs about no notifications' do visit notifications_path - - expect(page).to have_text('You don\'t have any notifications at the moment.') + expect(page).to have_css('#no-notifications', count: 1) end end end From 60d1d844ac0bb8c01654205983196505f9e15c01 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sun, 24 Mar 2019 12:58:39 +0100 Subject: [PATCH 42/59] Fix(Application SCSS): use SCSS imports --- Gemfile | 6 +++--- app/assets/stylesheets/application.scss | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index f41c8896..6d247e80 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,6 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.5.0' -# Gems to install: faker, shoulda matchers # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.1' # Use sqlite3 and postgres as the database for Active Record @@ -20,8 +19,6 @@ gem 'sassc-rails' gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes gem 'mini_racer', platforms: :ruby -# See https://github.com/bokmann/font-awesome-rails for details -gem 'font-awesome-rails' # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2' @@ -52,6 +49,9 @@ gem 'jquery-rails' # Jquery datatables ruby gems for assets pipeline, https://datatables.net/ # https://github.com/mkhairi/jquery-datatables gem 'jquery-datatables' +# The font-awesome font bundled as an asset for the rails asset pipeline +# See https://github.com/bokmann/font-awesome-rails +gem 'font-awesome-rails' # Ruby interface to the VMware vSphere API # https://github.com/vmware/rbvmomi diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 88eac47b..726c779a 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -10,16 +10,24 @@ * files in this directory. Styles in this file should be added after the last require_* statement. * It is generally better to create a new file per style scope. - *= require font-awesome - *= require_self *= require_tree . */ + + /* + * Remove all the *= require and *= require_tree statements from the Sass file. + * Instead, use @import to import Sass files. + * Do not use *= require in Sass or your other stylesheets will not be + * able to access the Bootstrap mixins and variables. + * See: https://github.com/twbs/bootstrap-rubygem#a-ruby-on-rails + */ $primary: #0C415F; $danger: #a80833; $primary-active: #1f6993; $primary-hover: #1a5b82; +// https://github.com/bokmann/font-awesome-rails#sass-support +@import "font-awesome"; // https://github.com/twbs/bootstrap-rubygem#a-ruby-on-rails // Custom bootstrap variables must be set or imported *before* bootstrap. @import "bootstrap"; From 68bd86867334e71063ac30ce332658442cf1ed7f Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sun, 24 Mar 2019 13:09:05 +0100 Subject: [PATCH 43/59] Fix/application SCSS): solely use SCSS imports --- app/assets/stylesheets/application.scss | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 726c779a..e3f1d31a 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -9,8 +9,6 @@ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS * files in this directory. Styles in this file should be added after the last require_* statement. * It is generally better to create a new file per style scope. - - *= require_tree . */ /* @@ -47,6 +45,12 @@ $primary-hover: #1a5b82; //@import 'datatables/extensions/Scroller/scroller.bootstrap4'; //@import 'datatables/extensions/Select/select.bootstrap4'; +@import 'notifications'; +@import 'operating_systems'; +@import 'requests'; +@import 'resource_allocation'; +@import 'vms'; + th { @extend .text-white; @extend .bg-primary; From 269625780468b0c0ad2ffad7aa0d5eb946ad556f Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sun, 24 Mar 2019 14:42:54 +0100 Subject: [PATCH 44/59] Fix(CSS):Remove unused classes --- app/assets/stylesheets/application.scss | 1 + app/assets/stylesheets/requests.scss | 17 ----------------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index e3f1d31a..8ca7fe39 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -87,6 +87,7 @@ body { #content { flex: 1 0 auto; + padding-bottom: 5em; } #footer { diff --git a/app/assets/stylesheets/requests.scss b/app/assets/stylesheets/requests.scss index 252bdaf6..9c43dc1e 100644 --- a/app/assets/stylesheets/requests.scss +++ b/app/assets/stylesheets/requests.scss @@ -13,23 +13,6 @@ label { display: block; } -#content{ - padding-bottom: 5em; -} - -.table-fixed-columns{ - table-layout: fixed; - word-wrap: break-word; -} - -.test{ - width: 30%; -} - -.right-buffer{ - margin-right: 5px; -} - /* Selected items on top */ .select2-selection__choice { background-color: #0C415F !important; From dc6af6f1515bb2c0397b36c524e78833c2b858da Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sun, 24 Mar 2019 14:57:18 +0100 Subject: [PATCH 45/59] Revert "Fix/application SCSS): solely use SCSS imports" This reverts commit 68bd86867334e71063ac30ce332658442cf1ed7f. --- app/assets/stylesheets/application.scss | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 8ca7fe39..f4ab336e 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -9,6 +9,8 @@ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS * files in this directory. Styles in this file should be added after the last require_* statement. * It is generally better to create a new file per style scope. + + *= require_tree . */ /* @@ -45,12 +47,6 @@ $primary-hover: #1a5b82; //@import 'datatables/extensions/Scroller/scroller.bootstrap4'; //@import 'datatables/extensions/Select/select.bootstrap4'; -@import 'notifications'; -@import 'operating_systems'; -@import 'requests'; -@import 'resource_allocation'; -@import 'vms'; - th { @extend .text-white; @extend .bg-primary; From 4c5403a9d0361ece2b3dce6be149820aa0af750b Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sun, 24 Mar 2019 15:25:15 +0100 Subject: [PATCH 46/59] Fix(Application SCSS): Use SCSS imports --- app/assets/javascripts/application.js | 5 ++--- app/assets/stylesheets/application.scss | 15 +++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 50073a3d..f1b138c3 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -30,9 +30,8 @@ // https://github.com/turbolinks/turbolinks#observing-navigation-events document.addEventListener("turbolinks:load", function() { // Initialize 'Select2', jQuery based replacement for select boxes - // https://github.com/argerim/select2-rails#usage - $('.selecttwo').select2(); - + // https://github.com/argerim/select2-rails#include-select2-rails-stylesheet-assets + $('.selecttwo').select2({ theme: "bootstrap" }); // Initialize Boostrap tooltips for all elements having data-toggle // attribute set to 'tooltip'. Uses the title attr as tooltip. // https://getbootstrap.com/docs/4.0/components/tooltips diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index f4ab336e..d3244c05 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -9,8 +9,6 @@ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS * files in this directory. Styles in this file should be added after the last require_* statement. * It is generally better to create a new file per style scope. - - *= require_tree . */ /* @@ -20,7 +18,8 @@ * able to access the Bootstrap mixins and variables. * See: https://github.com/twbs/bootstrap-rubygem#a-ruby-on-rails */ - + + // Custom bootstrap variables must be set or *before* bootstrap is imported $primary: #0C415F; $danger: #a80833; $primary-active: #1f6993; @@ -29,8 +28,10 @@ $primary-hover: #1a5b82; // https://github.com/bokmann/font-awesome-rails#sass-support @import "font-awesome"; // https://github.com/twbs/bootstrap-rubygem#a-ruby-on-rails -// Custom bootstrap variables must be set or imported *before* bootstrap. @import "bootstrap"; +// https://github.com/argerim/select2-rails/issues/135 +@import "select2.css"; +@import "select2-bootstrap"; // Bootstrap styling for datatables // https://github.com/mkhairi/jquery-datatables#stylesheets @import 'datatables/dataTables.bootstrap4'; @@ -47,6 +48,12 @@ $primary-hover: #1a5b82; //@import 'datatables/extensions/Scroller/scroller.bootstrap4'; //@import 'datatables/extensions/Select/select.bootstrap4'; +@import 'notifications'; +@import 'operating_systems'; +@import 'requests'; +@import 'resource_allocation'; +@import 'vms'; + th { @extend .text-white; @extend .bg-primary; From 602cda0ab2835090500e0aace0f8825dff6d4d03 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sun, 24 Mar 2019 15:26:39 +0100 Subject: [PATCH 47/59] Refactor(Gemfile): Restructure --- Gemfile | 85 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/Gemfile b/Gemfile index 6d247e80..28b25f54 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,10 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.5.0' +# +# Rails essentials +# + # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.1' # Use sqlite3 and postgres as the database for Active Record @@ -19,57 +23,47 @@ gem 'sassc-rails' gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes gem 'mini_racer', platforms: :ruby - -# Use CoffeeScript for .coffee assets and views -gem 'coffee-rails', '~> 4.2' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' +# Flexible authentication solution for Rails with Warden +# https://github.com/plataformatec/devise +gem 'devise' +gem 'devise-bootstrap-views', '~> 1.0' +gem 'devise-i18n' +# Provides different authentication strategies +gem 'omniauth' +gem 'omniauth_openid_connect' +# Role management, minimal authorization through OO design and pure Ruby classes +# https://github.com/varvet/pundit +gem 'pundit' +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' - # Use ActiveStorage variant # gem 'mini_magick', '~> 4.8' -# Flexible authentication solution for Rails with Warden -# https://github.com/plataformatec/devise -gem 'devise' -# Role management, minimal authorization through OO design and pure Ruby classes -# https://github.com/varvet/pundit -gem 'pundit' - -# Fancy default views and javascript helpers https://github.com/twbs/bootstrap-rubygem -gem 'bootstrap', '~> 4.3.1' -gem 'devise-bootstrap-views', '~> 1.0' -gem 'devise-i18n' -gem 'jquery-rails' -# Jquery datatables ruby gems for assets pipeline, https://datatables.net/ -# https://github.com/mkhairi/jquery-datatables -gem 'jquery-datatables' -# The font-awesome font bundled as an asset for the rails asset pipeline -# See https://github.com/bokmann/font-awesome-rails -gem 'font-awesome-rails' +# +# Application +# # Ruby interface to the VMware vSphere API # https://github.com/vmware/rbvmomi gem 'rbvmomi' - -# Provides form.select extensions -gem 'select2-rails' - -# Provides different authentication strategies -gem 'omniauth' -gem 'omniauth_openid_connect' - -# Allow locks on database -gem 'with_advisory_lock' - # Ruby Git gem 'git' - +# Allow locks on database +# https://github.com/ClosureTree/with_advisory_lock +gem 'with_advisory_lock' +# SSH private and public key generator in pure Ruby (RSA & DSA) +# https://github.com/bensie/sshkey +gem 'sshkey', '~> 1.9' # Mina for deployment # Have a look in the tutorial: # https://github.com/lnikell/wiki/wiki/Deploy-rails-application-with-Mina,-Nginx-and-Puma @@ -83,20 +77,32 @@ gem 'mina-logs', require: false # Announce Mina deploys to Slack channels, https://github.com/krichly/mina-slack gem 'execjs', require: false gem 'mina-slack', require: false, github: 'krichly/mina-slack' - -# Reduces boot times through caching; required in config/boot.rb -gem 'bootsnap', '>= 1.1.0', require: false - # Coveralls is a web service to help you track your code coverage # over time, and ensure that all your new code is fully covered # https://coveralls.io/github/hpi-swt2/vm-portal gem 'coveralls', require: false - # Report errors in production to central Errbit system # https://github.com/errbit/errbit # https://github.com/airbrake/airbrake gem 'airbrake', '~> 5.0' +# +# Packaged JS & CSS libraries +# + +# Fancy default views and javascript helpers https://github.com/twbs/bootstrap-rubygem +gem 'bootstrap', '~> 4.3.1' +# jQuery for Rails https://github.com/rails/jquery-rails +gem 'jquery-rails' +# Jquery datatables ruby gems for assets pipeline, https://datatables.net/ +# https://github.com/mkhairi/jquery-datatables +gem 'jquery-datatables' +# The font-awesome font bundled as an asset for the rails asset pipeline +# See https://github.com/bokmann/font-awesome-rails +gem 'font-awesome-rails' +# Integrate Select2 javascript library with Rails asset pipeline +# https://github.com/argerim/select2-rails +gem 'select2-rails' # Packaged clipboard.js JS library for copying text to clipboard # https://github.com/sadiqmmm/clipboard-rails gem 'clipboard-rails' @@ -149,4 +155,3 @@ end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] -gem 'sshkey', '~> 1.9' From 1423d9aa60c52e2b65e6e8ced106273b5e9c89cc Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sun, 24 Mar 2019 15:34:56 +0100 Subject: [PATCH 48/59] Fix(CSS): Select2 styling --- app/assets/stylesheets/requests.scss | 12 ++++++------ app/views/requests/_form.html.erb | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/requests.scss b/app/assets/stylesheets/requests.scss index 9c43dc1e..5389b171 100644 --- a/app/assets/stylesheets/requests.scss +++ b/app/assets/stylesheets/requests.scss @@ -13,15 +13,15 @@ label { display: block; } -/* Selected items on top */ +/* Selected items have Bootstrap primary background */ .select2-selection__choice { - background-color: #0C415F !important; - color: #FFFFFF !important; + @extend .text-white; + @extend .bg-primary; } -.select2-container { - width: 100% !important; -} +// .select2-container { +// width: 100% !important; +// } .styled-form { h5 { diff --git a/app/views/requests/_form.html.erb b/app/views/requests/_form.html.erb index c554bd54..9754a7e7 100644 --- a/app/views/requests/_form.html.erb +++ b/app/views/requests/_form.html.erb @@ -112,7 +112,7 @@ :human_readable_identifier, (@request.users - @request.sudo_users).collect(&:id)), {}, - {class: ' selecttwo', multiple: true} %> + {class: 'form-control selecttwo', multiple: true} %>
From df8ed1d28e3182e9067fe43802dc61a6260ab428 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sun, 24 Mar 2019 15:40:30 +0100 Subject: [PATCH 49/59] Fix(requests form): Remove CSS, adapt HTML --- app/assets/stylesheets/requests.scss | 29 ++++++++++++++-------------- app/views/requests/_form.html.erb | 2 +- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/assets/stylesheets/requests.scss b/app/assets/stylesheets/requests.scss index 5389b171..c96733e8 100644 --- a/app/assets/stylesheets/requests.scss +++ b/app/assets/stylesheets/requests.scss @@ -1,17 +1,16 @@ // Place all the styles related to the Requests controller here. // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ -//= require select2 -div { - &.field { - margin-bottom: 20px; - } -} +// div { +// &.field { +// margin-bottom: 20px; +// } +// } -label { - display: block; -} +// label { +// display: block; +// } /* Selected items have Bootstrap primary background */ .select2-selection__choice { @@ -23,9 +22,9 @@ label { // width: 100% !important; // } -.styled-form { - h5 { - font-weight: bold; - font-size: 1.2em; - } -} \ No newline at end of file +// .styled-form { +// h5 { +// font-weight: bold; +// font-size: 1.2em; +// } +// } \ No newline at end of file diff --git a/app/views/requests/_form.html.erb b/app/views/requests/_form.html.erb index 9754a7e7..b7b07213 100644 --- a/app/views/requests/_form.html.erb +++ b/app/views/requests/_form.html.erb @@ -79,7 +79,7 @@
- <%= form.label :operating_system, "Operating System *" %>
+ <%= form.label :operating_system, "Operating System *" %> <%= form.select :operating_system, operating_system_options, {}, id: 'operating_system', class: 'form-control' %>
From 26f92878a40a9a63417f409a3c735d34590f4f1f Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sun, 24 Mar 2019 15:46:21 +0100 Subject: [PATCH 50/59] Fix(OS form): Remove CSS --- app/assets/stylesheets/application.scss | 1 - app/assets/stylesheets/operating_systems.scss | 12 ------------ app/views/operating_systems/_form.html.erb | 2 +- 3 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 app/assets/stylesheets/operating_systems.scss diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index d3244c05..e274aef4 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -49,7 +49,6 @@ $primary-hover: #1a5b82; //@import 'datatables/extensions/Select/select.bootstrap4'; @import 'notifications'; -@import 'operating_systems'; @import 'requests'; @import 'resource_allocation'; @import 'vms'; diff --git a/app/assets/stylesheets/operating_systems.scss b/app/assets/stylesheets/operating_systems.scss deleted file mode 100644 index 621406b1..00000000 --- a/app/assets/stylesheets/operating_systems.scss +++ /dev/null @@ -1,12 +0,0 @@ -// Place all the styles related to the OperatingSystems controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ -div { - &.field, &.actions { - margin-bottom: 10px; - } - } - - label { - display: block; - } diff --git a/app/views/operating_systems/_form.html.erb b/app/views/operating_systems/_form.html.erb index ec2a0399..28db2ee0 100644 --- a/app/views/operating_systems/_form.html.erb +++ b/app/views/operating_systems/_form.html.erb @@ -16,7 +16,7 @@ <%= form.text_field :name, class: "form-control" %>
-
+
<%= form.submit class: "btn btn-primary" %>
<% end %> From f3e91afd6f4e656b2be11a62559f8065a563b761 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sun, 24 Mar 2019 16:33:00 +0100 Subject: [PATCH 51/59] Fix(CSS): Organize CSS styles --- app/assets/stylesheets/application.scss | 79 +--------------- .../{resource_allocation.scss => charts.scss} | 4 +- app/assets/stylesheets/custom.scss | 91 +++++++++++++++++++ app/assets/stylesheets/notifications.scss | 11 --- app/assets/stylesheets/requests.scss | 30 ------ app/assets/stylesheets/select2-custom.scss | 8 ++ app/assets/stylesheets/vms.scss | 17 ---- 7 files changed, 106 insertions(+), 134 deletions(-) rename app/assets/stylesheets/{resource_allocation.scss => charts.scss} (90%) create mode 100644 app/assets/stylesheets/custom.scss delete mode 100644 app/assets/stylesheets/notifications.scss delete mode 100644 app/assets/stylesheets/requests.scss create mode 100644 app/assets/stylesheets/select2-custom.scss delete mode 100644 app/assets/stylesheets/vms.scss diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index e274aef4..f167762f 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -19,7 +19,7 @@ * See: https://github.com/twbs/bootstrap-rubygem#a-ruby-on-rails */ - // Custom bootstrap variables must be set or *before* bootstrap is imported +// Custom bootstrap variables must be set or *before* bootstrap is imported $primary: #0C415F; $danger: #a80833; $primary-active: #1f6993; @@ -32,6 +32,8 @@ $primary-hover: #1a5b82; // https://github.com/argerim/select2-rails/issues/135 @import "select2.css"; @import "select2-bootstrap"; +// Custom styles for select2: app/assets/stylesheets/custom.scss +@import "select2-custom"; // Bootstrap styling for datatables // https://github.com/mkhairi/jquery-datatables#stylesheets @import 'datatables/dataTables.bootstrap4'; @@ -48,77 +50,6 @@ $primary-hover: #1a5b82; //@import 'datatables/extensions/Scroller/scroller.bootstrap4'; //@import 'datatables/extensions/Select/select.bootstrap4'; -@import 'notifications'; -@import 'requests'; -@import 'resource_allocation'; -@import 'vms'; - -th { - @extend .text-white; - @extend .bg-primary; -} - -html, body { - height: 100%; - min-width: 1000px; - width: 100%; -} - -.page-container { - margin: 25px 0 0 50px; - width: calc(100% - 100px); -} - -h1 { - color: $primary; -} - -.dashboard-header-link { - text-decoration: none !important; -} - -h3:hover { - text-decoration: none; - color: $primary-hover; -} - -body { - display: flex; - flex-direction: column; -} - -#content { - flex: 1 0 auto; - padding-bottom: 5em; -} - -#footer { - flex-shrink: 0; - - a { - color: white; - } - - .footer-element { - padding-top: 20px; - - &__left { - @extend .footer-element; - padding-left: 50px; - } - } -} - -.dropdown-menu { - padding: 10px; - width: auto; -} - -.unread { - background-color: #e6f3ff; -} - -#menu-profile-dropdown { - padding-top: 3px; -} +// All custom CSS: app/assets/stylesheets/custom.scss +@import 'custom'; diff --git a/app/assets/stylesheets/resource_allocation.scss b/app/assets/stylesheets/charts.scss similarity index 90% rename from app/assets/stylesheets/resource_allocation.scss rename to app/assets/stylesheets/charts.scss index 23acda0c..45dd5f63 100644 --- a/app/assets/stylesheets/resource_allocation.scss +++ b/app/assets/stylesheets/charts.scss @@ -1,5 +1,4 @@ // Place all the styles related to the Requests controller here. -// They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ .graphLabel { @@ -33,4 +32,5 @@ position: relative; text-align: center; display: inline-block; -} \ No newline at end of file +} + diff --git a/app/assets/stylesheets/custom.scss b/app/assets/stylesheets/custom.scss new file mode 100644 index 00000000..d328425d --- /dev/null +++ b/app/assets/stylesheets/custom.scss @@ -0,0 +1,91 @@ +th { + @extend .text-white; + @extend .bg-primary; +} + +html, body { + height: 100%; + min-width: 1000px; + width: 100%; +} + +.page-container { + margin: 25px 0 0 50px; + width: calc(100% - 100px); +} + +h1 { + color: $primary; +} + +.dashboard-header-link { + text-decoration: none !important; +} + +h3:hover { + text-decoration: none; + color: $primary-hover; +} + +body { + display: flex; + flex-direction: column; +} + +#content { + flex: 1 0 auto; + padding-bottom: 5em; +} + +#footer { + flex-shrink: 0; + + a { + color: white; + } + + .footer-element { + padding-top: 20px; + + &__left { + @extend .footer-element; + padding-left: 50px; + } + } +} + +.dropdown-menu { + padding: 10px; + width: auto; +} + +.unread { + background-color: #e6f3ff; +} + +#menu-profile-dropdown { + padding-top: 3px; +} + +.notification-bell { + #notification-alert { + margin-top: -0.4em; + margin-left: 0.6em; + display: none; + } +} + +.round { + height: 1rem; + width: 1rem; + border-radius: 0.5rem; + vertical-align: middle; + margin-right: 0.5rem; + display: inline-block; +} + +.half-screen-box { + width: 49%; + flex: 1; +} + diff --git a/app/assets/stylesheets/notifications.scss b/app/assets/stylesheets/notifications.scss deleted file mode 100644 index d8daaa78..00000000 --- a/app/assets/stylesheets/notifications.scss +++ /dev/null @@ -1,11 +0,0 @@ -// Place all the styles related to the Notifications controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -.notification-bell { - #notification-alert { - margin-top: -0.4em; - margin-left: 0.6em; - display: none; - } -} diff --git a/app/assets/stylesheets/requests.scss b/app/assets/stylesheets/requests.scss deleted file mode 100644 index c96733e8..00000000 --- a/app/assets/stylesheets/requests.scss +++ /dev/null @@ -1,30 +0,0 @@ -// Place all the styles related to the Requests controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -// div { -// &.field { -// margin-bottom: 20px; -// } -// } - -// label { -// display: block; -// } - -/* Selected items have Bootstrap primary background */ -.select2-selection__choice { - @extend .text-white; - @extend .bg-primary; -} - -// .select2-container { -// width: 100% !important; -// } - -// .styled-form { -// h5 { -// font-weight: bold; -// font-size: 1.2em; -// } -// } \ No newline at end of file diff --git a/app/assets/stylesheets/select2-custom.scss b/app/assets/stylesheets/select2-custom.scss new file mode 100644 index 00000000..6d705910 --- /dev/null +++ b/app/assets/stylesheets/select2-custom.scss @@ -0,0 +1,8 @@ +// Place all the styles related to styling select2 elements here +// You can use Sass (SCSS) here: http://sass-lang.com/ + +/* Selected items have Bootstrap primary background */ +.select2-selection__choice { + @extend .text-white; + @extend .bg-primary; +} diff --git a/app/assets/stylesheets/vms.scss b/app/assets/stylesheets/vms.scss deleted file mode 100644 index 493ccb7c..00000000 --- a/app/assets/stylesheets/vms.scss +++ /dev/null @@ -1,17 +0,0 @@ -// Place all the styles related to the vm controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ - -.half-screen-box { - width: 49%; - flex: 1; -} - -.round { - height: 1rem; - width: 1rem; - border-radius: 0.5rem; - vertical-align: middle; - margin-right: 0.5rem; - display: inline-block; -} From 5995b41f375d58c09a6d278194463165eb7edf50 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sun, 24 Mar 2019 16:37:25 +0100 Subject: [PATCH 52/59] Fix(CSS): .unread -> .bg-primary-light --- app/assets/stylesheets/custom.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/custom.scss b/app/assets/stylesheets/custom.scss index d328425d..7f7a0a29 100644 --- a/app/assets/stylesheets/custom.scss +++ b/app/assets/stylesheets/custom.scss @@ -59,7 +59,7 @@ body { width: auto; } -.unread { +.bg-primary-light { background-color: #e6f3ff; } From c58fc6f28b78134f08817a9ad371c40cb616f88d Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sun, 24 Mar 2019 16:54:32 +0100 Subject: [PATCH 53/59] Fix(dashboard): Remove custom styling --- app/assets/stylesheets/custom.scss | 9 --------- app/views/dashboard/_widget.erb | 10 +++++----- app/views/dashboard/index.html.erb | 2 +- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/app/assets/stylesheets/custom.scss b/app/assets/stylesheets/custom.scss index 7f7a0a29..7ab2c9af 100644 --- a/app/assets/stylesheets/custom.scss +++ b/app/assets/stylesheets/custom.scss @@ -18,15 +18,6 @@ h1 { color: $primary; } -.dashboard-header-link { - text-decoration: none !important; -} - -h3:hover { - text-decoration: none; - color: $primary-hover; -} - body { display: flex; flex-direction: column; diff --git a/app/views/dashboard/_widget.erb b/app/views/dashboard/_widget.erb index 785b3cfd..157c3417 100644 --- a/app/views/dashboard/_widget.erb +++ b/app/views/dashboard/_widget.erb @@ -1,10 +1,10 @@ <% unless vms.empty? %>
- <%= link_to vms_path, method: :get, class: "dashboard-header-link" do %> -
-

<%= header %>

-
- <% end %> +
+ <%= link_to vms_path, class: 'text-white' do %> +

<%= fa_icon('desktop', text: header) %>

+ <% end %> +
<%= render 'vms/table', {vms: vms, id: id, buttons: buttons, datatable_options: {searching: false, paging: false, info:false}} %> diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index e9da54ff..db70b4c2 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -12,7 +12,7 @@
- <%= link_to notifications_path, class: "dashboard-header-link text-white" do %> + <%= link_to notifications_path, class: "text-white" do %>

<%= fa_icon('bell') %> Notifications

<% end %>
From 78e3fe92c2a73c5ed3530c34ea9f9e19324d6065 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sun, 24 Mar 2019 17:15:45 +0100 Subject: [PATCH 54/59] Fix(CSS): custom datatables styling --- app/assets/stylesheets/application.scss | 1 + app/assets/stylesheets/datatables-custom.scss | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 app/assets/stylesheets/datatables-custom.scss diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index f167762f..d6d1e64e 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -37,6 +37,7 @@ $primary-hover: #1a5b82; // Bootstrap styling for datatables // https://github.com/mkhairi/jquery-datatables#stylesheets @import 'datatables/dataTables.bootstrap4'; +@import 'datatables-custom'; // optional datatables styles for extensions, include when used //@import 'datatables/extensions/AutoFill/autoFill.bootstrap4'; //@import 'datatables/extensions/Buttons/buttons.bootstrap4'; diff --git a/app/assets/stylesheets/datatables-custom.scss b/app/assets/stylesheets/datatables-custom.scss new file mode 100644 index 00000000..bf5a8436 --- /dev/null +++ b/app/assets/stylesheets/datatables-custom.scss @@ -0,0 +1,7 @@ +// Place all the styles related to styling datatables elements here +// You can use Sass (SCSS) here: http://sass-lang.com/ + +// Place search box +.dataTables_filter { + text-align: initial !important; +} \ No newline at end of file From d7c6133e8785b297ad2903ba2aee2c09dc2f79c5 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sun, 24 Mar 2019 17:17:35 +0100 Subject: [PATCH 55/59] Fix(CSS): Add comment for datatables custom CSS --- app/assets/stylesheets/application.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index d6d1e64e..a45b1ecf 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -37,6 +37,7 @@ $primary-hover: #1a5b82; // Bootstrap styling for datatables // https://github.com/mkhairi/jquery-datatables#stylesheets @import 'datatables/dataTables.bootstrap4'; +// Custom styles for datatables: app/assets/stylesheets/datatables-custom.scss @import 'datatables-custom'; // optional datatables styles for extensions, include when used //@import 'datatables/extensions/AutoFill/autoFill.bootstrap4'; From efb4825265598ffb2218a25db3345e4b4db3c950 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sun, 24 Mar 2019 18:59:06 +0100 Subject: [PATCH 56/59] Fix(Project form): Bootstrap layout --- app/views/projects/_form.html.erb | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/app/views/projects/_form.html.erb b/app/views/projects/_form.html.erb index a668a328..92095ce7 100644 --- a/app/views/projects/_form.html.erb +++ b/app/views/projects/_form.html.erb @@ -21,18 +21,15 @@ <%= form.text_area :description, cols: "40", rows: "4", class: 'form-control' %>
-

Responsible users:

- <%= form.select 'responsible_user_ids', - options_from_collection_for_select(User.all, - :id, - :human_readable_identifier, - selected: selected_user_ids), - {}, - { multiple: true, class: "selecttwo form-group", data: { placeholder: 'Responsible users' }} - %> - -
-
- <%= form.submit id: 'submitProjectButton', class: "btn btn-primary" %> +
+ <%= form.label "Responsible users" %> + <%= form.select 'responsible_user_ids', + options_from_collection_for_select(User.all, :id, + :human_readable_identifier, + selected: selected_user_ids), + {}, + { multiple: true, class: "selecttwo", data: { placeholder: 'Responsible users' }} %>
+ + <%= form.submit id: 'submitProjectButton', class: "btn btn-primary" %> <% end %> From c5927d8970037f73ba696ddabe62c90480311787 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sun, 24 Mar 2019 19:00:16 +0100 Subject: [PATCH 57/59] Fix(request template views): Remove back buttons, less HTML --- app/views/request_templates/_form.html.erb | 4 +--- app/views/request_templates/edit.html.erb | 1 - app/views/request_templates/show.html.erb | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/views/request_templates/_form.html.erb b/app/views/request_templates/_form.html.erb index c1a88bb7..d7425038 100644 --- a/app/views/request_templates/_form.html.erb +++ b/app/views/request_templates/_form.html.erb @@ -32,7 +32,5 @@ <%= form.select :operating_system, operating_system_options, {}, {class: 'form-control'}%>
-
- <%= form.submit class: "btn btn-primary" %> -
+ <%= form.submit class: "btn btn-primary" %> <% end %> diff --git a/app/views/request_templates/edit.html.erb b/app/views/request_templates/edit.html.erb index a5baa72b..69dc7cad 100644 --- a/app/views/request_templates/edit.html.erb +++ b/app/views/request_templates/edit.html.erb @@ -2,4 +2,3 @@ <%= render 'form', request_template: @request_template %> -<%= link_to 'Back', request_templates_path %> diff --git a/app/views/request_templates/show.html.erb b/app/views/request_templates/show.html.erb index ef8608d0..b3377ea1 100644 --- a/app/views/request_templates/show.html.erb +++ b/app/views/request_templates/show.html.erb @@ -30,4 +30,4 @@
<%= link_to 'Edit', edit_request_template_path(@request_template) %> | -<%= link_to 'Back', request_templates_path %> +<%= link_to 'Back', request_templates_path, class: "btn btn-secondary" %> From 08e3fbe5687f44b9da06bb58e9d6883defa9427d Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sun, 24 Mar 2019 19:07:53 +0100 Subject: [PATCH 58/59] Fix(Server form): Style 'Add software' button --- app/views/servers/_form.html.erb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/views/servers/_form.html.erb b/app/views/servers/_form.html.erb index 9677aeea..36d4e296 100644 --- a/app/views/servers/_form.html.erb +++ b/app/views/servers/_form.html.erb @@ -99,7 +99,7 @@ function addInput() var inputKind = document.createElement("INPUT"); inputKind.setAttribute("type", "text"); inputKind.setAttribute("placeholder", "Software " + countBox); - inputKind.setAttribute("class", "form-control"); + inputKind.setAttribute("class", "form-control mt-1"); inputKind.setAttribute("name", boxName); inputKind.setAttribute("id", boxName); @@ -110,11 +110,10 @@ function addInput() } -
- +
+
-
- <%= form.submit class: "btn btn-primary" %> -
+ <%= form.submit class: "btn btn-primary" %> <% end %> + From d2970eb678f67d13191997fc7d6fbc6b8aa383e9 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Sun, 24 Mar 2019 19:09:16 +0100 Subject: [PATCH 59/59] Fix(Server new): Remove back button --- app/views/servers/new.html.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/servers/new.html.erb b/app/views/servers/new.html.erb index 67f336b2..ab3c28f6 100644 --- a/app/views/servers/new.html.erb +++ b/app/views/servers/new.html.erb @@ -2,4 +2,3 @@ <%= render 'form', server: @server %> -<%= link_to 'Back', servers_path %>