{% extends "base.html" %}

{% import "bootstrap/wtf.html" as wtf %}
{% import "bootstrap/fixes.html" as fixes %}
{% import "bootstrap/utils.html" as util %}

{% block title %}BEL Commons{% endblock %}

{% block scripts %}
    {{ super() }}
    {% if current_user.is_authenticated and current_user.is_admin %}
        <script src="{{ url_for('static', filename='js/bootstrap-confirmation.min.js') }}"></script>
        <script>
            $('[data-toggle=confirmation]').confirmation({
                rootSelector: '[data-toggle=confirmation]'
                // other options
            });
        </script>
    {% endif %}
    <script>
        $(function () {
            $('[data-toggle="tooltip"]').tooltip()
        })
    </script>
{% endblock %}

{% block content %}
    <div class="container" style="margin-top: 50px">
        {{ util.flashed_messages(dismissible=True, container=False) }}

        {% if current_user.is_authenticated and current_user.is_admin %}
            <div class="panel panel-info" id="admin-panel">
                <div class="panel-heading">
                    <h3 class="panel-title">Admin
                        <button type="button" class="close" data-target="#admin-panel" data-dismiss="alert">
                            <span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
                        </button>
                    </h3>
                </div>
                <div class="panel-body">
                    <a class="btn btn-info" href="{{ url_for('admin.index') }}" role="button">
                        Flask Admin
                    </a>
                    <a class="btn btn-info" href="{{ url_for('ui.view_overview') }}" role="button">
                        Overview
                    </a>
                    <a class="btn btn-info" href="{{ url_for('ui.view_config') }}" role="button">
                        Configuration
                    </a>
                    <a class="btn btn-info" href="{{ url_for('ui.view_users') }}" role="button">
                        View Users
                    </a>
                    <a class="btn btn-info" href="{{ url_for('reporting.view_networks') }}" role="button">
                        View Pretty Reporting
                    </a>
                    <a class="btn btn-warning" href="{{ url_for('ui.rollback', next=url_for('ui.home')) }}"
                       role="button"
                       data-toggle="confirmation" data-btn-ok-icon="glyphicon glyphicon-share-alt"
                       data-btn-ok-class="btn-success" data-btn-cancel-icon="glyphicon glyphicon-ban-circle"
                       data-btn-cancel-class="btn-danger">
                        Rollback
                    </a>
                    <a class="btn btn-danger" href="{{ url_for('ui.nuke', next=url_for('ui.home')) }}" role="button"
                       data-toggle="confirmation" data-btn-ok-icon="glyphicon glyphicon-share-alt"
                       data-btn-ok-class="btn-success" data-btn-cancel-icon="glyphicon glyphicon-ban-circle"
                       data-btn-cancel-class="btn-danger">
                        Nuke Database
                    </a>
                    <a class="btn btn-primary" href="{{ url_for('ui.debug_celery') }}">
                        Debug Celery
                    </a>
                </div>
            </div>
        {% endif %}

        {% if current_user.is_authenticated and current_user.is_admin %}
            <div class="panel panel-default">
                <div class="panel-body">
                    <div class="btn-group">
                        {% for histogram_name, histogram_count, histogram_url in database_histogram %}
                            {% if histogram_url is not none %}
                                <a href="{{ histogram_url }}" class="btn btn-default btn-sm">
                                    {{ histogram_name }} <span class="badge">{{ histogram_count }}</span>
                                </a>
                            {% else %}
                                <span class="btn btn-default btn-sm">
                                {{ histogram_name }} <span class="badge">{{ histogram_count }}</span>
                                </span>
                            {% endif %}
                        {% endfor %}
                    </div>
                </div>
            </div>
        {% endif %}

        <div class="jumbotron">
            <div class="row">
                <img alt="BEL Commons Logo" width="150" style="float: left; margin-right:25px;"
                     src="{{ url_for('static', filename='img/BELcommons-square-1024.png') }}">
                <h1>BEL Commons <span style="color: red">3.0 Preview</span></h1>
                <p>
                    An environment for <strong>curating</strong>, <strong>validating</strong>, and
                    <strong>exploring</strong> knowledge assemblies encoded in Biological Expression Language
                    (BEL) to support <strong>elucidating</strong> disease-specific, mechanistic insight.
                </p>

                <small>
                    Running on PyBEL v{{ pybel_version }}, PyBEL-Tools v{{ tools_version }},
                    Bio2BEL v{{ bio2bel_version }}, and BEL-Commons v{{ bel_commons_version }}.
                </small>
            </div>
        </div>

        <div class="panel panel-default">
            <div class="panel-body">
                <div class="row">
                    {% if 'parser' in blueprints %}
                        <div class="col-lg-4 col-md-4 col-sm-4">
                            <h3>Upload</h3>
                            <p>
                                Parse BEL script, validate its contents, perform automatic enrichment, and
                                generate a network summary.
                            </p>
                            <p>
                                <a href="{{ url_for('parser.view_parser') }}" class="btn btn-primary btn-block">
                                    Upload BEL
                                </a>
                            </p>
                        </div>
                    {% endif %}

                    <div class="col-lg-4 col-md-4 col-sm-4">
                        <h3>Catalog</h3>
                        <p>
                            View summaries and statistics over curated networks and as a first step towards
                            exploration{% if 'analysis' in blueprints %}, visualization, and
                            <a href="{{ url_for('analysis.view_experiments') }}">analysis.</a>{% else %}
                            and visualization.{% endif %}
                        </p>
                        <p>
                            <a href="{{ url_for('ui.view_networks') }}" class="btn btn-primary btn-block">
                                Network Catalog
                            </a>
                        </p>
                    </div>

                    <div class="col-lg-4 col-md-4 col-sm-4">
                        <h3>Query</h3>
                        <p>
                            Build a network by investigating the knowledge related to interesting biological
                            entities, chemical matter, authors, or publications.
                        </p>
                        <p>
                            <a href="{{ url_for('ui.view_query_builder') }}"
                               class="btn btn-primary btn-block" role="button">Build Query</a>
                        </p>
                    </div>

                    {% if 'curation' in blueprints %}
                        <div class="col-lg-4 col-md-4 col-sm-4">
                            <h3>Curate</h3>
                            <p>
                                Tools for generating BEL script stubs, merging BEL namespace files, or curation feedback
                                on BEL namespace files.
                            </p>
                            <div class="btn-group">
                                <a href="{{ url_for('curation.get_boilerplate') }}" class="btn btn-primary"
                                   role="button" data-toggle="tooltip" data-placement="top"
                                   title="Generate a template BEL script given an optional list of PubMed identifiers or Entrez Gene identifiers">
                                    Generate
                                </a>
                                <a href="{{ url_for('curation.merge_namespaces') }}" class="btn btn-primary"
                                   role="button" data-toggle="tooltip" data-placement="top"
                                   title="Merge multiple BEL Namespace (BELNS) files">
                                    Merge
                                </a>
                                <a href="{{ url_for('curation.validate_resource') }}" class="btn btn-primary"
                                   role="button" data-toggle="tooltip" data-placement="top"
                                   title="Validate a manually curated BEL Namespace or Annotation with the EBI Ontology Lookup Service">
                                    Validate
                                </a>

                                {% if current_user.is_authenticated and current_user.is_admin %}
                                    <a href="{{ url_for('curation.view_curation_interface') }}"
                                       class="btn btn-warning">
                                        Curate
                                    </a>
                                {% endif %}
                            </div>
                        </div>
                    {% endif %}

                    <div class="col-lg-4 col-md-4 col-sm-4">
                        <h3>Terminologies</h3>
                        <p>
                            View the underlying namespaces and annotations along with their respective uniform resource
                            locators and version numbers.
                        </p>
                        <a href="{{ url_for('ui.view_namespaces') }}" class="btn btn-primary btn-block">
                            Resources <span class="badge">{{ manager.count_namespaces() }}</span>
                        </a>
                    </div>

                    {% if 'curation' in blueprints or 'parser' in blueprints %}
                        <div class="col-lg-4 col-md-4 col-sm-4">
                            <h3>Future Work</h3>
                            <p>
                                PyBEL is in constant development. Join us on the <a
                                    href="https://github.com/pybel/pybel">core</a>, <a
                                    href="https://github.com/pybel/pybel-tools">analytical tools</a>, or <a
                                    href="https://github.com/pybel/pybel-notebooks">notebooks</a> repositories for
                                upcoming code, protocols, and pipelines and additional entries in
                                <a href="https://github.com/bio2bel">Bio2BEL</a>.
                            </p>
                        </div>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>

    {% include "footer.html" %}
{% endblock %}
