{% extends "maposmatic/base.html" %}

{% comment %}
 coding: utf-8

 maposmatic, the web front-end of the MapOSMatic city map generation system
 Copyright (C) 2012  David Decotigny
 Copyright (C) 2012  Frédéric Lehobey
 Copyright (C) 2012  Pierre Mauduit
 Copyright (C) 2012  David Mentré
 Copyright (C) 2012  Maxime Petazzoni
 Copyright (C) 2012  Thomas Petazzoni
 Copyright (C) 2012  Gaël Utard
 Copyright (C) 2018  Hartmut Holzgraefe

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License as
 published by the Free Software Foundation, either version 3 of the
 License, or 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 Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
{% endcomment %}
{% load i18n %}
{% load l10n %}
{% load extratags %}

{% block body-class %}maps{% endblock %}
{% block menu-maps %}active{% endblock %}

{% block title %}{{ map.maptitle }}{% endblock %}
{% block extrajs %}
{% if map.needs_waiting %}
  setInterval(function() {
    var t = $('.refresh-time > span').text() - 1;
    $('.refresh-time > span').text(t);
    if (t == 0) {
      $('.refresh-time').text('{% trans "Updating now..." %}');
      $('#map-rendering-status').load("../../apis/rendering-status/{{ map.id }}")
    }
  }, 1000);
{% endif %}
{% endblock %}

{% block page %}
<div class="row-fluid" style="margin-top: 30px;">
  <div class="span8">
    <h1>{{ map.maptitle }}</h1>

    <div class="card card-default mb-3">
      <div class="card-header">{% trans "Rendering status" %}</div>
      <div id="map-rendering-status" class="card-body">
	{% include "maposmatic/map-full-parts/rendering-status.html" %}
      </div>
    </div>    

    <div class="card card-default mb-3">
      <div class="card-header">{% trans "Map details" %}</div>
      <div class="card-body">
	
	<table class="table table-striped">
	  <tbody>
            {% if map.administrative_osmid %}
            <tr><td><strong>{% trans "City" %}</strong></td>
              <td>{{ map.administrative_city }} ({{ map.administrative_osmid }})</td></tr>
            {% else %}
            <tr><td><strong>{% trans "Bounding box" %}</strong></td>
              <td>
		{{ map.lat_upper_left|latitude }}, {{ map.lon_upper_left|longitude }}
		&rarr;
		{{ map.lat_bottom_right|latitude }}, {{ map.lon_bottom_right|longitude }}
		&nbsp;&nbsp;&nbsp;({{ map|bbox_km }})
	      </td>
	    </tr>
            {% endif %}
            <tr><td><strong>{% trans "Layout" %}</strong></td>
              <td>{{ map.layout }}</td></tr>
            <tr><td><strong>{% trans "Stylesheet" %}</strong></td>
              <td>{{ map.stylesheet }}</td></tr>
	    {% if map.overlay %}
            <tr><td><strong>{% trans "Overlays" %}</strong></td>
              <td>{{ map.overlay|add_blank_after_comma }}</td></tr>
	    {% endif %}
	    {% if map.track %}
            <tr><td><strong>{% trans "GPX Track" %}</strong></td>
              <td>{{ map.track|file_basename }}</td></tr>
	    {% endif %}
	    {% if map.umap %}
            <tr><td><strong>{% trans "UMAP File" %}</strong></td>
              <td>{{ map.umap|file_basename }}</td></tr>
	    {% endif %}
            <tr><td><strong>{% trans "Paper format" %}</strong></td>
              <td>{{ map.paper_width_mm }}&times;{{ map.paper_height_mm }} mm²</td></tr>
	    <tr><td><strong>{% trans "Map locale" %}</strong></td>
	      <td>{{ MAP_LANGUAGES|getitem:map.map_language }}</td></tr>
	  </tbody>
	</table>
      </div>
    </div>

    <div class="card card-default mb-3">
      <div class="card-header">{% trans "Map preview" %}</div>
      <div class="card-body">
	<div class="span4 map mapthumbnail" id="map-{{ map.id }}"
	     data-geo-osm-id="{{ map.administrative_osmid }}"
	     data-geo-from-lat="{{ map.lat_upper_left }}"
	     data-geo-from-lon="{{ map.lon_upper_left }}"
	     data-geo-to-lat="{{ map.lat_bottom_right }}"
	     data-geo-to-lon="{{ map.lon_bottom_right }}">
	  <p>GIS database is not available.</p>
	</div>
      </div>
    </div>

  </div>
</div>

{% endblock %}
