diff --git a/app/assets/javascripts/foreman_wds/wds_servers.js b/app/assets/javascripts/foreman_wds/wds_servers.js index 91762a43aec4844226e26bf4c00ec05f8f98be4c..f496511f70012be2a680ebdff0b9c5024f9e6f2b 100644 --- a/app/assets/javascripts/foreman_wds/wds_servers.js +++ b/app/assets/javascripts/foreman_wds/wds_servers.js @@ -1,4 +1,4 @@ -function wds_images_load(element){ +function wds_load(element){ var url = $(element).attr('data-url'); tfm.tools.showSpinner(); $.ajax({ @@ -8,11 +8,12 @@ function wds_images_load(element){ reloadOnAjaxComplete(element); }, success: function(request) { - $('#images').html(request); + element.html(request); } }); } $(function() { - wds_images_load($('#images')); + wds_load($('#images')); + wds_load($('#clients')); })(); diff --git a/app/controllers/wds_servers_controller.rb b/app/controllers/wds_servers_controller.rb index 457c976a7a89552019c7644a12b527e4ec3ace8d..89587e83257eadd8b48d1664a4437386eb6bacbc 100644 --- a/app/controllers/wds_servers_controller.rb +++ b/app/controllers/wds_servers_controller.rb @@ -60,10 +60,16 @@ class WdsServersController < ::ApplicationController render partial: 'form', locals: { wds_server: @wds_server } end + def wds_clients + @clients = @wds_server.clients + + render partial: 'wds_servers/clients/list' + end + def wds_images @images = @wds_server.boot_images + @wds_server.install_images - render partial: 'wds_images/list' + render partial: 'wds_servers/images/list' end private diff --git a/app/views/wds_servers/clients/_list.html.erb b/app/views/wds_servers/clients/_list.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..a7c294dce73558ebdc4ebd76a565ae0858934b28 --- /dev/null +++ b/app/views/wds_servers/clients/_list.html.erb @@ -0,0 +1,36 @@ +<% title _('WDS Clients') %> + +<table id="wds_clients" class="<%= table_css_classes %>" data-table='inline'> + <thead> + <tr> + <th><%= s_("Client|Name") %></th> + <th><%= s_("Client|Group") %></th> + <th><%= s_("Client|ID") %></th> + <th><%= s_("Client|Architecture") %></th> + <th><%= s_("Client|Boot Image") %></th> + <th><%= s_("Client|Unattend") %></th> + </tr> + </thead> + <tbody> + <%- @clients.each do |client| -%> +<%- + host = begin + if client[:device_id] =~ /([0-9A-F]{2}-){5}[0-9A-F]{2}/ + nic = Nic::Managed.find_by(mac: client[:device_id].downcase.tr('-', ':')) + nic && nic.host + else + Host::Managed.find_by(name: client[:device_name]) + end + end +-%> + <tr> + <td><%= host ? link_to_if_authorized(client[:device_name], hash_for_host_path(:id => host)) : client[:device_name] %></td> + <td><%= client[:group] %></td> + <td><%= client[:device_id] %></td> + <td><%= client[:architecture] %></td> + <td><%= client[:boot_image_path] %></td> + <td><%= client[:wds_client_unattend] %></td> + </tr> + <%- end -%> + </tbody> +</table> diff --git a/app/views/wds_images/_list.html.erb b/app/views/wds_servers/images/_list.html.erb similarity index 95% rename from app/views/wds_images/_list.html.erb rename to app/views/wds_servers/images/_list.html.erb index 929b74ec4221a129ce6c6010135a4437121845f6..5c6d4ed69ad29d9ce60711e8b30bdefce0e680d7 100644 --- a/app/views/wds_images/_list.html.erb +++ b/app/views/wds_servers/images/_list.html.erb @@ -13,7 +13,7 @@ </tr> </thead> <tbody> - <% @images.each do |image| %> + <%- @images.each do |image| -%> <tr> <td><%= image.name %></td> <td><%= image.image_group if image.respond_to? :image_group %></td> @@ -31,6 +31,6 @@ </td> <td><%= image.type_name %></td> </tr> - <% end %> + <%- end -%> </tbody> </table> diff --git a/app/views/wds_servers/show.html.erb b/app/views/wds_servers/show.html.erb index d3441204b0840ace35e423c96c898eee5efb49de..c5114737ac58d091aa1afff15b496c7ac19e42bc 100644 --- a/app/views/wds_servers/show.html.erb +++ b/app/views/wds_servers/show.html.erb @@ -7,6 +7,7 @@ <ul class="nav nav-tabs" data-tabs="tabs"> <li class="active"><a href="#primary" data-toggle="tab"><%= _("WDS Server") %></a></li> <li><a href="#images" data-toggle="tab"><%= _("Images") %></a></li> + <li><a href="#clients" data-toggle="tab"><%= _("Clients") %></a></li> </ul> <div class="tab-content"> @@ -39,4 +40,7 @@ <div id="images" class="tab-pane" data-url="<%= wds_images_wds_server_path(@wds_server) %>#wds_images"> <%= spinner(_('Loading image information ...')) %> </div> + <div id="clients" class="tab-pane" data-url="<%= wds_clients_wds_server_path(@wds_server) %>#wds_clients"> + <%= spinner(_('Loading image information ...')) %> + </div> </div> diff --git a/config/routes.rb b/config/routes.rb index b22413475e83b82e3b6f1bb48589ef2a4ea003ed..367222c772f2ac3d14dd6caa783252d21321d3d5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,6 +8,7 @@ Rails.application.routes.draw do end member do post 'refresh_cache' + get 'wds_clients' get 'wds_images' end end