AW-6046 Angular improvement
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<div class="app fullscreen" (click)="handleClick($event)" [ngClass]="{'fullscreen' :(fullScreen|async),'pagemode':(isPageMode|async),'appmode':!(isPageMode|async)}">
|
||||
<div class="app fullscreen" (click)="handleClick()" [ngClass]="{'fullscreen' :(fullScreen|async),'pagemode':(isPageMode|async),'appmode':!(isPageMode|async)}">
|
||||
<nav class="navbar navbar-light navbar-expand bg-light navigation-clean">
|
||||
<div class="container-fluid p-3 justify-content-start">
|
||||
<div class="header-logo pageonly"><router-outlet name="header-logo"></router-outlet></div>
|
||||
@@ -20,7 +20,7 @@
|
||||
<div class="container-fluid">
|
||||
<div class="body">
|
||||
<div class="d-flex flex-row">
|
||||
<div class="mt-2 mb-2 flex-grow-1 logo" (click)="handleHome($event)"><router-outlet name="side-panel-logo"></router-outlet></div>
|
||||
<div class="mt-2 mb-2 flex-grow-1 logo" (click)="handleHome()"><router-outlet name="side-panel-logo"></router-outlet></div>
|
||||
<div class="mt-2 mb-2 ms-2"><button type="button" class="btn btn-outline-secondary" (click)="handleToggleMenu($event)"><i class="fal fa-times" aria-hidden="true"></i></button></div>
|
||||
</div>
|
||||
<div class="d-flex flex-column cards">
|
||||
|
@@ -1,21 +1,18 @@
|
||||
import { Component, OnInit, OnDestroy, Inject, Optional, ViewEncapsulation, RendererFactory2, PLATFORM_ID, ChangeDetectionStrategy, HostListener, Input } from '@angular/core';
|
||||
import { Router, NavigationStart, NavigationEnd, RouteConfigLoadStart, RouteConfigLoadEnd, ActivatedRoute, PRIMARY_OUTLET } from '@angular/router';
|
||||
import { Meta, Title, MetaDefinition } from '@angular/platform-browser'; import { DOCUMENT } from "@angular/common";
|
||||
import { Subscription, Observable } from 'rxjs';
|
||||
import { ChangeDetectionStrategy, Component, HostListener, Inject, Input, OnDestroy, OnInit, Optional, ViewEncapsulation } from '@angular/core';
|
||||
import { NavigationEnd, NavigationStart, RouteConfigLoadEnd, RouteConfigLoadStart, Router } from '@angular/router';
|
||||
import { Action, Store } from '@ngrx/store';
|
||||
import { OAuthErrorEvent, OAuthService } from 'angular-oauth2-oidc';
|
||||
import { Observable, Subscription } from 'rxjs';
|
||||
import { distinctUntilChanged } from 'rxjs/operators';
|
||||
import { Store, Action } from '@ngrx/store';
|
||||
import { IUser } from '../../models/user';
|
||||
import { OAuthService, OAuthErrorEvent } from 'angular-oauth2-oidc';
|
||||
import { FM_COMMON_STARTPAGE } from '../../common.module';
|
||||
import { IUser } from '../../models/user';
|
||||
|
||||
//AppCommon
|
||||
import * as commonActions from '../../actions/app-common.actions';
|
||||
import { IEventMessage } from '../../models/event.message';
|
||||
import { IListItem } from '../../models/list.item';
|
||||
import { EventService } from '../../services/event.service';
|
||||
import { ItemTypeService } from '../../services/itemtype.service';
|
||||
import * as commonActions from '../../actions/app-common.actions';
|
||||
import { HealthCheckService } from '../../services/healthcheck.service';
|
||||
import { AppConfig } from '../../shared/app.config';
|
||||
|
||||
import * as appReducers from '../../reducers/app-common.reducer';
|
||||
|
||||
@@ -27,12 +24,6 @@ import * as appReducers from '../../reducers/app-common.reducer';
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
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 = 'Farmmaps';
|
||||
// If no Title is provided, we'll use a default one before the dash(-)
|
||||
private defaultPageTitle = 'Farmmaps';
|
||||
|
||||
private routerSub$: Subscription;
|
||||
private eventSub$: Subscription;
|
||||
|
||||
@@ -54,19 +45,12 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||
constructor(
|
||||
@Optional() @Inject(FM_COMMON_STARTPAGE) public startPage: string,
|
||||
public router: Router,
|
||||
private activatedRoute$: ActivatedRoute,
|
||||
private title$: Title,
|
||||
private meta$: Meta,
|
||||
private store$: Store<appReducers.State>,
|
||||
private eventService$: EventService,
|
||||
private healthCheckService$: HealthCheckService,
|
||||
private itemTypeService$: ItemTypeService,
|
||||
private oauthService$: OAuthService,
|
||||
private appConfig$: AppConfig
|
||||
) {
|
||||
private oauthService$: OAuthService) {
|
||||
}
|
||||
|
||||
|
||||
getActionFromEvent(event: IEventMessage): Action {
|
||||
let action: Action = null;
|
||||
//console.debug(`${event.eventType} Event received`);
|
||||
@@ -163,30 +147,28 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private InstallRouteEventHandler() {
|
||||
const other = this;
|
||||
this.routerSub$ = this.router.events.subscribe(event => {
|
||||
if (event instanceof RouteConfigLoadStart) {
|
||||
other.store$.dispatch(new commonActions.StartRouteLoading());
|
||||
this.store$.dispatch(new commonActions.StartRouteLoading());
|
||||
}
|
||||
if (event instanceof NavigationEnd && (event.url == "/" || event.url.startsWith("/content"))) {
|
||||
other.store$.dispatch(new commonActions.SetPageMode(true));
|
||||
this.store$.dispatch(new commonActions.SetPageMode(true));
|
||||
} else if (event instanceof NavigationEnd) {
|
||||
other.store$.dispatch(new commonActions.SetPageMode(false));
|
||||
this.store$.dispatch(new commonActions.SetPageMode(false));
|
||||
}
|
||||
if (event instanceof RouteConfigLoadEnd) {
|
||||
other.store$.dispatch(new commonActions.EndRouteLoading());
|
||||
this.store$.dispatch(new commonActions.EndRouteLoading());
|
||||
}
|
||||
if (event instanceof NavigationStart) {
|
||||
other.store$.dispatch(new commonActions.SetMenuVisible(false));
|
||||
this.store$.dispatch(new commonActions.SetMenuVisible(false));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private InstallEventServiceEventHandler() {
|
||||
const other = this;
|
||||
this.eventSub$ = this.eventService$.event.subscribe(event => {
|
||||
const action = other.getActionFromEvent(event);
|
||||
if (action) other.store$.dispatch(action);
|
||||
const action = this.getActionFromEvent(event);
|
||||
if (action) this.store$.dispatch(action);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -201,7 +183,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
handleClick(event: MouseEvent) {
|
||||
handleClick() {
|
||||
this.store$.dispatch(new commonActions.Escape(false, true));
|
||||
}
|
||||
|
||||
@@ -214,7 +196,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||
this.store$.dispatch(new commonActions.ToggleMenu());
|
||||
}
|
||||
|
||||
handleHome(event: MouseEvent) {
|
||||
handleHome() {
|
||||
this.router.navigate(['/']);
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { OAuthService } from 'angular-oauth2-oidc';
|
||||
import { Location} from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'fm-auth-callback',
|
||||
@@ -10,11 +9,11 @@ import { Location} from '@angular/common';
|
||||
export class AuthCallbackComponent {
|
||||
|
||||
constructor(private router$: Router,private oauthService$:OAuthService) {
|
||||
oauthService$.loadDiscoveryDocument().then(() => {
|
||||
oauthService$.tryLoginCodeFlow().then(() => {
|
||||
router$.navigateByUrl((oauthService$.state && oauthService$.state!="")?decodeURIComponent(oauthService$.state):"");
|
||||
this.oauthService$.loadDiscoveryDocument().then(() => {
|
||||
this.oauthService$.tryLoginCodeFlow().then(() => {
|
||||
this.router$.navigateByUrl((this.oauthService$.state && this.oauthService$.state!="")?decodeURIComponent(this.oauthService$.state):"");
|
||||
}).catch(() => {
|
||||
router$.navigateByUrl("/");
|
||||
this.router$.navigateByUrl("/");
|
||||
});
|
||||
})
|
||||
}
|
||||
|
@@ -1,8 +1,7 @@
|
||||
import { Component, OnInit,ViewChild,ElementRef,EventEmitter, Output } from '@angular/core';
|
||||
import { HttpClient, HttpParams,HttpHeaders } from "@angular/common/http";
|
||||
import {NgbModal} from "@ng-bootstrap/ng-bootstrap"
|
||||
import { ImageCroppedEvent,LoadedImage } from 'ngx-image-cropper';
|
||||
import {ImageService } from '../../services/image.service';
|
||||
import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core';
|
||||
import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
|
||||
import { ImageCroppedEvent, LoadedImage } from 'ngx-image-cropper';
|
||||
import { ImageService } from '../../services/image.service';
|
||||
|
||||
@Component({
|
||||
selector: 'fm-edit-image-modal',
|
||||
@@ -47,7 +46,8 @@ export class EditImageModalComponent implements OnInit {
|
||||
imageCropped(event: ImageCroppedEvent) {
|
||||
this.croppedImage = event.base64;
|
||||
}
|
||||
imageLoaded(image: LoadedImage) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
imageLoaded(_image: LoadedImage) {
|
||||
this.isImageLoaded=true;
|
||||
}
|
||||
cropperReady() {
|
||||
|
@@ -1,11 +1,8 @@
|
||||
import { Directive, ViewContainerRef,TemplateRef,OnInit,Input,OnDestroy } from '@angular/core';
|
||||
import { Store} from '@ngrx/store';
|
||||
import * as appCommonReducer from '../../reducers/app-common.reducer'
|
||||
import { IPackages } from '../../models/package';
|
||||
import { Observable, Subscription } from 'rxjs';
|
||||
import { skip } from 'rxjs/operators';
|
||||
import {OAuthService } from 'angular-oauth2-oidc';
|
||||
import { Directive, Input, OnInit, TemplateRef, ViewContainerRef } from '@angular/core';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { Observable } from 'rxjs';
|
||||
import { IUser } from '../../models/user';
|
||||
import * as appCommonReducer from '../../reducers/app-common.reducer';
|
||||
|
||||
@Directive({
|
||||
selector: '[fm-hasclaim]',
|
||||
|
@@ -34,8 +34,8 @@ export class HasPackageDirective implements OnDestroy, AfterViewInit {
|
||||
|
||||
constructor(private hostTemplateRef: TemplateRef<any>, private viewContainerRef: ViewContainerRef,
|
||||
private store: Store<appCommonReducer.State>, private packageService: PackageService) {
|
||||
this.thenTemplate = hostTemplateRef;
|
||||
this.packSub = this.store.select(appCommonReducer.SelectGetValidUserPackages).subscribe((_) => {
|
||||
this.thenTemplate = this.hostTemplateRef;
|
||||
this.packSub = this.store.select(appCommonReducer.SelectGetValidUserPackages).subscribe(() => {
|
||||
this.updateView();
|
||||
});
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { Component, OnInit,Input } from '@angular/core';
|
||||
import { Store, Action } from '@ngrx/store';
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { Store } from '@ngrx/store';
|
||||
import * as commonActions from '../../actions/app-common.actions';
|
||||
import * as appReducers from '../../reducers/app-common.reducer';
|
||||
import * as commonActions from '../../actions/app-common.actions';
|
||||
|
||||
@Component({
|
||||
selector: 'fm-menu-background',
|
||||
|
@@ -34,8 +34,8 @@ export class PackageExistsDirective implements OnDestroy, AfterViewInit {
|
||||
|
||||
constructor(private hostTemplateRef: TemplateRef<any>, private viewContainerRef: ViewContainerRef,
|
||||
private store: Store<appCommonReducer.State>, private packageService: PackageService) {
|
||||
this.thenTemplate = hostTemplateRef;
|
||||
this.packSub = this.store.select(appCommonReducer.SelectGetPackages).subscribe((_) => {
|
||||
this.thenTemplate = this.hostTemplateRef;
|
||||
this.packSub = this.store.select(appCommonReducer.SelectGetPackages).subscribe(() => {
|
||||
this.updateView();
|
||||
});
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
import { Component, Input,Output, HostListener, ChangeDetectorRef, OnDestroy, OnInit,EventEmitter } from '@angular/core';
|
||||
import { ResumableFileUploadService, File } from './resumable-file-upload.service';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { ChangeDetectorRef, Component, HostListener, Input, OnDestroy, OnInit } from '@angular/core';
|
||||
import { Store } from '@ngrx/store';
|
||||
import * as commonReducer from '../../reducers/app-common.reducer';
|
||||
import { Subscription } from 'rxjs';
|
||||
import * as commonActions from '../../actions/app-common.actions';
|
||||
import * as commonReducer from '../../reducers/app-common.reducer';
|
||||
import { File, ResumableFileUploadService } from './resumable-file-upload.service';
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -29,7 +29,7 @@ export class ResumableFileUploadComponent implements OnInit, OnDestroy {
|
||||
|
||||
ngOnInit() {
|
||||
this.uploadService.init();
|
||||
this.refreshSub = this.uploadService.refresh.subscribe((e: any) => {
|
||||
this.refreshSub = this.uploadService.refresh.subscribe(() => {
|
||||
this.cd.markForCheck();
|
||||
});
|
||||
}
|
||||
|
@@ -1,8 +1,7 @@
|
||||
import { Injectable, OnDestroy } from '@angular/core';
|
||||
import { OAuthService } from 'angular-oauth2-oidc';
|
||||
import { Subject , Subscription } from 'rxjs';
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { UploadxService, UploadState,UploadxOptions} from 'ngx-uploadx';
|
||||
import { UploadState, UploadxOptions, UploadxService } from 'ngx-uploadx';
|
||||
import { Subject, Subscription } from 'rxjs';
|
||||
import { AppConfig } from '../../shared/app.config';
|
||||
|
||||
|
||||
@@ -19,7 +18,7 @@ export class ResumableFileUploadService implements OnDestroy{
|
||||
private _eventSub:Subscription;
|
||||
private initialized = false;
|
||||
|
||||
constructor(private httpClient: HttpClient,private oauthService: OAuthService,private uploadService: UploadxService,public appConfig: AppConfig) {
|
||||
constructor(private oauthService: OAuthService,private uploadService: UploadxService,public appConfig: AppConfig) {
|
||||
|
||||
}
|
||||
|
||||
@@ -41,11 +40,9 @@ export class ResumableFileUploadService implements OnDestroy{
|
||||
|
||||
updatetotalprogress() {
|
||||
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++;
|
||||
}
|
||||
}
|
||||
this.totalProgress=totalProgress/this.files.length;
|
||||
@@ -86,7 +83,7 @@ export class ResumableFileUploadService implements OnDestroy{
|
||||
this.refresh.next({});
|
||||
}
|
||||
|
||||
addFiles = (files: any[], event: any, metadata:any) => {
|
||||
addFiles = (files: any[], _event: any, metadata:any) => {
|
||||
for (const f of files) {
|
||||
const options:UploadxOptions = {metadata:metadata};
|
||||
this.uploadService.handleFiles(f,options);
|
||||
@@ -133,7 +130,6 @@ export class ResumableFileUploadService implements OnDestroy{
|
||||
}
|
||||
|
||||
export class File {
|
||||
private file: any;
|
||||
public fileName: string;
|
||||
public progress: number;
|
||||
public identifier: string;
|
||||
@@ -142,9 +138,7 @@ export class File {
|
||||
public error: boolean;
|
||||
public errorMessage: string;
|
||||
|
||||
|
||||
constructor(state: UploadState) {
|
||||
this.file = state;
|
||||
this.fileName = state.file.name;
|
||||
this.progress = state.progress?state.progress:0;
|
||||
this.identifier = state.uploadId;
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { Router, ActivatedRoute, ParamMap } from '@angular/router';
|
||||
import { Component } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Store } from '@ngrx/store';
|
||||
import * as appCommonReducers from '../../reducers/app-common.reducer';
|
||||
import * as appCommonActions from '../../actions/app-common.actions';
|
||||
import * as appCommonReducers from '../../reducers/app-common.reducer';
|
||||
|
||||
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<div class="side-panel hidden" [ngClass]="{'hidden':!visible,'collapsed':collapsed,'resizeable':(resizeable && mobile),'resizing':resizing,'left':left,'extrawide':extrawide}" [ngStyle]="{'top':top}">
|
||||
<div *ngIf="collapsable" class="arrow rounded-end p-2" (click)="handleToggleClick($event)">
|
||||
<div *ngIf="collapsable" class="arrow rounded-end p-2" (click)="handleToggleClick()">
|
||||
<i class="fal fa-chevron-left" aria-hidden="true"></i>
|
||||
</div>
|
||||
<div draggable="true" class="resizegrip" (dragstart)="handleStartGripDrag($event)" (touchstart)="handleStartGripDrag($event)" (dragend)="handleEndGripDrag()" (touchend)="handleEndGripDrag()" (drag)="handleGripDrag($event)" (touchmove)="handleGripDrag($event)">
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { Component, Input,Output,ViewChild,EventEmitter, ElementRef,OnChanges,SimpleChanges,HostListener,ChangeDetectorRef, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, ElementRef, EventEmitter, HostListener, Input, OnChanges, Output, SimpleChanges, ViewChild } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'fm-side-panel',
|
||||
@@ -22,7 +22,7 @@ export class SidePanelComponent implements OnChanges {
|
||||
private resizeTop=50;
|
||||
public resizing=false;
|
||||
|
||||
constructor(private element: ElementRef,private ref: ChangeDetectorRef) {
|
||||
constructor(private element: ElementRef) {
|
||||
this.collapsable = false;
|
||||
this.setTop();
|
||||
}
|
||||
@@ -46,7 +46,7 @@ export class SidePanelComponent implements OnChanges {
|
||||
this.setTop();
|
||||
}
|
||||
|
||||
handleToggleClick(event) {
|
||||
handleToggleClick() {
|
||||
if (this.collapsable) {
|
||||
this.collapsed = !this.collapsed;
|
||||
}
|
||||
@@ -85,7 +85,7 @@ export class SidePanelComponent implements OnChanges {
|
||||
}
|
||||
|
||||
@HostListener('window:resize', ['$event'])
|
||||
handleResize(event) {
|
||||
handleResize() {
|
||||
this.setTop();
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<span class="tag rounded bg-primary text-white" *ngFor="let tag of tags;"><span>{{tag}}</span> <i
|
||||
(click)="handleDeleteTag(tag)" class="fal fa-times" aria-hidden="true"></i></span><input
|
||||
type="text" #tagInputElement
|
||||
(blur)="handleBlur($event, false)"
|
||||
(blur)="handleBlur(false)"
|
||||
(keyup)="handleKeyUp($event)"
|
||||
[(ngModel)]="tag"
|
||||
[ngbTypeahead]="findTag"
|
||||
|
@@ -65,7 +65,7 @@ export class TagInputComponent implements ControlValueAccessor {
|
||||
this.propagateChange(tags);
|
||||
}
|
||||
|
||||
handleBlur(event, keepFocus = true) {
|
||||
handleBlur(keepFocus = true) {
|
||||
if (!this.typeahead.isPopupOpen()) {
|
||||
this.addTag(this.tag, keepFocus);
|
||||
} else {
|
||||
@@ -89,6 +89,7 @@ export class TagInputComponent implements ControlValueAccessor {
|
||||
this.tag = '';
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
propagateChange = (_: any) => {
|
||||
};
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<div class="timespan p-1" (window:resize)="handleResize($event)">
|
||||
<div class="timespan p-1" (window:resize)="handleResize()">
|
||||
<div (click)="handleClick()">{{caption}}</div>
|
||||
<ng-template #popoverContent let-caption="popoverCaption">{{caption}}</ng-template>
|
||||
<div class="popover-anchor" [style.left.px] = "startPopoverLeft" [ngbPopover]="popoverContent" #popoverStart="ngbPopover"> </div>
|
||||
@@ -17,13 +17,13 @@
|
||||
<option value="8">Year</option>
|
||||
</select>
|
||||
</div> -->
|
||||
<div class="timeline" (window:mousemove)="handleMouseMove($event)" (window:touchmove)="handleMouseMove($event)" (window:mouseup)="handleMouseUp($event)" (window:touchend)="handleMouseUp($event)" (wheel)="handleMouseWheel($event)" [style.height.px]="height">
|
||||
<canvas #timeLine (mousedown)="handleViewPanMouseDown($event)" (touchstart)="handleViewPanMouseDown($event)" (mousemove)="handleCanvasMouseMove($event)" (mouseleave)="handleCanvasMouseLeave($event)">
|
||||
<div class="timeline" (window:mousemove)="handleMouseMove($event)" (window:touchmove)="handleMouseMove($event)" (window:mouseup)="handleMouseUp()" (window:touchend)="handleMouseUp()" (wheel)="handleMouseWheel($event)" [style.height.px]="height">
|
||||
<canvas #timeLine (mousedown)="handleViewPanMouseDown($event)" (touchstart)="handleViewPanMouseDown($event)" (mousemove)="handleCanvasMouseMove($event)" (mouseleave)="handleCanvasMouseLeave()">
|
||||
</canvas>
|
||||
<div class="control-container" [style.margin-left.px]="marginLeft" [style.height.px]="lineHeight" >
|
||||
<div class="leftGrip rounded-start" (mousedown)="handleLeftGripMouseDown($event)" (touchstart)="handleLeftGripMouseDown($event)" (mouseenter)="handleLeftGripMouseEnter($event)" (mouseleave)="handleLeftGripMouseLeave($event)"><i class="fal fa-ellipsis-v" aria-hidden="true"></i></div>
|
||||
<div class="range" [style.width.px]="rangeWidth" (mousedown)="handleRangeGripMouseDown($event)" (touchstart)="handleRangeGripMouseDown($event)" (mouseenter)="handleRangeGripMouseEnter($event)"></div>
|
||||
<div class="rightGrip rounded-end" (mousedown)="handleRightGripMouseDown($event)" (touchstart)="handleRightGripMouseDown($event)" (mouseenter)="handleRightGripMouseEnter($event)" (mouseleave)="handleRightGripMouseLeave($event)"><i class="fal fa-ellipsis-v" aria-hidden="true"></i></div>
|
||||
<div class="leftGrip rounded-start" (mousedown)="handleLeftGripMouseDown($event)" (touchstart)="handleLeftGripMouseDown($event)" (mouseenter)="handleLeftGripMouseEnter()" (mouseleave)="handleLeftGripMouseLeave()"><i class="fal fa-ellipsis-v" aria-hidden="true"></i></div>
|
||||
<div class="range" [style.width.px]="rangeWidth" (mousedown)="handleRangeGripMouseDown($event)" (touchstart)="handleRangeGripMouseDown($event)" (mouseenter)="handleRangeGripMouseEnter()"></div>
|
||||
<div class="rightGrip rounded-end" (mousedown)="handleRightGripMouseDown($event)" (touchstart)="handleRightGripMouseDown($event)" (mouseenter)="handleRightGripMouseEnter()" (mouseleave)="handleRightGripMouseLeave()"><i class="fal fa-ellipsis-v" aria-hidden="true"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { Component, OnInit,Input,ViewChild,OnChanges,ChangeDetectorRef,Output, EventEmitter,SimpleChanges } from '@angular/core';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import {NgbPopover} from '@ng-bootstrap/ng-bootstrap';
|
||||
import { ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, OnInit, Output, ViewChild } from '@angular/core';
|
||||
import { NgbPopover } from '@ng-bootstrap/ng-bootstrap';
|
||||
|
||||
export interface TimeSpan {
|
||||
startDate:Date;
|
||||
@@ -73,7 +73,8 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
canvas.width = this.elementWidth * this.ratio;
|
||||
}
|
||||
|
||||
getPosibleUnits(scale:number):number[] {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
getPosibleUnits(_scale:number):number[] {
|
||||
const posibleUnits = [];
|
||||
for(const u of [3,4,6,8]) {
|
||||
if((this.unitScale <=u) )
|
||||
@@ -119,7 +120,6 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
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";
|
||||
@@ -234,9 +234,6 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
getNextTick(viewStartDate:Date, tick:number,step:number,unitScale:number):number {
|
||||
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);
|
||||
const nextDateOffset =this.getUnitDateOffset(viewStartDate,unitScale,nextTick);
|
||||
const nextDate = new Date(viewStartDate.getTime() + nextDateOffset);
|
||||
@@ -347,7 +344,8 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
this.caption=this.getCaption(startDate,endDate,this.unitScale);
|
||||
}
|
||||
|
||||
snapToUnit(date:Date,unitScale:number):Date {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
snapToUnit(date:Date,_unitScale:number):Date {
|
||||
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);
|
||||
@@ -417,14 +415,14 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
handleRightGripMouseEnter(event:MouseEvent) {
|
||||
handleRightGripMouseEnter() {
|
||||
this.mouseX=-1;
|
||||
this.mouseY=-1;
|
||||
this.redraw();
|
||||
if(!this.rangeGripMove && !this.leftGripMove && !this.rightGripMove) this.popoverEnd.open(this.endCaption);
|
||||
}
|
||||
|
||||
handleRightGripMouseLeave(event:MouseEvent) {
|
||||
handleRightGripMouseLeave() {
|
||||
if(!this.rightGripMove) this.popoverEnd.close();
|
||||
}
|
||||
|
||||
@@ -435,18 +433,18 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
handleLeftGripMouseEnter(event:MouseEvent|TouchEvent) {
|
||||
handleLeftGripMouseEnter() {
|
||||
this.mouseX=-1;
|
||||
this.mouseY=-1;
|
||||
this.redraw();
|
||||
if(!this.rangeGripMove && !this.leftGripMove && !this.rightGripMove) this.popoverStart.open(this.startCaption);
|
||||
}
|
||||
|
||||
handleLeftGripMouseLeave(event:MouseEvent) {
|
||||
handleLeftGripMouseLeave() {
|
||||
if(!this.leftGripMove) this.popoverStart.close();
|
||||
}
|
||||
|
||||
handleRangeGripMouseEnter(event:MouseEvent) {
|
||||
handleRangeGripMouseEnter() {
|
||||
this.mouseX=-1;
|
||||
this.mouseY=-1;
|
||||
this.redraw();
|
||||
@@ -464,7 +462,7 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
handleMouseUp(event:MouseEvent|TouchEvent) {
|
||||
handleMouseUp() {
|
||||
//this.updateControl(event);
|
||||
this.startDate = this.getStartDate(this.lastOffsetInPixels);
|
||||
this.endDate = this.getEndDate(this.lastOffsetInPixels);
|
||||
@@ -498,7 +496,7 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
this.redraw();
|
||||
}
|
||||
|
||||
handleCanvasMouseLeave(event:MouseEvent) {
|
||||
handleCanvasMouseLeave() {
|
||||
this.mouseX = -1;
|
||||
this.mouseY = -1;
|
||||
this.redraw();
|
||||
@@ -510,7 +508,6 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
return true;
|
||||
} else {
|
||||
nextScale*=1.1;
|
||||
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);
|
||||
@@ -565,7 +562,7 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
this.updateStyle(this.startDate,this.endDate);
|
||||
}
|
||||
|
||||
handleResize(event:any) {
|
||||
handleResize() {
|
||||
if(this.initialized) {
|
||||
this.setCanvasSize();
|
||||
this.updateStyle(this.startDate,this.endDate);
|
||||
@@ -573,7 +570,7 @@ export class TimespanComponent implements OnInit, OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
ngOnChanges (changes: SimpleChanges) {
|
||||
ngOnChanges() {
|
||||
if(this.initialized) {
|
||||
this.setCanvasSize();
|
||||
this.updateStyle(this.startDate,this.endDate);
|
||||
|
Reference in New Issue
Block a user