Aw4751 eslint fixes
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
2023-03-06 14:04:14 +01:00
parent 945c641503
commit 6555e68145
78 changed files with 655 additions and 655 deletions

View File

@@ -14,7 +14,7 @@ export class AppMenuComponent implements OnInit {
@Input() user:IUser;
@Input() showMenu:boolean;
public noContent: boolean = true;
public noContent = true;
constructor(private store: Store<appReducers.State>) { }

View File

@@ -29,9 +29,9 @@ import * as appReducers from '../../reducers/app-common.reducer';
export class AppComponent implements OnInit, OnDestroy {
// This will go at the END of your title for example "Home - Angular Universal..." <-- after the dash (-)
private endPageTitle: string = 'Farmmaps';
private endPageTitle = 'Farmmaps';
// If no Title is provided, we'll use a default one before the dash(-)
private defaultPageTitle: string = 'Farmmaps';
private defaultPageTitle = 'Farmmaps';
private routerSub$: Subscription;
private eventSub$: Subscription;
@@ -49,7 +49,7 @@ export class AppComponent implements OnInit, OnDestroy {
public unreadNotifications: Observable<number> = this.store$.select(appReducers.SelectgetUnreadNotifications);
public user: Observable<IUser> = this.store$.select(appReducers.SelectGetUser);
public isPageMode: Observable<boolean> = this.store$.select(appReducers.SelectGetIsPageMode);
@Input() showUploadProgress: boolean = true;
@Input() showUploadProgress = true;
constructor(
@Optional() @Inject(FM_COMMON_STARTPAGE) public startPage: string,
@@ -68,7 +68,7 @@ export class AppComponent implements OnInit, OnDestroy {
getActionFromEvent(event: IEventMessage): Action {
var action: Action = null;
let action: Action = null;
console.debug(`${event.eventType} Event received`);
switch (event.eventType) {
case "ItemChanged": {
@@ -131,7 +131,7 @@ export class AppComponent implements OnInit, OnDestroy {
@HostListener('document:keyup', ['$event'])
onKeyUp(event: KeyboardEvent) {
let x = event.keyCode;
const x = event.keyCode;
if (x === 27) {
this.store$.dispatch(new commonActions.Escape(true, false));
}
@@ -148,8 +148,8 @@ export class AppComponent implements OnInit, OnDestroy {
this.oauthService$.events.subscribe((event) => {
console.debug(event.type);
if (event.type == 'token_error' || event.type == 'silent_refresh_timeout' || event.type == 'logout') {
let e = event as OAuthErrorEvent;
let p = e.params as any;
const e = event as OAuthErrorEvent;
const p = e.params as any;
if (event.type == 'silent_refresh_timeout' || event.type == 'logout' || (p.error && p.error == 'login_required')) {
console.debug("Session expired");
this.router.navigate(['loggedout'], { queryParams: { redirectTo: this.router.url } });
@@ -169,7 +169,7 @@ export class AppComponent implements OnInit, OnDestroy {
}
private InstallRouteEventHandler() {
var other = this;
const other = this;
this.routerSub$ = this.router.events.subscribe(event => {
if (event instanceof RouteConfigLoadStart) {
other.store$.dispatch(new commonActions.StartRouteLoading());
@@ -189,9 +189,9 @@ export class AppComponent implements OnInit, OnDestroy {
}
private InstallEventServiceEventHandler() {
var other = this;
const other = this;
this.eventSub$ = this.eventService$.event.subscribe(event => {
var action = other.getActionFromEvent(event);
const action = other.getActionFromEvent(event);
if (action) other.store$.dispatch(action);
});
}

View File

@@ -12,8 +12,8 @@ export class AvatarComponent implements OnInit {
@Input() user: IUser;
@Input() bgColor: string;
@Input() fgColor: string;
@Input() size: number = 75;
@Input() round: boolean = true;
@Input() size = 75;
@Input() round = true;
@Output() click = new EventEmitter();

View File

@@ -16,16 +16,16 @@ export class EditImageModalComponent implements OnInit {
constructor(private modalService: NgbModal,public imageService:ImageService) { }
isImageLoaded:boolean = false;
isImageLoaded = false;
aspectRatio:number = 4/3;
imageChangedEvent: any = '';
croppedImage: string = '';
croppedImage = '';
endpointUrl:string = null;
imageUrl:string = null;
maxWidth:number = 200;
roundImage:boolean = false;
imageType:string = "jpeg";
saveImage:boolean = true;
maxWidth = 200;
roundImage = false;
imageType = "jpeg";
saveImage = true;
ngOnInit(): void {
}
@@ -59,7 +59,7 @@ export class EditImageModalComponent implements OnInit {
save() {
if(this.croppedImage) {
var blob = this.imageService.dataUrltoBlob(this.croppedImage);
const blob = this.imageService.dataUrltoBlob(this.croppedImage);
if(this.saveImage) {
this.imageService.putImage(this.endpointUrl,blob).subscribe(() => {
this.changed.emit({});

View File

@@ -8,10 +8,10 @@ import { IItem } from '../../models/item';
})
export class GradientSelectComponent implements OnChanges {
public listVisible:boolean = false;
@Input() showLabel:boolean = true;
public listVisible = false;
@Input() showLabel = true;
@Input() gradientItems:IItem[];
@Input() showAdd:boolean = false;
@Input() showAdd = false;
@Input() selectedItem:IItem;
@Output() onSelect:EventEmitter<any> = new EventEmitter<any>();
@Output() onAdd:EventEmitter<MouseEvent> = new EventEmitter<MouseEvent>();
@@ -44,8 +44,8 @@ export class GradientSelectComponent implements OnChanges {
isSelected(item:IItem):boolean {
if(this.selectedItem && this.selectedItem.data && this.selectedItem.data.gradient && item && item.data && item.data.gradient) {
let sid = JSON.stringify(this.selectedItem.data.gradient)+this.selectedItem.name;
let id = JSON.stringify( item.data.gradient) + item.name;
const sid = JSON.stringify(this.selectedItem.data.gradient)+this.selectedItem.name;
const id = JSON.stringify( item.data.gradient) + item.name;
return sid == id;
}
return false;

View File

@@ -19,7 +19,7 @@ export class GradientComponent implements OnInit,OnChanges {
getGradientStyle(item:IItem):any {
if(item.data && item.data.gradient) {
let gradient = item.data.gradient as IGradientstop[];
const gradient = item.data.gradient as IGradientstop[];
return this.gradientService.getGradientStyle(gradient);
}
}
@@ -32,7 +32,7 @@ export class GradientComponent implements OnInit,OnChanges {
ngOnChanges(changes: SimpleChanges) {
if(changes['gradientItem']) {
let gradientItem = changes['gradientItem'].currentValue;
const gradientItem = changes['gradientItem'].currentValue;
if(gradientItem && gradientItem.itemType == "vnd.farmmaps.itemtype.gradient") {
this.gradientStyle = this.getGradientStyle(changes['gradientItem'].currentValue);
this.ref.markForCheck();

View File

@@ -27,6 +27,6 @@ export class HasRoleDirective implements OnInit, OnDestroy{
});
}
ngOnDestroy() {
if (this.sub) {this.sub.unsubscribe() };
if (this.sub) {this.sub.unsubscribe() }
}
}

View File

@@ -15,7 +15,7 @@ export class HelpMenuComponent implements OnInit {
@Input() user:IUser;
@Input() showMenu:boolean;
public noContent: boolean = true;
public noContent = true;
constructor(private store: Store<appReducers.State>) { }

View File

@@ -9,7 +9,7 @@ import * as commonActions from '../../actions/app-common.actions';
styleUrls: ['./menu-background.component.scss'],
})
export class MenuBackgroundComponent implements OnInit {
@Input() visible:boolean = false;
@Input() visible = false;
constructor(private store: Store<appReducers.State>) { }
ngOnInit() { }

View File

@@ -15,7 +15,7 @@ export class NotificationMenuComponent implements OnInit {
@Input() unread:number;
@Input() user:IUser;
@Input() showMenu:boolean;
public noContent: boolean = true;
public noContent = true;
constructor(private store: Store<appReducers.State>) { }

View File

@@ -40,9 +40,9 @@ export class ResumableFileUploadService implements OnDestroy{
}
updatetotalprogress() {
var totalProgress =0;
var n=0;
for(var i =0;i<this.files.length;i++) {
let totalProgress =0;
let n=0;
for(let i =0;i<this.files.length;i++) {
if(!this.files[i].error) {
totalProgress+=this.files[i].progress;
n++;
@@ -53,9 +53,9 @@ export class ResumableFileUploadService implements OnDestroy{
}
handleState(state:UploadState) {
var file =this.files.find((f) => f.identifier == state.uploadId )
const file =this.files.find((f) => f.identifier == state.uploadId )
if(state.status != "cancelled" && !file) {
let file = new File(state);
const file = new File(state);
this.files.push(file);
this.isClosed=false;
this.addedFiles.next(file)
@@ -66,29 +66,29 @@ export class ResumableFileUploadService implements OnDestroy{
this.isUploading = true;
file.progress = (state.progress?state.progress:0);
}
};break;
}break;
case "complete": {
if(file) {
var parts = state.url.split("/");
const parts = state.url.split("/");
file.itemCode = parts[parts.length-1];
file.progress = (state.progress?state.progress:0);
file.success=true;
}
};break;
}break;
case "error": {
if(file) {
file.error=true;
file.errorMessage = state.response as string;
}
};break;
}break;
}
this.updatetotalprogress();
this.refresh.next({});
}
addFiles = (files: any[], event: any, metadata:any) => {
for (let f of files) {
var options:UploadxOptions = {metadata:metadata};
for (const f of files) {
const options:UploadxOptions = {metadata:metadata};
this.uploadService.handleFiles(f,options);
}
}
@@ -99,7 +99,7 @@ export class ResumableFileUploadService implements OnDestroy{
cancelFile = function (file) {
this.uploadService.control({action:'cancel',uploadId:file.identifier});
var index = this.files.indexOf(file, 0);
const index = this.files.indexOf(file, 0);
if (index > -1) {
this.files.splice(index, 1);
}
@@ -109,7 +109,7 @@ export class ResumableFileUploadService implements OnDestroy{
};
doClose = function () {
var toCancel = this.files.filter((f) => !f.success);
const toCancel = this.files.filter((f) => !f.success);
toCancel.forEach(f => {
this.uploadService.control({action:'cancel',uploadId:f.identifier});
});

View File

@@ -11,15 +11,15 @@ export class SidePanelComponent implements OnChanges {
@Input() public visible: boolean;
@Input() public collapsed: boolean;
@Input() public collapsable: boolean;
@Input() public resizeable: boolean = false;
@Input() public left: boolean = false;
@Input() public resizeable = false;
@Input() public left = false;
@Output() onResize: EventEmitter<number> = new EventEmitter<number>();
@ViewChild("resizeGrip") elementView: ElementRef;
public mobile:boolean = true;
private parentHeight:number = 0;
public mobile = true;
private parentHeight = 0;
public top = "100%";
private resizeTop:number=50;
public resizing:boolean=false;
private resizeTop=50;
public resizing=false;
constructor(private element: ElementRef,private ref: ChangeDetectorRef) {
this.collapsable = false;
@@ -27,9 +27,9 @@ export class SidePanelComponent implements OnChanges {
}
checkMobile():boolean {
let size = parseFloat(getComputedStyle(document.documentElement).width);
let rem = parseFloat(getComputedStyle(document.documentElement).fontSize);
let threshold = 40 * rem;
const size = parseFloat(getComputedStyle(document.documentElement).width);
const rem = parseFloat(getComputedStyle(document.documentElement).fontSize);
const threshold = 40 * rem;
return !(size>threshold);
}
@@ -54,7 +54,7 @@ export class SidePanelComponent implements OnChanges {
handleStartGripDrag(event:DragEvent|TouchEvent) {
this.resizing=true;
if(event instanceof DragEvent) {
var crt = new Image();
const crt = new Image();
crt.style.display = "none";
document.body.appendChild(crt);
event.dataTransfer.setDragImage(crt,0,0);
@@ -66,7 +66,7 @@ export class SidePanelComponent implements OnChanges {
}
handleGripDrag(event:DragEvent|TouchEvent) {
var clientY = 0;
let clientY = 0;
if((event instanceof TouchEvent)) {
clientY = (event as TouchEvent).changedTouches[0].clientY;
} else {

View File

@@ -16,8 +16,8 @@ import { AppConfig } from "../../shared/app.config";
export class ThumbnailComponent {
@Input() public item: IListItem;
@Input() public edit: boolean = false;
@Input() public save: boolean = true;
@Input() public edit = false;
@Input() public save = true;
@Output() changed = new EventEmitter();
@ViewChild('thumbnail') el:ElementRef;
@ViewChild('modal') modal:EditImageModalComponent;
@@ -40,7 +40,7 @@ import { AppConfig } from "../../shared/app.config";
getFontSize():string {
if(this.el) {
var h = this.el.nativeElement.offsetHeight - (this.el.nativeElement.offsetHeight / 5 )
const h = this.el.nativeElement.offsetHeight - (this.el.nativeElement.offsetHeight / 5 )
return h + "px";
} else {
return "1em";

View File

@@ -18,55 +18,55 @@ export class TimespanComponent implements OnInit, OnChanges {
unitScales:number[] = [1,1000,1000*60,1000*60*60,1000*60*60*24,1000*60*60*24*7,1000*60*60*24*31,1000*60*60*24*31*3,1000*60*60*24*365.25];
units:string[] = [ 'millisecond','second','minute','hour','day','week','month','quarter','year'];
quarters:string[] = ['KW1','KW2','KW3','KW4'];
unitScale:number = 3;
unitScale = 3;
viewMinDate:Date;
viewMaxDate:Date;
extentMinDate:Date;
extentMaxDate:Date;
cursorDate:Date;
leftGripMove:boolean = false;
rightGripMove:boolean = false;
rangeGripMove:boolean = false;
viewPan:boolean = false;
downX:number = -1;
mouseX: number = -1;
mouseY: number = -1;
leftGripMove = false;
rightGripMove = false;
rangeGripMove = false;
viewPan = false;
downX = -1;
mouseX = -1;
mouseY = -1;
elementWidth:number;
elementHeight:number;
lastOffsetInPixels:number=0;
lastOffsetInPixels=0;
@ViewChild('timeLine', { static: true }) canvasRef;
@ViewChild('popoverStart', { static: true }) public popoverStart:NgbPopover;
@ViewChild('popoverEnd', { static: true }) public popoverEnd:NgbPopover;
@Input() collapsed: boolean = true;
@Input() collapsed = true;
@Input() startDate: Date = new Date(2018,1,3);
@Input() endDate: Date = new Date(2018,1,5);
@Input() unit:string;
@Input() color:string = '#000000';
@Input() background:string = '#ffffff';
@Input() hoverColor:string ='#ffffff';
@Input() hoverBackground:string ='#0000ff';
@Input() lineColor:string='#000000';
@Input() lineWidth:number=1;
@Input() padding:number = 4;
@Input() color = '#000000';
@Input() background = '#ffffff';
@Input() hoverColor ='#ffffff';
@Input() hoverBackground ='#0000ff';
@Input() lineColor='#000000';
@Input() lineWidth=1;
@Input() padding = 4;
@Output() change:EventEmitter<TimeSpan> = new EventEmitter();
public caption:string = "2016/2017";
public marginLeft:number = 100;
public startPopoverLeft:number=110;
public endPopoverLeft:number=120;
public rangeWidth:number =75;
public caption = "2016/2017";
public marginLeft = 100;
public startPopoverLeft=110;
public endPopoverLeft=120;
public rangeWidth =75;
public startCaption={};
public endCaption={};
private ratio:number=1;
private initialized:boolean=false;
private ratio=1;
private initialized=false;
private ctx:CanvasRenderingContext2D;
public posibleUnits:number[] = [];
public height:number = 0;
public lineHeight:number = 0;
public height = 0;
public lineHeight = 0;
constructor(private changeDetectorRef: ChangeDetectorRef,private datePipe: DatePipe) { }
setCanvasSize() {
let canvas = this.canvasRef.nativeElement;
const canvas = this.canvasRef.nativeElement;
this.elementWidth = canvas.offsetWidth;
this.elementHeight = canvas.offsetHeight;
canvas.height = this.elementHeight * this.ratio;
@@ -74,8 +74,8 @@ export class TimespanComponent implements OnInit, OnChanges {
}
getPosibleUnits(scale:number):number[] {
let posibleUnits = [];
for(let u of [3,4,6,8]) {
const posibleUnits = [];
for(const u of [3,4,6,8]) {
if((this.unitScale <=u) )
posibleUnits.push(u);
}
@@ -94,7 +94,7 @@ export class TimespanComponent implements OnInit, OnChanges {
ngOnInit() {
this.ratio = 2;
this.unitScale = this.getUnitScale(this.unit);
let canvas:HTMLCanvasElement = this.canvasRef.nativeElement;
const canvas:HTMLCanvasElement = this.canvasRef.nativeElement;
this.ctx = canvas.getContext('2d');
this.elementWidth = canvas.offsetWidth;
this.elementHeight = canvas.offsetHeight;
@@ -102,13 +102,13 @@ export class TimespanComponent implements OnInit, OnChanges {
this.startDate = new Date(this.startDate.getTime() + this.getUnitDateOffset(this.startDate,this.unitScale,0));
this.endDate = new Date(this.endDate.getTime() + this.getUnitDateOffset(this.endDate,this.unitScale,1));
this.change.emit({startDate:this.startDate,endDate:this.endDate});
let rangeInMilliseconds = this.endDate.getTime() - this.startDate.getTime();
const rangeInMilliseconds = this.endDate.getTime() - this.startDate.getTime();
this.scale = this.getFitScale(rangeInMilliseconds,this.elementWidth);
this.posibleUnits=this.getPosibleUnits(this.scale);
this.height=this.getHeight();
this.lineHeight= this.getLineHeight();
this.setCanvasSize();
let center = (this.startDate.getTime()+this.endDate.getTime())/2;
const center = (this.startDate.getTime()+this.endDate.getTime())/2;
this.viewMinDate = new Date(center - (this.elementWidth/2* this.scale));
this.viewMaxDate = new Date(center + (this.elementWidth/2* this.scale));
this.updateStyle(this.startDate,this.endDate);
@@ -118,8 +118,8 @@ export class TimespanComponent implements OnInit, OnChanges {
this.initialized=true;
}
getStartEndCaption(date:Date,otherDate:Date,unitScale:number,suffix:boolean = false,extended:boolean=true):string {
let showSuffix = false;
getStartEndCaption(date:Date,otherDate:Date,unitScale:number,suffix = false,extended=true):string {
const showSuffix = false;
otherDate=new Date(otherDate.getTime()-1); // fix year edge case
if(unitScale == 3) {
let format="HH:00";
@@ -152,7 +152,7 @@ export class TimespanComponent implements OnInit, OnChanges {
return this.datePipe.transform(date,format);
}
if(unitScale == 7) {
let q = Math.trunc(date.getMonth() /3 );
const q = Math.trunc(date.getMonth() /3 );
return this.quarters[q];
}
if(unitScale == 8) {
@@ -161,17 +161,17 @@ export class TimespanComponent implements OnInit, OnChanges {
return "";
}
getStartCaption(startDate:Date,unitScale:number,suffix:boolean=false,extended:boolean=true):string {
getStartCaption(startDate:Date,unitScale:number,suffix=false,extended=true):string {
return this.getStartEndCaption(new Date(startDate.getTime() + (this.unitScales[unitScale]/2)), this.endDate,unitScale,suffix,extended);
}
getEndCaption(endDate:Date,unitScale:number,suffix:boolean=true):string {
getEndCaption(endDate:Date,unitScale:number,suffix=true):string {
return this.getStartEndCaption(new Date(endDate.getTime() - (this.unitScales[unitScale]/2)),this.startDate, unitScale,suffix);
}
getCaption(startDate:Date,endDate:Date,unitScale:number):string {
let startCaption=this.getStartCaption(startDate,unitScale);
let endCaption=this.getEndCaption(endDate,unitScale);
const startCaption=this.getStartCaption(startDate,unitScale);
const endCaption=this.getEndCaption(endDate,unitScale);
if((endDate.getTime() - startDate.getTime()) < (1.5*this.unitScales[this.unitScale]))
return endCaption;
return `${startCaption}-${endCaption}`;
@@ -186,20 +186,20 @@ export class TimespanComponent implements OnInit, OnChanges {
}
getFitScale(rangeInMilliSeconds:number,elementWidth:number):number {
let width = elementWidth*0.33;
const width = elementWidth*0.33;
return rangeInMilliSeconds/width;
}
getUnitScale(unit:string):number {
if(!unit) return 3; // hour
for(var _i=0;_i<this.units.length;_i++) {
for(let _i=0;_i<this.units.length;_i++) {
if(this.units[_i]==unit.toLowerCase()) return _i;
}
throw new Error(`Invalid unit : {{unit}} `);
}
getUnitDateOffset(date:Date, unitScale:number,tick:number):number {
var offsetDate:Date;
let offsetDate:Date;
if(unitScale==0)
offsetDate = new Date(date.getFullYear(),date.getMonth(),date.getDate() ,date.getHours() ,date.getMinutes(),date.getSeconds(),date.getMilliseconds()+ tick);
if(unitScale==1)
@@ -213,7 +213,7 @@ export class TimespanComponent implements OnInit, OnChanges {
if(unitScale==6)
offsetDate = new Date(date.getFullYear(),date.getMonth()+tick,1,0,0,0,0);
if(unitScale==7) {
var month = (tick * 3);
const month = (tick * 3);
offsetDate = new Date(date.getFullYear(),month,1,0,0,0,0);
}
if(unitScale==8)
@@ -234,12 +234,12 @@ export class TimespanComponent implements OnInit, OnChanges {
}
getNextTick(viewStartDate:Date, tick:number,step:number,unitScale:number):number {
let unitTextWidth = this.getUnitTextWidth(unitScale);
let dateOffset =this.getUnitDateOffset(viewStartDate,unitScale,tick);
let date = new Date(viewStartDate.getTime() + dateOffset);
const unitTextWidth = this.getUnitTextWidth(unitScale);
const dateOffset =this.getUnitDateOffset(viewStartDate,unitScale,tick);
const date = new Date(viewStartDate.getTime() + dateOffset);
let nextTick=tick+step+Math.trunc(step/2);
let nextDateOffset =this.getUnitDateOffset(viewStartDate,unitScale,nextTick);
let nextDate = new Date(viewStartDate.getTime() + nextDateOffset);
const nextDateOffset =this.getUnitDateOffset(viewStartDate,unitScale,nextTick);
const nextDate = new Date(viewStartDate.getTime() + nextDateOffset);
let n=1;
switch(unitScale) {
case 4:n=nextDate.getDate()-1;break;
@@ -247,7 +247,7 @@ export class TimespanComponent implements OnInit, OnChanges {
case 8:n=nextDate.getFullYear();break;
default: n = 1;break;
}
let a = Math.trunc(n / step)*step;
const a = Math.trunc(n / step)*step;
nextTick=nextTick-n+a;
if(nextTick<=tick) return tick+step;
return nextTick;
@@ -262,16 +262,16 @@ export class TimespanComponent implements OnInit, OnChanges {
}
drawUnits(yOffset:number,width:number,viewStartDate:Date,unitScale:number):number {
let oneUnit = (this.getUnitDateOffset(viewStartDate,unitScale,1)- this.getUnitDateOffset(viewStartDate,unitScale,0)) / this.scale;
const oneUnit = (this.getUnitDateOffset(viewStartDate,unitScale,1)- this.getUnitDateOffset(viewStartDate,unitScale,0)) / this.scale;
this.ctx.font=`normal ${this.ratio*10}pt Sans-serif`;
let lineHeight = this.getLineHeight();
const lineHeight = this.getLineHeight();
let dateOffset = this.getUnitDateOffset(viewStartDate,unitScale,0);
let pixelOffset = (dateOffset / this.scale);
let caption = this.getStartCaption(new Date(viewStartDate.getTime()+dateOffset),unitScale,false,false);
let unitTextWidth=this.getUnitTextWidth(unitScale);
const unitTextWidth=this.getUnitTextWidth(unitScale);
this.ctx.beginPath();
this.ctx.strokeStyle=this.lineColor;
let steps=this.getSteps(unitScale);
const steps=this.getSteps(unitScale);
let s=0;
let step=steps[s];
let steppedOneUnit=oneUnit*step;
@@ -283,10 +283,10 @@ export class TimespanComponent implements OnInit, OnChanges {
this.ctx.moveTo(0,yOffset*this.ratio);
this.ctx.lineTo(width*this.ratio,yOffset*this.ratio);
this.ctx.stroke();
var x:number = pixelOffset;
var nextDateOffset = this.getUnitDateOffset(viewStartDate,unitScale,1);
var nextX:number = (nextDateOffset / this.scale);
var n=0;
let x:number = pixelOffset;
let nextDateOffset = this.getUnitDateOffset(viewStartDate,unitScale,1);
let nextX:number = (nextDateOffset / this.scale);
let n=0;
while(x < width) {
this.ctx.fillStyle=this.color;
//mouseover
@@ -320,12 +320,12 @@ export class TimespanComponent implements OnInit, OnChanges {
redraw() {
let yOffset=0;
let canvas = this.canvasRef.nativeElement;
let height = canvas.offsetHeight;
let width = canvas.offsetWidth;
const canvas = this.canvasRef.nativeElement;
const height = canvas.offsetHeight;
const width = canvas.offsetWidth;
this.ctx.lineWidth = this.lineWidth;// *this.ratio;
this.ctx.clearRect(0,0,width *this.ratio,height*this.ratio);
for(let unit of this.posibleUnits) {
for(const unit of this.posibleUnits) {
if(this.unitScale <=unit) yOffset+=this.drawUnits(yOffset,width,this.viewMinDate,unit);
}
}
@@ -335,9 +335,9 @@ export class TimespanComponent implements OnInit, OnChanges {
}
updateStyle(startDate:Date,endDate:Date) {
let rangeInMilliseconds = endDate.getTime() - startDate.getTime();
let range = rangeInMilliseconds / this.scale;
let left = (startDate.getTime() - this.viewMinDate.getTime()) / this.scale;
const rangeInMilliseconds = endDate.getTime() - startDate.getTime();
const range = rangeInMilliseconds / this.scale;
const left = (startDate.getTime() - this.viewMinDate.getTime()) / this.scale;
this.startPopoverLeft=(left-10);
this.endPopoverLeft=(left+range+10);
this.marginLeft = (left - 15);
@@ -348,14 +348,14 @@ export class TimespanComponent implements OnInit, OnChanges {
}
snapToUnit(date:Date,unitScale:number):Date {
var d = new Date(date.getTime() + (this.unitScales[this.unitScale]/2));
var offsetInMilliseconds =this.getUnitDateOffset(d,this.unitScale,0)
const d = new Date(date.getTime() + (this.unitScales[this.unitScale]/2));
const offsetInMilliseconds =this.getUnitDateOffset(d,this.unitScale,0)
return new Date(d.getTime()+offsetInMilliseconds);
}
getEndDate(offsetInPixels:number):Date {
let oneUnit = this.unitScales[this.unitScale];
let offsetInMilliseconds = offsetInPixels * this.scale;
const oneUnit = this.unitScales[this.unitScale];
const offsetInMilliseconds = offsetInPixels * this.scale;
if(this.leftGripMove) {
if(this.startDate.getTime() + offsetInMilliseconds > this.endDate.getTime() - oneUnit) {
return this.snapToUnit(new Date(this.startDate.getTime() + offsetInMilliseconds + oneUnit),this.unitScale);
@@ -367,8 +367,8 @@ export class TimespanComponent implements OnInit, OnChanges {
}
getStartDate(offsetInPixels:number):Date {
let oneUnit = this.unitScales[this.unitScale];
let offsetInMilliseconds = offsetInPixels * this.scale;
const oneUnit = this.unitScales[this.unitScale];
const offsetInMilliseconds = offsetInPixels * this.scale;
if(this.leftGripMove || this.rangeGripMove) {
return this.snapToUnit(new Date(this.startDate.getTime() + offsetInMilliseconds),this.unitScale);
} else if(this.rightGripMove) {
@@ -380,14 +380,14 @@ export class TimespanComponent implements OnInit, OnChanges {
}
updateControl(event:MouseEvent|TouchEvent) {
let offsetInPixels = this.getClientX(event) - this.downX;
const offsetInPixels = this.getClientX(event) - this.downX;
if(this.leftGripMove || this.rightGripMove || this.rangeGripMove) {
let startDate = this.getStartDate(offsetInPixels);
let endDate = this.getEndDate(offsetInPixels);
const startDate = this.getStartDate(offsetInPixels);
const endDate = this.getEndDate(offsetInPixels);
this.updateStyle(startDate,endDate)
this.changeDetectorRef.detectChanges();
} else if(this.viewPan) {
let offsetInMilliseconds = offsetInPixels*this.scale;
const offsetInMilliseconds = offsetInPixels*this.scale;
this.viewMinDate = new Date(this.viewMinDate.getTime()-offsetInMilliseconds);
this.viewMaxDate = new Date(this.viewMaxDate.getTime()-offsetInMilliseconds);
this.updateStyle(this.startDate,this.endDate);
@@ -510,10 +510,10 @@ export class TimespanComponent implements OnInit, OnChanges {
return true;
} else {
nextScale*=1.1;
let canZoom=false;
let oneUnit = (this.getUnitDateOffset(this.viewMinDate,8,1)- this.getUnitDateOffset(this.viewMinDate,8,0)) / nextScale;
let unitTextWidth=this.getUnitTextWidth(8);
let steps=this.getSteps(8);
const canZoom=false;
const oneUnit = (this.getUnitDateOffset(this.viewMinDate,8,1)- this.getUnitDateOffset(this.viewMinDate,8,0)) / nextScale;
const unitTextWidth=this.getUnitTextWidth(8);
const steps=this.getSteps(8);
let s=0;
let step=steps[s];
let steppedOneUnit=oneUnit*step;
@@ -527,7 +527,7 @@ export class TimespanComponent implements OnInit, OnChanges {
handleMouseWheel(event:WheelEvent) {
if(!this.canZoom(this.scale,event.deltaY)) return;
let oldOffsetInMilliseconds = event.clientX * this.scale;
const oldOffsetInMilliseconds = event.clientX * this.scale;
if(event.deltaY>=0)
this.scale*=1.1;
else
@@ -536,8 +536,8 @@ export class TimespanComponent implements OnInit, OnChanges {
this.height=this.getHeight();
this.changeDetectorRef.detectChanges();
this.setCanvasSize();
let newOffsetInMilliseconds = event.clientX * this.scale;
let offsetInMilliseconds = newOffsetInMilliseconds-oldOffsetInMilliseconds;
const newOffsetInMilliseconds = event.clientX * this.scale;
const offsetInMilliseconds = newOffsetInMilliseconds-oldOffsetInMilliseconds;
this.viewMinDate = new Date(this.viewMinDate.getTime()-offsetInMilliseconds);
this.viewMaxDate = new Date(this.viewMaxDate.getTime()-offsetInMilliseconds);
this.updateStyle(this.startDate,this.endDate);