Skip to content

Commit

Permalink
Merge branch '2.2' into master-3.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	package.json
#	src/app/cartography/components/experimental-map/drawing/drawings/rect/rect.component.html
#	src/app/cartography/converters/map/map-drawing-to-svg-converter.ts
#	src/app/components/preferences/qemu/qemu-vm-template-details/qemu-vm-template-details.component.html
#	src/app/components/project-map/drawings-editors/style-editor/style-editor.component.ts
#	src/app/components/project-map/new-template-dialog/new-template-dialog.component.ts
#	yarn.lock
  • Loading branch information
grossmj committed Aug 2, 2023
2 parents 45d5663 + bfc72c2 commit 93a98f1
Show file tree
Hide file tree
Showing 24 changed files with 181 additions and 26 deletions.
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 = `${mapDrawing.element.stroke_dasharray == '' ? `<rect fill=\"${mapDrawing.element.fill}\" fill-opacity=\"${mapDrawing.element.fill_opacity}\" height=\"${mapDrawing.element.height}\" width=\"${mapDrawing.element.width}\"/>` :`<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}\" stroke-dasharray=\"${mapDrawing.element.stroke_dasharray}\" />`}`;
elem = `${mapDrawing.element.stroke_dasharray == '' ? `<rect fill=\"${mapDrawing.element.fill}\" fill-opacity=\"${mapDrawing.element.fill_opacity}\" height=\"${mapDrawing.element.height}\" width=\"${mapDrawing.element.width}\" rx=\"${mapDrawing.element.rx}\" ry=\"${mapDrawing.element.ry}\" />` :`<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}\" stroke-dasharray=\"${mapDrawing.element.stroke_dasharray}\" rx=\"${mapDrawing.element.rx}\" ry=\"${mapDrawing.element.ry}\" />`}`;
} else if (mapDrawing.element instanceof EllipseElement) {
elem = `${mapDrawing.element.stroke_dasharray == '' ? `<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}\"/>` :`<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}\" stroke-dasharray=\"${mapDrawing.element.stroke_dasharray}\" />`}`;
} 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 @@ -107,14 +107,14 @@ <h1 class="col">IOU device configuration</h1>
<mat-checkbox [(ngModel)]="iouTemplate.l1_keepalives">
Enable layer 1 keepalive messages (non-functional) </mat-checkbox
><br />
<mat-checkbox [(ngModel)]="defaultSettings"> Use default IOU values for memories </mat-checkbox>
<mat-form-field class="form-field" *ngIf="!defaultSettings">
<mat-checkbox [(ngModel)]="iouTemplate.use_default_iou_values"> Use default IOU values for memories </mat-checkbox>
<mat-form-field class="form-field" *ngIf="!iouTemplate.use_default_iou_values">
<input matInput type="number" [(ngModel)]="iouTemplate.ram" placeholder="RAM size" />
<span matSuffix>MB</span>
</mat-form-field>
<mat-form-field class="form-field" *ngIf="!defaultSettings">
<mat-form-field class="form-field" *ngIf="!iouTemplate.use_default_iou_values">
<input matInput type="number" [(ngModel)]="iouTemplate.nvram" placeholder="NVRAM size" />
<span matSuffix>MB</span>
<span matSuffix>KB</span>
</mat-form-field>
</mat-expansion-panel>
<mat-expansion-panel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ <h1 class="col">QEMU VM configuration</h1>
<mat-form-field class="form-field">
<input matInput type="number" [(ngModel)]="qemuTemplate.cpus" placeholder="vCPUs" />
</mat-form-field>

<mat-form-field class="form-field">
<mat-select placeholder="Boot priority" [(ngModel)]="qemuTemplate.boot_priority">
<mat-option *ngFor="let priority of bootPriorities" [value]="priority[1]">
Expand Down Expand Up @@ -200,6 +200,7 @@ <h1 class="col">QEMU VM configuration</h1>
<button mat-button class="configButton" (click)="setCustomAdaptersConfiguratorState(true)">
Configure custom adapters</button
><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 @@ -278,6 +279,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 @@ -69,6 +69,9 @@ export class ConsoleDeviceActionBrowserComponent {
uri = `gns3+vnc://${this.node.console_host}:${this.node.console}?name=${this.node.name}&project_id=${this.node.project_id}&node_id=${this.node.node_id}`;
} else if (this.node.console_type.startsWith('spice')) {
uri = `gns3+spice://${this.node.console_host}:${this.node.console}?name=${this.node.name}&project_id=${this.node.project_id}&node_id=${this.node.node_id}`
} else if (this.node.console_type.startsWith('http')) {
uri = `${this.node.console_type}://${this.node.console_host}:${this.node.console}`
return window.open(uri); // open an http console directly in a new window/tab
} else {
this.toasterService.error('Supported console types are: telnet, vnc, spice and spice+agent.');
}
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,14 +23,32 @@ <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">
<mat-select placeholder="Border style" [ngModelOptions]="{ standalone: true }" [(ngModel)]="element.stroke_dasharray">
<mat-option *ngFor="let type of borderTypes" [value]="type.value"> {{ type.name }} </mat-option>
</mat-select>
</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 @@ -69,6 +69,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 Down Expand Up @@ -105,6 +110,12 @@ export class StyleEditorDialogComponent implements OnInit {
this.drawing.element.stroke_dasharray = this.element.stroke_dasharray;
this.drawing.element.stroke_width = this.element.stroke_width === 0 ? 2 : 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 @@ -125,4 +136,6 @@ export class ElementData {
stroke: string;
stroke_width: number;
stroke_dasharray: string;
rx: number;
ry: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class ImportApplianceComponent implements OnInit {
template.console_auto_start = appliance.iou.console_auto_start;
template.ethernet_adapters = appliance.iou.ethernet_adapters;
template.l1_keepalives = appliance.iou.l1_keepalives;
template.use_default_iou_values = appliance.iou.use_default_iou_values;
template.nvram = appliance.iou.nvram;
template.ram = appliance.iou.ram;
template.serial_adapters = appliance.iou.serial_adapters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy {
location.assign(
`gns3+spice://${node.console_host}:${node.console}?name=${node.name}&project_id=${node.project_id}&node_id=${node.node_id}`
);
} else if (node.console_type.startsWith('http')) {
window.open(`${node.console_type}://${node.console_host}:${node.console}`);
} else {
this.showCommand('Supported console types are: telnet, vnc, spice and spice+agent');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,22 @@ <h1 mat-dialog-title>Add new template</h1>
</ng-container>

<!-- <ng-container matColumnDef="expandedDetail">
<mat-cell *matCellDef="let detail">
<mat-cell *matCellDef="let detail">
The symbol for {{detail.element}}
</mat-cell>
</ng-container> -->

<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>

<!-- <mat-row
<!-- <mat-row
*matRowDef="let row; columns: displayedColumns;"
matRipple
class="element-row"
matRipple
class="element-row"
[class.expanded]="expandedElement == row"
(click)="expandedElement = row">
</mat-row>
<mat-row
<mat-row
*matRowDef="let row; columns: ['expandedDetail']; when: isExpansionDetailRow"
[@detailExpand]="row.element == expandedElement ? 'expanded' : 'collapsed'"
style="overflow: hidden">
Expand Down Expand Up @@ -255,6 +255,70 @@ <h1 mat-dialog-title>Add new template</h1>
</div>
</div>

<div class="list-item-inside" *ngIf="version.images.hdc_disk_image">
<span>
{{ version.images.hdb_disk_image }}
</span>

<div>
<span *ngIf="checkImageFromVersion(version.images.hdc_disk_image)"
><mat-icon matTooltip="Ready to install" matTooltipClass="custom-tooltip">check</mat-icon></span
>
<span *ngIf="!checkImageFromVersion(version.images.hdc_disk_image)"
><mat-icon matTooltip="Missing" matTooltipClass="custom-tooltip">close</mat-icon></span
>

<input
type="file"
class="non-visible"
#file4
(change)="importImage($event, version.images.hdc_disk_image)"
ng2FileSelect
[uploader]="uploaderImage"
/>
<button class="button" mat-raised-button (click)="file4.click()">Import</button>
<button
class="button"
mat-raised-button
(click)="downloadImageFromVersion(version.images.hdc_disk_image)"
>
Download
</button>
</div>
</div>

<div class="list-item-inside" *ngIf="version.images.hdd_disk_image">
<span>
{{ version.images.hdd_disk_image }}
</span>

<div>
<span *ngIf="checkImageFromVersion(version.images.hdd_disk_image)"
><mat-icon matTooltip="Ready to install" matTooltipClass="custom-tooltip">check</mat-icon></span
>
<span *ngIf="!checkImageFromVersion(version.images.hdd_disk_image)"
><mat-icon matTooltip="Missing" matTooltipClass="custom-tooltip">close</mat-icon></span
>

<input
type="file"
class="non-visible"
#file5
(change)="importImage($event, version.images.hdd_disk_image)"
ng2FileSelect
[uploader]="uploaderImage"
/>
<button class="button" mat-raised-button (click)="file5.click()">Import</button>
<button
class="button"
mat-raised-button
(click)="downloadImageFromVersion(version.images.hdd_disk_image)"
>
Download
</button>
</div>
</div>

<div class="list-item-inside" *ngIf="version.images.cdrom_image">
<span>
{{ version.images.cdrom_image}}
Expand All @@ -271,12 +335,12 @@ <h1 mat-dialog-title>Add new template</h1>
<input
type="file"
class="non-visible"
#file4
#file6
(change)="importImage($event, version.images.cdrom_image)"
ng2FileSelect
[uploader]="uploaderImage"
/>
<button class="button" mat-raised-button (click)="file4.click()">Import</button>
<button class="button" mat-raised-button (click)="file6.click()">Import</button>
<button
class="button"
mat-raised-button
Expand Down
Loading

0 comments on commit 93a98f1

Please sign in to comment.