{% load i18n %}
{% load promgen %}

<div class="panel panel-primary">
  <div class="panel-heading">Configuration</div>
  <div class="panel-body">
    <div class="btn-group btn-group-sm" role="group" aria-label="...">
      <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        {% trans "Register" %} <span class="caret"></span>
      </button>
      <ul class="dropdown-menu">
        <li role="presentation"><a href="{% url 'project-exporter' project.id %}">{% trans "Register Exporter" %}</a></li>
        <li role="presentation"><a href="{% url 'rule-new' 'project' project.id %}">{% trans "Register Rule" %}</a></li>
        <li role="presentation"><a href="{% url 'project-notifier' project.id %}">{% trans "Register Notifier" %}</a></li>
      </ul>
    </div>

    <form action="{% url 'project-notifier' project.id %}" style="display:inline" method="post">{% csrf_token %}
      <input type="hidden" name="sender" value="promgen.notification.user">
      <input type="hidden" name="value" value="{{request.user.username}}" />
      <button class="btn btn-primary btn-sm">{% trans "Subscribe to Notifications" %}</button>
    </form>

    <div class="btn-group btn-group-sm" role="group" aria-label="...">
      <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        {% trans "Change History" %} <span class="caret"></span>
      </button>
      <ul class="dropdown-menu">
        <li role="presentation"><a href="{% urlqs 'audit-list' project=project.id  %}">{% trans "Edit History" %}</a></li>
        <li role="presentation"><a href="{% urlqs 'alert-list' project=project.name %}">{% trans "Alert History" %}</a></li>
      </ul>
    </div>

    <a href="{% url 'project-update' project.id %}" class="btn btn-warning btn-sm">{% trans "Update Project" %}</a>
    <a @click="setSilenceDataset" class="btn btn-warning btn-sm" data-project="{{project.name}}" data-service="{{project.service.name}}">{% trans "Silence" %}</a>

    <div class="btn-group btn-group-sm" role="group" aria-label="...">
      <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        Export <span class="caret"></span>
      </button>
      <ul class="dropdown-menu">
        <li role="presentation"><a href="{% url 'api:project-rules' name=project.name %}">{% trans "Export Rules" %}</a></li>
        <li role="presentation"><a href="{% url 'api:project-targets' name=project.name %}">{% trans "Export Project" %}</a></li>
      </ul>
    </div>

    <form method="post" action="{% url 'project-delete' project.id %}" onsubmit="return confirm('{% trans " Delete this Project?" %}')" style="display: inline">
      {% csrf_token %}
      <button class="btn btn-danger btn-sm pull-right">{% trans "Delete Project" %}</button>
    </form>
  </div>

  {% if project.description %}

  <div class="panel-body">
    {{project.description|linebreaksbr|urlize}}
  </div>

  {% endif %}

  <div class="panel-footer">
    Datasource: <a href="{{project.shard.get_absolute_url}}">{{project.shard.name}}</a>
    ( <a href="{{project.shard.url}}">{{project.shard.url}}</a> )
  </div>
</div>
