Skip to content

Commit

Permalink
Merge pull request #1458 from GNS3/release-v2.2.42
Browse files Browse the repository at this point in the history
Release v2.2.42
  • Loading branch information
grossmj authored Aug 9, 2023
2 parents de07558 + 662aba4 commit 535649f
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gns3-web-ui",
"version": "2.2.42.dev1",
"version": "2.2.42",
"author": {
"name": "GNS3 Technology Inc.",
"email": "[email protected]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
[attr.stroke-dasharray]="stroke_dasharray"
[attr.width]="rect.width"
[attr.height]="rect.height"
[attr.rx]="rect.rx"
[attr.ry]="rect.ry"
/>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class MapDrawingToSvgConverter implements Converter<MapDrawing, string> {
let elem = ``;

if (mapDrawing.element instanceof RectElement) {
elem = `<rect fill=\"${mapDrawing.element.fill}\" fill-opacity=\"${mapDrawing.element.fill_opacity}\" height=\"${mapDrawing.element.height}\" width=\"${mapDrawing.element.width}\" stroke=\"${mapDrawing.element.stroke}\" stroke-width=\"${mapDrawing.element.stroke_width}\" />`;
elem = `<rect fill=\"${mapDrawing.element.fill}\" fill-opacity=\"${mapDrawing.element.fill_opacity}\" height=\"${mapDrawing.element.height}\" width=\"${mapDrawing.element.width}\" stroke=\"${mapDrawing.element.stroke}\" stroke-width=\"${mapDrawing.element.stroke_width}\" rx=\"${mapDrawing.element.rx}\" ry=\"${mapDrawing.element.ry}\" />`;
} else if (mapDrawing.element instanceof EllipseElement) {
elem = `<ellipse fill=\"${mapDrawing.element.fill}\" fill-opacity=\"${mapDrawing.element.fill_opacity}\" cx=\"${mapDrawing.element.cx}\" cy=\"${mapDrawing.element.cy}\" rx=\"${mapDrawing.element.rx}\" ry=\"${mapDrawing.element.ry}\" stroke=\"${mapDrawing.element.stroke}\" stroke-width=\"${mapDrawing.element.stroke_width}\" />`;
} else if (mapDrawing.element instanceof LineElement) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export class RectangleElementFactory implements DrawingElementFactory {
rectElement.stroke_width = 2;
rectElement.width = 200;
rectElement.height = 100;
rectElement.rx = 0;
rectElement.ry = 0;
return rectElement;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ describe('RectConverter', () => {

element.setAttribute('width', '100px');
element.setAttribute('height', '200px');
element.setAttribute('rx', '0');
element.setAttribute('ry', '0');

const drawing = rectConverter.convert(element);
expect(drawing.fill).toEqual('#ffffff');
Expand All @@ -25,6 +27,8 @@ describe('RectConverter', () => {
expect(drawing.stroke_dasharray).toEqual('5,25,25');
expect(drawing.width).toEqual(100);
expect(drawing.height).toEqual(200);
expect(drawing.rx).toEqual(0);
expect(drawing.ry).toEqual(0);
});

it('should parse with no attributes', () => {
Expand All @@ -37,5 +41,7 @@ describe('RectConverter', () => {
expect(drawing.stroke_dasharray).toBeUndefined();
expect(drawing.width).toBeUndefined();
expect(drawing.height).toBeUndefined();
expect(drawing.rx).toBeUndefined();
expect(drawing.ry).toBeUndefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ export class RectConverter implements SvgConverter {
drawing.height = parseInt(height.value, 10);
}

const rx = element.attributes.getNamedItem('rx');
if (rx) {
drawing.rx = parseInt(rx.value, 0);
}

const ry = element.attributes.getNamedItem('ry');
if (ry) {
drawing.ry = parseInt(ry.value, 0);
}

return drawing;
}
}
2 changes: 2 additions & 0 deletions src/app/cartography/models/drawings/rect-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ export class RectElement implements DrawingElement {
stroke: string;
stroke_width: number;
stroke_dasharray: string;
rx: number;
ry: number;
}
4 changes: 4 additions & 0 deletions src/app/cartography/widgets/drawings/rect-drawing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ describe('RectDrawingWidget', () => {
rect.stroke_dasharray = '5,25,25';
rect.width = 100;
rect.height = 200;
rect.rx = 0;
rect.ry = 0;
drawing.element = rect;

const drawings = svg.canvas.selectAll<SVGGElement, MapDrawing>('g.drawing').data([drawing]);
Expand All @@ -46,5 +48,7 @@ describe('RectDrawingWidget', () => {
expect(rect_element.getAttribute('stroke-dasharray')).toEqual('5,25,25');
expect(rect_element.getAttribute('width')).toEqual('100');
expect(rect_element.getAttribute('height')).toEqual('200');
expect(rect_element.getAttribute('rx')).toEqual('0');
expect(rect_element.getAttribute('ry')).toEqual('0');
});
});
4 changes: 3 additions & 1 deletion src/app/cartography/widgets/drawings/rect-drawing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export class RectDrawingWidget implements DrawingShapeWidget {
.attr('stroke-width', (rect) => rect.stroke_width)
.attr('stroke-dasharray', (rect) => this.qtDasharrayFixer.fix(rect.stroke_dasharray))
.attr('width', (rect) => rect.width)
.attr('height', (rect) => rect.height);
.attr('height', (rect) => rect.height)
.attr('rx', (rect) => rect.rx)
.attr('ry', (rect) => rect.ry);

drawing.exit().remove();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,10 @@ <h1 class="col">QEMU VM configuration</h1>
</mat-form-field>
<button mat-button class="configButton" (click)="setCustomAdaptersConfiguratorState(true)">
Configure custom adapters</button
><br />
<mat-checkbox [(ngModel)]="qemuTemplate.legacy_networking"> Use the legacy networking mode </mat-checkbox>
>
<br /><mat-checkbox [(ngModel)]="qemuTemplate.legacy_networking"> Use the legacy networking mode </mat-checkbox>
<br /><mat-checkbox [(ngModel)]="qemuTemplate.replicate_network_connection_state"> Replicate network connection state </mat-checkbox>

</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel-header>
Expand Down Expand Up @@ -271,6 +273,8 @@ <h1 class="col">QEMU VM configuration</h1>
<input matInput type="text" [(ngModel)]="qemuTemplate.options" placeholder="Options" />
</mat-form-field>
<mat-checkbox [(ngModel)]="qemuTemplate.linked_clone"> Use as a linked base VM </mat-checkbox>
<br /><mat-checkbox [(ngModel)]="qemuTemplate.tpm"> Enable the Trusted Platform Module (TPM)</mat-checkbox>
<br /><mat-checkbox [(ngModel)]="qemuTemplate.uefi"> Enable the UEFI boot mode </mat-checkbox>
</mat-card-content>
</mat-card>
</mat-expansion-panel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ <h1 mat-dialog-title>Style editor</h1>

<div class="modal-form-container">
<form [formGroup]="formGroup">
<mat-form-field class="form-field">
<mat-form-field class="form-field" *ngIf="element.fill !== undefined">
<input
matInput
[ngModelOptions]="{ standalone: true }"
Expand All @@ -23,7 +23,13 @@ <h1 mat-dialog-title>Style editor</h1>
</mat-form-field>

<mat-form-field class="form-field">
<input matInput formControlName="borderWidth" placeholder="Border width" type="number" />
<input
matInput formControlName="borderWidth"
placeholder="Border width"
type="number"
min="0"
max="100"
/>
</mat-form-field>

<mat-form-field class="form-field" *ngIf="element.stroke_dasharray">
Expand All @@ -36,6 +42,18 @@ <h1 mat-dialog-title>Style editor</h1>
/>
</mat-form-field>

<mat-form-field class="form-field" *ngIf="element.rx !== undefined">
<input
matInput
[ngModelOptions]="{ standalone: true }"
placeholder="Corner radius"
type="number"
min="0"
max="100"
[(ngModel)]="element.rx"
/>
</mat-form-field>

<mat-form-field class="form-field">
<input matInput formControlName="rotation" placeholder="Rotation" type="number" />
</mat-form-field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ export class StyleEditorDialogComponent implements OnInit {
this.element.stroke_width = this.drawing.element.stroke_width;
}

if (this.drawing.element instanceof RectElement) {
this.element.rx = this.drawing.element.rx;
this.element.ry = this.drawing.element.ry;
}

if (this.element.stroke_width === undefined) this.element.stroke_width = 0;
this.formGroup.controls['borderWidth'].setValue(this.element.stroke_width);
this.formGroup.controls['rotation'].setValue(this.drawing.rotation);
Expand All @@ -83,6 +88,11 @@ export class StyleEditorDialogComponent implements OnInit {
this.drawing.element.stroke_width = this.element.stroke_width;
}

if (this.drawing.element instanceof RectElement) {
this.drawing.element.rx = this.element.rx;
this.drawing.element.ry = this.element.rx; // set ry with rx because we don't have ry in the form
}

let mapDrawing = this.drawingToMapDrawingConverter.convert(this.drawing);
mapDrawing.element = this.drawing.element;

Expand All @@ -103,4 +113,6 @@ export class ElementData {
stroke: string;
stroke_width: number;
stroke_dasharray: string;
rx: number;
ry: number;
}
3 changes: 3 additions & 0 deletions src/app/models/templates/qemu-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ export class QemuTemplate {
template_id: string;
template_type: string;
usage: string;
replicate_network_connection_state: boolean;
tpm: boolean;
uefi: boolean;
}
2 changes: 1 addition & 1 deletion src/app/services/drawing.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('DrawingService', () => {
drawing.z = 1;
drawing.rotation = 0;
drawing.svg =
'<svg height="100" width="200"><rect fill="#ffffff" fill-opacity="1.0" height="100" stroke="#000000" stroke-width="2" width="200" /></svg>';
'<svg height="100" width="200"><rect fill="#ffffff" fill-opacity="1.0" height="100" stroke="#000000" stroke-width="2" width="200" rx="0" ry="0" /></svg>';

service.duplicate(server, drawing.project_id, drawing).subscribe();

Expand Down
6 changes: 6 additions & 0 deletions src/app/services/qemu.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ describe('QemuService', () => {
template_id: '1',
template_type: 'qemu',
usage: '',
replicate_network_connection_state: true,
tpm: false,
uefi: false,
};

service.saveTemplate(server, template).subscribe();
Expand Down Expand Up @@ -131,6 +134,9 @@ describe('QemuService', () => {
template_id: '',
template_type: 'qemu',
usage: '',
replicate_network_connection_state: true,
tpm: false,
uefi: false,
};

service.addTemplate(server, template).subscribe();
Expand Down
3 changes: 3 additions & 0 deletions src/app/services/template-mocks.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ export class TemplateMocksService {
template_id: '',
template_type: 'qemu',
usage: '',
replicate_network_connection_state: true,
tpm: false,
uefi: false,
};

return of(template);
Expand Down

0 comments on commit 535649f

Please sign in to comment.