diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/rpc/single-switch-widget.component.scss b/ui-ngx/src/app/modules/home/components/widget/lib/rpc/single-switch-widget.component.scss
index bb5648a16d..27207e5f9d 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/rpc/single-switch-widget.component.scss
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/rpc/single-switch-widget.component.scss
@@ -39,12 +39,6 @@ $switchColorDisabled: var(--tb-single-switch-color-disabled, #D5D7E5);
position: absolute;
inset: 12px;
}
- .tb-single-switch-progress {
- position: absolute;
- bottom: 0;
- left: 0;
- right: 0;
- }
> div.tb-single-switch-title-panel {
position: absolute;
top: 12px;
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/rpc/single-switch-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/rpc/single-switch-widget.component.ts
index 1103afde39..2c15634893 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/rpc/single-switch-widget.component.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/rpc/single-switch-widget.component.ts
@@ -97,6 +97,8 @@ export class SingleSwitchWidgetComponent extends
offLabel = '';
offLabelStyle: ComponentStyle = {};
+ disabledColor = 'rgba(0, 0, 0, 0.38)';
+
autoScale = false;
private panelResize$: ResizeObserver;
@@ -129,22 +131,18 @@ export class SingleSwitchWidgetComponent extends
this.showLabel = this.settings.showLabel;
this.label$ = this.ctx.registerLabelPattern(this.settings.label, this.label$);
this.labelStyle = textStyle(this.settings.labelFont);
- this.labelStyle.color = this.settings.labelColor;
this.showIcon = this.settings.showIcon;
this.icon = this.settings.icon;
this.iconStyle = iconStyle(this.settings.iconSize, this.settings.iconSizeUnit );
- this.iconStyle.color = this.settings.iconColor;
this.showOnLabel = this.settings.showOnLabel;
this.onLabel = this.settings.onLabel;
this.onLabelStyle = textStyle(this.settings.onLabelFont);
- this.onLabelStyle.color = this.settings.onLabelColor;
this.showOffLabel = this.settings.showOffLabel;
this.offLabel = this.settings.offLabel;
this.offLabelStyle = textStyle(this.settings.offLabelFont);
- this.offLabelStyle.color = this.settings.offLabelColor;
const switchVariablesCss = `.tb-single-switch-panel {\n`+
`--tb-single-switch-tumbler-color-on: ${this.settings.tumblerColorOn};\n`+
`--tb-single-switch-tumbler-color-off: ${this.settings.tumblerColorOff};\n`+
@@ -211,13 +209,15 @@ export class SingleSwitchWidgetComponent extends
}
public onToggleChange(event: MouseEvent) {
- event.preventDefault();
- const targetValue = this.value;
- const targetSetter = targetValue ? this.onValueSetter : this.offValueSetter;
- this.updateValue(targetSetter, targetValue, {
- next: () => this.onValue(targetValue),
- error: () => this.onValue(!targetValue)
- });
+ if (!this.ctx.isEdit && !this.ctx.isPreview) {
+ event.preventDefault();
+ const targetValue = this.value;
+ const targetSetter = targetValue ? this.onValueSetter : this.offValueSetter;
+ this.updateValue(targetSetter, targetValue, {
+ next: () => this.onValue(targetValue),
+ error: () => this.onValue(!targetValue)
+ });
+ }
}
private onValue(value: boolean): void {
@@ -227,33 +227,6 @@ export class SingleSwitchWidgetComponent extends
private onDisabled(value: boolean): void {
this.disabled = !!value;
- if (this.disabled) {
- if (this.showLabel) {
- this.labelStyle = {...this.labelStyle, color: 'rgba(0, 0, 0, 0.38)'};
- }
- if (this.showIcon) {
- this.iconStyle = {...this.iconStyle, color: 'rgba(0, 0, 0, 0.38)'};
- }
- if (this.showOnLabel) {
- this.onLabelStyle = {...this.onLabelStyle, color: 'rgba(0, 0, 0, 0.38)'};
- }
- if (this.showOffLabel) {
- this.offLabelStyle = {...this.offLabelStyle, color: 'rgba(0, 0, 0, 0.38)'};
- }
- } else {
- if (this.showLabel) {
- this.labelStyle = {...this.labelStyle, color: this.settings.labelColor};
- }
- if (this.showIcon) {
- this.iconStyle = {...this.iconStyle, color: this.settings.iconColor};
- }
- if (this.showOnLabel) {
- this.onLabelStyle = {...this.onLabelStyle, color: this.settings.onLabelColor};
- }
- if (this.showOffLabel) {
- this.offLabelStyle = {...this.offLabelStyle, color: this.settings.offLabelColor};
- }
- }
this.cd.markForCheck();
}
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/button/command-button-widget-settings.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/button/command-button-widget-settings.component.html
new file mode 100644
index 0000000000..29f3833983
--- /dev/null
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/button/command-button-widget-settings.component.html
@@ -0,0 +1,49 @@
+
+
+
+
+
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/button/command-button-widget-settings.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/button/command-button-widget-settings.component.ts
new file mode 100644
index 0000000000..ff34a28503
--- /dev/null
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/button/command-button-widget-settings.component.ts
@@ -0,0 +1,68 @@
+///
+/// Copyright © 2016-2024 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 { TargetDevice, WidgetSettings, WidgetSettingsComponent, widgetType } from '@shared/models/widget.models';
+import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
+import { Store } from '@ngrx/store';
+import { AppState } from '@core/core.state';
+import { ValueType } from '@shared/models/constants';
+import { commandButtonDefaultSettings } from '@home/components/widget/lib/button/command-button-widget.models';
+
+@Component({
+ selector: 'tb-command-button-widget-settings',
+ templateUrl: './command-button-widget-settings.component.html',
+ styleUrls: ['./../widget-settings.scss']
+})
+export class CommandButtonWidgetSettingsComponent extends WidgetSettingsComponent {
+
+ get targetDevice(): TargetDevice {
+ return this.widgetConfig?.config?.targetDevice;
+ }
+
+ get widgetType(): widgetType {
+ return this.widgetConfig?.widgetType;
+ }
+ get borderRadius(): string {
+ return this.widgetConfig?.config?.borderRadius;
+ }
+
+ valueType = ValueType;
+
+ commandButtonWidgetSettingsForm: UntypedFormGroup;
+
+ constructor(protected store: Store
,
+ private fb: UntypedFormBuilder) {
+ super(store);
+ }
+
+ protected settingsForm(): UntypedFormGroup {
+ return this.commandButtonWidgetSettingsForm;
+ }
+
+ protected defaultSettings(): WidgetSettings {
+ return {...commandButtonDefaultSettings};
+ }
+
+ protected onSettingsSet(settings: WidgetSettings) {
+ this.commandButtonWidgetSettingsForm = this.fb.group({
+ onClickState: [settings.onClickState, []],
+ disabledState: [settings.disabledState, []],
+
+ appearance: [settings.appearance, []]
+ });
+ }
+}
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/set-value-action-settings-panel.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/set-value-action-settings-panel.component.ts
index 37b8f4d37a..d718168b11 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/set-value-action-settings-panel.component.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/set-value-action-settings-panel.component.ts
@@ -22,14 +22,12 @@ import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { merge } from 'rxjs';
import {
- getValueActions,
SetValueAction,
- setValueActions, setValueActionsByWidgetType,
+ setValueActionsByWidgetType,
setValueActionTranslations,
SetValueSettings,
ValueToDataType
} from '@shared/models/action-widget-settings.models';
-import { ValueType } from '@shared/models/constants';
import { TargetDevice, widgetType } from '@shared/models/widget.models';
import { AttributeScope, DataKeyType, telemetryTypeTranslationsShort } from '@shared/models/telemetry/telemetry.models';
import { IAliasController } from '@core/api/widget-api.models';
@@ -50,9 +48,6 @@ export class SetValueActionSettingsPanelComponent extends PageComponent implemen
@Input()
setValueSettings: SetValueSettings;
- @Input()
- valueType: ValueType;
-
@Input()
aliasController: IAliasController;
@@ -84,8 +79,6 @@ export class SetValueActionSettingsPanelComponent extends PageComponent implemen
functionScopeVariables = this.widgetService.getWidgetScopeVariables();
- ValueType = ValueType;
-
setValueSettingsFormGroup: UntypedFormGroup;
constructor(private fb: UntypedFormBuilder,
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/set-value-action-settings.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/set-value-action-settings.component.ts
index c29cab1643..fce1e23673 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/set-value-action-settings.component.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/set-value-action-settings.component.ts
@@ -30,7 +30,6 @@ import { MatButton } from '@angular/material/button';
import { TbPopoverService } from '@shared/components/popover.service';
import { SetValueAction, SetValueSettings, ValueToDataType } from '@shared/models/action-widget-settings.models';
import { TranslateService } from '@ngx-translate/core';
-import { ValueType } from '@shared/models/constants';
import { IAliasController } from '@core/api/widget-api.models';
import { TargetDevice, widgetType } from '@shared/models/widget.models';
import { isDefinedAndNotNull } from '@core/utils';
@@ -59,9 +58,6 @@ export class SetValueActionSettingsComponent implements OnInit, ControlValueAcce
@Input()
panelTitle: string;
- @Input()
- valueType: ValueType;
-
@Input()
aliasController: IAliasController;
@@ -118,7 +114,6 @@ export class SetValueActionSettingsComponent implements OnInit, ControlValueAcce
const ctx: any = {
setValueSettings: this.modelValue,
panelTitle: this.panelTitle,
- valueType: this.valueType,
aliasController: this.aliasController,
targetDevice: this.targetDevice,
widgetType: this.widgetType
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/button/widget-button-custom-style-panel.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/button/widget-button-custom-style-panel.component.html
index 7e4a316eef..e5750fd4bb 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/button/widget-button-custom-style-panel.component.html
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/button/widget-button-custom-style-panel.component.html
@@ -48,6 +48,7 @@
widgets.button.preview