Merge branch 'visual-console-refactor' of https://brutus.artica.lan:8081/artica/pandorafms into visual-console-refactor
Former-commit-id: 77a3a34e1803d4a462535af2dc0e174a31e6ff7f
This commit is contained in:
commit
a9b409c21f
|
@ -26,7 +26,7 @@ export type EventsHistoryProps = {
|
||||||
export function eventsHistoryPropsDecoder(
|
export function eventsHistoryPropsDecoder(
|
||||||
data: UnknownObject
|
data: UnknownObject
|
||||||
): EventsHistoryProps | never {
|
): EventsHistoryProps | never {
|
||||||
if (stringIsEmpty(data.html) || stringIsEmpty(data.encodedHtml)) {
|
if (stringIsEmpty(data.html) && stringIsEmpty(data.encodedHtml)) {
|
||||||
throw new TypeError("missing html content.");
|
throw new TypeError("missing html content.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,6 @@ interface LineProps extends ItemProps {
|
||||||
* is missing from the raw object or have an invalid type.
|
* is missing from the raw object or have an invalid type.
|
||||||
*/
|
*/
|
||||||
export function linePropsDecoder(data: UnknownObject): LineProps | never {
|
export function linePropsDecoder(data: UnknownObject): LineProps | never {
|
||||||
const lineWidth = parseIntOr(data.lineWidth, 0);
|
|
||||||
|
|
||||||
const props: LineProps = {
|
const props: LineProps = {
|
||||||
...itemBasePropsDecoder({ ...data, width: 1, height: 1 }), // Object spread. It will merge the properties of the two objects.
|
...itemBasePropsDecoder({ ...data, width: 1, height: 1 }), // Object spread. It will merge the properties of the two objects.
|
||||||
type: ItemType.LINE_ITEM,
|
type: ItemType.LINE_ITEM,
|
||||||
|
@ -49,7 +47,7 @@ export function linePropsDecoder(data: UnknownObject): LineProps | never {
|
||||||
x: parseIntOr(data.endX, 0),
|
x: parseIntOr(data.endX, 0),
|
||||||
y: parseIntOr(data.endY, 0)
|
y: parseIntOr(data.endY, 0)
|
||||||
},
|
},
|
||||||
lineWidth: lineWidth > 0 ? lineWidth : 1,
|
lineWidth: parseIntOr(data.lineWidth || data.borderWidth, 1),
|
||||||
color: notEmptyStringOr(data.borderColor || data.color, null)
|
color: notEmptyStringOr(data.borderColor || data.color, null)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -99,16 +97,33 @@ export default class Line extends Item<LineProps> {
|
||||||
// SVG container.
|
// SVG container.
|
||||||
const svg = document.createElementNS(svgNS, "svg");
|
const svg = document.createElementNS(svgNS, "svg");
|
||||||
// Set SVG size.
|
// Set SVG size.
|
||||||
svg.setAttribute("width", this.props.width.toString());
|
svg.setAttribute(
|
||||||
svg.setAttribute("height", this.props.height.toString());
|
"width",
|
||||||
|
(this.props.width + this.props.lineWidth).toString()
|
||||||
|
);
|
||||||
|
svg.setAttribute(
|
||||||
|
"height",
|
||||||
|
(this.props.height + this.props.lineWidth).toString()
|
||||||
|
);
|
||||||
const line = document.createElementNS(svgNS, "line");
|
const line = document.createElementNS(svgNS, "line");
|
||||||
line.setAttribute("x1", `${this.props.startPosition.x - this.props.x}`);
|
line.setAttribute(
|
||||||
line.setAttribute("y1", `${this.props.startPosition.y - this.props.y}`);
|
"x1",
|
||||||
line.setAttribute("x2", `${this.props.endPosition.x - this.props.x}`);
|
`${this.props.startPosition.x - this.props.x + this.props.lineWidth / 2}`
|
||||||
line.setAttribute("y2", `${this.props.endPosition.y - this.props.y}`);
|
);
|
||||||
|
line.setAttribute(
|
||||||
|
"y1",
|
||||||
|
`${this.props.startPosition.y - this.props.y + this.props.lineWidth / 2}`
|
||||||
|
);
|
||||||
|
line.setAttribute(
|
||||||
|
"x2",
|
||||||
|
`${this.props.endPosition.x - this.props.x + this.props.lineWidth / 2}`
|
||||||
|
);
|
||||||
|
line.setAttribute(
|
||||||
|
"y2",
|
||||||
|
`${this.props.endPosition.y - this.props.y + this.props.lineWidth / 2}`
|
||||||
|
);
|
||||||
line.setAttribute("stroke", this.props.color || "black");
|
line.setAttribute("stroke", this.props.color || "black");
|
||||||
line.setAttribute("stroke-width", this.props.lineWidth.toString());
|
line.setAttribute("stroke-width", this.props.lineWidth.toString());
|
||||||
line.setAttribute("stroke-linecap", "round");
|
|
||||||
|
|
||||||
svg.append(line);
|
svg.append(line);
|
||||||
element.append(svg);
|
element.append(svg);
|
||||||
|
|
Loading…
Reference in New Issue