|
|
|
@ -1,11 +1,9 @@
|
|
|
|
|
import { AfterViewInit, ChangeDetectorRef, Component, Input, OnInit, ViewChild } from '@angular/core';
|
|
|
|
|
import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core';
|
|
|
|
|
import { NgxMoveableComponent, OnDragEnd, OnResize, OnResizeEnd } from 'ngx-moveable';
|
|
|
|
|
import { OnDrag } from 'ngx-moveable';
|
|
|
|
|
import { ConfigService } from '../services/config.service';
|
|
|
|
|
import { Rect } from '../models/generated/Rect';
|
|
|
|
|
import { Plan } from '../models/plan';
|
|
|
|
|
import { Color } from '../color-picker/color-picker.component';
|
|
|
|
|
import { Subject } from 'rxjs';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'plan-display',
|
|
|
|
@ -13,7 +11,7 @@ import { Subject } from 'rxjs';
|
|
|
|
|
styleUrls: ['./plan-display.component.scss']
|
|
|
|
|
})
|
|
|
|
|
export class PlanDisplayComponent implements AfterViewInit {
|
|
|
|
|
@ViewChild('targetRef') targetRef: any;
|
|
|
|
|
@ViewChild('targetRef') targetRef!: ElementRef;
|
|
|
|
|
@Input() plan: boolean = false;
|
|
|
|
|
@Input() backgroundColor?: Color;
|
|
|
|
|
draggable: boolean = true;
|
|
|
|
@ -34,7 +32,14 @@ export class PlanDisplayComponent implements AfterViewInit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngAfterViewInit(): void {
|
|
|
|
|
this.rect = this.configService.config.initialPlanWindowPosition;
|
|
|
|
|
const cfgRect = this.configService.config.initialPlanWindowPosition;
|
|
|
|
|
console.log(window.innerWidth);
|
|
|
|
|
this.rect = {
|
|
|
|
|
x: cfgRect.x * window.innerWidth,
|
|
|
|
|
y: cfgRect.y * window.innerHeight,
|
|
|
|
|
width: cfgRect.width * window.innerWidth,
|
|
|
|
|
height: cfgRect.height * window.innerHeight,
|
|
|
|
|
}
|
|
|
|
|
this.cdr.detectChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -44,7 +49,7 @@ export class PlanDisplayComponent implements AfterViewInit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onDragEnd(e: OnDragEnd) {
|
|
|
|
|
this.configService.config.initialPlanWindowPosition = this.rect!;
|
|
|
|
|
this.saveRect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onResize(e: OnResize) {
|
|
|
|
@ -56,6 +61,16 @@ export class PlanDisplayComponent implements AfterViewInit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onResizeEnd(e: OnResizeEnd) {
|
|
|
|
|
this.configService.config.initialPlanWindowPosition = this.rect!;
|
|
|
|
|
this.saveRect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
saveRect() {
|
|
|
|
|
const toCfgRect = this.rect!;
|
|
|
|
|
this.configService.config.initialPlanWindowPosition = {
|
|
|
|
|
x: toCfgRect.x / window.innerWidth,
|
|
|
|
|
y: toCfgRect.y / window.innerHeight,
|
|
|
|
|
width: toCfgRect.width / window.innerWidth,
|
|
|
|
|
height: toCfgRect.height / window.innerHeight,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|