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);

View File

@@ -21,7 +21,7 @@ export class AppCommonEffects {
ofType(appCommonActions.LOGIN),
withLatestFrom(this.store$.select(appCommonReducers.selectGetInitialized)),
mergeMap(([action, initialized]) => {
var a = (action as appCommonActions.Login);
const a = (action as appCommonActions.Login);
this.oauthService$.initCodeFlow(a.url,{"prompt":"login"});
return [];
})),{dispatch:false});
@@ -75,7 +75,7 @@ export class AppCommonEffects {
userPackagesChanged$ = createEffect(() => this.actions$.pipe(
ofType(appCommonActions.ITEMCHANGEDEVENT),
switchMap((action) => {
let a = action as appCommonActions.ItemChangedEvent;
const a = action as appCommonActions.ItemChangedEvent;
if(a.itemCode.endsWith(":USER_PACKAGES"))
return of(new appCommonActions.InitUserPackages());
else
@@ -97,7 +97,7 @@ export class AppCommonEffects {
initUserSettingsRootChanged$ = createEffect(() => this.actions$.pipe(
ofType(appCommonActions.ITEMCHANGEDEVENT),
switchMap((action) => {
let a = action as appCommonActions.ItemChangedEvent;
const a = action as appCommonActions.ItemChangedEvent;
if(a.itemCode.endsWith(":USER_SETTINGS"))
return of(new appCommonActions.InitUserSettingsRoot());
else
@@ -134,10 +134,10 @@ export class AppCommonEffects {
ofType(appCommonActions.EDITITEM),
withLatestFrom(this.store$.select(appCommonReducers.selectGetItemTypes)),
switchMap(([action, itemtypes]) => {
var a = action as appCommonActions.EditItem;
const a = action as appCommonActions.EditItem;
var editor = "property";
if(a.item.itemType) {
var itemType = itemtypes[a.item.itemType];
const itemType = itemtypes[a.item.itemType];
var editor = itemType && itemType.editor ? itemType.editor : editor;
}
this.router$.navigate(['/editor',editor,'item', a.item.code])
@@ -149,12 +149,12 @@ export class AppCommonEffects {
ofType(appCommonActions.VIEWITEM),
withLatestFrom(this.store$.select(appCommonReducers.selectGetItemTypes)),
switchMap(([action, itemtypes]) => {
var a = action as appCommonActions.EditItem;
var itemType = itemtypes[a.item.itemType];
var viewer = itemType.viewer;
var editor = itemType.editor;
const a = action as appCommonActions.EditItem;
const itemType = itemtypes[a.item.itemType];
const viewer = itemType.viewer;
const editor = itemType.editor;
if(viewer == 'select_as_mapitem') {
let queryState = {
const queryState = {
itemCode: a.item.code,
parentCode: null,
level: 1,
@@ -166,7 +166,7 @@ export class AppCommonEffects {
startDate: null,
bbox: []
};
let query = this.stateSerializerService$.serialize(queryState);
const query = this.stateSerializerService$.serialize(queryState);
this.router$.navigate(['/map', query ])
}else if(viewer == 'edit_in_editor') {
this.router$.navigate(['/editor', editor, 'item', a.item.code])
@@ -181,7 +181,7 @@ export class AppCommonEffects {
fail$ = createEffect(() => this.actions$.pipe(
ofType(appCommonActions.FAIL),
map((action) => {
let failAction = action as appCommonActions.Fail;
const failAction = action as appCommonActions.Fail;
console.debug(failAction.payload)
return null;
})),{dispatch:false});

View File

@@ -2,4 +2,4 @@ import { IItemType } from './item.type';
export interface IItemTypes{
[id: string]: IItemType;
};
}

View File

@@ -58,9 +58,9 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
return tassign(state,{initialized: true});
}
case appCommonActions.INITUSERSUCCESS: {
let a = action as appCommonActions.InitUserSuccess;
let claims = { ...a.userinfo.info };
var user:IUser = {
const a = action as appCommonActions.InitUserSuccess;
const claims = { ...a.userinfo.info };
const user:IUser = {
code:a.user.code,
email:claims["email"]!== undefined ? claims["email"] : a.user.name,
name:claims["name"]!== undefined?claims["name"] : a.user.email,
@@ -70,7 +70,7 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
return tassign(state, { user: user });
}
case appCommonActions.INITROOTSUCCESS: {
let a = action as appCommonActions.InitRootSuccess;
const a = action as appCommonActions.InitRootSuccess;
return tassign(state, { rootItems:a.items});
}
case appCommonActions.OPENMODAL: {
@@ -80,7 +80,7 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
return tassign(state, { openedModalName: null });
}
case appCommonActions.LOADITEMTYPESSUCCESS: {
let a = action as appCommonActions.LoadItemTypesSuccess;
const a = action as appCommonActions.LoadItemTypesSuccess;
return tassign(state, { itemTypes: a.itemTypes });
}
case appCommonActions.FULLSCREEN: {
@@ -122,12 +122,12 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
return tassign(state, { menuVisible: false,accountMenuVisible:false,appMenuVisible: false,notificationMenuVisible:false,helpMenuVisible:false });
}
case appCommonActions.SETMENUVISIBLE: {
let a = action as appCommonActions.SetMenuVisible;
const a = action as appCommonActions.SetMenuVisible;
return tassign(state, { menuVisible: a.visible,accountMenuVisible:a.visible?false:state.accountMenuVisible,appMenuVisible:a.visible?false:state.appMenuVisible,notificationMenuVisible:a.visible?false:state.notificationMenuVisible,helpMenuVisible:a.visible?false:state.helpMenuVisible });
}
case appCommonActions.INITUSERPACKAGESSUCCESS:{
let a = action as appCommonActions.InitUserPackagesSuccess;
let packages = {}
const a = action as appCommonActions.InitUserPackagesSuccess;
const packages = {}
a.items.forEach((item) => {
item.data.dataDate = item.dataDate;
item.data.dataEndDate = item.dataEndDate;
@@ -140,8 +140,8 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
return tassign(state,{userPackages:packages});
}
case appCommonActions.INITPACKAGESSUCCESS:{
let a = action as appCommonActions.InitPackagesSuccess;
let packages = {}
const a = action as appCommonActions.InitPackagesSuccess;
const packages = {}
a.items.forEach((item) => {
packages[item.data.id] = item.data;
});
@@ -149,7 +149,7 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
return tassign(state,{packages:packages});
}
case appCommonActions.INITUSERSETTINGSROOTSUCCESS:{
let a = action as appCommonActions.InitUserSettingsRootSuccess;
const a = action as appCommonActions.InitUserSettingsRootSuccess;
return tassign(state, { userSettingsRoot : a.item });
}
case appCommonActions.LOGOUT:{
@@ -165,11 +165,11 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
return tassign(state,{isOnline:false});
}
case appCommonActions.SETPAGEMODE: {
let a = action as appCommonActions.SetPageMode;
const a = action as appCommonActions.SetPageMode;
return tassign(state,{isPageMode:a.pageMode});
}
case appCommonActions.NOTIFICATIONEVENT: {
let a = action as appCommonActions.NotificationEvent;
const a = action as appCommonActions.NotificationEvent;
let unread = 0;
if(a.attributes["unread"]) {
unread = parseInt(a.attributes["unread"]);
@@ -177,7 +177,7 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
return tassign(state,{unreadNotifications:unread});
}
case appCommonActions.SETUNREADNOTIFICATIONS: {
let a = action as appCommonActions.SetUnreadNotifications;
const a = action as appCommonActions.SetUnreadNotifications;
return tassign(state,{unreadNotifications:a.unread});
}
default: {

View File

@@ -21,7 +21,7 @@ export class AdminService {
}
getItemList(itemType?: string, dataFilter?: any, level?: number, atItemLocationItemCode?: string, indexed?: boolean, validToday?: boolean): Observable<IItem[]> {
var params = new HttpParams();
let params = new HttpParams();
if(itemType) params = params.append("it", itemType);
if(dataFilter) params = params.append("df", JSON.stringify(dataFilter));
if(atItemLocationItemCode) params = params.append("ail",atItemLocationItemCode);

View File

@@ -23,14 +23,14 @@ export class AuthGuard implements CanActivate, CanLoad, CanActivateChild {
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
console.debug("AuthGuard->canActivate", route, state);
let url: string = state.url;
const url: string = state.url;
return this.checkLogin(url, route);
}
canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
console.debug("AuthGuard->canActivateChild", childRoute, state);
let url: string = state.url;
const url: string = state.url;
return this.checkLogin(url, childRoute);
}

View File

@@ -5,9 +5,9 @@ import { Injectable } from '@angular/core';
})
export class DeviceService {
public IsMobile() {
let w = window as any;
const w = window as any;
let check = false;
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||w.opera);
return check;
};
}
}

View File

@@ -14,7 +14,7 @@ export class EventService {
public event:Subject <IEventMessage> = new Subject<IEventMessage>();
private _connection: HubConnection = null;
private _apiEndPoint: string;
public authenticated:boolean = false;
public authenticated = false;
constructor(private oauthService: OAuthService, private appConfig: AppConfig) {
this._apiEndPoint = appConfig.getConfig("apiEndPoint");
@@ -42,7 +42,7 @@ export class EventService {
}
private Authenticate() {
var accessToken = this.oauthService.getAccessToken();
const accessToken = this.oauthService.getAccessToken();
if (this.oauthService.hasValidAccessToken()) {
this._connection.send('authenticate', this.oauthService.getAccessToken());
this.authenticated=true;

View File

@@ -8,10 +8,10 @@ export class GradientService {
constructor() {
}
getGradientStyle(gradient:IGradientstop[],portrait:boolean = false ):any {
getGradientStyle(gradient:IGradientstop[],portrait = false ):any {
let gd = '{ "background": "linear-gradient(to ' + (portrait?'bottom':'right') +',';
for(var i=0;i<gradient.length;i++) {
let gs = gradient[i];
for(let i=0;i<gradient.length;i++) {
const gs = gradient[i];
if(i>0) gd+=",";
gd += `rgba(${gs.color.red},${gs.color.green},${gs.color.blue},${gs.color.alpha/255})`;
gd +=` ${gs.relativestop*100}%`

View File

@@ -19,7 +19,7 @@ import { AppConfig } from "../shared/app.config";
}
check(interval:number): Observable<boolean> {
let retval = new BehaviorSubject<boolean>(true);
const retval = new BehaviorSubject<boolean>(true);
setInterval(() => {
this.httpClient.get(`${this.ApiEndpoint()}/api/v1/healthcheck`).pipe(map(() => true),catchError((error) => of(false))).toPromise().then((status) => {
retval.next(status);

View File

@@ -22,8 +22,8 @@ export class ImageService {
}
dataUrltoBlob(dataURI:string):Blob {
var mime = dataURI.split( ';base64,')[0].split(':')[1];
var byteCharacters = atob(dataURI.split( ';base64,')[1]);
const mime = dataURI.split( ';base64,')[0].split(':')[1];
const byteCharacters = atob(dataURI.split( ';base64,')[1]);
const sliceSize = 512;
@@ -52,7 +52,7 @@ export class ImageService {
blobToDataUrl(blob:File):Promise<string> {
return new Promise<string>((resolve) => {
let reader = new FileReader();
const reader = new FileReader();
reader.addEventListener('error', () => {
resolve("");
});

View File

@@ -25,7 +25,7 @@ export class ItemService {
}
getFeatures(extent: number[], crs: string, searchText?: string, searchTags?:string,startDate?:Date,endDate?:Date,itemType?:string,parentCode?:string,dataFilter?:string,level?:number,indexed?:boolean): Observable<any> {
var params = new HttpParams();
let params = new HttpParams();
params = params.append("crs", crs);
if (extent) params =params.append("bbox", extent.join(","));
if (searchText) params = params.append("q", searchText);
@@ -34,7 +34,7 @@ export class ItemService {
if (endDate) params = params.append("ed", endDate.toISOString());
if (itemType) {
params = params.append("it", itemType);
let extraAttributes = this.itemTypeService.getExtraAttributes(itemType);
const extraAttributes = this.itemTypeService.getExtraAttributes(itemType);
if(extraAttributes) {
params = params.append("da", extraAttributes);
}
@@ -47,13 +47,13 @@ export class ItemService {
}
getFeature(code:string, crs: string): Observable<any> {
var params = new HttpParams();
let params = new HttpParams();
params = params.append("crs", crs);
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${code}/feature/`, { params: params });
}
getItemFeature(code:string, fid:number, crs: string): Observable<any> {
var params = new HttpParams();
let params = new HttpParams();
params = params.append("crs", crs);
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${code}/feature/${fid}`, { params: params });
}
@@ -63,7 +63,7 @@ export class ItemService {
}
getItemData(code: string,start?:number,size?:number): Observable<ArrayBuffer> {
var headers = new HttpHeaders();
let headers = new HttpHeaders();
if(start !== undefined && size !== undefined) headers=headers.set("Range",`bytes=${start}-${size-1}`);
return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/items/${code}/data`,{ headers: headers,responseType: 'arraybuffer' });
}
@@ -73,7 +73,7 @@ export class ItemService {
}
getItemList(itemType?: string, dataFilter?: any, level?: number, atItemLocationItemCode?: string, indexed?: boolean, validToday?: boolean): Observable<IItem[]> {
var params = new HttpParams();
let params = new HttpParams();
if(itemType) params = params.append("it", itemType);
if(dataFilter) params = params.append("df", JSON.stringify(dataFilter));
if(atItemLocationItemCode) params = params.append("ail",atItemLocationItemCode);
@@ -83,9 +83,9 @@ export class ItemService {
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/items/`, { params: params });
}
getChildItemList(parentcode: string, itemType: string, dataFilter?: any, level: number = 1, deep: boolean = true,
getChildItemList(parentcode: string, itemType: string, dataFilter?: any, level = 1, deep = true,
startDate?: Date, endDate?: Date): Observable<IItem[]> {
var params = new HttpParams();
let params = new HttpParams();
if(itemType != null) {
params = params.append("it", itemType);
}
@@ -99,17 +99,17 @@ export class ItemService {
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/items/${parentcode}/children`, { params: params });
}
getChildItemListCount(parentcode: string, itemType: string,dataFilter?: any): Observable<Number> {
var params = new HttpParams();
getChildItemListCount(parentcode: string, itemType: string,dataFilter?: any): Observable<number> {
let params = new HttpParams();
params = params.append("it", itemType);
if (dataFilter != null) {
params = params.append("df", JSON.stringify(dataFilter));
}
return this.httpClient.get<Number>(`${this.ApiEndpoint()}/api/v1/items/${parentcode}/children/count`, { params: params });
return this.httpClient.get<number>(`${this.ApiEndpoint()}/api/v1/items/${parentcode}/children/count`, { params: params });
}
getChildItemListByExtent(parentcode: string, itemType: string, extent: number[], crs: string, dataFilter?: any, level: number = 1): Observable<IItem[]> {
var params = new HttpParams();
getChildItemListByExtent(parentcode: string, itemType: string, extent: number[], crs: string, dataFilter?: any, level = 1): Observable<IItem[]> {
let params = new HttpParams();
params = params.append("it", itemType);
params = params.append("bbox", extent.join(","));
params = params.append("crs", crs);
@@ -121,7 +121,7 @@ export class ItemService {
}
getItemFeatures(code: string, extent: number[], crs: string, layerIndex?:number): Observable<any> {
var params = new HttpParams();
let params = new HttpParams();
params = params.append("crs", crs);
if(extent != null) {
params = params.append("bbox", extent.join(","));
@@ -153,7 +153,7 @@ export class ItemService {
}
getTemporal(code: string, startDate?: Date, endDate?: Date): Observable<any> {
var params = new HttpParams();
let params = new HttpParams();
if (startDate) params = params.append("sd", startDate.toISOString());
if (endDate) params = params.append("ed", endDate.toISOString());
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${code}/temporal/`, { params: params });
@@ -164,20 +164,20 @@ export class ItemService {
}
getItemTaskList(itemcode: string, unfinishedOnly?: boolean): Observable<IItemTask[]> {
var params = new HttpParams();
let params = new HttpParams();
if (unfinishedOnly) params = params.append("unfinishedOnly", unfinishedOnly.toString());
return this.httpClient.get<IItemTask[]>(`${this.ApiEndpoint()}/api/v1/items/${itemcode}/tasks`, { params: params });
}
getItemListUsingRelationship(itemType: string, relationshipItemType: string, relationshipDataFilter: any): Observable<IItem[]> {
var params = new HttpParams();
let params = new HttpParams();
params = params.append("it", itemType);
params = params.append("rsit", relationshipItemType);
params = params.append("rsdf", JSON.stringify(relationshipDataFilter));
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/items/userelationship`, { params: params });
}
getLayerValue(itemCode: string, layerIndex:number,x:number,y:number,crs:string = "EPSG:3857"): Observable<number> {
getLayerValue(itemCode: string, layerIndex:number,x:number,y:number,crs = "EPSG:3857"): Observable<number> {
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${itemCode}/value/layer/${layerIndex}?c=${x},${y}&crs=${crs}`);
}

View File

@@ -14,19 +14,19 @@ export class ItemTypeService {
}
getIcon(itemType: string) {
var icon = "fal fa-file";
let icon = "fal fa-file";
if (this.itemTypes[itemType]) icon = this.itemTypes[itemType].icon;
return icon;
}
getColor(itemType: string) {
var color = "#000000";
let color = "#000000";
if (this.itemTypes[itemType]) color = this.itemTypes[itemType].iconColor;
return color;
}
getExtraAttributes(itemType: string) {
var extraAttributes = null;
let extraAttributes = null;
if (this.itemTypes[itemType]) extraAttributes = this.itemTypes[itemType].extraAttributes;
return extraAttributes;
}
@@ -38,25 +38,25 @@ export class ItemTypeService {
}
hasViewer(item: IItem) {
let itemType: string = item.itemType;
const itemType: string = item.itemType;
if (this.itemTypes[itemType]) return this.itemTypes[itemType].viewer !== undefined;
return false;
}
hasEditor(item: IItem) {
let itemType: string = item.itemType;
const itemType: string = item.itemType;
if (this.itemTypes[itemType]) return this.itemTypes[itemType].editor !== undefined;
return false;
}
isLayer(item: IItem) {
let itemType: string = item.itemType;
const itemType: string = item.itemType;
return itemType == "vnd.farmmaps.itemtype.geotiff.processed" || itemType == "vnd.farmmaps.itemtype.layer" || itemType == "vnd.farmmaps.itemtype.shape.processed";
}
public load(config:AppConfig): Promise<any> {
if(this.itemTypes==null) {
var url = `${ config.getConfig("apiEndPoint")}/api/v1/itemtypes/`
const url = `${ config.getConfig("apiEndPoint")}/api/v1/itemtypes/`
return this.httpClient.get(url)
.toPromise()
.then((itemTypes:IItemTypes) => {
@@ -67,5 +67,5 @@ export class ItemTypeService {
} else {
return new Promise<void>((resolve) => {resolve()});
}
};
}
}

View File

@@ -13,8 +13,8 @@ export class SenmlService {
getSenMLItem(layer:IDataLayer,jsonLine:IJsonline): ISenMLItem {
if (jsonLine) {
var senmlPack = jsonLine.data as ISenMLItem[];
var temp = senmlPack.filter((i) => i.u == layer.indexKey);
const senmlPack = jsonLine.data as ISenMLItem[];
const temp = senmlPack.filter((i) => i.u == layer.indexKey);
if (temp.length == 1) return temp[0];
return null;
}
@@ -24,7 +24,7 @@ export class SenmlService {
if(item && item.data && item.data["layers"] && item.data["layers"].length > 0 ) {
return item.data["layers"][0] as IDataLayer;
} else {
let retVal:IDataLayer = { name:"Soil moisture",index:0,scale:1,unit:"%",indexKey:"%vol" };
const retVal:IDataLayer = { name:"Soil moisture",index:0,scale:1,unit:"%",indexKey:"%vol" };
return retVal;
}
}

View File

@@ -8,7 +8,7 @@ export class StateSerializerService {
serialize(queryState: IQueryState): string {
var state = "";
let state = "";
state += (queryState.itemCode) ? queryState.itemCode : "";
state += ";";
state += (queryState.parentCode) ? queryState.parentCode + ";" + queryState.level.toString() : ";";
@@ -31,8 +31,8 @@ export class StateSerializerService {
}
deserialize(queryState: string): IQueryState {
var state: IQueryState = { itemCode: null, parentCode: null, level: 1, itemType: null, query: null, tags: null, bboxFilter: false, startDate: null, endDate: null,bbox:[] };
var stateParts = atob(queryState).split(";");
const state: IQueryState = { itemCode: null, parentCode: null, level: 1, itemType: null, query: null, tags: null, bboxFilter: false, startDate: null, endDate: null,bbox:[] };
const stateParts = atob(queryState).split(";");
if (stateParts.length == 10) {
if (stateParts[0] != "") state.itemCode = stateParts[0];
if (stateParts[1] != "") {

View File

@@ -13,8 +13,8 @@ export class TimespanService {
units: string[] = ['millisecond', 'second', 'minute', 'hour', 'day', 'week', 'month', 'quarter', 'year'];
quarters: string[] = ['KW1', 'KW2', 'KW3', 'KW4'];
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";
@@ -47,7 +47,7 @@ export class TimespanService {
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) {
@@ -56,11 +56,11 @@ export class TimespanService {
return "";
}
getStartCaption(startDate: Date, endDate: Date, unitScale: number, suffix: boolean = false, extended: boolean = true): string {
getStartCaption(startDate: Date, endDate: Date, unitScale: number, suffix = false, extended = true): string {
return this.getStartEndCaption(new Date(startDate.getTime() + (this.unitScales[unitScale] / 2)), endDate, unitScale, suffix, extended);
}
getEndCaption(startDate: Date,endDate: Date, unitScale: number, suffix: boolean = true): string {
getEndCaption(startDate: Date,endDate: Date, unitScale: number, suffix = true): string {
return this.getStartEndCaption(new Date(endDate.getTime() - (this.unitScales[unitScale] / 2)), startDate, unitScale, suffix);
}
@@ -75,8 +75,8 @@ export class TimespanService {
scale =3
}
}
let startCaption = this.getStartCaption(startDate, endDate, scale);
let endCaption = this.getEndCaption(startDate,endDate, scale);
const startCaption = this.getStartCaption(startDate, endDate, scale);
const endCaption = this.getEndCaption(startDate,endDate, scale);
if ((endDate.getTime() - startDate.getTime()) < (1.5 * this.unitScales[scale]))
return endCaption;
return `${startCaption}-${endCaption}`;

View File

@@ -15,15 +15,15 @@ export class TypeaheadService {
return this.appConfig.getConfig("apiEndPoint");
}
getSearchTypeaheadItems(searchText:string,skip:number = 0,take:number = 10): Observable<ITypeaheadItem[]> {
getSearchTypeaheadItems(searchText:string,skip = 0,take = 10): Observable<ITypeaheadItem[]> {
return this.httpClient.get<ITypeaheadItem[]>(`${this.ApiEndpoint()}/api/v1/typeahead/search/?q=${searchText}&skip=${skip}&take=${take}`);
}
getTagTypeaheadItems(searchText: string, skip: number = 0, take: number = 10): Observable<ITypeaheadItem[]> {
getTagTypeaheadItems(searchText: string, skip = 0, take = 10): Observable<ITypeaheadItem[]> {
return this.httpClient.get<ITypeaheadItem[]>(`${this.ApiEndpoint()}/api/v1/typeahead/tag/?q=${searchText}&skip=${skip}&take=${take}`);
}
getCityTypeaheadItems(searchText: string, skip: number = 0, take: number = 10): Observable<ITypeaheadItem[]> {
getCityTypeaheadItems(searchText: string, skip = 0, take = 10): Observable<ITypeaheadItem[]> {
return this.httpClient.get<ITypeaheadItem[]>(`${this.ApiEndpoint()}/api/v1/typeahead/city/?q=${searchText}&skip=${skip}&take=${take}`);
}
}

View File

@@ -21,8 +21,8 @@ export class AccessTokenInterceptor implements HttpInterceptor {
}
hasAudience(url: string): boolean {
let u = new URL(url,this.base);
for (let audience of this.audience) {
const u = new URL(url,this.base);
for (const audience of this.audience) {
if (u.href.startsWith(audience)) return true;
}
return false;

View File

@@ -22,7 +22,7 @@ export class AppConfig {
}
public load(): Promise<any> {
var url = this.location.prepareExternalUrl('/configuration.json');
const url = this.location.prepareExternalUrl('/configuration.json');
return this.httpClient.get(url)
.toPromise()
.then(data => {
@@ -30,5 +30,5 @@ export class AppConfig {
//return data;
})
.catch(error => this.config = null);
};
}
}

View File

@@ -7,7 +7,7 @@ export interface IAuthconfigFactory {
export class AuthConfigFactory implements IAuthconfigFactory {
getAuthConfig(appConfig: AppConfig): AuthConfig {
let authConfig: AuthConfig = new AuthConfig();
const authConfig: AuthConfig = new AuthConfig();
authConfig.issuer = appConfig.getConfig("issuer");
authConfig.redirectUri = window.location.origin + "/cb";
authConfig.silentRefreshRedirectUri = window.location.origin + "/silent-refresh.html";

View File

@@ -18,7 +18,7 @@ export class SecureOAuthStorage extends OAuthStorage {
return window.sessionStorage.getItem(key);
}
};
}
removeItem(key: string): void {
if(this.secureKey(key)) {
delete this.storage[key];