<% 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 :page_tools do %>
<%=
toolbar do |tb|
  tb.link t('link.edit'),
          href: edit_device_path(@school, @device),
          icon: 'pencil'

  tb.dropdown t('link.more'), right: true do |menu|
    if @permit_device_school_change
      menu.link t('.change_school'),
                href: select_school_device_path(@school, @device),
                icon: 'exchange'
    end

    if @device.puavoDeviceType == 'laptop' && @pme_enabled
      menu.link t('layouts.application.puavomenu_editor'),
                href: device_puavomenu_path(@school, @device),
                icon: 'list'
    end

    menu.separator

    if @device.puavoDeviceType == 'laptop' && @permit_device_reset
      if @device.has_pending_reset
        menu.link t('link.clear_reset_mode'),
                  href: clear_reset_mode_device_path(@school, @device),
                  method: 'put',
                  icon: 'flag-empty'
      else
        menu.link t('link.set_reset_mode'),
                  href: set_reset_mode_device_path(@school, @device),
                  confirm: t('reset_confirm', object_name: @device.puavoHostname),
                  method: 'put',
                  danger: true,
                  icon: 'flag'
      end
    end

    menu.separator

    if @permit_device_deletion
      if @device.hostCertificates
        menu.link t('link.set_install_mode'),
                  href: revoke_certificate_device_path(@school, @device),
                  confirm: t('general_confirm'),
                  method: 'delete',
                  danger: true,
                  icon: 'cancel'
      end

      menu.link t('link.delete_device'),
                href: device_path(@school, @device),
                confirm: t('destroy_confirm', object_name: @device.puavoHostname),
                method: 'delete',
                danger: true,
                icon: 'trash'
    end
  end
end %>
<% end %>

<% unless test_environment? %>
<% content_for :javascript do %>

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

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