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/octet-stream
- application/msword - application/msword
- text/plain - text/plain
- text/html
- text/css - text/css
- application/sla - application/sla
path_locked: path_locked:

View file

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

View file

@ -24,6 +24,9 @@ class StlFileType extends AbstractType
'required' => true, 'required' => true,
'attr' => [ 'attr' => [
], ],
'row_attr' => [
'class' => 'col-md-6',
],
'constraints' => [ 'constraints' => [
new NotBlank(), new NotBlank(),
], ],
@ -34,8 +37,25 @@ class StlFileType extends AbstractType
'file', 'file',
FilePickerType::class, FilePickerType::class,
[ [
'label' => false, 'label' => 'Fichier STL',
'required' => true, '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' => [ 'constraints' => [
], ],
] ]

View file

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

View file

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