Merge branch '2.2' into master-3.0

# 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
This commit is contained in:
grossmj 2023-08-02 18:39:15 +10:00
commit 93a98f1335
24 changed files with 181 additions and 26 deletions

View File

@ -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"
/>

Before

Width:  |  Height:  |  Size: 303 B

After

Width:  |  Height:  |  Size: 349 B

View File

@ -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) {

View File

@ -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;
}
}

View File

@ -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');
@ -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', () => {
@ -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();
});
});

View File

@ -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;
}
}

View File

@ -8,4 +8,6 @@ export class RectElement implements DrawingElement {
stroke: string;
stroke_width: number;
stroke_dasharray: string;
rx: number;
ry: number;
}

View File

@ -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]);
@ -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');
});
});

View File

@ -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();
}

View File

@ -107,14 +107,14 @@
<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>

View File

@ -200,6 +200,7 @@
<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>
@ -278,6 +279,8 @@
<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>

View File

@ -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.');
}

View File

@ -2,7 +2,7 @@
<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 }"
@ -23,7 +23,13 @@
</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">
@ -31,6 +37,18 @@
</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>

View File

@ -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);
@ -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;
@ -125,4 +136,6 @@ export class ElementData {
stroke: string;
stroke_width: number;
stroke_dasharray: string;
rx: number;
ry: number;
}

View File

@ -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;

View File

@ -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');
}

View File

@ -255,6 +255,70 @@
</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}}
@ -271,12 +335,12 @@
<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

View File

@ -488,7 +488,7 @@ export class NewTemplateDialogComponent implements OnInit {
iouTemplate.startup_config = this.applianceToInstall.iou.startup_config;
iouTemplate.builtin = this.applianceToInstall.builtin;
iouTemplate.category = this.getCategory();
iouTemplate.default_name_format = this.applianceToInstall.port_name_format;
iouTemplate.default_name_format = this.applianceToInstall.default_name_format;
iouTemplate.symbol = this.applianceToInstall.symbol;
iouTemplate.compute_id = 'local';
iouTemplate.template_id = uuid();
@ -536,7 +536,7 @@ export class NewTemplateDialogComponent implements OnInit {
iosTemplate.slot7 = this.applianceToInstall.dynamips.slot7;
iosTemplate.builtin = this.applianceToInstall.builtin;
iosTemplate.category = this.getCategory();
iosTemplate.default_name_format = this.applianceToInstall.port_name_format;
iosTemplate.default_name_format = this.applianceToInstall.default_name_format;
iosTemplate.symbol = this.applianceToInstall.symbol;
iosTemplate.compute_id = 'local';
iosTemplate.template_id = uuid();
@ -574,7 +574,7 @@ export class NewTemplateDialogComponent implements OnInit {
dockerTemplate.console_type = this.applianceToInstall.docker.console_type;
dockerTemplate.builtin = this.applianceToInstall.builtin;
dockerTemplate.category = this.getCategory();
dockerTemplate.default_name_format = this.applianceToInstall.port_name_format;
dockerTemplate.default_name_format = this.applianceToInstall.default_name_format;
dockerTemplate.symbol = this.applianceToInstall.symbol;
dockerTemplate.compute_id = 'local';
dockerTemplate.template_id = uuid();
@ -626,11 +626,16 @@ export class NewTemplateDialogComponent implements OnInit {
qemuTemplate.category = this.getCategory();
qemuTemplate.first_port_name = this.applianceToInstall.first_port_name;
qemuTemplate.port_name_format = this.applianceToInstall.port_name_format;
qemuTemplate.port_segment_size = this.applianceToInstall.port_segment_size;
qemuTemplate.default_name_format = this.applianceToInstall.default_name_format
qemuTemplate.symbol = this.applianceToInstall.symbol;
qemuTemplate.compute_id = 'local';
qemuTemplate.template_id = uuid();
qemuTemplate.hda_disk_image = version.images.hda_disk_image;
qemuTemplate.hdb_disk_image = version.images.hdb_disk_image;
qemuTemplate.hdc_disk_image = version.images.hdc_disk_image;
qemuTemplate.hdd_disk_image = version.images.hdd_disk_image;
qemuTemplate.cdrom_image = version.images.cdrom_image;
qemuTemplate.template_type = 'qemu';
qemuTemplate.usage = this.applianceToInstall.usage;
qemuTemplate.platform = this.applianceToInstall.qemu.arch;

View File

@ -20,13 +20,14 @@
</mat-select>
</mat-form-field>
<mat-checkbox [(ngModel)]="node.console_auto_start"> Auto start console </mat-checkbox><br />
<mat-form-field class="form-field">
<mat-checkbox [(ngModel)]="node.properties.use_default_iou_values"> Use default IOU values for memories </mat-checkbox>
<mat-form-field class="form-field" *ngIf="!node.properties.use_default_iou_values">
<input matInput type="number" [(ngModel)]="node.properties.ram" placeholder="RAM size" />
<span matSuffix>MB</span>
</mat-form-field>
<mat-form-field class="form-field">
<mat-form-field class="form-field" *ngIf="!node.properties.use_default_iou_values">
<input matInput type="number" [(ngModel)]="node.properties.nvram" placeholder="NVRAM size" />
<span matSuffix>MB</span>
<span matSuffix>KB</span>
</mat-form-field>
</mat-tab>
@ -38,7 +39,7 @@
matInput
formControlName="ethernetAdapters"
type="number"
[(ngModel)]="node.ethernet_adapters"
[(ngModel)]="node.properties.ethernet_adapters"
placeholder="Ethernet adapters"
/>
</mat-form-field>
@ -47,7 +48,7 @@
matInput
formControlName="serialAdapters"
type="number"
[(ngModel)]="node.serial_adapters"
[(ngModel)]="node.properties.serial_adapters"
placeholder="Serial adapters"
/>
</mat-form-field>

View File

@ -61,7 +61,7 @@
{{ node.name }}
</div>
<div *ngIf="node.console != null && node.console != undefined && node.console_type != 'none'">
{{ node.console_type }} {{ node.console_host }}:{{ node.console }}
{{ node.console_type }}://{{ node.console_host }}:{{ node.console }}
</div>
<div *ngIf="node.console === null || node.console === undefined || node.console_type === 'none'">
none

View File

@ -56,6 +56,9 @@ export interface Iou {
export interface Images {
hda_disk_image: string;
hdb_disk_image: string;
hdc_disk_image: string;
hdd_disk_image: string;
cdrom_image: string;
}
export interface Version {
@ -75,11 +78,13 @@ export interface Appliance {
maintainer_email: string;
name: string;
port_name_format: string;
port_segment_size: number;
product_name: string;
product_url: string;
registry_version: number;
status: string;
symbol: string;
default_name_format: string;
usage: string;
vendor_name: string;
vendor_url: string;

View File

@ -42,4 +42,7 @@ export class QemuTemplate {
template_id: string;
template_type: string;
usage: string;
replicate_network_connection_state: boolean;
tpm: boolean;
uefi: boolean;
}

View File

@ -150,7 +150,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(controller, drawing.project_id, drawing).subscribe();

View File

@ -78,6 +78,9 @@ describe('QemuService', () => {
template_id: '1',
template_type: 'qemu',
usage: '',
replicate_network_connection_state: true,
tpm: false,
uefi: false,
};
service.saveTemplate(controller, template).subscribe();
@ -130,6 +133,9 @@ describe('QemuService', () => {
template_id: '',
template_type: 'qemu',
usage: '',
replicate_network_connection_state: true,
tpm: false,
uefi: false,
};
service.addTemplate(controller, template).subscribe();

View File

@ -58,6 +58,9 @@ export class TemplateMocksService {
template_id: '',
template_type: 'qemu',
usage: '',
replicate_network_connection_state: true,
tpm: false,
uefi: false,
};
return of(template);