test-server: Reimplement add whole api example

This commit is contained in:
Siklos 2022-08-01 09:51:49 +02:00
parent 0a7b6e5204
commit 16d88f11b0

View file

@ -6,33 +6,7 @@ serve({
fetch(request) { fetch(request) {
console.log(`${request.method}: ${request.url}`); console.log(`${request.method}: ${request.url}`);
if (request.method === 'POST') { if (request.method === 'POST') {
const json = JSON.stringify( const json = JSON.stringify(getBody());
{
AvailableContainers: [
{
Type: 'Chassis',
BorderColor: '#ff0000',
TypeChildContainerDefault: 'Trou',
BorderWidth: 48,
MinWidth: 500,
MaxWidth: 3000,
Width: 500,
Style: {
fillOpacity: 0,
borderWidth: 2,
stroke: 'red'
}
}
],
AvailableSymbols: [],
MainContainer: {
Type: 'Trou',
BorderColor: '#ffffff',
Height: 300,
Width: 2000
}
}
);
return new Response(json, { return new Response(json, {
status: 200, status: 200,
headers: { headers: {
@ -51,3 +25,96 @@ serve({
}); });
} }
}); });
const getBody = () => {
return {
AvailableContainers: [
{
Type: 'Chassis',
BorderColor: '#ff0000',
TypeChildContainerDefault: 'Trou',
BorderWidth: 48,
MinWidth: 500,
MaxWidth: 3000,
Width: 500,
Style: {
fillOpacity: 0,
borderWidth: 2,
stroke: 'red'
}
},
{
Type: 'Trou',
BorderColor: '#FFFFFF',
TypeChildContainerDefault: 'Remplissage'
},
{
Type: 'Remplissage',
BodyColor: '#99C8FF',
BorderColor: '#00FF00',
ContainerDimensionning: {
DimensionningStyle: 1
},
ContainerActions: [
{
Action: 'SplitRemplissage',
Label: 'Diviser le remplissage',
Description: 'Diviser le remplissage en insérant un montant',
CustomLogo: {
Url: ''
}
}
]
},
{
Type: 'Montant',
BorderColor: '#FFA947',
BodyColor: '#FFA947',
Width: 50,
XPositionReference: 1
},
{
Type: 'Ouverture',
BorderColor: '#FF6DE6',
BodyColor: '#FFA3D1',
ContainerDimensionning: { ShowDimensionning: false }
},
{
Type: 'Dilatation',
BodyColor: '#000000',
Width: 8,
ContainerDimensionning: { ShowLabel: false }
},
{
Type: '',
BorderColor: '#54616c',
BodyColor: '#dee2e4',
ContainerActions: [{
ContainerActions: {
Action: 'FillHoleWithChassis',
Label: 'Calepiner',
Description: 'Remplir le trou avec des châssis',
CustomLogo: { Url: '' },
AddingBehavior: 0
}
}]
}
],
AvailableSymbols: [
{
Name: 'Poteau structure',
Image: { Url: 'https://www.manutan.fr/img/S/GRP/ST/AIG3930272.jpg' }
},
{
Name: 'Joint de structure',
Image: { Url: 'https://e7.pngegg.com/pngimages/647/127/png-clipart-svg-working-group-information-world-wide-web-internet-structure.png' }
}
],
MainContainer: {
Type: 'Trou',
BorderColor: '#ffffff',
Height: 300,
Width: 2000
}
};
};