Compare commits
No commits in common. "cf1a3a7eec95ab297edbb37501e1ab4f2e5cb7ac" and "6f45e07feefd5855a9583291189ca647a43f1e92" have entirely different histories.
cf1a3a7eec
...
6f45e07fee
4 changed files with 196 additions and 53 deletions
|
@ -14,8 +14,6 @@ text {
|
||||||
stroke-linecap: butt;
|
stroke-linecap: butt;
|
||||||
stroke-linejoin: miter;
|
stroke-linejoin: miter;
|
||||||
stroke-opacity: 1;
|
stroke-opacity: 1;
|
||||||
transform: translateX(-50%);
|
|
||||||
transform-box: fill-box;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes fadein {
|
@keyframes fadein {
|
||||||
|
|
|
@ -212,19 +212,13 @@ class Editor extends React.Component<IEditorProps> {
|
||||||
throw new Error('[OnPropertyChange] Container model was not found among children of the main container!');
|
throw new Error('[OnPropertyChange] Container model was not found among children of the main container!');
|
||||||
}
|
}
|
||||||
|
|
||||||
let x = 0;
|
|
||||||
const lastChild: IContainerModel | undefined = parent.children.at(-1);
|
|
||||||
if (lastChild !== undefined) {
|
|
||||||
x = lastChild.properties.x + Number(lastChild.properties.width);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the container
|
// Create the container
|
||||||
const newContainer = new ContainerModel(
|
const newContainer = new ContainerModel(
|
||||||
parent,
|
parent,
|
||||||
{
|
{
|
||||||
id: `${type}-${count}`,
|
id: `${type}-${count}`,
|
||||||
parentId: parent.properties.id,
|
parentId: parent.properties.id,
|
||||||
x,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
width: properties?.Width,
|
width: properties?.Width,
|
||||||
height: parent.properties.height,
|
height: parent.properties.height,
|
||||||
|
|
|
@ -43,8 +43,23 @@ const GetSVGLayoutConfiguration = () => {
|
||||||
return {
|
return {
|
||||||
AvailableContainers: [
|
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',
|
Type: 'Chassis',
|
||||||
|
TypeChildContainerDefault: 'Trou',
|
||||||
Width: 500,
|
Width: 500,
|
||||||
|
XPositionReference: 0,
|
||||||
Style: {
|
Style: {
|
||||||
fillOpacity: 0,
|
fillOpacity: 0,
|
||||||
borderWidth: 2,
|
borderWidth: 2,
|
||||||
|
@ -52,25 +67,158 @@ const GetSVGLayoutConfiguration = () => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
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',
|
Type: 'Trou',
|
||||||
Width: 300,
|
TypeChildContainerDefault: 'Remplissage',
|
||||||
Style: {
|
Width: 0,
|
||||||
fillOpacity: 0,
|
XPositionReference: 0
|
||||||
borderWidth: 2,
|
|
||||||
stroke: 'green'
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: 'Montant',
|
BodyColor: '#99C8FF',
|
||||||
Width: 100,
|
BorderColor: '#00FF00',
|
||||||
Style: {
|
BorderWidth: 0,
|
||||||
fillOpacity: 0,
|
ContainerActions: [
|
||||||
borderWidth: 2,
|
{
|
||||||
stroke: 'blue',
|
Action: 'SplitRemplissage',
|
||||||
transform: 'translateX(-50%)',
|
AddingBehavior: 0,
|
||||||
transformOrigin: 'center',
|
CustomLogo: {
|
||||||
transformBox: 'fill-box'
|
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: [
|
AvailableSymbols: [
|
||||||
|
@ -100,8 +248,23 @@ const GetSVGLayoutConfiguration = () => {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
MainContainer: {
|
MainContainer: {
|
||||||
|
BodyColor: null,
|
||||||
|
BorderColor: '#FFFFFF',
|
||||||
|
BorderWidth: 0,
|
||||||
|
ContainerActions: null,
|
||||||
|
ContainerDimensionning: null,
|
||||||
|
DefaultChildrenContainers: null,
|
||||||
Height: 200,
|
Height: 200,
|
||||||
Width: 1000
|
IsPositionFixed: false,
|
||||||
|
IsWidthFixed: false,
|
||||||
|
MaxHeight: 0,
|
||||||
|
MaxWidth: 0,
|
||||||
|
MinHeight: 0,
|
||||||
|
MinWidth: 0,
|
||||||
|
Type: 'Trou',
|
||||||
|
TypeChildContainerDefault: null,
|
||||||
|
Width: 1000,
|
||||||
|
XPositionReference: 0
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,32 +2,18 @@ import http from 'http';
|
||||||
const host = 'localhost';
|
const host = 'localhost';
|
||||||
const port = 5000;
|
const port = 5000;
|
||||||
|
|
||||||
const requestListener = async(request, response) => {
|
const requestListener = function(request, response) {
|
||||||
response.setHeader('Access-Control-Allow-Origin', '*');
|
|
||||||
response.setHeader('Access-Control-Allow-Headers', '*');
|
|
||||||
response.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
|
|
||||||
if (request.method === 'POST') {
|
if (request.method === 'POST') {
|
||||||
|
response.setHeader('Access-Control-Allow-Origin', '*');
|
||||||
response.setHeader('Content-Type', 'application/json');
|
response.setHeader('Content-Type', 'application/json');
|
||||||
const url = request.url;
|
const url = request.url;
|
||||||
let json;
|
let json;
|
||||||
if (url === '/ApplicationState') {
|
if (url === '/GetSVGLayoutConfiguration') {
|
||||||
const buffers = [];
|
json = GetSVGLayoutConfiguration();
|
||||||
for await (const chunk of request) {
|
} else if (url === '/FillHoleWithChassis') {
|
||||||
buffers.push(chunk);
|
json = FillHoleWithChassis(request);
|
||||||
}
|
} else if (url === '/SplitRemplissage') {
|
||||||
const data = Buffer.concat(buffers).toString();
|
json = SplitRemplissage(request);
|
||||||
const bodyParsed = JSON.parse(data);
|
|
||||||
console.log(bodyParsed);
|
|
||||||
switch (bodyParsed.Action) {
|
|
||||||
case 'FillHoleWithChassis':
|
|
||||||
json = FillHoleWithChassis(bodyParsed);
|
|
||||||
break;
|
|
||||||
case 'SplitRemplissage':
|
|
||||||
json = SplitRemplissage(bodyParsed);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// TODO: Return 404 rather than this
|
// TODO: Return 404 rather than this
|
||||||
json = GetSVGLayoutConfiguration();
|
json = GetSVGLayoutConfiguration();
|
||||||
|
@ -35,6 +21,8 @@ const requestListener = async(request, response) => {
|
||||||
response.writeHead(200);
|
response.writeHead(200);
|
||||||
return response.end(JSON.stringify(json));
|
return response.end(JSON.stringify(json));
|
||||||
} else if (request.method === 'OPTIONS') {
|
} 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);
|
response.writeHead(200);
|
||||||
return response.end();
|
return response.end();
|
||||||
}
|
}
|
||||||
|
@ -281,18 +269,18 @@ const GetSVGLayoutConfiguration = () => {
|
||||||
|
|
||||||
const FillHoleWithChassis = (request) => {
|
const FillHoleWithChassis = (request) => {
|
||||||
const maxWidthChassis = 3000;
|
const maxWidthChassis = 3000;
|
||||||
const nbChassis = Math.ceil(request.ContainerAction.Width / maxWidthChassis);
|
const nbChassis = Math.ceil(request.ContainerActions.Width / maxWidthChassis);
|
||||||
const lstModels = [];
|
const lstModels = [];
|
||||||
for (let i = 0; i <= nbChassis; i++) {
|
for (let i = 0; i <= nbChassis; i++) {
|
||||||
if (i === 1 && request.ContainerAction.ExistOnBefore) {
|
if (i === 1 && request.ContainerAction.ExistOnBefore) {
|
||||||
lstModels.push({ Type: 'Dilatation' });
|
lstModels.Add({ Type: 'Dilatation' });
|
||||||
}
|
}
|
||||||
lstModels.push({ Type: 'Chassis' });
|
lstModels.Add({ Type: 'Chassis' });
|
||||||
if (i < nbChassis) {
|
if (i < nbChassis) {
|
||||||
lstModels.push({ Type: 'Dilatation' });
|
lstModels.Add({ Type: 'Dilatation' });
|
||||||
}
|
}
|
||||||
if (i === nbChassis && request.ContainerAction.ExistOnAfter) {
|
if (i === nbChassis && request.ContainerAction.ExistOnAfter) {
|
||||||
lstModels.push({ Type: 'Dilatation' });
|
lstModels.Add({ Type: 'Dilatation' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue