18 changed files with 31 additions and 352 deletions
@ -1,54 +0,0 @@ |
|||
///
|
|||
/// Copyright © 2016-2023 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 } from '@angular/core'; |
|||
import { WidgetSettings } from '@shared/models/widget.models'; |
|||
import { UntypedFormBuilder, Validators } from '@angular/forms'; |
|||
import { Store } from '@ngrx/store'; |
|||
import { AppState } from '@core/core.state'; |
|||
import { |
|||
AnalogueGaugeWidgetSettingsComponent |
|||
} from '@home/components/widget/lib/settings/gauge/analogue-gauge-widget-settings.component'; |
|||
import { |
|||
GaugeBasicConfigComponent |
|||
} from '@home/components/widget/config/basic/gauge/analog-gauge-basic-config.component'; |
|||
import { WidgetConfigComponent } from '@home/components/widget/widget-config.component'; |
|||
import { WidgetConfigComponentData } from '@home/models/widget-component.models'; |
|||
import { DataKeyType } from '@shared/models/telemetry/telemetry.models'; |
|||
|
|||
@Component({ |
|||
selector: 'tb-speed-gauge-basic-config', |
|||
templateUrl: './analog-gauge-basic-config.component.html', |
|||
styleUrls: ['../basic-config.scss'] |
|||
}) |
|||
export class SpeedGaugeBasicConfigComponent extends GaugeBasicConfigComponent { |
|||
|
|||
gaugeType = 'speed'; |
|||
|
|||
constructor(protected store: Store<AppState>, |
|||
protected widgetConfigComponent: WidgetConfigComponent, |
|||
protected fb: UntypedFormBuilder) { |
|||
super(store, widgetConfigComponent, fb); |
|||
} |
|||
|
|||
protected setupDefaults(configData: WidgetConfigComponentData) { |
|||
return super.setupDefaults(configData, [{ name: 'speed', label: 'Speed', type: DataKeyType.timeseries }]); |
|||
} |
|||
|
|||
protected onConfigSet(configData: WidgetConfigComponentData) { |
|||
super.onConfigSet(configData); |
|||
} |
|||
} |
|||
@ -1,61 +0,0 @@ |
|||
<!-- |
|||
|
|||
Copyright © 2016-2023 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. |
|||
|
|||
--> |
|||
<mat-expansion-panel class="gauge-highlight" fxFlex [formGroup]="gaugeHighlightFormGroup" [(expanded)]="expanded"> |
|||
<mat-expansion-panel-header> |
|||
<div fxFlex fxLayout="row" fxLayoutAlign="start center"> |
|||
<mat-panel-title> |
|||
<div fxLayout="row" fxFlex fxLayoutAlign="start center"> |
|||
<div>{{ highlightRangeText() }}</div> |
|||
<div class="tb-color-preview" style="margin-left: 6px;"> |
|||
<div class="tb-color-result" [ngStyle]="{background: gaugeHighlightFormGroup.get('color').value}"></div> |
|||
</div> |
|||
</div> |
|||
</mat-panel-title> |
|||
<span fxFlex></span> |
|||
<button *ngIf="!disabled" mat-icon-button style="min-width: 40px;" |
|||
type="button" |
|||
(click)="removeHighlight.emit()" |
|||
matTooltip="{{ 'action.remove' | translate }}" |
|||
matTooltipPosition="above"> |
|||
<mat-icon>delete</mat-icon> |
|||
</button> |
|||
</div> |
|||
</mat-expansion-panel-header> |
|||
<ng-template matExpansionPanelContent> |
|||
<div fxLayout="column" fxLayoutGap="0.5em"> |
|||
<mat-divider></mat-divider> |
|||
<section class="tb-widget-settings" fxLayout="column"> |
|||
<section fxLayout="row" fxLayout.xs="column" fxLayoutGap.gt-xs="8px" fxLayoutAlign.gt-xs="start center"> |
|||
<mat-form-field fxFlex> |
|||
<mat-label translate>widgets.gauge.highlight-from</mat-label> |
|||
<input matInput type="number" formControlName="from"> |
|||
</mat-form-field> |
|||
<mat-form-field fxFlex> |
|||
<mat-label translate>widgets.gauge.highlight-to</mat-label> |
|||
<input matInput type="number" formControlName="to"> |
|||
</mat-form-field> |
|||
</section> |
|||
<tb-color-input |
|||
formControlName="color" |
|||
icon="format_color_fill" |
|||
label="{{ 'widgets.gauge.highlight-color' | translate }}" openOnInput colorClearButton> |
|||
</tb-color-input> |
|||
</section> |
|||
</div> |
|||
</ng-template> |
|||
</mat-expansion-panel> |
|||
@ -1,40 +0,0 @@ |
|||
/** |
|||
* Copyright © 2016-2023 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. |
|||
*/ |
|||
:host { |
|||
display: block; |
|||
.mat-expansion-panel { |
|||
box-shadow: none; |
|||
&.gauge-highlight { |
|||
border: 1px groove rgba(0, 0, 0, .25); |
|||
.mat-expansion-panel-header { |
|||
padding: 0 24px 0 8px; |
|||
&.mat-expanded { |
|||
height: 48px; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
:host ::ng-deep { |
|||
.mat-expansion-panel { |
|||
&.gauge-highlight { |
|||
.mat-expansion-panel-body { |
|||
padding: 0 8px 8px; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,116 +0,0 @@ |
|||
///
|
|||
/// Copyright © 2016-2023 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, EventEmitter, forwardRef, Input, OnInit, Output } from '@angular/core'; |
|||
import { ControlValueAccessor, UntypedFormBuilder, UntypedFormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms'; |
|||
import { PageComponent } from '@shared/components/page.component'; |
|||
import { Store } from '@ngrx/store'; |
|||
import { AppState } from '@core/core.state'; |
|||
import { TranslateService } from '@ngx-translate/core'; |
|||
import { isNumber } from '@core/utils'; |
|||
|
|||
export interface GaugeHighlight { |
|||
from: number; |
|||
to: number; |
|||
color: string; |
|||
} |
|||
|
|||
@Component({ |
|||
selector: 'tb-gauge-highlight', |
|||
templateUrl: './gauge-highlight.component.html', |
|||
styleUrls: ['./gauge-highlight.component.scss'], |
|||
providers: [ |
|||
{ |
|||
provide: NG_VALUE_ACCESSOR, |
|||
useExisting: forwardRef(() => GaugeHighlightComponent), |
|||
multi: true |
|||
} |
|||
] |
|||
}) |
|||
export class GaugeHighlightComponent extends PageComponent implements OnInit, ControlValueAccessor { |
|||
|
|||
@Input() |
|||
disabled: boolean; |
|||
|
|||
@Input() |
|||
expanded = false; |
|||
|
|||
@Output() |
|||
removeHighlight = new EventEmitter(); |
|||
|
|||
private modelValue: GaugeHighlight; |
|||
|
|||
private propagateChange = null; |
|||
|
|||
public gaugeHighlightFormGroup: UntypedFormGroup; |
|||
|
|||
constructor(protected store: Store<AppState>, |
|||
private translate: TranslateService, |
|||
private fb: UntypedFormBuilder) { |
|||
super(store); |
|||
} |
|||
|
|||
ngOnInit(): void { |
|||
this.gaugeHighlightFormGroup = this.fb.group({ |
|||
from: [null, []], |
|||
to: [null, []], |
|||
color: [null, []] |
|||
}); |
|||
this.gaugeHighlightFormGroup.valueChanges.subscribe(() => { |
|||
this.updateModel(); |
|||
}); |
|||
} |
|||
|
|||
registerOnChange(fn: any): void { |
|||
this.propagateChange = fn; |
|||
} |
|||
|
|||
registerOnTouched(fn: any): void { |
|||
} |
|||
|
|||
setDisabledState(isDisabled: boolean): void { |
|||
this.disabled = isDisabled; |
|||
if (isDisabled) { |
|||
this.gaugeHighlightFormGroup.disable({emitEvent: false}); |
|||
} else { |
|||
this.gaugeHighlightFormGroup.enable({emitEvent: false}); |
|||
} |
|||
} |
|||
|
|||
writeValue(value: GaugeHighlight): void { |
|||
this.modelValue = value; |
|||
this.gaugeHighlightFormGroup.patchValue( |
|||
value, {emitEvent: false} |
|||
); |
|||
} |
|||
|
|||
highlightRangeText(): string { |
|||
const value: GaugeHighlight = this.gaugeHighlightFormGroup.value; |
|||
const from = isNumber(value.from) ? value.from : 0; |
|||
const to = isNumber(value.to) ? value.to : 0; |
|||
return `${from} - ${to}`; |
|||
} |
|||
|
|||
private updateModel() { |
|||
const value: GaugeHighlight = this.gaugeHighlightFormGroup.value; |
|||
this.modelValue = value; |
|||
if (this.gaugeHighlightFormGroup.valid) { |
|||
this.propagateChange(this.modelValue); |
|||
} else { |
|||
this.propagateChange(null); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue