This commit is contained in:
Maksym Dudnik 2023-05-31 13:57:51 +03:00
parent d7909e7b71
commit 15690ead07
12 changed files with 20 additions and 257 deletions

View File

@ -1,30 +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.
-->
<div class="action-buttons-container" [style]="{'align-content': settings.alignment}">
<button mat-button [color]="settings.buttonsClass"
*ngFor="let action of ctx.actionsApi.getActionDescriptors('actionButtonClick')"
[ngClass]="{
'mat-mdc-button mat-mdc-raised-button': settings.buttonsType === 'raised',
'mdc-button--outlined mat-mdc-outlined-button': settings.buttonsType === 'stroked',
'mat-mdc-unelevated-button': settings.buttonsType === 'flat',
'mat-mdc-menu-item mdc-list-item': settings.buttonsType === 'menu'
}"
(click)="actionButtonClick($event, action)"
>{{action.displayName}}
</button>
</div>

View File

@ -1,34 +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 {
width: 100%;
height: 100%;
.action-buttons-container {
display: flex;
flex-wrap: wrap;
flex-direction: row;
height: 100%;
width: 100%;
button {
flex-grow: 1;
margin: 10px;
min-width: 150px;
height: auto;
}
}
}

View File

@ -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.
///
import { Component, Input, OnInit } from '@angular/core';
import { WidgetContext } from '@home/models/widget-component.models';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { WidgetActionDescriptor } from '@shared/models/widget.models';
import { PageComponent } from '@shared/components/page.component';
import { ThemePalette } from '@angular/material/core';
interface ActionButtonsWidgetSettings {
buttonsType: string,
buttonsClass: ThemePalette,
alignment: string
}
@Component({
selector: 'tb-action-buttons-widget',
templateUrl: './action-buttons.component.html',
styleUrls: ['./action-buttons.component.scss']
})
export class ActionButtonsComponent implements OnInit {
@Input()
ctx: WidgetContext;
settings: ActionButtonsWidgetSettings;
constructor() {
}
ngOnInit(): void {
this.settings = this.ctx.settings;
}
actionButtonClick($event: MouseEvent, actionDescriptor: WidgetActionDescriptor) {
let entityId, entityName, entityLabel;
if (this.ctx.datasources) {
entityId = this.ctx.datasources[0].entity.id;
entityName = this.ctx.datasources[0].entityName;
entityLabel = this.ctx.datasources[0].entityLabel;
}
this.ctx.actionsApi.handleWidgetAction($event, actionDescriptor, entityId, entityName, null, entityLabel);
}
}

View File

@ -1,43 +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.
-->
<section class="tb-widget-settings" [formGroup]="ActionButtonsSettingsForm" fxLayout="column">
<mat-form-field fxFlex class="mat-block">
<mat-label translate>widgets.action-buttons.button-type</mat-label>
<mat-select required formControlName="buttonsType">
<mat-option *ngFor="let type of buttonTypes" [value]="type">
{{type}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field fxFlex class="mat-block">
<mat-label translate>widgets.action-buttons.button-class</mat-label>
<mat-select required formControlName="buttonsClass">
<mat-option *ngFor="let class of buttonClasses" [value]="class">
{{class}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field fxFlex class="mat-block">
<mat-label translate>widgets.action-buttons.alignment</mat-label>
<mat-select required formControlName="alignment">
<mat-option *ngFor="let type of alignment" [value]="type">
{{type}}
</mat-option>
</mat-select>
</mat-form-field>
</section>

View File

@ -1,62 +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, WidgetSettingsComponent } from '@shared/models/widget.models';
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
@Component({
selector: 'tb-action-buttons-widget-settings',
templateUrl: './action-buttons-widget-settings.component.html',
styleUrls: ['./../widget-settings.scss']
})
export class ActionButtonsWidgetSettingsComponent extends WidgetSettingsComponent {
ActionButtonsSettingsForm: UntypedFormGroup;
buttonTypes = ['basic', 'raised', 'stroked', 'flat'];
buttonClasses = ['basic', 'primary', 'accent', 'warn'];
alignment = ['center', 'start', 'end', 'normal', 'baseline', 'space-between', 'space-around', 'stretch'];
constructor(protected store: Store<AppState>,
private fb: UntypedFormBuilder) {
super(store);
}
protected settingsForm(): UntypedFormGroup {
return this.ActionButtonsSettingsForm;
}
protected defaultSettings(): WidgetSettings {
return {
buttonsType: 'basic',
buttonsClass: 'basic',
alignment: 'center'
};
}
protected onSettingsSet(settings: WidgetSettings) {
this.ActionButtonsSettingsForm = this.fb.group({
buttonsType: [settings.buttonsType, []],
buttonsClass: [settings.buttonsClass, []],
alignment: [settings.alignment, []]
});
}
}

View File

@ -259,9 +259,6 @@ import {
import { import {
TripAnimationPointSettingsComponent TripAnimationPointSettingsComponent
} from '@home/components/widget/lib/settings/map/trip-animation-point-settings.component'; } from '@home/components/widget/lib/settings/map/trip-animation-point-settings.component';
import {
ActionButtonsWidgetSettingsComponent
} from '@home/components/widget/lib/settings/cards/action-buttons-widget-settings.component';
import { import {
GatewayLogsSettingsComponent GatewayLogsSettingsComponent
} from '@home/components/widget/lib/settings/gateway/gateway-logs-settings.component'; } from '@home/components/widget/lib/settings/gateway/gateway-logs-settings.component';
@ -368,7 +365,6 @@ import {
MapWidgetSettingsComponent, MapWidgetSettingsComponent,
RouteMapWidgetSettingsComponent, RouteMapWidgetSettingsComponent,
TripAnimationWidgetSettingsComponent, TripAnimationWidgetSettingsComponent,
ActionButtonsWidgetSettingsComponent,
GatewayLogsSettingsComponent, GatewayLogsSettingsComponent,
GatewayServiceRPCSettingsComponent GatewayServiceRPCSettingsComponent
], ],
@ -474,7 +470,6 @@ import {
MapWidgetSettingsComponent, MapWidgetSettingsComponent,
RouteMapWidgetSettingsComponent, RouteMapWidgetSettingsComponent,
TripAnimationWidgetSettingsComponent, TripAnimationWidgetSettingsComponent,
ActionButtonsWidgetSettingsComponent,
GatewayLogsSettingsComponent, GatewayLogsSettingsComponent,
GatewayServiceRPCSettingsComponent GatewayServiceRPCSettingsComponent
] ]
@ -544,7 +539,6 @@ export const widgetSettingsComponentsMap: {[key: string]: Type<IWidgetSettingsCo
'tb-map-widget-settings': MapWidgetSettingsComponent, 'tb-map-widget-settings': MapWidgetSettingsComponent,
'tb-route-map-widget-settings': RouteMapWidgetSettingsComponent, 'tb-route-map-widget-settings': RouteMapWidgetSettingsComponent,
'tb-trip-animation-widget-settings': TripAnimationWidgetSettingsComponent, 'tb-trip-animation-widget-settings': TripAnimationWidgetSettingsComponent,
'tb-action-buttons-widget-settings': ActionButtonsWidgetSettingsComponent,
'tb-gateway-logs-settings': GatewayLogsSettingsComponent, 'tb-gateway-logs-settings': GatewayLogsSettingsComponent,
'tb-gateway-service-rpc-settings':GatewayServiceRPCSettingsComponent 'tb-gateway-service-rpc-settings':GatewayServiceRPCSettingsComponent
}; };

View File

@ -42,7 +42,6 @@ import { JsonInputWidgetComponent } from '@home/components/widget/lib/json-input
import { QrCodeWidgetComponent } from '@home/components/widget/lib/qrcode-widget.component'; import { QrCodeWidgetComponent } from '@home/components/widget/lib/qrcode-widget.component';
import { MarkdownWidgetComponent } from '@home/components/widget/lib/markdown-widget.component'; import { MarkdownWidgetComponent } from '@home/components/widget/lib/markdown-widget.component';
import { SelectEntityDialogComponent } from '@home/components/widget/lib/maps/dialogs/select-entity-dialog.component'; import { SelectEntityDialogComponent } from '@home/components/widget/lib/maps/dialogs/select-entity-dialog.component';
import { ActionButtonsComponent } from '@home/components/widget/lib/action-buttons.component';
@NgModule({ @NgModule({
declarations: declarations:
@ -65,8 +64,7 @@ import { ActionButtonsComponent } from '@home/components/widget/lib/action-butto
NavigationCardWidgetComponent, NavigationCardWidgetComponent,
QrCodeWidgetComponent, QrCodeWidgetComponent,
MarkdownWidgetComponent, MarkdownWidgetComponent,
SelectEntityDialogComponent, SelectEntityDialogComponent
ActionButtonsComponent
], ],
imports: [ imports: [
CommonModule, CommonModule,
@ -90,8 +88,7 @@ import { ActionButtonsComponent } from '@home/components/widget/lib/action-butto
NavigationCardsWidgetComponent, NavigationCardsWidgetComponent,
NavigationCardWidgetComponent, NavigationCardWidgetComponent,
QrCodeWidgetComponent, QrCodeWidgetComponent,
MarkdownWidgetComponent, MarkdownWidgetComponent
ActionButtonsComponent
], ],
providers: [ providers: [
CustomDialogService, CustomDialogService,

View File

@ -571,7 +571,7 @@
</mat-slide-toggle> </mat-slide-toggle>
<mat-form-field fxFlex="calc(50%-15px)" class="mat-block tb-value-type"> <mat-form-field fxFlex="calc(50%-15px)" class="mat-block tb-value-type">
<mat-label translate>gateway.statistics.send-period</mat-label> <mat-label translate>gateway.statistics.send-period</mat-label>
<input matInput formControlName="statsSendPeriodInSeconds" type="number" min="0" /> <input matInput formControlName="statsSendPeriodInSeconds" type="number" min="1" />
<mat-error <mat-error
*ngIf="gatewayConfigGroup.get('thingsboard.statistics.statsSendPeriodInSeconds').hasError('required')"> *ngIf="gatewayConfigGroup.get('thingsboard.statistics.statsSendPeriodInSeconds').hasError('required')">
{{'gateway.statistics.send-period-required' | translate }} {{'gateway.statistics.send-period-required' | translate }}

View File

@ -100,8 +100,8 @@ export const securityTypesTranslationsMap = new Map<SecurityTypes, string>(
[ [
[SecurityTypes.ACCESS_TOKEN, 'gateway.security-types.access-token'], [SecurityTypes.ACCESS_TOKEN, 'gateway.security-types.access-token'],
[SecurityTypes.USERNAME_PASSWORD, 'gateway.security-types.username-password'], [SecurityTypes.USERNAME_PASSWORD, 'gateway.security-types.username-password'],
// [SecurityTypes.TLS_ACCESS_TOKEN, 'gateway.security-types.tls-access-token'], [SecurityTypes.TLS_ACCESS_TOKEN, 'gateway.security-types.tls-access-token'],
[SecurityTypes.TLS_PRIVATE_KEY, 'gateway.security-types.tls-private-key'], // [SecurityTypes.TLS_PRIVATE_KEY, 'gateway.security-types.tls-private-key'],
] ]
); );
@ -152,7 +152,7 @@ export class GatewayConfigurationComponent implements OnInit {
checkConnectorsConfigurationInSeconds: [60, [Validators.required, Validators.min(1), Validators.pattern(/^-?[0-9]+$/)]], checkConnectorsConfigurationInSeconds: [60, [Validators.required, Validators.min(1), Validators.pattern(/^-?[0-9]+$/)]],
statistics: this.fb.group({ statistics: this.fb.group({
enable: [true, []], enable: [true, []],
statsSendPeriodInSeconds: [3600, [Validators.required, Validators.min(0), Validators.pattern(/^-?[0-9]+$/)]], statsSendPeriodInSeconds: [3600, [Validators.required, Validators.min(1), Validators.pattern(/^-?[0-9]+$/)]],
commands: this.fb.array([], []) commands: this.fb.array([], [])
}), }),
maxPayloadSizeBytes: [1024, [Validators.required, Validators.min(1), Validators.pattern(/^-?[0-9]+$/)]], maxPayloadSizeBytes: [1024, [Validators.required, Validators.min(1), Validators.pattern(/^-?[0-9]+$/)]],

View File

@ -17,7 +17,7 @@
--> -->
<mat-card fxLayout="row" class="command-form" fxLayoutGap="10px" [formGroup]="commandForm"> <mat-card fxLayout="row" class="command-form" fxLayoutGap="10px" [formGroup]="commandForm">
<mat-form-field class="mat-block tb-value-type"> <mat-form-field class="mat-block tb-value-type">
<mat-label>Command</mat-label> <mat-label>{{'gateway.statistics.command' | translate}}</mat-label>
<mat-select formControlName="command" *ngIf="!isConnector"> <mat-select formControlName="command" *ngIf="!isConnector">
<mat-option *ngFor="let command of RPCCommands" [value]="command"> <mat-option *ngFor="let command of RPCCommands" [value]="command">
{{command}} {{command}}
@ -26,11 +26,11 @@
<input matInput formControlName="command" *ngIf="isConnector"/> <input matInput formControlName="command" *ngIf="isConnector"/>
</mat-form-field> </mat-form-field>
<mat-form-field class="mat-block tb-value-type" fxFlex *ngIf="!isConnector"> <mat-form-field class="mat-block tb-value-type" fxFlex *ngIf="!isConnector">
<mat-label>Time</mat-label> <mat-label>{{'gateway.statistics.timeout-ms' | translate}}</mat-label>
<input matInput formControlName="time" type="number"/> <input matInput formControlName="time" type="number"/>
</mat-form-field> </mat-form-field>
<mat-form-field class="mat-block tb-value-type" fxFlex *ngIf="isConnector"> <mat-form-field class="mat-block tb-value-type" fxFlex *ngIf="isConnector">
<mat-label>Parameters</mat-label> <mat-label>{{'widget-config.datasource-parameters' | translate}}</mat-label>
<input matInput formControlName="params" type="JSON"/> <input matInput formControlName="params" type="JSON"/>
<mat-icon class="material-icons-outlined" aria-hidden="false" aria-label="help-icon" <mat-icon class="material-icons-outlined" aria-hidden="false" aria-label="help-icon"
matSuffix style="cursor:pointer;" matSuffix style="cursor:pointer;"

View File

@ -19,7 +19,7 @@
<div class="statistics-container" fxLayout="row"> <div class="statistics-container" fxLayout="row">
<mat-card [formGroup]="statisticForm" *ngIf="!general"> <mat-card [formGroup]="statisticForm" *ngIf="!general">
<mat-form-field class="mat-block"> <mat-form-field class="mat-block">
<mat-label>Statistic</mat-label> <mat-label>{{'gateway.statistics.statistic' | translate}}</mat-label>
<mat-select formControlName="statisticKey"> <mat-select formControlName="statisticKey">
<mat-option *ngFor="let key of statisticsKeys" [value]="key"> <mat-option *ngFor="let key of statisticsKeys" [value]="key">
{{key}} {{key}}
@ -29,12 +29,12 @@
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<!-- <mat-form-field class="mat-block" *ngIf="commandObj">-->
<!-- <mat-label>Timeout</mat-label>-->
<!-- <input matInput [value]="commandObj.timeout" disabled>-->
<!-- </mat-form-field>-->
<mat-form-field class="mat-block" *ngIf="commandObj"> <mat-form-field class="mat-block" *ngIf="commandObj">
<mat-label>Timeout</mat-label> <mat-label>{{'gateway.statistics.command' | translate}}</mat-label>
<input matInput [value]="commandObj.timeout" disabled>
</mat-form-field>
<mat-form-field class="mat-block" *ngIf="commandObj">
<mat-label>Command</mat-label>
<input matInput [value]="commandObj.command" disabled> <input matInput [value]="commandObj.command" disabled>
</mat-form-field> </mat-form-field>
</mat-card> </mat-card>

View File

@ -2608,9 +2608,10 @@
"server-port": "Server port", "server-port": "Server port",
"stats-send-period-in-sec": "Stats send period in seconds", "stats-send-period-in-sec": "Stats send period in seconds",
"statistics": { "statistics": {
"statistic": "Statistic",
"statistics": "Statistics", "statistics": "Statistics",
"commands": "Commands", "commands": "Commands",
"send-period": "Statistic send period (in ms)", "send-period": "Statistic send period (in sec)",
"send-period-required": "Statistic send period is required", "send-period-required": "Statistic send period is required",
"send-period-min": "Statistic send period can not be less then 1", "send-period-min": "Statistic send period can not be less then 1",
"send-period-pattern": "Statistic send period is not valid", "send-period-pattern": "Statistic send period is not valid",
@ -2620,6 +2621,7 @@
"check-connectors-configuration-pattern": "Check connectors configuration is not valid", "check-connectors-configuration-pattern": "Check connectors configuration is not valid",
"add": "Add command", "add": "Add command",
"timeout": "Timeout", "timeout": "Timeout",
"timeout-ms": "Timeout (in ms)",
"timeout-required": "Timeout is required", "timeout-required": "Timeout is required",
"timeout-min": "Timeout can not be less then 1", "timeout-min": "Timeout can not be less then 1",
"timeout-pattern": "Timeout is not valid", "timeout-pattern": "Timeout is not valid",
@ -2685,7 +2687,7 @@
"messages-ttl-in-days-pattern": "Number is not valid.", "messages-ttl-in-days-pattern": "Number is not valid.",
"mqtt-qos": "QoS", "mqtt-qos": "QoS",
"mqtt-qos-required": "QoS is required", "mqtt-qos-required": "QoS is required",
"mqtt-qos-range": "QoS values range is from 0 to 2", "mqtt-qos-range": "QoS values range is from 0 to 1",
"tls-path-private-key": "Path to private key on gateway", "tls-path-private-key": "Path to private key on gateway",
"toggle-fullscreen": "Toggle fullscreen", "toggle-fullscreen": "Toggle fullscreen",
"transformer-json-config": "Configuration JSON*", "transformer-json-config": "Configuration JSON*",
@ -2726,7 +2728,7 @@
"check-device-activity": "Enables monitor the activity of each connected device", "check-device-activity": "Enables monitor the activity of each connected device",
"inactivity-timeout": "Inactivity device time after whose the gateway will disconnect device", "inactivity-timeout": "Inactivity device time after whose the gateway will disconnect device",
"inactivity-period": "Periodicity of device activity check", "inactivity-period": "Periodicity of device activity check",
"minimal-pack-delay": "Delay between sending packets (Decreasing this setting results in increased CPU usage", "minimal-pack-delay": "Delay between sending packets (Decreasing this setting results in increased CPU usage)",
"qos": "Quality of Service in MQTT messaging (0 - at most once, 1 - at least once)" "qos": "Quality of Service in MQTT messaging (0 - at most once, 1 - at least once)"
} }
}, },