{% extends "base.html" %}

{% block dojango_content %}
<script type="text/javascript">
    require([
        "dojo/ready",
	"dijit/registry",
        "dojo/parser",
        "dojo/fx/easing",
        "dijit/_base/manager",
	"dijit/form/TextBox",
        "dijit/layout/BorderContainer",
        "dijit/layout/ContentPane",
        "dijit/layout/TabContainer",
        "dijit/Dialog",
        "dijit/MenuBar",
        "dijit/MenuBarItem"
        ], function(ready, registry) {
        ready(function() {
              registry.byId("login").show();
        });
    });
</script>
<!-- THIS IS A LOGIN WEBPAGE -->
<div data-dojo-type="dijit.layout.TabContainer" style="width:100%;" data-dojo-props="doLayout: false, region: 'center'">
{% if form.errors %}
<script type="dojo/method">
require(["dojo/_base/fx", "dojo/dom", "dojo/fx/easing", "dojo/_base/html", "dojo/ready", "dojo/domReady!"], function(fx, dom, easing, html, ready) {

    ready(function() {
        var easingArea = dom.byId("login");
        var easingCoords = html.coords(easingArea);
        fx.animateProperty({
            node: dom.byId("login"),
            duration: 1000,
	    easing: easing.elasticInOut,
            properties: {
                left: easingCoords.x-5,
                top: easingCoords.y-5
            }
        }).play();
    });
});
</script>
<p>{% trans "Your username and password didn't match. Please try again." %}</p>
{% endif %}

{% if user.is_authenticated %}
<p>{% blocktrans with user.username as username %}Welcome, {{ username }}. Thanks for logging in.{% endblocktrans %}</p>
{% else %}
<div id="login" data-dojo-type="dijit.Dialog" data-dojo-props="title: '{% blocktrans with sw_login_version=sw_login_version sw_name=sw_name %}Welcome to {{ sw_name }}&reg; {{ sw_login_version }}{% endblocktrans %}'" style="max-width: 400px;">
<form action="." method="post">{% csrf_token %}
{% if reset_password %}
<p>{% trans "The web admin user has been removed in this release in order to unify the web and Unix authentication mechanisms." %}</p>
<p>{% trans "Administrators should log in to the web UI as root, since the web UI already confers superuser privileges in many areas." %}</p>

<p>{% trans "For security reasons, you must now set a new root password:" %}</p>
{% endif %}
<table>
 {{ form }}
</table>
<button data-dojo-type="dijit.form.Button" type="submit" data-dojo-props="type:'submit'">{% trans "Log In" %}</button>
<input type="hidden" name="next" value="{{ next }}" />
</form>
    </div>
{% endif %}
</div>
{% endblock %}
