Update node-http.js

This commit is contained in:
Eric NGUYEN 2022-09-21 16:12:27 +02:00
parent 54d0504c90
commit 1af5b45dbb

View file

@ -28,8 +28,23 @@ const requestListener = async(request, response) => {
default:
break;
}
} else if (url === '/GetFeedback') {
const buffers = [];
for await (const chunk of request) {
buffers.push(chunk);
}
const data = Buffer.concat(buffers).toString();
const bodyParsed = JSON.parse(data);
console.log(bodyParsed);
json = {
messages: [
{
text: `${new Date()}`,
type: 3
}
]
}
} else {
// TODO: Return 404 rather than this
json = GetSVGLayoutConfiguration();
}
response.writeHead(200);
@ -54,32 +69,45 @@ const GetSVGLayoutConfiguration = () => {
AvailableContainers: [
{
Type: 'Chassis',
Width: 500,
DisplayedText: 'Chassis?',
Whitelist: ["Trou"],
MaxWidth: 500,
MinWidth: 200,
Width: 200,
DefaultChildType: 'Trou',
Style: {
fillOpacity: 1,
strokeWidth: 2,
stroke: 'red',
fill: '#d3c9b7',
}
},
ShowSelfDimensions: true,
IsDimensionBorrower: true,
Category: "Stuff"
},
{
Type: 'Trou',
DefaultX: 10,
DefaultY: 10,
Width: 480,
Height: 180,
Blacklist: ["Chassis"],
DefaultX: 0,
DefaultY: 0,
Margin: {
left: 10,
bottom: 10,
top: 10,
right: 10,
},
DefaultChildType: 'Remplissage',
Style: {
fillOpacity: 1,
strokeWidth: 2,
stroke: 'green',
fill: 'white'
}
},
Category: "Stuff"
},
{
Type: 'Remplissage',
Category: "Other stuff",
CustomSVG: `
<rect width="{width}" height="{height}" style="{style}"></rect>
<rect width="{width}" height="{height}" stroke="black" fill-opacity="0"></rect>
@ -87,6 +115,17 @@ const GetSVGLayoutConfiguration = () => {
<line x1="{width}" y1="0" x2="0" y2="{height}" stroke="black" style='{userData.styleLine}'></line>
`
,
Actions: [
{
Action: "SplitRemplissage",
Label: "Diviser le remplissage",
Description: "Diviser le remplissage en insérant un montant",
CustomLogo: {
Url: ""
},
AddingBehavior: 2
}
],
Style: {
fillOpacity: 1,
strokeWidth: 1,
@ -103,17 +142,53 @@ const GetSVGLayoutConfiguration = () => {
Type: 'Montant',
Width: 10,
XPositionReference: 1,
MarkPositionToDimensionBorrower: true,
Style: {
fillOpacity: 0,
strokeWidth: 2,
stroke: '#713f12',
fill: '#713f12',
}
},
{
Type: 'Dilatation',
Width: 4,
XPositionReference: 1,
MarkPositionToDimensionBorrower: true,
Style: {
fillOpacity: 0,
strokeWidth: 2,
stroke: '#713f12',
fill: '#713f12',
}
},
{
Type: '200',
MaxWidth: 500,
MinWidth: 200,
Style: {
fillOpacity: 1,
strokeWidth: 2,
stroke: 'blue',
fill: 'blue',
}
},
{
Type: '400',
MaxWidth: 500,
MinWidth: 400,
Style: {
fillOpacity: 1,
strokeWidth: 2,
stroke: 'red',
fill: 'red',
}
}
],
AvailableSymbols: [
{
Height: 0,
Width: 32,
Height: 32,
Image: {
Base64Image: null,
Name: null,
@ -121,11 +196,11 @@ const GetSVGLayoutConfiguration = () => {
Url: 'https://www.manutan.fr/img/S/GRP/ST/AIG3930272.jpg'
},
Name: 'Poteau structure',
Width: 0,
XPositionReference: 1
},
{
Height: 0,
Width: 32,
Height: 32,
Image: {
Base64Image: null,
Name: null,
@ -133,28 +208,22 @@ const GetSVGLayoutConfiguration = () => {
Url: 'https://e7.pngegg.com/pngimages/647/127/png-clipart-svg-working-group-information-world-wide-web-internet-structure.png'
},
Name: 'Joint de structure',
Width: 0,
XPositionReference: 0
}
],
Categories: [
{
Type: "Stuff",
DisplayedText: "Stuff made here"
},
{
Type: "Other stuff",
DisplayedText: "Stuff not made here"
}
],
MainContainer: {
BodyColor: null,
BorderColor: '#FFFFFF',
BorderWidth: 0,
ContainerActions: null,
ContainerDimensionning: null,
DefaultChildrenContainers: null,
Height: 200,
IsPositionFixed: false,
IsWidthFixed: false,
MaxHeight: 0,
MaxWidth: 0,
MinHeight: 0,
MinWidth: 0,
Type: 'Trou',
TypeChildContainerDefault: null,
Width: 1000,
XPositionReference: 0
Width: 800
}
};
};
@ -176,20 +245,26 @@ const FillHoleWithChassis = (request) => {
}
}
return {
ApplicationState: {
Containers: lstModels
}
};
};
const SplitRemplissage = (request) => {
const lstModels = [
{ Type: 'Remplissage' },
{ Type: 'Montant' },
{ Type: 'Remplissage' }
{
Type: 'Remplissage'
},
{
Type: 'Montant'
},
{
Type: 'Remplissage'
},
];
return {
ApplicationState: { Containers: lstModels }
Containers: lstModels
};
};