<%
  define_admin_breadcrumbs do
    add_admin_breadcrumb('用户站点列表', admins_site_pages_path)
    add_admin_breadcrumb('站点详情')
  end
%>

<div class="box site_page-edit-container">
  <div class="site_page-info mb-4 row">
    <%= link_to "/#{@site_page.user.login}", class: 'user-info-avatar col-md-1', target: '_blank', data: { toggle: 'tooltip', title: '个人中心' } do %>
      <img src="/<%= url_to_avatar(@user) %>" class="rounded-circle" width="80" height="80" />
    <% end %>
    
    <div class="d-flex flex-column justify-content-between col-md-3 user-info-content">
      <div class="user-info-name flex"><%= @user.real_name %> | <%= @user.id %> | <%= @user.login %></div>

      <div class="d-flex flex-row user-info-auth">
        <% if @user.authentication? %>
          <i class="fa fa-user text-success" data-toggle="tooltip" data-placement="bottom" title="已实名认证"></i>
        <% elsif @user.process_real_name_apply.present? %>
          <i class="fa fa-user text-danger" data-toggle="tooltip" data-placement="bottom" title="实名认证中"></i>
        <% else %>
          <i class="fa fa-user text-muted" data-toggle="tooltip" data-placement="bottom" title="未实名认证"></i>
        <% end %>

        <% if @user.professional_certification %>
          <i class="fa fa-list-alt text-success" data-toggle="tooltip" data-placement="bottom" title="已职业认证"></i>
        <% elsif @user.process_professional_apply.present? %>
          <i class="fa fa-list-alt text-danger" data-toggle="tooltip" data-placement="bottom" title="职业认证中"></i>
        <% else %>
          <i class="fa fa-list-alt text-muted" data-toggle="tooltip" data-placement="bottom" title="未职业认证"></i>
        <% end %>

        <% if @user.phone.present? %>
          <i class="fa fa-mobile text-success" data-toggle="tooltip" data-placement="bottom" title="已绑定手机"></i>
        <% else %>
          <i class="fa fa-mobile text-muted" data-toggle="tooltip" data-placement="bottom" title="未绑定手机"></i>
        <% end %>

        <% if @user.mail.present? %>
          <i class="fa fa-envelope text-success" data-toggle="tooltip" data-placement="bottom" title="已绑定邮箱"></i>
        <% else %>
          <i class="fa fa-envelope text-muted" data-toggle="tooltip" data-placement="bottom" title="未绑定邮箱"></i>
        <% end %>
      </div>
      <div class="user-info-last-login">最近登录：<%= @user.last_login_on&.strftime('%Y-%m-%d %H:%M') %></div>
    </div>
  </div>

  <%= simple_form_for(@site_page, url: admins_site_page_path(@site_page)) do |f| %>

    <div class="mt-4">
            
      <label>当前用户的站点权限为： <b><%=@site_page.user.website_permission == true ? "正常" : "关闭，已被管理员强制关闭建站权限" %></b></label></br>
      <label>当前站点状态为： <b><%=@site_page.state == true ? "正常" : "关闭，关闭理由为：#{@site_page.state_description}" %></b></label>
      <div class="form-row">
        <%= f.input :identifier, label: '站点标识', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, class: 'col-md-5' , value: @site_page.identifier } %>
      </div>

      <div class="form-row">
        <%= f.input :site_name, label: '站点名', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, class: 'col-md-5' , value: @site_page.site_name } %>
      </div>
      
      <div class="form-row">
        <%= f.input :language_frame, label: '建站工具', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true,  type:'text', class: 'col-md-5' , value: @site_page.language_frame } %>
      </div>
      
      <div class="form-row">
        <%= f.input :theme, label: '主题', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, class: 'col-md-5' , value: @site_page.theme } %>
      </div>
      </br>


      <div class="form-row">
          <label>当前站点：</label>
          <a href="<%= @site_page.url%>" target="_blank"> <%= @site_page.url%> </a>
      </div>
      </br>
      <div class="form-row">
        <label>是否关闭站点？　</label>
        <%= f.radio_button :state, 'false' %> 关闭
      </div>
      </br>
      <div class="form-row">
        <label>注意，因为关闭站点涉及操作另外一台服务器，所以站点关闭后<b>无法重新打开</b>，请谨慎操作, 关闭站点后该仓库再也不能进行 <b>开通站点、部署等</b>操作 </label>
      </div>
      </br>
      <div class="form-row">
        <%= f.input :state_description, as: :text,label: '关闭理由，如需关闭 理由不能为空', wrapper_html: { class: 'col-md-12' }, input_html: { maxlength: 100, size: 40, class: 'col-md-11' , value: @site_page.state_description } %>
      </div>

      <div class="form-row mt-4">
          <%= f.button :submit, value: '保存', class: 'btn-primary mr-3 px-4' %>
          <%= link_to '取消', admins_site_pages_path, class: 'btn btn-secondary px-4' %>
      </div>
    </div>
    
  <% end %>
</div>
