Merge branch 'master' into master-3.0

This commit is contained in:
piotrpekala7 2021-05-25 13:00:19 +02:00
commit d01fcbcfe1
8 changed files with 88 additions and 21 deletions

View File

@ -1,4 +1,4 @@
<button mat-menu-item (click)="delete()">
<button mat-menu-item (click)="confirmDelete()">
<mat-icon>delete</mat-icon>
<span>Delete</span>
</button>

View File

@ -1,4 +1,5 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MatBottomSheetModule } from '@angular/material/bottom-sheet';
import { MatIconModule } from '@angular/material/icon';
import { MatMenuModule } from '@angular/material/menu';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
@ -24,7 +25,7 @@ describe('DeleteActionComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [MatIconModule, MatMenuModule, NoopAnimationsModule],
imports: [MatIconModule, MatMenuModule, NoopAnimationsModule, MatBottomSheetModule],
providers: [
{ provide: NodesDataSource, useClass: NodesDataSource },
{ provide: DrawingsDataSource, useClass: DrawingsDataSource },

View File

@ -1,4 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { MatBottomSheet } from '@angular/material/bottom-sheet';
import { ConfirmationBottomSheetComponent } from 'app/components/projects/confirmation-bottomsheet/confirmation-bottomsheet.component';
import { DrawingsDataSource } from '../../../../../cartography/datasources/drawings-datasource';
import { LinksDataSource } from '../../../../../cartography/datasources/links-datasource';
import { NodesDataSource } from '../../../../../cartography/datasources/nodes-datasource';
@ -26,11 +28,23 @@ export class DeleteActionComponent implements OnInit {
private linksDataSource: LinksDataSource,
private nodeService: NodeService,
private drawingService: DrawingService,
private linkService: LinkService
private linkService: LinkService,
private bottomSheet: MatBottomSheet
) {}
ngOnInit() {}
confirmDelete() {
this.bottomSheet.open(ConfirmationBottomSheetComponent);
let bottomSheetRef = this.bottomSheet._openedBottomSheetRef;
bottomSheetRef.instance.message = 'Do you want to delete all selected objects?';
const bottomSheetSubscription = bottomSheetRef.afterDismissed().subscribe((result: boolean) => {
if (result) {
this.delete();
}
});
}
delete() {
this.nodes.forEach((node) => {
this.nodesDataSource.remove(node);

View File

@ -259,6 +259,38 @@
</button>
</div>
</div>
<div class="list-item-inside" *ngIf="version.images.cdrom_image">
<span>
{{ version.images.cdrom_image}}
</span>
<div>
<span *ngIf="checkImageFromVersion(version.images.cdrom_image)"
><mat-icon matTooltip="Ready to install" matTooltipClass="custom-tooltip">check</mat-icon></span
>
<span *ngIf="!checkImageFromVersion(version.images.cdrom_image)"
><mat-icon matTooltip="Missing" matTooltipClass="custom-tooltip">close</mat-icon></span
>
<input
type="file"
class="non-visible"
#file4
(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)="downloadImageFromVersion(version.images.cdrom_image)"
>
Download
</button>
</div>
</div>
</div>
</div>
</div>

View File

@ -391,16 +391,27 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
Mousetrap.bind('del', (event: Event) => {
event.preventDefault();
const selected = this.selectionManager.getSelected();
this.deleteItems();
});
}
selected
.filter((item) => item instanceof MapNode)
.forEach((item: MapNode) => {
const node = this.mapNodeToNode.convert(item);
this.nodeService.delete(this.server, node).subscribe((data) => {
this.toasterService.success('Node has been deleted');
deleteItems() {
this.bottomSheet.open(ConfirmationBottomSheetComponent);
let bottomSheetRef = this.bottomSheet._openedBottomSheetRef;
bottomSheetRef.instance.message = 'Do you want to delete all selected objects?';
const bottomSheetSubscription = bottomSheetRef.afterDismissed().subscribe((result: boolean) => {
if (result) {
const selected = this.selectionManager.getSelected();
selected
.filter((item) => item instanceof MapNode)
.forEach((item: MapNode) => {
const node = this.mapNodeToNode.convert(item);
this.nodeService.delete(this.server, node).subscribe((data) => {
this.toasterService.success('Node has been deleted');
});
});
});
}
});
}
@ -453,33 +464,33 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
const onLinkContextMenu = this.linkWidget.onContextMenu.subscribe((eventLink: LinkContextMenu) => {
const link = this.mapLinkToLink.convert(eventLink.link);
this.contextMenu.openMenuForListOfElements([], [], [], [link], eventLink.event.pageY, eventLink.event.pageX);
this.contextMenu.openMenuForListOfElements([], [], [], [link], eventLink.event.screenY - 60, eventLink.event.screenX);
});
const onEthernetLinkContextMenu = this.ethernetLinkWidget.onContextMenu.subscribe((eventLink: LinkContextMenu) => {
const link = this.mapLinkToLink.convert(eventLink.link);
this.contextMenu.openMenuForListOfElements([], [], [], [link], eventLink.event.pageY, eventLink.event.pageX);
this.contextMenu.openMenuForListOfElements([], [], [], [link], eventLink.event.screenY - 60, eventLink.event.screenX);
});
const onSerialLinkContextMenu = this.serialLinkWidget.onContextMenu.subscribe((eventLink: LinkContextMenu) => {
const link = this.mapLinkToLink.convert(eventLink.link);
this.contextMenu.openMenuForListOfElements([], [], [], [link], eventLink.event.pageY, eventLink.event.pageX);
this.contextMenu.openMenuForListOfElements([], [], [], [link], eventLink.event.screenY - 60, eventLink.event.screenX);
});
const onNodeContextMenu = this.nodeWidget.onContextMenu.subscribe((eventNode: NodeContextMenu) => {
const node = this.mapNodeToNode.convert(eventNode.node);
this.contextMenu.openMenuForNode(node, eventNode.event.pageY, eventNode.event.pageX);
this.contextMenu.openMenuForNode(node, eventNode.event.screenY - 60, eventNode.event.screenX);
});
const onDrawingContextMenu = this.drawingsWidget.onContextMenu.subscribe((eventDrawing: DrawingContextMenu) => {
const drawing = this.mapDrawingToDrawing.convert(eventDrawing.drawing);
this.contextMenu.openMenuForDrawing(drawing, eventDrawing.event.pageY, eventDrawing.event.pageX);
this.contextMenu.openMenuForDrawing(drawing, eventDrawing.event.screenY - 60, eventDrawing.event.screenX);
});
const onLabelContextMenu = this.labelWidget.onContextMenu.subscribe((eventLabel: LabelContextMenu) => {
const label = this.mapLabelToLabel.convert(eventLabel.label);
const node = this.nodes.find((n) => n.node_id === eventLabel.label.nodeId);
this.contextMenu.openMenuForLabel(label, node, eventLabel.event.pageY, eventLabel.event.pageX);
this.contextMenu.openMenuForLabel(label, node, eventLabel.event.screenY - 60, eventLabel.event.screenX);
});
const onInterfaceLabelContextMenu = this.interfaceLabelWidget.onContextMenu.subscribe(
@ -489,8 +500,8 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
this.contextMenu.openMenuForInterfaceLabel(
linkNode,
link,
eventInterfaceLabel.event.pageY,
eventInterfaceLabel.event.pageX
eventInterfaceLabel.event.screenY - 60,
eventInterfaceLabel.event.screenX
);
}
);
@ -535,6 +546,9 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
return;
}
nodeAddedEvent.x = nodeAddedEvent.x / this.mapScaleService.getScale();
nodeAddedEvent.y = nodeAddedEvent.y / this.mapScaleService.getScale();
this.progressService.activate();
this.nodeService
.createFromTemplate(

View File

@ -1,10 +1,12 @@
.import-button {
height: 40px;
width: 160px;
margin: 20px;
}
.add-button {
height: 40px;
width: 160px;
margin: 20px;
}
@ -13,3 +15,7 @@
margin-left: -470px;
left: 50%;
}
.row {
display: flex;
}

View File

@ -35,7 +35,7 @@
</mat-form-field>
</div>
<div mat-dialog-actions>
<button mat-button (click)="onNoClick()" tabindex="-1" color="accent">No Thanks</button>
<button mat-button (click)="onNoClick()" tabindex="-1" color="accent">Cancel</button>
<button mat-button (click)="onAddClick()" tabindex="2" mat-raised-button color="primary">Add</button>
</div>
</form>

View File

@ -18,6 +18,6 @@
</form>
</div>
<div mat-dialog-actions>
<button mat-button (click)="onNoClick()" tabindex="-1" color="accent">No Thanks</button>
<button mat-button (click)="onNoClick()" tabindex="-1" color="accent">Cancel</button>
<button mat-button (click)="onAddClick()" tabindex="2" mat-raised-button color="primary">Add</button>
</div>