|
|
@@ -17,6 +17,7 @@ import org.springframework.context.MessageSource;
|
|
|
import org.springframework.core.io.ByteArrayResource;
|
|
|
import org.springframework.core.io.Resource;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
@@ -52,7 +53,6 @@ public class PresentationController
|
|
|
//@SuppressWarnings("unused")
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(PresentationController.class);
|
|
|
|
|
|
- // TODO version diaporama pour affichage sur écran de régie
|
|
|
// TODO raccourci ouvrir/fermer/calculer les votes
|
|
|
|
|
|
@Autowired
|
|
|
@@ -165,7 +165,7 @@ public class PresentationController
|
|
|
.ok()
|
|
|
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"presentations.pdf\"")
|
|
|
.header(HttpHeaders.CONTENT_LENGTH, "" + binaire.length)
|
|
|
- .header(HttpHeaders.CONTENT_TYPE, "application/pdf")
|
|
|
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_PDF.toString())
|
|
|
.body(r);
|
|
|
}
|
|
|
|
|
|
@@ -209,7 +209,7 @@ public class PresentationController
|
|
|
private Row createProductionRow(ProductionShort production, int nombre)
|
|
|
{
|
|
|
return Row.builder()
|
|
|
- .add(createCell("#" + (nombre < 27 ? LETTRES.charAt(nombre - 1) : "?")))
|
|
|
+ .add(createCell("#" + ((nombre < 27) ? LETTRES.charAt(nombre - 1) : "?")))
|
|
|
.add(createCell(production.titre()))
|
|
|
.add(createCell(production.auteurs()))
|
|
|
.add(createCell(production.groupes()))
|
|
|
@@ -232,7 +232,143 @@ public class PresentationController
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+ @GetMapping(value = "/diapos/{id}")
|
|
|
+ @PreAuthorize("hasRole('ADMIN')")
|
|
|
+ public ResponseEntity<String> getDiaporama(@PathVariable int id, HttpServletRequest request)
|
|
|
+ {
|
|
|
+ Locale locale = localeResolver.resolveLocale(request);
|
|
|
+
|
|
|
+ Categorie categorie = categorieRepository.findById(id);
|
|
|
+
|
|
|
+ List<Presentation> presentations = presentationRepository.findByCategorie(id);
|
|
|
+
|
|
|
+ if ((categorie != null) && (presentations != null))
|
|
|
+ {
|
|
|
+ String libelleCategorie = categorie.getLibelle();
|
|
|
+
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+
|
|
|
+ sb.append("<html>\n");
|
|
|
+ sb.append("<header>\n");
|
|
|
+
|
|
|
+ // TODO version diaporama en HTML pour affichage sur écran de régie
|
|
|
+
|
|
|
+ /*
|
|
|
+ .diapo_compo_start { }
|
|
|
+ .diapo_compo_page { }
|
|
|
+ .diapo_compo_finish { }
|
|
|
+ .diapo_bouton { }
|
|
|
+ .diapo_compo { }
|
|
|
+ .diapo_order { }
|
|
|
+ .diapo_title { }
|
|
|
+ .diapo_authors { }
|
|
|
+ .diapo_comments { }
|
|
|
+ .diapo_warning { }
|
|
|
+ .diapo_alert { }
|
|
|
+ .diapo_image_container { }
|
|
|
+ .diapo_image_content { }
|
|
|
+ .diapo_image { }
|
|
|
+ .diapo_audio_container { }
|
|
|
+ .diapo_video_container { }
|
|
|
+ */
|
|
|
+
|
|
|
+ sb.append("</header>\n");
|
|
|
+ sb.append("<body>\n");
|
|
|
+
|
|
|
+ sb.append("<div class=\"diapo_compo_start\" id=\"diapo_page_0\">\n");
|
|
|
+
|
|
|
+ sb.append("<div class=\"diapo_compo\">").append(libelleCategorie).append("</div>\n");
|
|
|
+
|
|
|
+ sb.append("<div class=\"diapo_hub\">\n");
|
|
|
+ sb.append("<button class=\"diapo_bouton\" title=\"").append(messageSource.getMessage("show.file.next", null, locale)).append("\">►</button>\n");
|
|
|
+ sb.append("</div>\n");
|
|
|
+
|
|
|
+ sb.append("</div>\n");
|
|
|
+
|
|
|
+ int n = 1;
|
|
|
+
|
|
|
+ for (int i = 0; i < presentations.size(); i++)
|
|
|
+ {
|
|
|
+ Presentation d = presentations.get(i);
|
|
|
+ Production p = d.getProduction();
|
|
|
+
|
|
|
+ sb.append("<div class=\"diapo_compo_page\" id=\"diapo_page_" + n + "\">\n");
|
|
|
+
|
|
|
+ sb.append("<div class=\"diapo_compo\">").append(libelleCategorie).append("</div>\n");
|
|
|
+ sb.append("<div class=\"diapo_order\">").append("#").append((i < 26) ? LETTRES.charAt(i) : "?").append("</div>\n");
|
|
|
+ sb.append("<div class=\"diapo_title\">").append(p.getTitre()).append("</div>\n");
|
|
|
+ sb.append("<div class=\"diapo_authors\">").append(p.getAuteurs()).append(" / ").append(p.getGroupes()).append("</div>\n");
|
|
|
+ sb.append("<div class=\"diapo_comments\">").append(p.getCommentaire()).append("</div>\n");
|
|
|
+
|
|
|
+ switch (d.getEtatMedia())
|
|
|
+ {
|
|
|
+ case 1:
|
|
|
+
|
|
|
+ if (d.getMimeMedia().startsWith("image/"))
|
|
|
+ {
|
|
|
+ sb.append("<div id=\"\" class=\"diapo_image_container\"><div class=\" class=\"diapo_image_content\">");
|
|
|
+ sb.append("<img src=\"").append(d.getDataMediaAsString()).append("\" alt=\"\" class=\"diapo_image\" />");
|
|
|
+ sb.append("</div></div>\n");
|
|
|
+ }
|
|
|
+ else if (d.getMimeMedia().startsWith("audio/"))
|
|
|
+ {
|
|
|
+ sb.append("<div id=\"\" class=\"diapo_audio_container\">");
|
|
|
+ sb.append("<audio controls><source src=\"").append(d.getDataMediaAsString()).append("\" type=\"").append(d.getMimeMedia()).append("\" />").append("</audio>");
|
|
|
+ sb.append("</div>\n");
|
|
|
+ }
|
|
|
+ else if (d.getMimeMedia().startsWith("video/"))
|
|
|
+ {
|
|
|
+ sb.append("<div id=\"\" class=\"diapo_video_container\">");
|
|
|
+ sb.append("<video controls width=\"480\" height=\"240\"><source src=\"").append(d.getDataMediaAsString()).append("\" type=\"").append(d.getMimeMedia()).append("\" />");
|
|
|
+ sb.append("</video>");
|
|
|
+ sb.append("</div>\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+
|
|
|
+ sb.append("<div class=\"diapo_warning\">").append(messageSource.getMessage("show.file.acknowlegded", null, locale)).append("</div>\n");
|
|
|
+
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+
|
|
|
+ sb.append("<div class=\"diapo_alert\">").append(messageSource.getMessage("show.file.missing", null, locale)).append("</div>\n");
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ sb.append("<div class=\"diapo_hub\">\n");
|
|
|
+ sb.append("<button class=\"diapo_bouton\" title=\"").append(messageSource.getMessage("show.file.previous", null, locale)).append("\">◄</button>\n");
|
|
|
+ sb.append("<button class=\"diapo_bouton\" title=\"").append(messageSource.getMessage("show.file.next", null, locale)).append("\">►</button>\n");
|
|
|
+ sb.append("</div>\n");
|
|
|
+
|
|
|
+ sb.append("</div>");
|
|
|
+ n++;
|
|
|
+ }
|
|
|
+
|
|
|
+ sb.append("<div class=\"diapo_compo_finish\" id=\"diapo_page_" + n + "\">\n");
|
|
|
+
|
|
|
+ sb.append("<div class=\"diapo_compo\">").append(libelleCategorie).append("</div>\n");
|
|
|
+
|
|
|
+ sb.append("<div class=\"diapo_hub\">\n");
|
|
|
+ sb.append("<button class=\"diapo_bouton\" title=\"").append(messageSource.getMessage("show.file.previous", null, locale)).append("\">◄</button>\n");
|
|
|
+ sb.append("</div>\n");
|
|
|
+
|
|
|
+ sb.append("</div>\n");
|
|
|
+
|
|
|
+ sb.append("</body>\n");
|
|
|
+ sb.append("</html>\n");
|
|
|
+
|
|
|
+ return ResponseEntity
|
|
|
+ .ok()
|
|
|
+ .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + libelleCategorie +".html\"")
|
|
|
+ .header(HttpHeaders.CONTENT_LENGTH, "" + sb.length())
|
|
|
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_HTML.toString())
|
|
|
+ .body(sb.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ return ResponseEntity.notFound().build();
|
|
|
+ }
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/list-linked/{id}")
|