{% extends "base.html" %}

{% block title %}Instruments — {{ service_name }}{% endblock %}

{% block content %}
  <h1>Instruments</h1>
  <p class="text-muted">Instruments in {{ service_name }} map real instruments to <a href="{{ url_for('.actions') }}">actions</a> performed with them. <a href="https://scientific-it-systems.iffgit.fz-juelich.de/SampleDB/user_guide/instruments.html">Read more.</a></p>
  {% if current_user.is_admin and not current_user.is_readonly %}
    <a href="{{ url_for('.new_instrument') }}" class="btn btn-default">Create Instrument</a>
  {% endif %}
  {% for instrument in instruments %}
    <form action="{{ url_for('.toggle_favorite_instrument') }}" method="post">
    <input type="hidden" name="instrument_id" value="{{ instrument.id }}">
    {{ toggle_favorite_instrument_form.csrf_token() }}
    <h2>
      <a href="{{ url_for('.instrument', instrument_id=instrument.id) }}" title="{{ instrument.name }}">{{ instrument.name }}</a>
      <button type="submit" class="fa {% if instrument.id in user_favorite_instrument_ids %}fav-star-on{% else %}fav-star-off{% endif %}" value=""></button>
    </h2>
    </form>
    {% if instrument.is_hidden %}
    <p class="text-muted"><i class="fa fa-eye-slash" aria-hidden="true"></i> This instrument has been hidden from instrument lists.</p>
    {% endif %}
    {% if instrument.description_as_html or instrument.description %}
    <div class="instrument-user-content">
    {% if instrument.description_as_html %}{{ instrument.description_as_html | safe }}{% else %}<p>{{ instrument.description }}</p>{% endif %}
    </div>
    {% endif %}
    {% include "instruments/instrument_scientists.html" %}
  {% endfor %}
{% endblock %}

{% block scripts %}
  {{ super() }}
  <script src="{{ url_for('static', filename='js/markdown_image_viewer.js') }}"></script>
{% endblock %}
