add html preview file

This commit is contained in:
Simon Vieille 2021-11-13 23:32:25 +01:00
parent 372ea209b7
commit f0cab56ca0
5 changed files with 33 additions and 1 deletions

View file

@ -72,6 +72,7 @@ core:
- application/octet-stream
- application/msword
- text/plain
- text/html
- text/css
- application/sla
path_locked:

View file

@ -56,6 +56,10 @@ class StlMeshController extends PageController
throw $this->createNotFoundException();
}
if (isset($file['htmlPreviewFile'])) {
$file['htmlPreviewFile'] = file_get_contents($file['htmlPreviewFile']);
}
return $this->render('page/mesh/viewer.html.twig', [
'mesh' => $stlMesh,
'file' => $file,

View file

@ -24,6 +24,9 @@ class StlFileType extends AbstractType
'required' => true,
'attr' => [
],
'row_attr' => [
'class' => 'col-md-6',
],
'constraints' => [
new NotBlank(),
],
@ -34,8 +37,25 @@ class StlFileType extends AbstractType
'file',
FilePickerType::class,
[
'label' => false,
'label' => 'Fichier STL',
'required' => true,
'row_attr' => [
'class' => 'col-md-6',
],
'constraints' => [
],
]
);
$builder->add(
'htmlPreviewFile',
FilePickerType::class,
[
'label' => 'Rendu HTML',
'required' => false,
'row_attr' => [
'class' => 'col-md-6',
],
'constraints' => [
],
]

View file

@ -67,6 +67,9 @@ class StlMeshType extends AbstractType
'required' => false,
'attr' => [
],
'row_attr' => [
'class' => 'col-md-6',
],
'constraints' => [
],
]

View file

@ -1,3 +1,6 @@
{% if not file.htmlPreviewFile is empty %}
{{ file.htmlPreviewFile|raw }}
{% else %}
<!DOCTYPE html>
<html lang="en">
<head>
@ -14,3 +17,4 @@
</body>
</html>
{% endif %}