Commit d3c42f99 authored by CLOUARD Regis's avatar CLOUARD Regis
Browse files

Addition of a print button on the list of courses, it uses the same function...

parent dd63ff7e
......@@ -122,7 +122,7 @@ function previewMap(data, divMap, divLeaflet, map, overlay, img) {
img.src = response.url;
} else {
let error = document.getElementById("map-not-found");
error.style.display="block";
error.style.display = "block";
img.width = 0;
img.height = 0;
overlay.setUrl("/empty");
......@@ -159,7 +159,7 @@ function previewMap(data, divMap, divLeaflet, map, overlay, img) {
function addControlPointOnMap(data, map) {
for (let [key, value] of Object.entries(data.xml2)) {
a = L.circleMarker(value, {
const a = L.circleMarker(value, {
radius: 8.0,
fillColor: '#ff0000',
color: '#000000',
......@@ -175,4 +175,16 @@ function showPreview(data, divXml, divMap, divLeaflet, map, overlay, img) {
previewXml(data, divXml);
previewMap(data, divMap, divLeaflet, map, overlay, img);
addControlPointOnMap(data, map);
}
function downloadMap(imageURL){ //see library printJS for further print options.
let printableMap = window.open(window.location.origin + "/" + imageURL);
printableMap.download();
}
function switchMapDisplay(overlay, overlayOpacity) {
let hideButton = document.getElementById("hide-map");
let showButton = document.getElementById("show-map");
overlayOpacity === 100 ? (overlayOpacity = 0, hideButton.style.display = "block", showButton.style.display = "none") : (overlayOpacity = 100, hideButton.style.display = "none", showButton.style.display = "block");
overlay.setOpacity(overlayOpacity);
}
\ No newline at end of file
......@@ -35,12 +35,13 @@ class AdminController extends AbstractController
/**
* @Route("/admin/delete_user/{id}", name="delete_user")
*/
public function delete(int $id): RedirectResponse
public function delete(int $id, TranslatorInterface $translator): RedirectResponse
{
$user = $this->getDoctrine()->getRepository(User::class)->find($id);
$user->remove($this->getDoctrine()->getManager());
return $this->redirectToRoute('all_planners');
$message = $translator->trans("deletion.succeeded");
return $this->redirectToRoute('all_planners', ['message' => $message . ' !']);
}
/**
......@@ -56,7 +57,7 @@ class AdminController extends AbstractController
$creator = new CreateUser($user, $translator);
$valid = $creator->addUser($encoder, $this->getDoctrine()->getManager());
if ($valid === true) {
$creator->sendEmail($mailer, true);
$creator->sendEmail($mailer, true, $translator);
return $this->redirectToRoute('all_planners');
} else {
......@@ -81,35 +82,16 @@ class AdminController extends AbstractController
/**
* @Route("/admin/change_planner_password/{id}", name="change_planner_password")
* @param int $id
* @return Response
*/
public function change_planner_password(int $id): Response
{
$user = $this->getDoctrine()->getRepository(User::class)->find($id);
return $this->render(
'admin/change_planner_password.html.twig',
[
'name' => $user->getUsername(),
'submit_route' => $this->generateUrl("change_password",['id' => $id]),
]
);
}
/**
* @Route("/admin/change_password/{id}", name="change_password")
* @param int $id
* @return RedirectResponse
*/
public function password_modification(int $id, UserPasswordEncoderInterface $encoder, TranslatorInterface $translator): RedirectResponse
public function password_modification(int $id, UserPasswordEncoderInterface $encoder, TranslatorInterface $translator, Swift_Mailer $mailer): RedirectResponse
{
$user = $this->getDoctrine()->getRepository(User::class)->find($id);
$creator = new CreateUser($user, $translator);
$request = Request::createFromGlobals();
$newPassword = $request->request->get('new_password');
$creator->changePassword($newPassword, $encoder, $this->getDoctrine()->getManager());
$creator->forgotPassword($encoder, $this->getDoctrine()->getManager());
$creator->sendEmail($mailer, false,$translator); //the user is notified of the password change
$message = $translator->trans("modification.succeed");
$message = $translator->trans("password.reset.succeeded");
return $this->redirectToRoute('all_planners', ['message' => $message . ' !']);
}
}
\ No newline at end of file
......@@ -130,6 +130,7 @@ class CourseController extends AbstractController
'course/info.html.twig',
[
'name' => $course->getName(),
'clubName' => $course->getClubName(),
'route_map' => $this->generateUrl('course_map', ['id' => $id]),
'creator' => $user->getUsername(),
'day' => $date->format("d"),
......@@ -137,6 +138,7 @@ class CourseController extends AbstractController
'year' => $date->format("Y"),
'control_point_number' => count($lengths),
'length' => $course->getLength(),
'isPrintable' => $course->getPrintable(),
]
);
}
......
......@@ -53,7 +53,7 @@ class SecurityController extends AbstractController
if ($user) {
$creator = new CreateUser($user, $translator);
$creator->forgotPassword($encoder, $this->getDoctrine()->getManager());
$creator->sendEmail($mailer, false);
$creator->sendEmail($mailer, false,$translator);
return $this->redirectToRoute('all_planners');
} else {
......
......@@ -9,6 +9,7 @@ use Doctrine\ORM\Mapping as ORM;
use App\Model\CourseValidator;
use Doctrine\Persistence\ObjectManager;
use Symfony\Component\Intl\Exception\BadMethodCallException;
/**
* @ORM\Entity(repositoryClass="App\Repository\CourseRepository")
......@@ -82,6 +83,11 @@ class Course
*/
private ?int $length;
/**
* @ORM\Column(type="boolean")
*/
private $printable;
public function __construct()
{
$this->orienteer = new ArrayCollection();
......@@ -94,7 +100,8 @@ class Course
$this->name,
$this->xml,
$this->image,
$this->kml
$this->kml,
$this->printable
);
return $this->error == CourseValidator::$NO_ERROR;
......@@ -134,9 +141,11 @@ class Course
return $this->xml;
}
public function setXml(string $xml): self
public function setXml(string $xml, string $clubName = ""): self
{
$this->xml = $xml;
$xml = simplexml_load_string($xml); //from string to SimpleXMLElement
$xml->Extensions->Creator = $clubName;
$this->xml = $xml->asXML(); //from SimpleXMLElement to String with xml format
return $this;
}
......@@ -189,6 +198,17 @@ class Course
return $this;
}
public function getClubName(): ?string
{
$xmlData = simplexml_load_string($this->getXml());
return $xmlData->Extensions->Creator;
}
public function setClubName(string $clubName): self
{
throw new BadMethodCallException("setClubName should not be used, see setXml for club-name modification");
}
/**
* @return Collection|Track[]
*/
......@@ -286,4 +306,16 @@ class Course
return $this;
}
public function getPrintable(): ?bool
{
return $this->printable;
}
public function setPrintable(bool $printable): self
{
$this->printable = $printable;
return $this;
}
}
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200522171530 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('CREATE TABLE track (id INT AUTO_INCREMENT NOT NULL, course_id INT NOT NULL, name VARCHAR(255) NOT NULL, total_time INT NOT NULL, format INT DEFAULT 0, control_points LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\', trace LONGTEXT NOT NULL, INDEX IDX_D6E3F8A6591CC992 (course_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE course (id INT AUTO_INCREMENT NOT NULL, creator_id INT NOT NULL, xml TEXT NOT NULL, image VARCHAR(255) NOT NULL, kml VARCHAR(2000) NOT NULL, update_at DATETIME NOT NULL, name VARCHAR(255) NOT NULL, latitude VARCHAR(255) NOT NULL, longitude VARCHAR(255) NOT NULL, length INT NOT NULL, INDEX IDX_169E6FB961220EA6 (creator_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE missing_control_point (id INT AUTO_INCREMENT NOT NULL, course_id INT NOT NULL, control_point_id VARCHAR(20) NOT NULL, INDEX IDX_D3F3931591CC992 (course_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, username VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, email TEXT NOT NULL, phone TEXT DEFAULT NULL, UNIQUE INDEX UNIQ_8D93D649F85E0677 (username), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE track ADD CONSTRAINT FK_D6E3F8A6591CC992 FOREIGN KEY (course_id) REFERENCES course (id)');
$this->addSql('ALTER TABLE course ADD CONSTRAINT FK_169E6FB961220EA6 FOREIGN KEY (creator_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE missing_control_point ADD CONSTRAINT FK_D3F3931591CC992 FOREIGN KEY (course_id) REFERENCES course (id)');
}
public function down(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE track DROP FOREIGN KEY FK_D6E3F8A6591CC992');
$this->addSql('ALTER TABLE missing_control_point DROP FOREIGN KEY FK_D3F3931591CC992');
$this->addSql('ALTER TABLE course DROP FOREIGN KEY FK_169E6FB961220EA6');
$this->addSql('DROP TABLE track');
$this->addSql('DROP TABLE course');
$this->addSql('DROP TABLE missing_control_point');
$this->addSql('DROP TABLE user');
}
}
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210421121523 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE course ADD printable TINYINT(1) NOT NULL DEFAULT false');
/*$this->addSql('ALTER TABLE missing_control_point RENAME INDEX idx_d3f3931591cc992 TO IDX_52AD13B591CC992');*/
$this->addSql('ALTER TABLE track CHANGE format format INT NOT NULL');
$this->addSql('ALTER TABLE user CHANGE email email LONGTEXT NOT NULL');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE course DROP printable');
/*$this->addSql('ALTER TABLE missing_control_point RENAME INDEX idx_52ad13b591cc992 TO IDX_D3F3931591CC992');*/
$this->addSql('ALTER TABLE track CHANGE format format INT DEFAULT 0');
$this->addSql('ALTER TABLE user CHANGE email email TEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`');
}
}
......@@ -13,6 +13,8 @@ class CourseValidator
static int $ERROR_COURSE_NAME_INVALID = 1;
static int $ERROR_IMAGE_NOT_FOUND = 2;
static int $ERROR_IMAGE_TYPE_INVALID = 3;
static int $ERROR_COURSE_PRINTABLE_INVALID = 4;
static int $ERROR_COURSE_CLUB_NAME_INVALID = 5;
static int $ERROR_XML_EMPTY = 10;
static int $ERROR_XML_INVALID = 11;
static int $ERROR_XML_INVALID_CONTENTS = 12;
......@@ -117,14 +119,24 @@ class CourseValidator
return self::$NO_ERROR;
}
public static function checkValid(string $name, string $xml, string $image, string $kml)
public static function checkPrintable(bool $printable): int
{
if ($printable !== true && $printable !== false) { // TODO Simplify
return self::$ERROR_COURSE_PRINTABLE_INVALID;
}
return self::$NO_ERROR;
}
public static function checkValid(string $name, string $xml, string $image, string $kml, bool $printable)
{
//smallest error code is always NO_ERROR
return max(
self::checkName($name),
self::checkXml($xml),
self::checkImage($image),
self::checkKml($kml)
self::checkKml($kml),
self::checkPrintable($printable)
);
}
}
......@@ -48,16 +48,19 @@ class CreateCourse
if ($this->id != -1) {
$data["title"] = $this->translator->trans("course.modify");
$data["name"] = $this->course->getName();
$data["clubName"] = $this->course->getClubName();
$data["isPrintable"] = $this->course->getPrintable();
$data["modify"] = true;
} else {
$data["title"] = $this->translator->trans("course.add");
$data["modify"] = false;
$data["isPrintable"] = false;
}
return $data;
}
private function generatePreviewXml1(string $xml)
private function generatePreviewXml1(string $xml) // TODO 1 ?
{
$error = CourseValidator::checkXml($xml);
if ($error == CourseValidator::$NO_ERROR) {
......@@ -76,7 +79,7 @@ class CreateCourse
}
}
private function generatePreviewXml2(string $xml)
private function generatePreviewXml2(string $xml) // TODO 2 ?
{
$error = CourseValidator::checkXml($xml);
if ($error == CourseValidator::$NO_ERROR) {
......@@ -118,7 +121,7 @@ class CreateCourse
{
$data = array();
$post = $request->request;
if ($post->get("xml") == "true") { // TODO Strange test, why not if ($post->get("xml")) {
if ($post->get("xml") == "true") {
$xml = file_get_contents(FileUploader::getFile($this->user->getId(), "xml"));
$data["xml1"] = $this->generatePreviewXml1($xml);
$data["xml2"] = $this->generatePreviewXml2($xml);
......@@ -160,6 +163,8 @@ class CreateCourse
$kml = FileUploader::getFile($this->user->getId(), "kml");
$image = FileUploader::getFile($this->user->getId(), "image");
$name = $post->get("name");
$printable = $post->get("printable");
$clubName = $post->get("clubName");
$this->course->setUpdateAt(new DateTime('NOW'));
if ($this->id == -1) {
if ($name == null) {
......@@ -178,7 +183,7 @@ class CreateCourse
return $data;
}
$this->course->setName($name);
$this->course->setXml(file_get_contents($xml));
$this->course->setXml(file_get_contents($xml),$clubName);
$this->course->setKml(file_get_contents($kml));
$this->course->setImage($image);
$this->course->setCreator($this->user);
......@@ -191,6 +196,7 @@ class CreateCourse
$this->course->setLatitude($latitude);
$this->course->setLongitude($longitude);
$this->course->setLength($length);
$this->course->setPrintable($printable);
if (!$this->course->isValid()) {
$data["error"] = $this->translateError($this->course->getError());
......@@ -219,11 +225,14 @@ class CreateCourse
$this->course->setName($name);
}
if ($xml != null) {
$this->course->setXml(file_get_contents($xml));
$this->course->setXml(file_get_contents($xml),$clubName);
}
if ($kml != null) {
$this->course->setKml(file_get_contents($kml));
}
if ($printable != null){
$this->course->setPrintable($printable);
}
if (!$this->course->isValid()) {
$data["error"] = $this->translateError($this->course->getError());
......@@ -282,6 +291,8 @@ class CreateCourse
return $this->translator->trans("error.no");
case CourseValidator::$ERROR_COURSE_NAME_INVALID:
return $this->translator->trans("error.course.name.invalid");
case CourseValidator::$ERROR_COURSE_CLUB_NAME_INVALID:
return $this->translator->trans("error.course.club.name.invalid");
case CourseValidator::$ERROR_IMAGE_NOT_FOUND;
return $this->translator->trans("error.image.does.not.exist");
case CourseValidator::$ERROR_IMAGE_TYPE_INVALID;
......@@ -304,6 +315,8 @@ class CreateCourse
return $this->translator->trans("error.kml.structure.invalid");
case CourseValidator::$ERROR_KML_INVALID_POS:
return $this->translator->trans("error.kml.position.invalid");
case CourseValidator::$ERROR_COURSE_PRINTABLE_INVALID :
return $this->translator->trans("error.printable.choice.invalid");
default: //unknow error
return $this->translator->trans("error.unknown");
}
......
......@@ -107,17 +107,17 @@ class CreateUser
$entityManager->flush();
}
public function sendEmail(Swift_Mailer $mailer, $new)
public function sendEmail(Swift_Mailer $mailer, $new,TranslatorInterface $translator)
{
if ($new) {
$body = "Bonjour,\nVos données de connexion en tant que traceur sur le serveur vikazimut.vikazim.fr sont :\n";
$body .= "Nom d'utilisateur: ".$this->user->getUsername()."\n";
$body = $translator->trans('mailer.hello') . ",\n" . $translator->trans('mailer.your.connection.data') . ": \n";
$body .= $translator->trans('mailer.username') . " : ".$this->user->getUsername()."\n";
} else {
$body = "Bonjour ".$this->user->getUsername()."\n";
$body .= "Vore mot de passe à été réinitialisé.\n";
$body = $translator->trans('mailer.hello') . " " . $this->user->getUsername()."\n";
$body .= $translator->trans('mailer.password.reset') . ".\n";
}
$body .= "Mot de passe provisoire : ".$this->plainPassword."\n";
$body .= "Merci de ne pas répondre à ce mail";
$body .= $translator->trans('mailer.temporary.password') . " : " . $this->plainPassword."\n\n";
$body .= $translator->trans('mailer.no.reply') . ".\n";
$message = (new Swift_Message("Vikazimut"))
->setFrom("noreply@vikazimut.vikazim.fr")
->setTo($this->user->getEmail())
......
......@@ -38,6 +38,7 @@ class FileUploader
date_default_timezone_set("UTC");
$day_value = 24 * 60 * 60;
$dir = "tmp_files";
if (!is_dir($dir)){mkdir($dir);}
foreach (scandir($dir) as $file) {
if (!is_dir($dir."/".$file)) {
$files_parts = preg_split("/[.]/", $file);
......
{% extends 'base.html.twig' %}
{% block title %}{% trans %}admin.change.planner.password.title{% endtrans %}{% endblock %}
{% block body %}
<div class="container mt-3">
<h2> {% trans %}admin.change.planner.password.title{% endtrans %}</h2>
<h3> {% trans %}admin.change.planner.password.planner{% endtrans %} {{ name }}</h3>
<form action="{{ submit_route }}" method="post">
<div class="form-group row">
<label for="inputPassword" class="col-sm-3 col-form-label">{% trans %}admin.new.planner.password{% endtrans %}</label>
<div class="col-sm-5">
<input type="password" class="form-control" id="inputPassword" name="new_password" placeholder="{% trans %}admin.new.planner.password{% endtrans %}">
</div>
</div>
<button type="submit" class="btn btn-primary mb-2">{% trans %}admin.change.planner.password.confirm{% endtrans %}</button>
</form>
</div>
{% endblock %}
\ No newline at end of file
......@@ -22,9 +22,27 @@
<button class="btn btn-info">{% trans %}admin_list_planners.info{% endtrans %} </button>
</a>
<a href="{{ path('change_planner_password', {id: user.id}) }}">
<button class="btn btn-warning">{% trans %}admin_list_planners.change_password{% endtrans %} </button>
</a>
{# Reset password #}
<button type="button" class="btn btn-warning" data-toggle="modal" data-target="#confirm-password-reset--{{ user.id }}">{% trans %}admin_list_planners.change_password{% endtrans %}</button>
<div class="modal fade" id="confirm-password-reset--{{ user.id }}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{% trans %}admin_list_planners.ask.for.password.reset.confirmation{% endtrans %}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
{% trans %}admin_list_planners.ask.for.password.reset{% endtrans %}
</div>
<div class="modal-footer">
<a href="{{ path('change_planner_password', {id: user.id}) }}" type="button" class="btn btn-secondary">{% trans %}admin_list_planners.confirm.password.reset{% endtrans %}</a>
<button type="button" class="btn btn-primary" data-dismiss="modal">{% trans %}admin_list_planners.abort.password.reset{% endtrans %}</button>
</div>
</div>
</div>
</div>
{# Delete #}
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#confirm-delete--{{ user.id }}">{% trans %}admin_list_planners.delete{% endtrans %}</button>
......@@ -32,7 +50,7 @@
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{% trans %}admin_list_planners.ask.for.confirmation{% endtrans %}</h5>
<h5 class="modal-title">{% trans %}admin_list_planners.ask.for.delete.confirmation{% endtrans %}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
......
......@@ -2,17 +2,25 @@
{% block title %}{% trans %}courses.title{% endtrans %}{% endblock %}
{% block javascripts %}
<script src="{{ asset('/public/javascript/showMap.js') }}"></script>
{% endblock %}
{% block body %}
<div class="container" style="padding-top: 20pt">
<h2 class="text-center">{% trans %}courses.title{% endtrans %}</h2>
<div class="border border-secondary rounded">
{% for course in courses %}
<div class="list-group list-group-item-action d-flex flex-row align-items-center p-2">
<div class="d-flex flex-column">
<div class="list-group list-group-item-action d-flex flex-row flex-wrap justify-content-end align-items-center p-2">
<div class="d-flex flex-column mr-auto" style="max-width: 35vw">
<span class="list-group-item-secondary">{{ course.name }}</span>
<span class="flex-shrink-1 badge badge-primary badge-pill">{% trans %}course.number_of_routes{% endtrans %}: {{ course.orienteer|length }}</span>
</div>
<a href="{{ path('show_info', {id: course.id}) }}" class="ml-auto btn btn-primary">{% trans %}course.show.info{% endtrans %}</a>
{% if course.printable %}
<button onclick="downloadMap('{{ course.image }}')" class="btn btn-secondary">{% trans %}course.print.map{% endtrans %}</button>
{% endif %}
<a href="{{ path('show_info', {id: course.id}) }}" class="ml-2 btn btn-primary">{% trans %}course.show.info{% endtrans %}</a>
<a href="{{ path('show_tracks', {id: course.id}) }}" class="ml-2 btn btn-primary">{% trans %}course.show.tracks{% endtrans %}</a>
</div>
{% endfor %}
......
</
......@@ -50,18 +50,18 @@
xhr.send()
}
function switchMapDisplay(){
function printMap() { //see library printJS for further print options.
let printableMap = window.open(window.location.origin + "/" + imageURL);
printableMap.print();
}
function switchMapDisplay() { // TODO new
let hideButton = document.getElementById("hide-map");
let showButton = document.getElementById("show-map");
overlayOpacity === 100 ? (overlayOpacity = 0, hideButton.style.display = "block", showButton.style.display = "none" ) : (overlayOpacity = 100, hideButton.style.display = "none", showButton.style.display = "block" ) ;
overlayOpacity === 100 ? (overlayOpacity = 0, hideButton.style.display = "block", showButton.style.display = "none") : (overlayOpacity = 100, hideButton.style.display = "none", showButton.style.display = "block");
overlay.setOpacity(overlayOpacity);
}
function printMap(){ //see library printJS for further print options.
let printableMap = window.open(window.location.origin + "/" + imageURL);
printableMap.print();
}
window.addEventListener("load", function () {
divLeaflet = document.createElement("div");
map = generateMap(divLeaflet);
......@@ -85,18 +85,23 @@
<!-- Tab content -->
<div id="map-tab" class="tab-content">
<button class="btn btn-primary" id="show-map" onclick="switchMapDisplay()" style="position: absolute; z-index: 9999; top: 60px; right: 35px">{% trans %} course.description.mask.map {% endtrans %}</button>
<button class="btn btn-primary" id="hide-map" onclick="switchMapDisplay()" style="display:none; position: absolute; z-index: 9999; top: 60px; right: 35px">{% trans %} course.description.show.map {% endtrans %}</button>
<!-- button class="btn btn-primary" onclick="printMap()" style="position: absolute; z-index: 9999; top: 105px; right: 35px">{% trans %} course.description.print {% endtrans %}</button -->
<button class="btn btn-primary" id="show-map" onclick="switchMapDisplay(overlay, 100)" style="position: absolute; z-index: 9999; top: 60px; right: 35px">{% trans %} course.description.mask.map {% endtrans %}</button>
<button class="btn btn-primary" id="hide-map" onclick="switchMapDisplay(overlay, 0)" style="display:none; position: absolute; z-index: 9999; top: 60px; right: 35px">{% trans %} course.description.show.map {% endtrans %}</button>
{% if isPrintable %}
<button class="btn btn-primary" onclick="downloadMap(imageURL)" style="position: absolute; z-index: 9999; top: 105px; right: 35px">{% trans %} course.description.download {% endtrans %}</button>
{% endif %}