mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-23 00:49:01 +00:00
Merge branch 'Lock/unlock-all-items-on-map' into Moving-the-menu-code-from-the-project-map-component
This commit is contained in:
@ -42,7 +42,9 @@ import { MapLabelToLabelConverter } from '../../cartography/converters/map/map-l
|
||||
import { RecentlyOpenedProjectService } from '../../services/recentlyOpenedProject.service';
|
||||
import { MapLink } from '../../cartography/models/map/map-link';
|
||||
import { MapLinkToLinkConverter } from '../../cartography/converters/map/map-link-to-link-converter';
|
||||
import { MovingEventSource } from '../../cartography/events/moving-event-source';
|
||||
import { LinkWidget } from '../../cartography/widgets/link';
|
||||
import { MapScaleService } from '../../services/mapScale.service';
|
||||
import { NodeCreatedLabelStylesFixer } from './helpers/node-created-label-styles-fixer';
|
||||
import { ProjectMapMenuComponent } from './project-map-menu/project-map-menu.component';
|
||||
|
||||
@ -103,6 +105,8 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
private selectionManager: SelectionManager,
|
||||
private selectionTool: SelectionTool,
|
||||
private recentlyOpenedProjectService: RecentlyOpenedProjectService,
|
||||
private movingEventSource: MovingEventSource,
|
||||
private mapScaleService: MapScaleService,
|
||||
private nodeCreatedLabelStylesFixer: NodeCreatedLabelStylesFixer
|
||||
) {}
|
||||
|
||||
@ -177,6 +181,18 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
this.mapChangeDetectorRef.detectChanges();
|
||||
})
|
||||
);
|
||||
|
||||
this.addKeyboardListeners();
|
||||
}
|
||||
|
||||
addKeyboardListeners() {
|
||||
Mousetrap.bind('ctrl++', (event: Event) => {
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
Mousetrap.bind('ctrl+-', (event: Event) => {
|
||||
event.preventDefault();
|
||||
});;
|
||||
}
|
||||
|
||||
onProjectLoad(project: Project) {
|
||||
@ -301,7 +317,8 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
|
||||
public toggleMovingMode() {
|
||||
this.tools.moving = !this.tools.moving;
|
||||
this.toolsService.movingToolActivation(this.tools.moving);
|
||||
this.movingEventSource.movingModeState.emit(this.tools.moving);
|
||||
|
||||
if (!this.readonly) {
|
||||
this.tools.selection = !this.tools.moving;
|
||||
this.toolsService.selectionToolActivation(this.tools.selection);
|
||||
@ -326,6 +343,43 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
this.isProjectMapMenuVisible = true;
|
||||
}
|
||||
|
||||
zoomIn() {
|
||||
this.mapScaleService.setScale(this.mapScaleService.getScale() + 0.1);
|
||||
}
|
||||
|
||||
zoomOut() {
|
||||
let currentScale = this.mapScaleService.getScale();
|
||||
|
||||
if ((currentScale - 0.1) > 0) {
|
||||
this.mapScaleService.setScale(currentScale - 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
resetZoom() {
|
||||
this.mapScaleService.resetToDefault();
|
||||
}
|
||||
|
||||
public uploadImageFile(event) {
|
||||
this.readImageFile(event.target);
|
||||
}
|
||||
|
||||
private readImageFile(fileInput) {
|
||||
let file: File = fileInput.files[0];
|
||||
let fileReader: FileReader = new FileReader();
|
||||
let imageToUpload = new Image();
|
||||
|
||||
fileReader.onloadend = () => {
|
||||
let image = fileReader.result;
|
||||
let svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"
|
||||
height=\"${imageToUpload.height}\" width=\"${imageToUpload.width}\">\n<image height=\"${imageToUpload.height}\" width=\"${imageToUpload.width}\"
|
||||
xlink:href=\"${image}\"/>\n</svg>`;
|
||||
this.drawingService.add(this.server, this.project.project_id, -(imageToUpload.width/2), -(imageToUpload.height/2), svg).subscribe(() => {});
|
||||
}
|
||||
|
||||
imageToUpload.onload = () => { fileReader.readAsDataURL(file) };
|
||||
imageToUpload.src = window.URL.createObjectURL(file);
|
||||
}
|
||||
|
||||
public ngOnDestroy() {
|
||||
this.drawingsDataSource.clear();
|
||||
this.nodesDataSource.clear();
|
||||
|
Reference in New Issue
Block a user