{% extends 'master.html' %}
{% from 'macros.html' import icon,render_nav_item %}

{% block title%}{{title if title else "Admin"}}{% endblock %}
{% block bodyclass %}{%endblock%}
{% block body_header %}{%endblock%}


{% block nav_bar %}
{% include "donation.html" %}
<!-- Navbar -->
<nav class="main-header navbar navbar-expand {{"navbar-dark" if hconfig(ConfigEnum.is_parent) else "bg-white navbar-light"}} border-bottom">
  <!-- Left navbar links -->



  <div class="navbar-nav">
  <a class="nav-link" data-widget="pushmenu" href="#"><i class="fa fa-bars"></i> <span class="brand-text font-weight-light">{{_("master.page-title")}} <span class="badge d-none d-sm-inline-block">{{version}}</span>
  % if hconfig(ConfigEnum.is_parent)
  {{_("Parent Panel")}}
  %endif
</a>
  </div>
  % if not hconfig(ConfigEnum.is_parent)
        
  <ul class="navbar-nav ml-auto">
    <a class="nav-link btn btn-outline-secondary form_post" href="{{url_for('admin.Actions:apply_configs')}}">
      {{icon('solid','bolt','nav-icon')}} {{_('admin.Actions:apply_configs')}}
    </a>  
  </ul>
  %endif
</nav>
<!-- /.navbar -->




<!-- Main Sidebar Container -->
<aside class="main-sidebar {{ "sidebar-light-info" if hconfig(ConfigEnum.is_parent) else "sidebar-dark-primary"}}  elevation-4">
  <!-- Brand Logo -->
  <a href="https://github.com/hiddify/hiddify-config/wiki" class="brand-link">
    <img src="{{url_for('static',filename='images/hiddify.png')}}" alt="AdminLTE Logo"
      class="brand-image img-circle elevation-3" style="opacity: .8">
    <span class="brand-text font-weight-light">{{_("master.page-title")}}</span> <span class="badge">{{version}}</span>
    % if False and  hconfig(ConfigEnum.is_parent)
    <br>
    <span class="badge">{{_("Parent Panel")}}</span>
    %endif  
  </a>
  

  <!-- Sidebar -->
  <div class="sidebar">
    <div>
      <!-- Sidebar user panel (optional) -->

      
      <!-- Sidebar Menu -->
      <nav class="mt-2">
        <div class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
          <!-- Add icons to the links using the .nav-icon class
                 with font-awesome or any other icon font library -->
                 {{ render_nav_item('admin.Dashboard:index', icon('solid','house','nav-icon')+(_("Parent Panel") if hconfig(ConfigEnum.is_parent) else _('admin.menu.home'))) }}
              
                % if hconfig(ConfigEnum.parent_panel)
                {{ render_nav_item(hconfig(ConfigEnum.parent_panel)+"/admin/user/", icon('solid','user','nav-icon')+_('admin.menu.user'),_badge=_('in parent panel') ) }}
                %else
                {{ render_nav_item('flask.user.index_view', icon('solid','user','nav-icon')+_('admin.menu.user')) }}
                %endif
                % if not hconfig(ConfigEnum.is_parent)
                 {{ render_nav_item('flask.domain.index_view', icon('solid','link','nav-icon')+_('admin.menu.domain')) }}
                 {{ render_nav_item('admin.ProxyAdmin:index', icon('solid','arrow-down-up-lock','nav-icon')+_('admin.menu.proxy')) }}
                 %endif
                 % if hconfig(ConfigEnum.is_parent)
                  {{ render_nav_item('flask.parentdomain.index_view', icon('solid','arrow-down-up-lock','nav-icon')+_('admin.menu.domain')) }}
                 %endif
                 {{ render_nav_item('admin.SettingAdmin:index',icon('solid','gear','nav-icon')+ _('admin.menu.config')) }}



          % if not hconfig(ConfigEnum.is_parent)
          {% set action_active = True if request.endpoint and "Actions:" in request.endpoint else False %}

          <li class="nav-item {{'menu-open' if action_active else ''}}">
            
            <a id= href="#"
              class="nav-link">{{icon('solid','suitcase','nav-icon')+_('admin.actions.title')}} <i class="right fas fa-angle-left"></i></a>
            <ul class="nav nav-treeview">
              {{ render_nav_item('admin.Actions:status',icon('solid','signal','nav-icon')+ _('admin.actions.status'), _use_li=True) }}
              {{ render_nav_item('admin.Actions:viewlogs',icon('solid','inbox','nav-icon')+ _('admin.actions.viewlogs'), _use_li=True) }}
              {{ render_nav_item('admin.Actions:apply_configs',icon('solid','bolt','nav-icon')+ _('admin.actions.apply_configs'), _use_li=True,extra_class="form_post") }}
              {{ render_nav_item('admin.Actions:reinstall', icon('solid','rotate','nav-icon')+_('admin.actions.reinstall'), _use_li=True,extra_class="form_post") }}
              {{ render_nav_item('admin.Actions:update', icon('solid','arrow-up-from-bracket','nav-icon')+_('admin.actions.update'), _use_li=True,extra_class="form_post") }}
              {{ render_nav_item('admin.Actions:reset', icon('solid','power-off','nav-icon')+_('admin.actions.reset'), _use_li=True,extra_class="form_post") }}
              <!-- {{ render_nav_item('admin.Actions:update_usage', icon('solid','charging-station','nav-icon')+_('User usage update'), _use_li=True) }} -->
            </ul>
          </li>
          %endif
          {{ render_nav_item('admin.Backup:index',icon('solid','floppy-disk','nav-icon')+ _('Backup'), _use_li=True) }}
          
          <a href="https://github.com/hiddify/hiddify-config/issues" target="_blank"
      class="nav-item nav-link">{{icon('solid','circle-question','nav-icon')+_('admin.menu.support')}}</a>

    <a href="https://t.me/hiddify" target="_blank"
      class="nav-item nav-link">{{icon('brands','telegram','nav-icon')+_('admin.menu.telegram')}}</a>
      <a class="nav-item nav-link" role="button" data-toggle="modal" data-target="#modal-donation">
        <i class="fa-solid fa-heart nav-icon"></i>&nbsp;{{_("Donation")}}
      </a>
        </div>
        
      </nav>
      <!-- /.sidebar-menu -->
    </div>
  </div>
  <!-- /.sidebar -->
</aside>

{% endblock %}


{%block tail_js %}
{{super()}}
<!-- <script src="https://unpkg.com/gijgo@1.9.14/js/gijgo.min.js" type="text/javascript"></script>
<link href="https://unpkg.com/gijgo@1.9.14/css/gijgo.min.css" rel="stylesheet" type="text/css" /> -->
<form id="action_form" method="post"></form>
<script>
$(document).ready(function () {
  // $('.datepicker').datepicker({uiLibrary: 'bootstrap4',format: 'yyyy-mm-dd'});
  if ($('#show-modal-donation').length){
    $("#modal-donation").modal()
  }
  $('.form_post').click(function (e) {
    e.preventDefault();
    console.log(this); console.log(e);
    var link = this.href;
    $("#action_form").attr("action",link)
    $("#action_form").submit()
  })
  // if ($('.').length){
  //   $("#modal-donation").modal()
  // }
})

</script>

{% endblock %}