<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#topNavbar" aria-controls="topNavbar" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

    <a class="navbar-brand" href="/"><img src="{{$.Static.WebsiteLogo}}" alt="{{$.Static.CompanyName}}"/></a>
    <div id="topNavbar" class="navbar-collapse collapse">
        <ul class="navbar-nav mr-auto mt-2 mt-lg-0">
            <li class="nav-spacer"></li>
            {{with eq $.Session.LoggedIn true}}{{with eq $.Session.IsAdmin true}}
            {{with eq $.Route "/admin/"}}
            <form class="form-inline my-2 my-lg-0" method="get">
                <input class="form-control mr-sm-2" name="search" type="search" placeholder="Search" aria-label="Search" value="{{index $.Session.Search "peers"}}">
                <button class="btn btn-outline-success my-2 my-sm-0" type="submit"><i class="fa fa-search"></i></button>
            </form>
            {{end}}
            {{with eq $.Route "/admin/users/"}}
            <form class="form-inline my-2 my-lg-0" method="get">
                <input class="form-control mr-sm-2" name="search" type="search" placeholder="Search" aria-label="Search" value="{{index $.Session.Search "users"}}">
                <button class="btn btn-outline-success my-2 my-sm-0" type="submit"><i class="fa fa-search"></i></button>
            </form>
            {{end}}
            {{end}}{{end}}
        </ul>
        {{with eq $.Session.LoggedIn true}}{{with eq $.Session.IsAdmin true}}
        {{with startsWith $.Route "/admin/"}}
        <form class="form-inline my-2 my-lg-0" method="get">
            <div class="form-group mr-sm-2">
                <select name="device" id="inputDevice" class="form-control device-selector">
                    {{range $d, $dn := $.DeviceNames}}
                    <option value="{{$d}}" {{if eq $d $.Session.DeviceName}}selected{{end}}>{{$d}} {{if and (ne $dn "") (ne $d $dn)}}({{$dn}}){{end}}</option>
                    {{end}}
                </select>
            </div>
        </form>
        {{end}}
        {{end}}{{end}}
        {{if eq $.Session.LoggedIn true}}
            <div class="nav-item dropdown">
                <a href="#" class="navbar-text dropdown-toggle" data-toggle="dropdown">{{$.Session.Firstname}} {{$.Session.Lastname}} <span class="caret"></span></a>
                <div class="dropdown-menu">
                    {{with eq $.Session.LoggedIn true}}{{with eq $.Session.IsAdmin true}}
                        <a class="dropdown-item" href="/admin/"><i class="fas fa-cogs"></i> Administration</a>
                        <a class="dropdown-item" href="/admin/users/"><i class="fas fa-users-cog"></i> User Management</a>
                        <div class="dropdown-divider"></div>
                    {{end}}{{end}}
                    <a class="dropdown-item" href="/user/profile"><i class="fas fa-user"></i> Profile</a>
                    <div class="dropdown-divider"></div>
                    <a class="dropdown-item" href="/auth/logout"><i class="fas fa-sign-out-alt"></i> Logout</a>
                </div>
            </div>
        {{else}}
            <a href="/auth/login" class="navbar-text"><i class="fas fa-sign-in-alt fa-sm fa-fw mr-2 text-gray-400"></i> Login</a></li>
        {{end}}
    </div><!--/.navbar-collapse -->
</nav>
{{if not $.Device.IsValid}}
<div class="container">
    <div class="alert alert-danger">Warning: WireGuard Interface {{$.Device.DeviceName}} is not fully configured! Configurations may be incomplete and non functional!</div>
</div>
{{end}}