view farol/templates/base.j2 @ 140:3a56d5501ffa

Add HTTP error handling
author Benoît Allard <benoit.allard@greenbone.net>
date Mon, 27 Oct 2014 16:46:18 +0100
parents 67c4b299736e
children 3500cb0c54d1
line wrap: on
line source
{#
# Description:
# Web Template used in Farol Design
#
# Authors:
# BenoƮt Allard <benoit.allard@greenbone.net>
#
# Copyright:
# Copyright (C) 2014 Greenbone Networks GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#}

{% extends "layout.j2" %}

{% from "macros.j2" import modal, POST_button -%}

{% block navbar %}
  {% if has_current %}
    <li{% if active == 'document' %} class="active"{% endif %}><a href="{{ url_for('document.view') }}">Document</a></li>
  {% endif %}
  {% if products %}
    <li class="dropdown{{ ' active' if active == 'product' }}">
      <a href="#" class="dropdown-toggle" data-toggle="dropdown">Products <span class="caret"></span></a>
      <ul class="dropdown-menu" role="menu">
        <li role="presentation">
          <a role="menuitem" tabindex="-1" href="{{ url_for('producttree.view') }}">View Product Tree</a>
        </li>
        <li role="presentation" class="divider"></li>
        {% for name, productid in products | sort %}
          <li><a href="{{ url_for('producttree.view_product', productid=productid) }}">{{ name }}</a></li>
        {% endfor %}
      </ul>
    </li>
  {% endif %}
  {% if vulnerabilities %}
    <li class="dropdown{{ ' active' if active == 'vulnerability' }}">
      <a href="#" class="dropdown-toggle" data-toggle="dropdown">Vulnerabilities <span class="caret"></span></a>
      <ul class="dropdown-menu" role="menu">
        {% for name, ord in vulnerabilities %}
          <li><a href="{{ url_for('vulnerability.view', ordinal=ord) }}">{{ name }}</a></li>
        {% endfor %}
      </ul>
    </li>
  {% endif %}
  {% if has_current %}
    <li>
      {% if error %}
        <p class="navbar-text">Document is <a id="error-popover" href="#" tabindex="0" class="navbar-link" data-toggle="popover" data-trigger="focus" data-placement="bottom" title="First Error:" data-content="{{ error }}"><strong>invalid</strong></a> <span class="badge progress-bar-danger"><strong>&#x2717;</strong></span></p>
      {% else %}
        <p class="navbar-text">Document looks valid <span class="badge progress-bar-success"><strong>&#x2713;</strong></span></p>
      {% endif %}
    </li>
  {% endif %}
{% endblock %}

{% block navbar_right %}
  {% if has_current %}
    <li class="dropdown{{ ' active' if active == 'render' }}">
      <a href="#" class="dropdown-toggle" data-toggle="dropdown">Export <span class="caret"></span></a>
      <ul class="dropdown-menu" role="menu">
        {% for format in ('cvrf', 'nasl', 'oval') %}<li><a href="{{ url_for('render', format_=format)}}">as {{ format | upper }}</a></li>{% endfor %}
      </ul>
    </li>
  {% endif %}
  {% if caching %}
    <li class="dropdown">
      <a href="#" class="dropdown-toggle" data-toggle="dropdown">Cache <span class="caret"></span></a>
      <ul class="dropdown-menu" role="menu">
        <li role="presentation"{{ ' class="disabled"' if not has_current }}>
          <a role="menuitem" tabindex="-1" href="{{ url_for('cache.save') }}">Save {{ current_id }}</a>
        </li>
        <li role="presentation" class="divider"></li>
        {% for element in cache | sort %}
          <li role="presentation">
            {% if has_current %}
              <a href="#{{element}}_modal" data-toggle="modal">Load {{ element }}</a>
            {% else %}
              {% call(selector) POST_button(url_for('cache.load', element=element), out=True) %}
                <a role="menuitem" href="#" onclick="{{ selector }}.submit();return false;">Load {{ element }}</a>
              {% endcall %}
            {% endif %}
          </li>
        {% endfor %}
      </ul>
    </li>
  {% endif %}
{% endblock %}

{% block pre_content %}
  {% if has_current %}
    {% for element in cache %}
      {# Put the modals for the load action here #}
      {% call modal(element + '_modal', 'Load %s from cache' % element) %}
        <p>You asked to load <strong>{{ element }}</strong>, your changes to <strong>{{ current_id }}</strong> will be lost.</p>
        <p>Do you want to save <strong>{{ current_id }}</strong> first ?</p>
      </div>
      <div class="modal-footer">
        <a href="{{ url_for('cache.save') }}" class="btn btn-success">Save {{ current_id }}</a>
        {{ POST_button(url_for('cache.load', element=element), text="Load " + element, style="btn-danger") }}
      {% endcall %}
    {% endfor %}
  {% endif %}
  {% with messages = get_flashed_messages(with_categories=True) %}
    {% if messages %}
    <div class="flashes">
    {% for category, message in messages %}
      {% if category == 'message' %}{% set category = "info" %}{% endif %}
      <div class="alert alert-{{ category }}">{{ message }}</div>
    {% endfor %}
    </div>
    {% endif %}
  {% endwith %}
{% endblock %}

{% block post_content %}
  {% if config.DEBUG and not config.DEBUG_SURE %}
    <div class="alert alert-danger"><strong>DEBUG:</strong> This application is running in debug mode. See the <a href="{{ url_for('about') }}#debug">about page</a> for more Details</div>
  {% endif %}
{% endblock %}

http://farol.wald.intevation.org