@ -0,0 +1,81 @@ |
|||
<!-- |
|||
|
|||
Copyright © 2016-2025 The Thingsboard Authors |
|||
|
|||
Licensed under the Apache License, Version 2.0 (the "License"); |
|||
you may not use this file except in compliance with the License. |
|||
You may obtain a copy of the License at |
|||
|
|||
http://www.apache.org/licenses/LICENSE-2.0 |
|||
|
|||
Unless required by applicable law or agreed to in writing, software |
|||
distributed under the License is distributed on an "AS IS" BASIS, |
|||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
See the License for the specific language governing permissions and |
|||
limitations under the License. |
|||
|
|||
--> |
|||
|
|||
<ng-container [formGroup]="tripTimelineSettingsFormGroup"> |
|||
<div class="tb-form-panel stroked tb-slide-toggle"> |
|||
<mat-expansion-panel class="tb-settings" [expanded]="settingsExpanded" |
|||
[disabled]="!tripTimelineSettingsFormGroup.get('showTimelineControl').value"> |
|||
<mat-expansion-panel-header class="flex flex-row flex-wrap"> |
|||
<mat-panel-title> |
|||
<mat-slide-toggle class="mat-slide flex items-stretch justify-center" formControlName="showTimelineControl" (click)="$event.stopPropagation()"> |
|||
{{ 'widgets.maps.timeline.control-panel' | translate }} |
|||
</mat-slide-toggle> |
|||
</mat-panel-title> |
|||
</mat-expansion-panel-header> |
|||
<ng-template matExpansionPanelContent> |
|||
<div class="tb-form-row space-between"> |
|||
<div translate>widgets.maps.timeline.time-step</div> |
|||
<mat-form-field appearance="outline" class="number" subscriptSizing="dynamic"> |
|||
<input matInput type="number" min="1" step="1" formControlName="timeStep" placeholder="{{ 'widget-config.set' | translate }}"> |
|||
<span matSuffix>ms</span> |
|||
</mat-form-field> |
|||
</div> |
|||
<div class="tb-form-row space-between"> |
|||
<div class="fixed-title-width" translate>widgets.maps.timeline.speed-options</div> |
|||
<mat-form-field class="flex-1" appearance="outline" subscriptSizing="dynamic"> |
|||
<mat-select formControlName="speedOptions" multiple> |
|||
<mat-option *ngFor="let speed of [1,5,10,15,25]" [value]="speed"> |
|||
{{ speed }} |
|||
</mat-option> |
|||
</mat-select> |
|||
</mat-form-field> |
|||
</div> |
|||
<div class="tb-form-row"> |
|||
<mat-slide-toggle class="mat-slide fixed-title-width" formControlName="showTimestamp"> |
|||
{{ 'widgets.maps.timeline.timestamp' | translate }} |
|||
</mat-slide-toggle> |
|||
<tb-date-format-select class="flex-1" |
|||
excludeLastUpdateAgo |
|||
formControlName="timestampFormat"></tb-date-format-select> |
|||
</div> |
|||
<div class="tb-form-panel tb-slide-toggle stroked"> |
|||
<mat-expansion-panel class="tb-settings" [expanded]="tripTimelineSettingsFormGroup.get('snapToRealLocation').value" |
|||
[disabled]="!tripTimelineSettingsFormGroup.get('snapToRealLocation').value"> |
|||
<mat-expansion-panel-header class="flex flex-row flex-wrap"> |
|||
<mat-panel-title> |
|||
<mat-slide-toggle class="mat-slide flex items-stretch justify-center" formControlName="snapToRealLocation" (click)="$event.stopPropagation()"> |
|||
{{ 'widgets.maps.timeline.snap-to-real-location' | translate }} |
|||
</mat-slide-toggle> |
|||
</mat-panel-title> |
|||
</mat-expansion-panel-header> |
|||
<ng-template matExpansionPanelContent> |
|||
<tb-js-func formControlName="locationSnapFilter" |
|||
required |
|||
withModules |
|||
[globalVariables]="functionScopeVariables" |
|||
[functionArgs]="['data', 'dsData']" |
|||
functionTitle="{{ 'widgets.maps.timeline.location-snap-filter-function' | translate }}" |
|||
helpId="widget/lib/map/trip_point_as_anchor_fn"> |
|||
</tb-js-func> |
|||
</ng-template> |
|||
</mat-expansion-panel> |
|||
</div> |
|||
</ng-template> |
|||
</mat-expansion-panel> |
|||
</div> |
|||
</ng-container> |
|||
@ -0,0 +1,172 @@ |
|||
///
|
|||
/// Copyright © 2016-2025 The Thingsboard Authors
|
|||
///
|
|||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|||
/// you may not use this file except in compliance with the License.
|
|||
/// You may obtain a copy of the License at
|
|||
///
|
|||
/// http://www.apache.org/licenses/LICENSE-2.0
|
|||
///
|
|||
/// Unless required by applicable law or agreed to in writing, software
|
|||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
/// See the License for the specific language governing permissions and
|
|||
/// limitations under the License.
|
|||
///
|
|||
|
|||
import { Component, DestroyRef, forwardRef, Input, OnInit } from '@angular/core'; |
|||
import { |
|||
ControlValueAccessor, |
|||
NG_VALIDATORS, |
|||
NG_VALUE_ACCESSOR, |
|||
UntypedFormBuilder, |
|||
UntypedFormControl, |
|||
UntypedFormGroup, |
|||
Validator, |
|||
Validators |
|||
} from '@angular/forms'; |
|||
import { merge } from 'rxjs'; |
|||
import { WidgetService } from '@core/http/widget.service'; |
|||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; |
|||
import { |
|||
DataLayerPatternSettings, |
|||
DataLayerPatternType, |
|||
DataLayerTooltipSettings, |
|||
dataLayerTooltipTriggers, |
|||
dataLayerTooltipTriggerTranslationMap, |
|||
pathDecoratorSymbols, pathDecoratorSymbolTranslationMap, |
|||
TripTimelineSettings |
|||
} from '@home/components/widget/lib/maps/models/map.models'; |
|||
import { coerceBoolean } from '@shared/decorators/coercion'; |
|||
import { MapSettingsContext } from '@home/components/widget/lib/settings/common/map/map-settings.component.models'; |
|||
|
|||
@Component({ |
|||
selector: 'tb-trip-timeline-settings', |
|||
templateUrl: './trip-timeline-settings.component.html', |
|||
styleUrls: ['./../../widget-settings.scss'], |
|||
providers: [ |
|||
{ |
|||
provide: NG_VALUE_ACCESSOR, |
|||
useExisting: forwardRef(() => TripTimelineSettingsComponent), |
|||
multi: true |
|||
}, |
|||
{ |
|||
provide: NG_VALIDATORS, |
|||
useExisting: forwardRef(() => TripTimelineSettingsComponent), |
|||
multi: true |
|||
} |
|||
] |
|||
}) |
|||
export class TripTimelineSettingsComponent implements OnInit, ControlValueAccessor, Validator { |
|||
|
|||
settingsExpanded = false; |
|||
|
|||
functionScopeVariables = this.widgetService.getWidgetScopeVariables(); |
|||
|
|||
@Input() |
|||
disabled: boolean; |
|||
|
|||
private modelValue: TripTimelineSettings; |
|||
|
|||
private propagateChange = null; |
|||
|
|||
public tripTimelineSettingsFormGroup: UntypedFormGroup; |
|||
|
|||
constructor(private fb: UntypedFormBuilder, |
|||
private widgetService: WidgetService, |
|||
private destroyRef: DestroyRef) { |
|||
} |
|||
|
|||
ngOnInit(): void { |
|||
|
|||
this.tripTimelineSettingsFormGroup = this.fb.group({ |
|||
showTimelineControl: [null], |
|||
timeStep: [null, [Validators.required, Validators.min(1)]], |
|||
speedOptions: [null, [Validators.required]], |
|||
showTimestamp: [null], |
|||
timestampFormat: [null, [Validators.required]], |
|||
snapToRealLocation: [null], |
|||
locationSnapFilter: [null, [Validators.required]] |
|||
}); |
|||
|
|||
this.tripTimelineSettingsFormGroup.valueChanges.pipe( |
|||
takeUntilDestroyed(this.destroyRef) |
|||
).subscribe(() => { |
|||
this.updateModel(); |
|||
}); |
|||
merge(this.tripTimelineSettingsFormGroup.get('showTimelineControl').valueChanges, |
|||
this.tripTimelineSettingsFormGroup.get('showTimestamp').valueChanges, |
|||
this.tripTimelineSettingsFormGroup.get('snapToRealLocation').valueChanges |
|||
).pipe( |
|||
takeUntilDestroyed(this.destroyRef) |
|||
).subscribe(() => { |
|||
this.updateValidators(); |
|||
}); |
|||
} |
|||
|
|||
registerOnChange(fn: any): void { |
|||
this.propagateChange = fn; |
|||
} |
|||
|
|||
registerOnTouched(_fn: any): void { |
|||
} |
|||
|
|||
setDisabledState(isDisabled: boolean): void { |
|||
this.disabled = isDisabled; |
|||
if (isDisabled) { |
|||
this.tripTimelineSettingsFormGroup.disable({emitEvent: false}); |
|||
} else { |
|||
this.tripTimelineSettingsFormGroup.enable({emitEvent: false}); |
|||
this.updateValidators(); |
|||
} |
|||
} |
|||
|
|||
writeValue(value: TripTimelineSettings): void { |
|||
this.modelValue = value; |
|||
this.tripTimelineSettingsFormGroup.patchValue( |
|||
value, {emitEvent: false} |
|||
); |
|||
this.updateValidators(); |
|||
this.settingsExpanded = this.tripTimelineSettingsFormGroup.get('showTimelineControl').value; |
|||
this.tripTimelineSettingsFormGroup.get('showTimelineControl').valueChanges.pipe( |
|||
takeUntilDestroyed(this.destroyRef) |
|||
).subscribe((show) => { |
|||
this.settingsExpanded = show; |
|||
}); |
|||
} |
|||
|
|||
public validate(c: UntypedFormControl) { |
|||
const valid = this.tripTimelineSettingsFormGroup.valid; |
|||
return valid ? null : { |
|||
tripTimelineSettings: { |
|||
valid: false, |
|||
}, |
|||
}; |
|||
} |
|||
|
|||
private updateValidators() { |
|||
const showTimelineControl: boolean = this.tripTimelineSettingsFormGroup.get('showTimelineControl').value; |
|||
const showTimestamp: boolean = this.tripTimelineSettingsFormGroup.get('showTimestamp').value; |
|||
const snapToRealLocation: boolean = this.tripTimelineSettingsFormGroup.get('snapToRealLocation').value; |
|||
if (showTimelineControl) { |
|||
this.tripTimelineSettingsFormGroup.enable({emitEvent: false}); |
|||
if (!showTimestamp) { |
|||
this.tripTimelineSettingsFormGroup.get('timestampFormat').disable({emitEvent: false}); |
|||
} |
|||
if (!snapToRealLocation) { |
|||
this.tripTimelineSettingsFormGroup.get('locationSnapFilter').disable({emitEvent: false}); |
|||
} |
|||
} else { |
|||
this.tripTimelineSettingsFormGroup.disable({emitEvent: false}); |
|||
this.tripTimelineSettingsFormGroup.get('showTimelineControl').enable({emitEvent: false}); |
|||
} |
|||
} |
|||
|
|||
private updateModel() { |
|||
this.modelValue = this.tripTimelineSettingsFormGroup.getRawValue(); |
|||
this.propagateChange(this.modelValue); |
|||
} |
|||
|
|||
protected readonly pathDecoratorSymbols = pathDecoratorSymbols; |
|||
protected readonly pathDecoratorSymbolTranslationMap = pathDecoratorSymbolTranslationMap; |
|||
} |
|||
|
After Width: | Height: | Size: 399 B |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 989 B |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 8.7 KiB |