{% 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 hold-transition sidebar-mini-md navbar navbar-expand {{"navbar-dark" if  g.darkmode 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>
  <ul class="navbar-nav ml-auto">
    %if g.darkmode
    <a class="nav-link btn" href="?darkmode=false">
      <i class="fa-solid fa-sun"></i>
    </a>
  %else
  <a class="nav-link btn" href="?darkmode=true">
    <i class="fa-solid fa-moon"></i>
  </a>
  %endif
  % if 0 and not hconfig(ConfigEnum.is_parent)
        
  
    <a class="nav-link btn btn-outline-secondary form_post d-none d-md-flex" href="{{url_for('admin.Actions:apply_configs')}}">
      {{icon('solid','bolt','nav-icon')}} {{_('admin.Actions:apply_configs')}}
    </a>  
  
  %endif
</ul>
</nav>
<!-- /.navbar -->




<!-- Main Sidebar Container -->
<aside id="main-sidebar" class="main-sidebar {{ "sidebar-dark-primary"}}  elevation-4">
  <!-- Brand Logo -->
  
  <a href="https://github.com/hiddify/hiddify-config/wiki" class="" style="text-align: center; color: white;display: block;">
  <img src="{{url_for('static',filename='images/WhiteLogo.png')}}" class=" " style="width: 50%;opacity: .8;margin: auto;display:block"/>
  <div class="ltr" style="font-size: 8pt;">{{version}}</div>
  % 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="n3av 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')),_use_li=True) }}
                
                % 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') ,_use_li=True) }}
                %else
                {{ render_nav_item('flask.user.index_view', icon('solid','user','nav-icon')+_('admin.menu.user'),_use_li=True) }}
                %endif
                
                {{ render_nav_item('flask.adminuser.index_view', icon('solid','user-secret','nav-icon')+_('Admins'),_use_li=True) }}
              

                 
                % if g.admin.mode!="agent"    
                 {% set settings_active = False if request.endpoint and ("user" in request.endpoint or "Actions:" in request.endpoint or "Dashboard" in request.endpoint) else True %}
                 <li class="nav-item {{'menu-open' if settings_active else ''}}" >
            
                  <a id= href="#" data-target="#setting-sidebar"
                    class="nav-link">{{icon('solid','gear','nav-icon')+_('admin.menu.config')}}</a>
                
                </li>
                %endif
                 % if hconfig(ConfigEnum.license)
                 %else
                 %if false
                 {{ render_nav_item('admin.CommercialInfo:index', icon('solid','dumpster','nav-icon')+_('Commercial use'),_use_li=True) }}
                 %endif
                 %endif


          
          {% set action_active = True if request.endpoint and "Actions:" in request.endpoint else False %}
          % if g.admin.mode=="super_admin"    
          <li class="nav-item {{'menu-open' if action_active else ''}}" >
            
            <a id= href="#" data-target="#action-sidebar"
              class="nav-link">{{icon('solid','suitcase','nav-icon')+_('admin.actions.title')}} <i class="right fas fa-angle-left"></i></a>
          
          </li>
          %endif
          
          <li class="nav-item">
          <a href="https://github.com/hiddify/hiddify-config/wiki/{{'%D9%87%D9%85%D9%87-%D8%A2%D9%85%D9%88%D8%B2%D8%B4%E2%80%8C%D9%87%D8%A7-%D9%88-%D9%88%DB%8C%D8%AF%D8%A6%D9%88%D9%87%D8%A7' if get_locale()=='fa' else 'All-tutorials-and-videos'}}" target="_blank"
      class=" nav-link">{{icon('solid','circle-question','nav-icon')+_('admin.menu.support')}}</a>
    </li>
    <li class="nav-item d-none">
    <a href="https://t.me/hiddify" target="_blank"
      class="nav-link">{{icon('brands','telegram','nav-icon')+_('admin.menu.telegram')}}</a>
    </li>
    <li class="nav-item">
      <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>
    </li>
        </div>
        
      </nav>
      <!-- /.sidebar-menu -->
    </div>
  </div>
  <!-- /.sidebar -->
</aside>



    <!-- Sub Sidebar Container -->
    <aside class="main-sidebar sidebar-dark-primary elevation-4 sub-sidebar" >
      <!-- Sidebar -->
      <div class="sidebar">

        <!-- Sub Sidebar Menu -->
        <nav class="mt-2">
          <ul class="nav nav-pills nav-sidebar flex-column" id="sub-sidebar">
            
            <div class="nav-item" id="action-sidebar">
              {{ 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:update', icon('solid','arrow-up-from-bracket','nav-icon')+_('admin.actions.update'), _use_li=True,extra_class="form_post") }}
              % if not hconfig(ConfigEnum.is_parent)
              {{ 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:reset', icon('solid','power-off','nav-icon')+_('admin.actions.reset'), _use_li=True,extra_class="form_post") }}
              % endif
            </div>
            <div class="nav-item" id="setting-sidebar">
              

              % if hconfig(ConfigEnum.is_parent)
              {{ render_nav_item('flask.parentdomain.index_view', icon('solid','arrow-down-up-lock','nav-icon')+_('admin.menu.domain'),_use_li=True) }}
              %endif

              % if not hconfig(ConfigEnum.is_parent)
              
                 {{ render_nav_item('flask.domain.index_view', icon('solid','link','nav-icon')+_('admin.menu.domain'),_use_li=True) }}
                 {{ render_nav_item('admin.ProxyAdmin:index', icon('solid','arrow-down-up-lock','nav-icon')+_('admin.menu.proxy'),_use_li=True) }}
                 %endif
                 % if g.admin.mode=='super_admin'
                    {{ render_nav_item('admin.SettingAdmin:index',icon('solid','gear','nav-icon')+ _('admin.menu.config'),_use_li=True) }}
                    
                    % if 0 or  hconfig(ConfigEnum.license)
                    {{ render_nav_item('admin.CommercialSettings:index', icon('solid','dumpster','nav-icon')+_('Commercial Settings'),_use_li=True) }}
                    %endif
                    {{ render_nav_item('admin.Backup:index',icon('solid','floppy-disk','nav-icon')+ _('Backup'), _use_li=True) }}
                %endif
                % if hconfig(ConfigEnum.telegram_bot_token) and g.bot
                {{ render_nav_item("tg://resolve?domain="+g.bot.username+"&start=admin_"+hconfig(ConfigEnum.admin_secret), icon('brands','telegram','nav-icon')+_('Telegram Bot'),_use_li=True) }}
                %endif              
            </div>
          </ul>
        </nav>
        <!-- /.sub-sidebar-menu -->
      </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)
    
    bootbox.confirm({
    message: '{{_("Are you sure you want to do this action?")}}',
    locale:'{{get_locale()}}',
    callback: function(result) {
      if (result) {    
        $("#action_form").submit()
      }
    }
  });
  return false;

    
  })
  // if ($('.').length){
  //   $("#modal-donation").modal()
  // }
})

</script>

{% endblock %}