Browse Source

Merge pull request #4221 from vvlladd28/improvement/alarm-widget/default-datasource

UI: Change default datasource type in alarm widget to created widget
pull/4224/head
Igor Kulikov 6 years ago
committed by GitHub
parent
commit
67dd34db69
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts
  2. 9
      ui-ngx/src/app/modules/home/components/widget/widget-config.component.html

9
ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts

@ -47,7 +47,7 @@ import {
} from '@app/shared/models/dashboard.models'; } from '@app/shared/models/dashboard.models';
import { WINDOW } from '@core/services/window.service'; import { WINDOW } from '@core/services/window.service';
import { WindowMessage } from '@shared/models/window-message.model'; import { WindowMessage } from '@shared/models/window-message.model';
import { deepClone, isDefined } from '@app/core/utils'; import { deepClone, isDefined, isDefinedAndNotNull } from '@app/core/utils';
import { import {
DashboardContext, DashboardContext,
DashboardPageLayout, DashboardPageLayout,
@ -62,6 +62,7 @@ import { MediaBreakpoints } from '@shared/models/constants';
import { AuthUser } from '@shared/models/user.model'; import { AuthUser } from '@shared/models/user.model';
import { getCurrentAuthState } from '@core/auth/auth.selectors'; import { getCurrentAuthState } from '@core/auth/auth.selectors';
import { import {
DatasourceType,
Widget, Widget,
WidgetConfig, WidgetConfig,
WidgetInfo, WidgetInfo,
@ -891,6 +892,12 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
const config: WidgetConfig = JSON.parse(widgetTypeInfo.defaultConfig); const config: WidgetConfig = JSON.parse(widgetTypeInfo.defaultConfig);
config.title = 'New ' + widgetTypeInfo.widgetName; config.title = 'New ' + widgetTypeInfo.widgetName;
config.datasources = []; config.datasources = [];
if (isDefinedAndNotNull(config.alarmSource)) {
config.alarmSource = {
type: DatasourceType.entity,
dataKeys: config.alarmSource.dataKeys || []
};
}
const newWidget: Widget = { const newWidget: Widget = {
isSystemType: widget.isSystemType, isSystemType: widget.isSystemType,
bundleAlias: widget.bundleAlias, bundleAlias: widget.bundleAlias,

9
ui-ngx/src/app/modules/home/components/widget/widget-config.component.html

@ -263,15 +263,6 @@
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<section class="tb-datasource" [ngSwitch]="alarmSourceSettings.get('type').value"> <section class="tb-datasource" [ngSwitch]="alarmSourceSettings.get('type').value">
<ng-template [ngSwitchCase]="datasourceType.function">
<mat-form-field floatLabel="always" [fxShow]="widgetType !== widgetTypes.alarm"
class="tb-datasource-name" style="min-width: 200px;">
<mat-label></mat-label>
<input matInput
placeholder="{{ 'datasource.name' | translate }}"
formControlName="name">
</mat-form-field>
</ng-template>
<ng-template [ngSwitchCase]="datasourceType.entity"> <ng-template [ngSwitchCase]="datasourceType.entity">
<tb-entity-alias-select <tb-entity-alias-select
[showLabel]="true" [showLabel]="true"

Loading…
Cancel
Save