<% page_title t('titles.schools'), @school.displayName, t('titles.devices'), @device.cn %>

<%= render :partial => 'shared/main_information', :locals => { :device => @device} %>

<%= render :partial => 'shared/linux_device_information', :locals => { :device => @device} %>

<% if @device.classes.include?('puavoPrinter') %>
<%= render :partial => 'cups', :locals => { :device => @device } %>
<% end %>

<% if ['laptop', 'fatclient', 'thinclient'].include?(@device.puavoDeviceType) %>
<%= render :partial => 'devices/hwinfo', :locals => { :rawInfo => @device.puavoDeviceHWInfo } %>
<% end %>

<hr>

<% content_for :tools do %>
<ul>
  <li>
    <%= link_to edit_device_path(@school, @device), class: 'btn' do %>
      <i class="icon-pencil"></i><%= t('link.edit') %>
    <% end %>
  </li>

  <li class="haveDropdown">
    <span class="btn"><i class='icon-collapse'></i><%= t('link.more') %></span>
    <div class="dropdown dropRight">
      <ul>
        <li>
          <%= link_to select_school_device_path(@school, @device) do%>
            <i class="icon-exchange"></i><%= t('.change_school') %>
          <% end %>
        </li>
      </ul>

      <% if @device.puavoDeviceType == 'laptop' && @pme_enabled %>
      <ul>
        <li>
          <%= link_to device_puavomenu_path(@school, @device) do%>
            <i class="icon-list"></i><%= t('layouts.application.puavomenu_editor') %>
          <% end %>
        </li>
      </ul>
      <% end %>

      <ul>
        <% if @device.puavoDeviceType == 'laptop' %>
          <li>
            <% if @device.has_pending_reset %>
              <%= link_to clear_reset_mode_device_path(@school, @device), :method => :put do %>
                <i class="icon-flag-empty"></i><%= t('link.clear_reset_mode') %>
              <% end %>
            <% else %>
              <%= link_to set_reset_mode_device_path(@school, @device),
                          data: { confirm: t('reset_confirm', object_name: @device.puavoHostname) },
                          :method => :put do %>
                <i class="icon-flag"></i><%= t('link.set_reset_mode') %>
              <% end %>
            <% end %>
          </li>
        <% end %>

        <li>
          <% if @device.hostCertificates %>
            <%= link_to revoke_certificate_device_path(@school, @device), data: { confirm: t('general_confirm') }, :method => :delete do %>
              <i class="icon-cancel"></i><%= t('link.set_install_mode') %>
            <% end %>
          <% end %>
        </li>

        <li>
          <%= link_to(device_path(@school, @device), data: { confirm: t('destroy_confirm', object_name: @device.puavoHostname) },
                      method: :delete) do %>
            <i class="icon-trash"></i><%= t('link.delete_device') %>
          <% end %>
        </li>
      </ul>
    </div>
  </li>
</ul>
<% end %>

<% content_for :javascript do %>

<script>
const ALL_PUAVOCONF = <%= raw JSON.pretty_generate(@full_puavoconf) %>;
</script>

<%= render partial: 'shared/copy_text.js' %>
<%= render partial: 'shared/copy_basic_info.js', locals: { device: @device } %>
<%= render partial: 'shared/puavoconf_table.js', locals: { select: "div.basicInfo select#changeVisibleConfig", container: "div.basicInfo div#puavoConfOutput", type: 'dev' } %>
<% end %>
