<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{{ agent.jid.local }} agent</title>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"
          integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"
          integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/admin-lte/2.4.2/css/AdminLTE.css"
          integrity="sha256-PVK9gAcsGOtzyQNV7pVrI3EiYYauwzOsXC/VjtwMXI4=" crossorigin="anonymous"/>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/admin-lte/2.4.2/css/adminlte.css.map">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css"
          integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/admin-lte/2.4.8/css/skins/_all-skins.css" />
    <link rel="stylesheet"
          href="https://cdnjs.cloudflare.com/ajax/libs/admin-lte/2.4.2/css/alt/AdminLTE-bootstrap-social.min.css"
          integrity="sha256-i0jvUu6F0mZkrmoxDnIbXMHzXk16eHsTwPcTxB2ua/Q=" crossorigin="anonymous"/>
</head>

<body class="sidebar-mini skin-blue" style="height: auto; min-height: 100%;">
<div class="wrapper" style="height: auto; min-height: 100%;">

    <header class="main-header">

        <!-- Logo -->
        <a href="/spade" class="logo">
            <!-- mini logo for sidebar mini 50x50 pixels -->
            <span class="logo-mini"><b>SPD</b></span>
            <!-- logo for regular state and mobile devices -->
            <span class="logo-lg"><b>SPADE</b></span>
        </a>

        <!-- Header Navbar -->
        <nav class="navbar navbar-static-top" role="navigation">
            <!-- Navbar Right Menu -->
            <div class="navbar-custom-menu">
                <ul class="nav navbar-nav">
                    <!-- Messages: style can be found in dropdown.less-->
                    <li class="dropdown messages-menu">
                        <!-- Menu toggle button -->
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            <i class="fa fa-envelope"></i>
                            <span class="label label-success">{{ agent.traces.received().__len__() }}</span>
                        </a>
                        <ul class="dropdown-menu">
                            <li class="header">You have {{ agent.traces.received().__len__() }} messages</li>
                            <li>
                                <!-- inner menu: contains the messages -->
                                <ul class="menu">
                                    {% for date, msg in messages %}
                                    <li>
                                        <!-- start message -->
                                        <a href="#">
                                            <!-- Message title -->
                                            <h4>
                                                <p>{{ msg.sender }}</p>
                                            </h4>
                                            <div class="pull-left">
                                                <!-- User Image -->
                                                <img src="{{ agent.build_avatar_url(msg.sender) }}" class="img-circle" alt="User Image">
                                            </div>
                                            <!-- The message -->
                                            <p>{% filter escape %}{{ msg.body }}{% endfilter %}</p>
                                            <p><small class="pull-right">
                                                <i class="fa fa-clock-o"></i> {{ date }}
                                                </small>
                                            </p>
                                        </a>
                                    </li>
                                    {% endfor %}
                                    <!-- end message -->
                                </ul>
                                <!-- /.menu -->
                            </li>
                            <li class="footer"><a href="/spade/messages/">See All Messages</a></li>
                        </ul>
                    </li>
                    <!-- /.messages-menu -->

                    <!-- User Account Menu -->
                    <li class="dropdown user user-menu">
                        <!-- Menu Toggle Button -->
                        <a href="/spade" class="dropdown-toggle" data-toggle="dropdown">
                            <!-- The user image in the navbar-->
                            <img src="{{ agent.avatar }}" class="user-image" alt="User Image">
                            <!-- hidden-xs hides the username on small devices so only the image appears. -->
                            <span class="hidden-xs">{{ agent.jid.localpart }}</span>
                        </a>
                        <ul class="dropdown-menu">
                            <!-- The user image in the menu -->
                            <li class="user-header">
                                <img src="{{ agent.avatar }}" class="img-circle" alt="User Image">

                                <p>
                                    {{ agent.jid }}
                                </p>
                            </li>

                            <!-- Menu Footer-->
                            <li class="user-footer">
                                <div class="pull-left">
                                    <a href="/spade/stop" class="btn btn-default btn-flat">Stop</a>
                                </div>
                                {# <div class="pull-right">
                                    <a href="#" class="btn btn-default btn-flat">Logout</a>
                                </div>#}
                            </li>
                        </ul>
                    </li>
                </ul>
            </div>
        </nav>
    </header>

    <!-- Left side column. contains the logo and sidebar -->
    <aside class="main-sidebar">

        <!-- sidebar: style can be found in sidebar.less -->
        <section class="sidebar">

            <!-- Sidebar user panel (optional) -->
            <div class="user-panel">
                <div class="pull-left image">
                    <img src="{{ agent.avatar }}" class="img-circle" alt="User Image">
                </div>
                <div class="pull-left info">
                    <p>{{ agent.jid.localpart }}</p>
                    <!-- Status -->
                    <a href="/spade"><i class="fa fa-circle text-success"></i> Online</a>
                </div>
            </div>


            <!-- Sidebar Menu -->
            <ul class="sidebar-menu" data-widget="tree">
                <!-- Optionally, you can add icons to the links -->
                {%  if active == "/spade" %}
                <li class="active">
                {% else %}
                <li>
                {% endif %}
                    <a href="/spade"><i class="fa fa-id-card"></i> <span>Dashboard</span></a></li>
                {% for name, entry in menu.items() %}
                    {%  if active == entry.0 %}
                    <li class="active">
                    {% else %}
                    <li>
                    {% endif %}
                        <a href="{{ entry.0 }}"><i class="{{ entry.1 }}"></i> <span>{{ name }}</span></a></li>
                {% endfor %}
            </ul>
            <!-- /.sidebar-menu -->
        </section>
        <!-- /.sidebar -->
    </aside>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper" style="min-height: 960px;">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                {% block content_title %}Dashboard{% endblock %}
            </h1>
            <ol class="breadcrumb">
                <li><a href="/spade"><i class="fa fa-dashboard"></i> Home</a></li>
                <li class="active">Dashboard</li>
            </ol>
        </section>
        {% if stopping %}
        <div class="col-md-12">
            <div class="box-body">
                <div class="alert alert-warning alert-dismissible">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    <h4><i class="icon fa fa-warning"></i> Alert!</h4>
                    <span>Agent is stopping now.</span>
                </div>
            </div>
        </div>
        <script type="application/javascript">
            var xhr = new XMLHttpRequest();
            xhr.open("GET", "/spade/stop/now/", true);
            xhr.send(null);
        </script>
        {% endif %}

        <!-- Main content -->
        {% block content %}
        <section class="content">
            <!-- Info boxes -->
            <!-- Main row -->
            <div class="row">

                <div class="col-md-4">

                    <!-- BEHAVIOURS LIST -->
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">Active Behaviours</h3>

                            <div class="box-tools pull-right">
                                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
                                        class="fa fa-minus"></i>
                                </button>
                            </div>
                        </div>
                        <!-- /.box-header -->
                        <div class="box-body">
                            <ul class="products-list product-list-in-box">
                                {% for behaviour in behaviours %}
                                    <li class="item">
                                        <div class="product-info">
                                            <a href="/spade/behaviour/{{behaviour}}/" class="product-title">{{ behaviour }}
                                            </a>
                                            <a href="/spade/behaviour/{{behaviour}}/kill/">
                                                <button type="button" class="btn btn-danger pull-right">Kill</button>
                                            </a>
                                            <span class="product-description">{{ behaviour.template }}</span>
                                        </div>
                                    </li>
                                {% endfor %}
                                <!-- /.item -->
                            </ul>
                        </div>
                        <!-- /.box-body -->
                    </div>
                    <!-- /.box -->
                </div>
                <!-- /.col -->
            <div class="col-md-6">
              <!-- USERS LIST -->
              <div class="box box-danger">
                <div class="box-header with-border">
                  <h3 class="box-title">Agent Friends</h3>

                  <div class="box-tools pull-right">
                    <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
                    </button>
                  </div>
                </div>
                <!-- /.box-header -->
                <div class="box-body no-padding">
                  <ul class="users-list clearfix">
                    <li>
                      <img src="http://www.gravatar.com/avatar/f1e36eae186f3313740ef11f6f3051b1?d=monsterid" alt="User Image">
                      <a class="users-list-name" href="#">Alexander Pierce</a>
                      <span class="users-list-date">Today</span>
                    </li>
                    <li>
                      <img src="http://www.gravatar.com/avatar/f1e36eae186f3313740ef11f6f3051b2?d=monsterid" alt="User Image">
                      <a class="users-list-name" href="#">Norman</a>
                      <span class="users-list-date">Yesterday</span>
                    </li>
                    <li>
                      <img src="http://www.gravatar.com/avatar/f1e36eae186f3313740ef11f6f3051b4?d=monsterid" alt="User Image">
                      <a class="users-list-name" href="#">Jane</a>
                      <span class="users-list-date">12 Jan</span>
                    </li>
                    <li>
                      <img src="http://www.gravatar.com/avatar/f1e36eae186f3313740ef11f6f3051b5?d=monsterid" alt="User Image">
                      <a class="users-list-name" href="#">John</a>
                      <span class="users-list-date">12 Jan</span>
                    </li>
                    <li>
                      <img src="http://www.gravatar.com/avatar/f1e36eae186f3313740ef11f6f3051b6?d=monsterid" alt="User Image">
                      <a class="users-list-name" href="#">Alexander</a>
                      <span class="users-list-date">13 Jan</span>
                    </li>
                    <li>
                      <img src="http://www.gravatar.com/avatar/f1e36eae186f3313740ef11f6f3051b7?d=monsterid" alt="User Image">
                      <a class="users-list-name" href="#">Sarah</a>
                      <span class="users-list-date">14 Jan</span>
                    </li>
                    <li>
                      <img src="http://www.gravatar.com/avatar/f1e36eae186f3313740ef11f6f3051b8?d=monsterid" alt="User Image">
                      <a class="users-list-name" href="#">Nora</a>
                      <span class="users-list-date">15 Jan</span>
                    </li>
                    <li>
                      <img src="http://www.gravatar.com/avatar/f1e36eae186f3313740ef11f6f3051b9?d=monsterid" alt="User Image">
                      <a class="users-list-name" href="#">Nadia</a>
                      <span class="users-list-date">15 Jan</span>
                    </li>
                  </ul>
                  <!-- /.users-list -->
                </div>
                <!-- /.box-body -->
                <div class="box-footer text-center">
                  <a href="javascript:void(0)" class="uppercase">View All Users</a>
                </div>
                <!-- /.box-footer -->
              </div>
              <!--/.box -->
            </div>
            </div>
            <!-- /.row -->
        </section>
        {% endblock %}
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->

    <footer class="main-footer">
        <div class="pull-right hidden-xs">
            <b>Version</b> 4.0.0rc2
        </div>
        <strong>Copyright © {% now 'local', '%Y' %} <a href="http://github.com/javipalanca/spade">SPADE</a>.</strong>
    </footer>


</div>
<!-- ./wrapper -->

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
        integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
        crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/admin-lte/2.4.2/js/adminlte.min.js"
        integrity="sha256-M/+/xbAPBtc0W7JWnReOYF+oPZq4OiOUrlP9qbv7w64=" crossorigin="anonymous"></script>
</body>
</html>
