Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Luciano Barletta
/
Pruebas-RTO
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 2c138709
authored
2020-01-15 14:20:01 +0000
by
Luciano Barletta
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
compilation workds
1 parent
ef14e1ff
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
154 additions
and
64 deletions
deploy.py
static/src/convert.js
static/src/div.js
templates/resultados.html
deploy.py
View file @
2c13870
...
...
@@ -7,7 +7,7 @@ app = Flask(__name__)
data
=
{
"header"
:
{
"dominio"
:
"dom"
,
"fecha"
:
"
07
-01-2019"
,
"fecha"
:
"
15
-01-2019"
,
},
"alineador"
:
{
"eje_delan"
:
"0.000"
...
...
@@ -24,9 +24,8 @@ data = {
"ren_der"
:
"0.000"
,
}
],
"freno"
:
[
"freno
s
"
:
[
{
"eje"
:
"0.000"
,
"f_izq"
:
"0.000"
,
"res_izq"
:
"0.000"
,
"ov_izq"
:
"0.000"
,
...
...
@@ -36,7 +35,6 @@ data = {
"ov_der"
:
"0.000"
,
},
{
"eje"
:
"0.000"
,
"f_izq"
:
"0.000"
,
"res_izq"
:
"0.000"
,
"ov_izq"
:
"0.000"
,
...
...
@@ -46,7 +44,6 @@ data = {
"ov_der"
:
"0.000"
,
},
{
"eje"
:
"0.000"
,
"f_izq"
:
"0.000"
,
"res_izq"
:
"0.000"
,
"ov_izq"
:
"0.000"
,
...
...
@@ -56,7 +53,6 @@ data = {
"ov_der"
:
"0.000"
,
},
{
"eje"
:
"0.000"
,
"f_izq"
:
"0.000"
,
"res_izq"
:
"0.000"
,
"ov_izq"
:
"0.000"
,
...
...
@@ -70,11 +66,9 @@ data = {
"f_izq"
:
"0.000"
,
"f_der"
:
"0.000"
},
"gases"
:
{
"gases
humos
"
:
{
"co"
:
"0.000"
,
"hc"
:
"0.000"
,
},
"humos"
:
{
"med"
:
"0.000"
}
}
...
...
static/src/convert.js
View file @
2c13870
...
...
@@ -6,9 +6,9 @@ const A4 = new Div(
new
Vector
(
595
,
842
)
);
const
Pos
ition
=
{
"beg
gining
"
:
0
,
"beg
gining
_margin"
:
5
,
const
Pos
=
{
"beg"
:
0
,
"beg_margin"
:
5
,
"quarter"
:
25
,
"third"
:
33.33
,
"middle"
:
50
,
...
...
@@ -18,6 +18,8 @@ const Position = {
"end"
:
100
};
const
containerSize
=
86
;
function
generateDivTree
(
data
)
{
/**
* The lambdas serve as "apply" functions
...
...
@@ -47,16 +49,16 @@ function generateDivTree(data) {
function
headerToPDF
(
pointer
,
data
)
{
const
header
=
A4
.
addChild
(
pointer
,
new
Vector
(
Pos
ition
.
end
,
3
));
const
header
=
A4
.
addChild
(
pointer
,
new
Vector
(
Pos
.
end
,
3
));
header
.
addText
(
"Dominio: "
+
data
[
'dominio'
],
new
Vector
(
Pos
ition
.
beggining_margin
,
Position
.
two_thirds
)
new
Vector
(
Pos
.
beg_margin
,
Pos
.
two_thirds
)
);
header
.
addText
(
"Fecha: "
+
data
[
'fecha'
],
new
Vector
(
Pos
ition
.
third
,
Position
.
two_thirds
)
new
Vector
(
Pos
.
third
,
Pos
.
two_thirds
)
);
return
new
Vector
(
pointer
.
x
,
pointer
.
y
+
3
);
...
...
@@ -64,21 +66,21 @@ function headerToPDF(pointer, data) {
function
alineadorToPDF
(
pointer
,
data
)
{
const
alineador
=
A4
.
addChild
(
pointer
,
new
Vector
(
Pos
ition
.
end
,
5
));
const
alineador
=
A4
.
addChild
(
pointer
,
new
Vector
(
Pos
.
end
,
5
));
const
title
=
alineador
.
addText
(
alineador
.
addText
(
"Resultado Pruebas en Banco de Alineador al Paso"
,
new
Vector
(
Pos
ition
.
beggining_margin
+
2
,
Position
.
third
)
new
Vector
(
Pos
.
beg_margin
+
2
,
Pos
.
third
)
);
const
subtitle
=
alineador
.
addText
(
alineador
.
addText
(
"Eje Delantero"
,
new
Vector
(
Pos
ition
.
beggining_margin
+
2
,
Position
.
two_thirds
)
new
Vector
(
Pos
.
beg_margin
+
2
,
Pos
.
two_thirds
)
);
const
value
=
alineador
.
addText
(
alineador
.
addText
(
data
[
'eje_delan'
],
new
Vector
(
Pos
ition
.
quarter
,
Position
.
two_thirds
)
new
Vector
(
Pos
.
quarter
,
Pos
.
two_thirds
)
);
return
new
Vector
(
pointer
.
x
,
pointer
.
y
+
5
);
...
...
@@ -86,47 +88,30 @@ function alineadorToPDF(pointer, data) {
function
suspensionToPDF
(
pointer
,
data
)
{
const
suspension
=
A4
.
addChild
(
pointer
,
new
Vector
(
Position
.
end
,
15
));
const
suspension
=
A4
.
addChild
(
pointer
,
new
Vector
(
Pos
.
end
,
15
));
const
divsize
=
new
Vector
(
containerSize
,
Pos
.
middle
);
const
eje1
=
suspension
.
addChild
(
new
Vector
(
Pos
ition
.
beggining_margin
+
2
,
0
),
new
Vector
(
86
,
50
)
)
const
eje2
=
suspension
.
addChild
(
new
Vector
(
Pos
ition
.
beggining_margin
+
2
,
50
),
new
Vector
(
86
,
50
)
)
const
eje1
=
suspension
.
addChild
(
new
Vector
(
Pos
.
beg_margin
+
2
,
Pos
.
beg
),
divsize
)
const
eje2
=
suspension
.
addChild
(
new
Vector
(
Pos
.
beg_margin
+
2
,
Pos
.
middle
),
divsize
)
const
table
=
(
container
,
eje
,
RI
,
peso
,
RD
)
=>
{
container
.
addText
(
`Resultado Pruebas en Banco de Suspensión - Eje
${
eje
}
`
,
new
Vector
(
0
,
Position
.
third
)
);
container
.
addTexts
([
[
`Resultado Pruebas en Banco de Suspensión - Eje
${
eje
}
`
,
new
Vector
(
0
,
Pos
.
third
)],
container
.
addText
(
"Rendimiento Izquierdo"
,
new
Vector
(
0
,
Position
.
two_thirds
)
);
[
"Rendimiento Izquierdo"
,
new
Vector
(
Pos
.
beg
,
Pos
.
two_thirds
)],
container
.
addText
(
RI
,
new
Vector
(
0
,
Position
.
end
)
);
[
RI
,
new
Vector
(
Pos
.
beg
+
10
,
Pos
.
end
)],
container
.
addText
(
"Peso Total del Eje"
,
new
Vector
(
37
,
Position
.
two_thirds
)
);
[
"Peso Total del Eje"
,
new
Vector
(
Pos
.
middle
-
10
,
Pos
.
two_thirds
)],
container
.
addText
(
peso
,
new
Vector
(
45
,
Position
.
end
)
);
[
peso
,
new
Vector
(
Pos
.
middle
-
3
,
Pos
.
end
)],
container
.
addText
(
"Rendimiento Derecho"
,
new
Vector
(
80
,
Position
.
two_thirds
)
);
[
"Rendimiento Derecho"
,
new
Vector
(
Pos
.
three_quarters
-
5
,
Pos
.
two_thirds
)],
container
.
addText
(
RD
,
new
Vector
(
90
,
Position
.
end
)
);
[
RD
,
new
Vector
(
Pos
.
three_quarters
+
5
,
Pos
.
end
)]
]);
};
table
(
eje1
,
1
,
data
[
0
][
"ren_izq"
],
data
[
0
][
"peso"
],
data
[
0
][
"ren_der"
])
...
...
@@ -136,29 +121,123 @@ function suspensionToPDF(pointer, data) {
}
function
frenosToPDF
(
pointer
,
data
)
{
A4
.
addChild
(
"frenos"
,
pointer
,
new
Vector
(
Position
.
end
,
60
));
const
frenos
=
A4
.
addChild
(
pointer
,
new
Vector
(
Pos
.
end
,
60
));
const
divsize
=
new
Vector
(
containerSize
,
Pos
.
quarter
);
const
eje1
=
frenos
.
addChild
(
new
Vector
(
Pos
.
beg_margin
+
2
,
Pos
.
beg
),
divsize
);
const
eje2
=
frenos
.
addChild
(
new
Vector
(
Pos
.
beg_margin
+
2
,
Pos
.
quarter
),
divsize
);
const
eje3
=
frenos
.
addChild
(
new
Vector
(
Pos
.
beg_margin
+
2
,
Pos
.
middle
),
divsize
);
const
eje4
=
frenos
.
addChild
(
new
Vector
(
Pos
.
beg_margin
+
2
,
Pos
.
three_quarters
),
divsize
);
const
table
=
(
container
,
eje
,
FI
,
RI
,
OI
,
peso
,
FD
,
RD
,
OD
)
=>
{
container
.
addTexts
([
[
`Diagnóstico de Frenos - Eje
${
eje
}
`
,
new
Vector
(
Pos
.
beg
,
Pos
.
beg_margin
+
10
)],
[
"Fuerza IZ"
,
new
Vector
(
Pos
.
beg_margin
,
Pos
.
quarter
)],
[
FI
,
new
Vector
(
Pos
.
beg_margin
+
3
,
Pos
.
quarter
+
10
)],
[
"Res.Rodadura IZ"
,
new
Vector
(
Pos
.
beg_margin
,
Pos
.
middle
)],
[
RI
,
new
Vector
(
Pos
.
beg_margin
+
3
,
Pos
.
middle
+
10
)],
[
"Ovalidad IZ"
,
new
Vector
(
Pos
.
beg_margin
,
Pos
.
three_quarters
)],
[
OI
,
new
Vector
(
Pos
.
beg_margin
+
3
,
Pos
.
three_quarters
+
10
)],
[
"Peso del Eje"
,
new
Vector
(
Pos
.
middle
-
10
,
Pos
.
quarter
)],
[
peso
,
new
Vector
(
Pos
.
middle
-
5
,
Pos
.
quarter
+
10
)],
[
"Fuerza DE"
,
new
Vector
(
Pos
.
three_quarters
,
Pos
.
quarter
)],
[
FD
,
new
Vector
(
Pos
.
three_quarters
+
3
,
Pos
.
quarter
+
10
)],
[
"Res.Rodadura DE"
,
new
Vector
(
Pos
.
three_quarters
,
Pos
.
middle
)],
[
RD
,
new
Vector
(
Pos
.
three_quarters
+
3
,
Pos
.
middle
+
10
)],
[
"Ovalidad DE"
,
new
Vector
(
Pos
.
three_quarters
,
Pos
.
three_quarters
)],
[
OD
,
new
Vector
(
Pos
.
three_quarters
+
3
,
Pos
.
three_quarters
+
10
)]
]);
};
let
x
;
x
=
data
[
0
];
table
(
eje1
,
1
,
x
[
"f_izq"
],
x
[
"res_izq"
],
x
[
"ov_izq"
],
x
[
"peso"
],
x
[
"f_der"
],
x
[
"res_der"
],
x
[
"ov_der"
])
x
=
data
[
1
];
table
(
eje2
,
2
,
x
[
"f_izq"
],
x
[
"res_izq"
],
x
[
"ov_izq"
],
x
[
"peso"
],
x
[
"f_der"
],
x
[
"res_der"
],
x
[
"ov_der"
])
x
=
data
[
2
];
table
(
eje3
,
3
,
x
[
"f_izq"
],
x
[
"res_izq"
],
x
[
"ov_izq"
],
x
[
"peso"
],
x
[
"f_der"
],
x
[
"res_der"
],
x
[
"ov_der"
])
x
=
data
[
3
];
table
(
eje4
,
4
,
x
[
"f_izq"
],
x
[
"res_izq"
],
x
[
"ov_izq"
],
x
[
"peso"
],
x
[
"f_der"
],
x
[
"res_der"
],
x
[
"ov_der"
])
return
new
Vector
(
pointer
.
x
,
pointer
.
y
+
60
);
}
function
traseroToPDF
(
pointer
,
data
)
{
A4
.
addChild
(
"trasero"
,
pointer
,
new
Vector
(
Position
.
end
,
9
));
const
trasero
=
A4
.
addChild
(
new
Vector
(
pointer
.
x
+
Pos
.
beg_margin
+
2
,
pointer
.
y
),
new
Vector
(
containerSize
,
9
));
trasero
.
addTexts
([
[
"Diagnóstico de Frenos - Eje Trasero - Frenos de Mano"
,
new
Vector
(
Pos
.
beg
,
Pos
.
third
)],
[
"Fuerza IZ"
,
new
Vector
(
Pos
.
beg_margin
,
Pos
.
two_thirds
)],
[
data
[
'f_izq'
],
new
Vector
(
Pos
.
beg_margin
,
Pos
.
end
)],
[
"Fuerza DE"
,
new
Vector
(
Pos
.
three_quarters
,
Pos
.
two_thirds
)],
[
data
[
'f_der'
],
new
Vector
(
Pos
.
three_quarters
,
Pos
.
end
)],
]);
return
new
Vector
(
pointer
.
x
,
pointer
.
y
+
9
);
}
function
gaseshumosToPDF
(
pointer
,
data
)
{
A4
.
addChild
(
"gaseshumos"
,
pointer
,
new
Vector
(
Position
.
end
,
9
));
const
gaseshumos
=
A4
.
addChild
(
new
Vector
(
pointer
.
x
+
Pos
.
beg_margin
+
2
,
pointer
.
y
),
new
Vector
(
containerSize
,
9
));
gaseshumos
.
addTexts
([
[
"Resultado Analizador de Gases"
,
new
Vector
(
Pos
.
beg
,
Pos
.
third
)],
[
"Resultado Analizador de Humos"
,
new
Vector
(
Pos
.
two_thirds
,
Pos
.
third
)],
[
`CO
${
data
[
'co'
]}
% HC
${
data
[
'hc'
]}
ppm`
,
new
Vector
(
Pos
.
beg
,
Pos
.
two_thirds
)],
[
`Medición
${
data
[
'med'
]}
`
,
new
Vector
(
Pos
.
three_quarters
,
Pos
.
two_thirds
)]
]);
return
new
Vector
(
pointer
.
x
,
pointer
.
y
+
9
);
}
function
compile
(
tree
,
pdf
)
{
pdf
.
setFont
(
"Courier"
);
pdf
.
setFontType
(
"normal"
);
pdf
.
setFontSize
(
10
);
tree
.
children
.
forEach
(
child
=>
{
switch
(
child
.
constructor
.
name
)
{
case
"Text"
:
pdf
.
text
(
child
.
text
,
child
.
position
.
x
,
child
.
position
.
y
);
break
;
case
"Div"
:
if
(
child
.
drawOutline
)
{
child
.
drawDivBox
(
pdf
);
}
compile
(
child
,
pdf
);
break
;
}
});
return
pdf
;
}
\ No newline at end of file
static/src/div.js
View file @
2c13870
...
...
@@ -49,10 +49,12 @@ class Div {
* Both arguments should be real coordinates and not a percentage based on parent element
* @param {Vector} position
* @param {Vector} size
* @param {bool} draw
*/
constructor
(
position
,
size
)
{
constructor
(
position
,
size
,
draw
=
false
)
{
this
.
position
=
position
;
this
.
size
=
size
;
this
.
drawOutline
=
draw
;
this
.
children
=
[];
}
...
...
@@ -80,7 +82,20 @@ class Div {
if
(
position
.
y
<
0
||
position
.
y
>
100
)
console
.
error
(
"position.y has to be an int between 0 and 100"
);
this
.
children
.
push
(
new
Text
(
text
,
position
));
this
.
children
.
push
(
new
Text
(
text
,
this
.
getDrawCoordinates
(
position
)
));
}
/**
* Array de arrays de la forma ['texto', VectorPosición]
* @param {array} textArray
*/
addTexts
(
textArray
)
{
textArray
.
forEach
(
args
=>
this
.
addText
(
args
[
0
],
args
[
1
])
);
}
/**
...
...
templates/resultados.html
View file @
2c13870
...
...
@@ -53,16 +53,16 @@
<div
class=
"TableContainer"
>
{% from "functions.html" import frenos %}
{% set freno = data['freno'][0] %}
{% set freno = data['freno
s
'][0] %}
{{ frenos(1,freno['f_izq'],freno['res_izq'],freno['ov_izq'],freno['peso'],freno['f_der'],freno['res_der'],freno['ov_der']) }}
{% set freno = data['freno'][1] %}
{% set freno = data['freno
s
'][1] %}
{{ frenos(2,freno['f_izq'],freno['res_izq'],freno['ov_izq'],freno['peso'],freno['f_der'],freno['res_der'],freno['ov_der']) }}
{% set freno = data['freno'][2] %}
{% set freno = data['freno
s
'][2] %}
{{ frenos(3,freno['f_izq'],freno['res_izq'],freno['ov_izq'],freno['peso'],freno['f_der'],freno['res_der'],freno['ov_der']) }}
{% set freno = data['freno'][3] %}
{% set freno = data['freno
s
'][3] %}
{{ frenos(4,freno['f_izq'],freno['res_izq'],freno['ov_izq'],freno['peso'],freno['f_der'],freno['res_der'],freno['ov_der']) }}
</div>
<!-- Frenos -->
...
...
@@ -81,7 +81,7 @@
<!-- Gases y Humos -->
<div
class=
"TableContainer"
>
{% from "functions.html" import gaseshumos %}
{{ gaseshumos(data['gases
']['co'], data['gases']['hc'], data['
humos']['med']) }}
{{ gaseshumos(data['gases
humos']['co'], data['gaseshumos']['hc'], data['gases
humos']['med']) }}
</div>
<!-- Gases y Humos -->
...
...
@@ -89,7 +89,9 @@
</div>
<div
class=
"PDFButtonContainer"
>
<button
class=
"PDFButton"
onclick=
"compile(generateDivTree( {{ data }} ), new jsPDF('portrait', 'pt', 'a4'))"
>
<button
class=
"PDFButton"
onclick=
"window.open(compile(generateDivTree( {{ data }} ), new jsPDF('portrait', 'pt', 'a4')).output('bloburl'))"
;
>
Convertir a PDF
</button>
</div>
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment