Compare commits
No commits in common. "a95e76865c183a846a2b51156b74c11b719859c4" and "b07acdb83dedc479f97c9e43f947c8b6016f07f2" have entirely different histories.
a95e76865c
...
b07acdb83d
4 changed files with 9 additions and 321 deletions
|
@ -7,7 +7,9 @@ steps:
|
||||||
image: node:16
|
image: node:16
|
||||||
commands:
|
commands:
|
||||||
- curl https://bun.sh/install | bash
|
- curl https://bun.sh/install | bash
|
||||||
- node ./test-server/node-http.js &
|
- export BUN_INSTALL="$HOME/.bun"
|
||||||
|
- export PATH="$BUN_INSTALL/bin:$PATH"
|
||||||
|
- bun run ../test-server.js
|
||||||
- npm install
|
- npm install
|
||||||
- npm test
|
- npm test
|
||||||
|
|
||||||
|
@ -20,6 +22,8 @@ steps:
|
||||||
image: node
|
image: node
|
||||||
commands:
|
commands:
|
||||||
- curl https://bun.sh/install | bash
|
- curl https://bun.sh/install | bash
|
||||||
- node ./test-server/node-http.js &
|
- export BUN_INSTALL="$HOME/.bun"
|
||||||
|
- export PATH="$BUN_INSTALL/bin:$PATH"
|
||||||
|
- bun run ../test-server.js
|
||||||
- npm install
|
- npm install
|
||||||
- npm test
|
- npm test
|
15
README.md
15
README.md
|
@ -19,19 +19,6 @@ Run `npm run dev`
|
||||||
|
|
||||||
This program fetch the data structure from others application, allowing it to assemble them later.
|
This program fetch the data structure from others application, allowing it to assemble them later.
|
||||||
|
|
||||||
### With NodeJS
|
|
||||||
|
|
||||||
```bash
|
|
||||||
node run ./test-server/node-http.js
|
|
||||||
```
|
|
||||||
|
|
||||||
The web server will be running at `http://localhost:5000`
|
|
||||||
|
|
||||||
Configure the file `.env.development` with the url
|
|
||||||
|
|
||||||
|
|
||||||
### With bun
|
|
||||||
|
|
||||||
Install `bun`
|
Install `bun`
|
||||||
|
|
||||||
Inside `test-server` folder, run :
|
Inside `test-server` folder, run :
|
||||||
|
@ -40,7 +27,7 @@ Inside `test-server` folder, run :
|
||||||
bun run http.js
|
bun run http.js
|
||||||
```
|
```
|
||||||
|
|
||||||
The web server will be running at `http://localhost:5000`
|
The web server will be running at localhost:5000
|
||||||
|
|
||||||
Configure the file `.env.development` with the url
|
Configure the file `.env.development` with the url
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@ serve({
|
||||||
let json;
|
let json;
|
||||||
if (url.pathname === '/GetSVGLayoutConfiguration') {
|
if (url.pathname === '/GetSVGLayoutConfiguration') {
|
||||||
json = JSON.stringify(GetSVGLayoutConfiguration());
|
json = JSON.stringify(GetSVGLayoutConfiguration());
|
||||||
} else if (url.pathname === '/FillHoleWithChassis') {
|
} else if (url.pathname === 'FillHoleWithChassis') {
|
||||||
json = JSON.stringify(FillHoleWithChassis(request));
|
json = JSON.stringify(FillHoleWithChassis(request));
|
||||||
} else if (url.pathname === '/SplitRemplissage') {
|
} else if (url.pathname === 'SplitRemplissage') {
|
||||||
json = JSON.stringify(SplitRemplissage(request));
|
json = JSON.stringify(SplitRemplissage(request));
|
||||||
} else {
|
} else {
|
||||||
// TODO: Return 404 rather than this
|
// TODO: Return 404 rather than this
|
||||||
|
|
|
@ -1,303 +0,0 @@
|
||||||
import http from 'http';
|
|
||||||
const host = 'localhost';
|
|
||||||
const port = 5000;
|
|
||||||
|
|
||||||
const requestListener = function(request, response) {
|
|
||||||
if (request.method === 'POST') {
|
|
||||||
response.setHeader('Access-Control-Allow-Origin', '*');
|
|
||||||
response.setHeader('Content-Type', 'application/json');
|
|
||||||
const url = request.url;
|
|
||||||
let json;
|
|
||||||
if (url === '/GetSVGLayoutConfiguration') {
|
|
||||||
json = GetSVGLayoutConfiguration();
|
|
||||||
} else if (url === '/FillHoleWithChassis') {
|
|
||||||
json = FillHoleWithChassis(request);
|
|
||||||
} else if (url === '/SplitRemplissage') {
|
|
||||||
json = SplitRemplissage(request);
|
|
||||||
} else {
|
|
||||||
// TODO: Return 404 rather than this
|
|
||||||
json = GetSVGLayoutConfiguration();
|
|
||||||
}
|
|
||||||
response.writeHead(200);
|
|
||||||
return response.end(JSON.stringify(json));
|
|
||||||
} else if (request.method === 'OPTIONS') {
|
|
||||||
response.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
|
|
||||||
response.setHeader('Access-Control-Allow-Headers', '*');
|
|
||||||
response.writeHead(200);
|
|
||||||
return response.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
response.setHeader('Content-Type', 'text/plain');
|
|
||||||
response.writeHead(200);
|
|
||||||
return response.end('Hello world');
|
|
||||||
};
|
|
||||||
|
|
||||||
const server = http.createServer(requestListener);
|
|
||||||
server.listen(port, host, () => {
|
|
||||||
console.log(`Server is running on http://${host}:${port}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
const GetSVGLayoutConfiguration = () => {
|
|
||||||
return {
|
|
||||||
AvailableContainers: [
|
|
||||||
{
|
|
||||||
BodyColor: null,
|
|
||||||
BorderColor: '#ff0000',
|
|
||||||
BorderWidth: 48,
|
|
||||||
ContainerActions: null,
|
|
||||||
ContainerDimensionning: null,
|
|
||||||
DefaultChildrenContainers: null,
|
|
||||||
Height: 0,
|
|
||||||
IsPositionFixed: false,
|
|
||||||
IsWidthFixed: false,
|
|
||||||
MaxHeight: 0,
|
|
||||||
MaxWidth: 3000,
|
|
||||||
MinHeight: 0,
|
|
||||||
MinWidth: 500,
|
|
||||||
Type: 'Chassis',
|
|
||||||
TypeChildContainerDefault: 'Trou',
|
|
||||||
Width: 500,
|
|
||||||
XPositionReference: 0,
|
|
||||||
Style: {
|
|
||||||
fillOpacity: 0,
|
|
||||||
borderWidth: 2,
|
|
||||||
stroke: 'red'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
BodyColor: null,
|
|
||||||
BorderColor: '#FFFFFF',
|
|
||||||
BorderWidth: 0,
|
|
||||||
ContainerActions: null,
|
|
||||||
ContainerDimensionning: null,
|
|
||||||
DefaultChildrenContainers: null,
|
|
||||||
Height: 0,
|
|
||||||
IsPositionFixed: false,
|
|
||||||
IsWidthFixed: false,
|
|
||||||
MaxHeight: 0,
|
|
||||||
MaxWidth: 0,
|
|
||||||
MinHeight: 0,
|
|
||||||
MinWidth: 0,
|
|
||||||
Type: 'Trou',
|
|
||||||
TypeChildContainerDefault: 'Remplissage',
|
|
||||||
Width: 0,
|
|
||||||
XPositionReference: 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
BodyColor: '#99C8FF',
|
|
||||||
BorderColor: '#00FF00',
|
|
||||||
BorderWidth: 0,
|
|
||||||
ContainerActions: [
|
|
||||||
{
|
|
||||||
Action: 'SplitRemplissage',
|
|
||||||
AddingBehavior: 0,
|
|
||||||
CustomLogo: {
|
|
||||||
Base64Image: null,
|
|
||||||
Name: null,
|
|
||||||
Svg: null,
|
|
||||||
Url: ''
|
|
||||||
},
|
|
||||||
Description: 'Diviser le remplissage en insérant un montant',
|
|
||||||
Id: null,
|
|
||||||
Label: 'Diviser le remplissage'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
ContainerDimensionning: {
|
|
||||||
DimensionningStyle: 1,
|
|
||||||
ShowDimensionning: false,
|
|
||||||
ShowLabel: false
|
|
||||||
},
|
|
||||||
DefaultChildrenContainers: null,
|
|
||||||
Height: 0,
|
|
||||||
IsPositionFixed: false,
|
|
||||||
IsWidthFixed: false,
|
|
||||||
MaxHeight: 0,
|
|
||||||
MaxWidth: 0,
|
|
||||||
MinHeight: 0,
|
|
||||||
MinWidth: 0,
|
|
||||||
Type: 'Remplissage',
|
|
||||||
TypeChildContainerDefault: null,
|
|
||||||
Width: 0,
|
|
||||||
XPositionReference: 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
BodyColor: '#FFA947',
|
|
||||||
BorderColor: '#FFA947',
|
|
||||||
BorderWidth: 0,
|
|
||||||
ContainerActions: null,
|
|
||||||
ContainerDimensionning: null,
|
|
||||||
DefaultChildrenContainers: null,
|
|
||||||
Height: 0,
|
|
||||||
IsPositionFixed: false,
|
|
||||||
IsWidthFixed: false,
|
|
||||||
MaxHeight: 0,
|
|
||||||
MaxWidth: 0,
|
|
||||||
MinHeight: 0,
|
|
||||||
MinWidth: 0,
|
|
||||||
Type: 'Montant',
|
|
||||||
TypeChildContainerDefault: null,
|
|
||||||
Width: 50,
|
|
||||||
XPositionReference: 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
BodyColor: '#FFA3D1',
|
|
||||||
BorderColor: '#FF6DE6',
|
|
||||||
BorderWidth: 0,
|
|
||||||
ContainerActions: null,
|
|
||||||
ContainerDimensionning: {
|
|
||||||
DimensionningStyle: 0,
|
|
||||||
ShowDimensionning: false,
|
|
||||||
ShowLabel: false
|
|
||||||
},
|
|
||||||
DefaultChildrenContainers: null,
|
|
||||||
Height: 0,
|
|
||||||
IsPositionFixed: false,
|
|
||||||
IsWidthFixed: false,
|
|
||||||
MaxHeight: 0,
|
|
||||||
MaxWidth: 0,
|
|
||||||
MinHeight: 0,
|
|
||||||
MinWidth: 0,
|
|
||||||
Type: 'Ouverture',
|
|
||||||
TypeChildContainerDefault: null,
|
|
||||||
Width: 0,
|
|
||||||
XPositionReference: 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
BodyColor: '#000000',
|
|
||||||
BorderColor: null,
|
|
||||||
BorderWidth: 0,
|
|
||||||
ContainerActions: null,
|
|
||||||
ContainerDimensionning: {
|
|
||||||
DimensionningStyle: 0,
|
|
||||||
ShowDimensionning: false,
|
|
||||||
ShowLabel: false
|
|
||||||
},
|
|
||||||
DefaultChildrenContainers: null,
|
|
||||||
Height: 0,
|
|
||||||
IsPositionFixed: false,
|
|
||||||
IsWidthFixed: false,
|
|
||||||
MaxHeight: 0,
|
|
||||||
MaxWidth: 0,
|
|
||||||
MinHeight: 0,
|
|
||||||
MinWidth: 0,
|
|
||||||
Type: 'Dilatation',
|
|
||||||
TypeChildContainerDefault: null,
|
|
||||||
Width: 8,
|
|
||||||
XPositionReference: 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
BodyColor: '#dee2e4',
|
|
||||||
BorderColor: '#54616c',
|
|
||||||
BorderWidth: 0,
|
|
||||||
ContainerActions: [
|
|
||||||
{
|
|
||||||
Action: 'FillHoleWithChassis',
|
|
||||||
AddingBehavior: 1,
|
|
||||||
CustomLogo: {
|
|
||||||
Base64Image: null,
|
|
||||||
Name: null,
|
|
||||||
Svg: null,
|
|
||||||
Url: ''
|
|
||||||
},
|
|
||||||
Description: 'Remplir le trou avec des châssis',
|
|
||||||
Id: null,
|
|
||||||
Label: 'Calepiner'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
ContainerDimensionning: null,
|
|
||||||
DefaultChildrenContainers: null,
|
|
||||||
Height: 0,
|
|
||||||
IsPositionFixed: false,
|
|
||||||
IsWidthFixed: false,
|
|
||||||
MaxHeight: 0,
|
|
||||||
MaxWidth: 0,
|
|
||||||
MinHeight: 0,
|
|
||||||
MinWidth: 0,
|
|
||||||
Type: '',
|
|
||||||
TypeChildContainerDefault: null,
|
|
||||||
Width: 0,
|
|
||||||
XPositionReference: 0
|
|
||||||
}
|
|
||||||
],
|
|
||||||
AvailableSymbols: [
|
|
||||||
{
|
|
||||||
Height: 0,
|
|
||||||
Image: {
|
|
||||||
Base64Image: null,
|
|
||||||
Name: null,
|
|
||||||
Svg: null,
|
|
||||||
Url: 'https://www.manutan.fr/img/S/GRP/ST/AIG3930272.jpg'
|
|
||||||
},
|
|
||||||
Name: 'Poteau structure',
|
|
||||||
Width: 0,
|
|
||||||
XPositionReference: 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Height: 0,
|
|
||||||
Image: {
|
|
||||||
Base64Image: null,
|
|
||||||
Name: null,
|
|
||||||
Svg: null,
|
|
||||||
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
|
|
||||||
}
|
|
||||||
],
|
|
||||||
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
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const FillHoleWithChassis = (request) => {
|
|
||||||
const maxWidthChassis = 3000;
|
|
||||||
const nbChassis = Math.ceil(request.ContainerActions.Width / maxWidthChassis);
|
|
||||||
const lstModels = [];
|
|
||||||
for (let i = 0; i <= nbChassis; i++) {
|
|
||||||
if (i === 1 && request.ContainerAction.ExistOnBefore) {
|
|
||||||
lstModels.Add({ Type: 'Dilatation' });
|
|
||||||
}
|
|
||||||
lstModels.Add({ Type: 'Chassis' });
|
|
||||||
if (i < nbChassis) {
|
|
||||||
lstModels.Add({ Type: 'Dilatation' });
|
|
||||||
}
|
|
||||||
if (i === nbChassis && request.ContainerAction.ExistOnAfter) {
|
|
||||||
lstModels.Add({ Type: 'Dilatation' });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
ApplicationState: {
|
|
||||||
Containers: lstModels
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const SplitRemplissage = (request) => {
|
|
||||||
const lstModels = [
|
|
||||||
{ Type: 'Remplissage' },
|
|
||||||
{ Type: 'Montant' },
|
|
||||||
{ Type: 'Remplissage' }
|
|
||||||
];
|
|
||||||
|
|
||||||
return {
|
|
||||||
ApplicationState: { Containers: lstModels }
|
|
||||||
};
|
|
||||||
};
|
|
Loading…
Add table
Add a link
Reference in a new issue