{% extends "base.html" %}
{% load i18n %}
{% load translations %}
{% load url from future %}

{% block content %}

{% if not user.is_authenticated %}
<p class="alert alert-info">
{% if demo_server %}
{% blocktrans %}This site runs <a href="{{ weblate_url }}">Weblate</a> demo server.{% endblocktrans %}
{% else %}
{% blocktrans %}This site runs <a href="{{ weblate_url }}">Weblate</a> for translating the software projects listed below.{% endblocktrans %}
{% endif %}
{% trans "You need to be logged in for translating, otherwise you can only make suggestions." %}
</p>
{% endif %}

{% if whiteboard_enabled %}
{% for msg in whiteboard_messages %}
{% show_message 'info whiteboard' msg.message %}
{% endfor %}
{% endif %}

<ul class="nav nav-pills">
{% if user.is_authenticated %}
<li class="active"><a href="#your" data-toggle="tab">{% trans "Your translations" %}</a></li>
<li><a href="#projects" data-toggle="tab">{% trans "Projects" %}</a></li>
{% else %}
<li class="active"><a href="#projects" data-toggle="tab">{% trans "Projects" %}</a></li>
{% endif %}
<li><a href="#search" data-toggle="tab">{% trans "Search" %}</a></li>
<li><a href="#history" data-toggle="tab">{% trans "History" %}</a></li>
<li><a href="#activity" data-toggle="tab" data-href="{% url 'view_activity' %}">{% trans "Activity" %}</a></li>
<li><a href="#stats" data-toggle="tab">{% trans "Statistics" %}</a></li>
<li class="dropdown">
  <a class="dropdown-toggle" data-toggle="dropdown" href="#">
    {% trans "Tools" %} <span class="caret"></span>
  </a>
  <ul class="dropdown-menu">
    <li><a href="{% url 'languages' %}">{% trans "Languages summary" %}</a></li>
    <li><a href="{% url 'checks' %}">{% trans "Checks overview" %}</a></li>
    <li><a href="{% url 'data_root' %}">{% trans "Data export" %}</a></li>
    <li><a href="{% url 'widgets_root' %}">{% trans "Widgets" %}</a></li>
  </ul>
</li>
</ul>

<div class="tab-content">
{% if user.is_authenticated %}
<div class="tab-pane active" id="your">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Your translations" %}</h4></div>
  <div class="panel-body">
{% if usertranslations %}
{% with usertranslations as translations and 2 as show_language %}
{% include "list-translations.html" %}
{% endwith %}
{% else %}
<p class="help-block">{% trans "Choose your languages in preferences and you will get an overview here of available translations for those languages." %}</p>
{% endif %}
  </div>
  <div class="panel-footer">
  <a class="btn btn-default" href="{% url 'profile' %}#preferences">{% trans "Manage your translations" %}</a>
  </div>
</div>
</div>
<div class="tab-pane" id="projects">
{% else %}
<div class="tab-pane active" id="projects">
{% endif %}

<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Projects" %}</h4></div>
  <div class="panel-body">
<table class="sort table">
<thead>
<tr>
<th>{% trans "Project" %}</th>
<th colspan="2">{% trans "Translated" %}</th>
</tr>
<tbody>
{% for prj in projects %}
{% with prj.get_translated_percent as percent and prj.get_fuzzy_percent as fuzzy and prj.get_failing_checks_percent as check_percent %}
<tr>
<th><a href="{{ prj.get_absolute_url }}">{{ prj }}</a></th>
<td class="progress-cell">{% translation_progress prj %}</td>
<td class="percent">{{ percent }}%</td>
</tr>
{% endwith %}
{% endfor %}
</tbody>
</table>

{% include "legend.html" %}

  </div>
{% if offer_hosting %}
  <div class="panel-footer">
  <a class="btn btn-default" href="{% url 'hosting' %}">{% trans "Ask for project hosting" %}</a>
  </div>
{% endif %}
</div>
</div>

<div class="tab-pane" id="search">

{% include "search-form.html" %}

</div>

<div class="tab-pane" id="activity">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Activity" %}</h4></div>
<div class="panel-body">
<p>{% trans "Loading…" %}</p>
</div>

</div>
</div>

<div class="tab-pane" id="stats">
<div class="row">
<div class="col-lg-6">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Most active translators" %}</h4></div>
<div class="panel-body">
<table class="table table-condensed">
<thead>
<tr>
<th>{% trans "User" %}</th>
<th>{% trans "Translated" %}</th>
</tr>
<tbody>
{% for u in top_translations %}
<tr>
<td>{{ u.get_user_display_link }}</td>
<td class="percent">{{ u.translated }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>


<div class="col-lg-6">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Most active suggesters" %}</h4></div>
<div class="panel-body">
<table class="table table-condensed">
<thead>
<tr>
<th>{% trans "User" %}</th>
<th>{% trans "Suggested" %}</th>
</tr>
<tbody>
{% for u in top_suggestions %}
<tr>
<td>{{ u.get_user_display_link }}</td>
<td class="percent">{{ u.suggested }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>

</div>
</div>

<div class="tab-pane" id="history">
{% include "last-changes.html" %}
</div>

</div>

{% endblock %}
