{% if not InDBox %}
<html>
	<head>
	  <!-- Required meta tags -->
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

		<!-- Bootstrap CSS -->
		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
		<link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.18.0/dist/bootstrap-table.min.css">
		<link rel="stylesheet" href="https://cdn.datatables.net/1.10.22/css/dataTables.bootstrap4.min.css">
		<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
		<script src="https://kit.fontawesome.com/9b4c7cf470.js" crossorigin="anonymous"></script>
		{% import "bootstrap/wtf.html" as wtf %}
        <style>
        .highlight { box-shadow: 0 0 7px 4px #5bc0de }
        .sm-txt { font-size: 0.8rem }
        </style>
	</head>
	<body>

	<!-- Modal Dialog Box, jquery used to show / set content -->
	<div id="dbox" class="modal fade" tabindex="-1" role="dialog">
		<div class="modal-dialog mw-100 w-100">
		    <div class="modal-content">
				<div class="modal-header">
					<h5 id="dbox-title" class="modal-title"></h5>
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
				</div>
				<div class="modal-body">
					<div class="container-fluid">
						<div id="dbox-content" class="row">
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<nav class="navbar navbar-expand-lg navbar-light bg-light justify-content-between">
		<a class="navbar-brand" href="/">Photo Assistant</a>
		<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
			<span class="navbar-toggler-icon"></span>
		</button>
		<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
			<div class="navbar-nav mr-auto">
				<div class="nav-item dropdown">
					<a class="nav-item dropdown nav-link dropdown-toggle" href="#" id="FileMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Files</a>
					<div class="dropdown-menu" aria-labelledby="FileMenu">
						<a class="dropdown-item" href="{{url_for('files')}}">View</a>
						<a class="dropdown-item" href="{{url_for('file_list')}}">View Details</a>
					</div>
				</div class="nav-item dropdown">
				<div class="nav-item dropdown">
					<a class="nav-item dropdown nav-link dropdown-toggle" href="#" id="PersonMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Person</a>
					<div class="dropdown-menu" aria-labelledby="AIMenuPerson">
						<a class="dropdown-item" href="{{url_for('new_person')}}">Create Person</a>
						<a class="dropdown-item" href="{{url_for('persons')}}">Show People</a>
					</div>
				</div class="nav-item dropdown">
				<div class="nav-item dropdown">
					<a class="nav-item dropdown nav-link dropdown-toggle" href="#" id="RefMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Ref Image</a>
					<div class="dropdown-menu" aria-labelledby="AIMenu">
						<a class="dropdown-item" href="{{url_for('new_refimg')}}">Create Reference Image</a>
						<a class="dropdown-item" href="{{url_for('refimgs')}}">View Reference Images</a>
					</div>
				</div class="nav-item dropdown">
				<div class="nav-item dropdown">
					<a class="nav-item dropdown nav-link dropdown-toggle" href="#" id="AIMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">AI</a>
					<div class="dropdown-menu" aria-labelledby="AIMenu">
						<a class="dropdown-item" href="{{url_for('aistats')}}">View Stats</a>
					</div>
				</div class="nav-item dropdown">
				<div class="nav-item dropdown">
					<a class="nav-item dropdown nav-link dropdown-toggle" href="#" id="AdminMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Admin</a>
					<div class="dropdown-menu" aria-labelledby="AdminMenu">
						<a class="dropdown-item" href="{{url_for('settings')}}">Edit Settings</a>
						<a class="dropdown-item" href="{{url_for('scannow')}}">Scan now (for new files)</a>
						<a class="dropdown-item" href="{{url_for('forcescan')}}">Force Scan (delete data & rebuild)</a>
						<a class="dropdown-item" href="{{url_for('wakeup')}}">Force wake the job manage</a>
					</div class="dropdow-menu">
				</div class="nav-item dropdown">
                <div class="nav-item ml-5">
                    <a href="{{url_for('jobs')}}"}}<span class="navbar-text">Active Jobs: 
                    {% set num_active_jobs = GetNumActiveJobs() %}
                    {% if num_active_jobs > 0 %}
                        <span class="badge badge-danger text-white"}}>{{num_active_jobs}}</span>
                    {% else %}
                        <span class="badge">0</span>
                    {% endif %}
                    </a>
                </div class="nav-item">
			</div class="navbar-nav">

			<form class="form-inline my-2 my-lg-0" method="POST" onSubmit="SetViewingOptionsForSearchForm()" action="/search">
                <input type="hidden" id="search_noo" name="noo" value="">
                <input type="hidden" id="search_grouping" name="grouping" value="">
                <input type="hidden" id="search_how_many" name="how_many" value="">
                <input type="hidden" id="search_offset" name="offset" value="">
                <input type="hidden" id="search_size" name="size" value="">
				<input id="term" class="form-control mr-sm-2" type="search" placeholder="by file, date (YYYMMDD) or tag" aria-label="Search" name="term">
				<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
			</form>
		</div class="collapse navbar-collapse">
	</nav>
	
	{% if GetMessage()|length %}
		<div class="row alert alert-{{GetAlert()}}">
			{{ GetMessage()|safe}}
		    {{ ClearStatus() }}
		</div>
	{% endif %}
	{% if GetJM_Message() != None %}
		{% set msg=GetJM_Message() %}
        {% if request.endpoint != "fix_dups" and request.endpoint != "rm_dups" %}
            <div class="row alert alert-{{msg.alert}}">
                {% if msg.job_id %}
                    <a href="{{url_for('joblog', id=msg.job_id)}}">Job #{{msg.job_id}}</a>: 
                {% endif %}
                {{msg.message|safe}}
            </div>
            {# if a JM is a danger message, allow code to remove the status, it should be 'permanent' until addressed -- e.g. you have duplicates, fix them #}
            {% if msg.alert != "danger" %}
                {% set dont_print=ClearJM_Message(msg.id) %}
            {% endif %}
        {% endif %}
	{% endif %}
{% endif %}

	{% block main_content %}
	{% endblock main_content %}

{% if not InDBox %}
	<!-- code to get bootstrap & bootstrap datatable to work -->
	<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
	<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
	<script src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.min.js"></script>
	<script src="https://cdn.datatables.net/1.10.22/js/dataTables.bootstrap4.min.js"></script>
    <script>
        function SetViewingOptionsForSearchForm()
        {
            if( $('#noo').length )
                $('#search_noo').val( $('#noo').val() )
            else
                $('#search_noo').val("Oldest")

            if( $('#grouping').length )
                $('#search_grouping').val( $('#grouping').val() )
            else
                $('#search_grouping').val("Day")

            if( $('#how_many').length )
                $('#search_how_many').val( $('#how_many').val() )
            else
                $('#search_how_many').val("10")

            if( $('#offset').length )
                $('#search_offset').val( $('#offset').val() )
            else
                $('#search_offset').val(0)

            if( $('#size').length )
                $('#search_size').val( $('#size').val() )
            else
                $('#search_size').val(128)
        }
    </script>
	{%block script_content %}{% endblock script_content %}
	</body>
</html>
{% endif %}
