in Frontend/src/app/geofences/geofence-editor/geofence-editor.component.ts [116:163]
submit() {
const checkedAssets = this.assets.filter(a => a['checked']);
this.geofence.assetIds = [];
for (const checkedAsset of checkedAssets) {
this.geofence.assetIds.push(checkedAsset.id);
}
if (this.geofence.areaType === AreaType.Polygon && this.geofence.fencePolygon.length <= 2) {
this.toasterService.pop('error', 'Geofence invalid', 'Please use the map to specify a valid geofence polygon');
return;
}
if (this.geofence.areaType === AreaType.Circular && !this.geofence.fenceCenter) {
this.toasterService.pop('error', 'Geofence invalid', 'Please use the map to specify a valid center for the geofence');
return;
}
if (this.geofence.areaType === AreaType.Circular && this.geofence.radiusInMeters <= 0 || this.geofence.radiusInMeters >= 3185500) {
this.toasterService.pop('error', 'Geofence invalid', 'Invalid geofence radius');
return;
}
if (this.geofence.fenceType === undefined) {
this.toasterService.pop('error', 'Fence Type invalid', 'Please specify the fence type');
return;
}
this.geofence.emailsToNotify = this.joinedEmails.split(',').map(function (item) {
return item.trim();
});
this.geofence.webhooksToNotify = this.joinedWebhooks.split(',').map(function (item) {
return item.trim();
});
if (this.isEditable) {
this.geofenceService.update(this.geofence)
.subscribe(() => {
this.router.navigate(['/geofences']);
});
} else {
this.geofenceService.add(this.geofence)
.subscribe(() => {
this.router.navigate(['geofences']);
});
}
}