Browse Source

Merge branch 'master' into new_add_float_from_hex_int

pull/11255/head
nick 2 years ago
parent
commit
7d52618cb3
  1. 2
      application/src/main/data/json/system/widget_types/update_server_string_attribute.json
  2. 2
      application/src/main/data/json/system/widget_types/update_shared_string_attribute.json
  3. 2
      application/src/main/data/json/system/widget_types/update_string_timeseries.json
  4. 4
      ui-ngx/src/app/core/services/utils.service.ts
  5. 2
      ui-ngx/src/app/modules/home/components/widget/config/basic/chart/bar-chart-with-labels-basic-config.component.html
  6. 24
      ui-ngx/src/app/modules/home/components/widget/lib/cards/unread-notification-widget.component.ts
  7. 2
      ui-ngx/src/app/modules/home/components/widget/lib/chart/time-series-chart-widget.component.ts
  8. 14
      ui-ngx/src/app/modules/home/components/widget/lib/chart/time-series-chart.ts
  9. 2
      ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/bar-chart-with-labels-widget-settings.component.html
  10. 2
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/chart-bar-settings.component.html
  11. 2
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/chart-fill-settings.component.html
  12. 2
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/chart-fill-settings.component.ts
  13. 1
      ui-ngx/src/app/modules/home/components/widget/widget.component.ts
  14. 2
      ui-ngx/src/app/modules/home/models/widget-component.models.ts
  15. 49
      ui-ngx/src/app/shared/components/entity/entity-list.component.ts

2
application/src/main/data/json/system/widget_types/update_server_string_attribute.json

File diff suppressed because one or more lines are too long

2
application/src/main/data/json/system/widget_types/update_shared_string_attribute.json

File diff suppressed because one or more lines are too long

2
application/src/main/data/json/system/widget_types/update_string_timeseries.json

File diff suppressed because one or more lines are too long

4
ui-ngx/src/app/core/services/utils.service.ts

@ -456,6 +456,10 @@ export class UtilsService {
return isDefined(value);
}
public isDefinedAndNotNull(value: any): boolean {
return isDefinedAndNotNull(value);
}
public defaultValue(value: any, defaultValue: any): any {
if (isDefinedAndNotNull(value)) {
return value;

2
ui-ngx/src/app/modules/home/components/widget/config/basic/chart/bar-chart-with-labels-basic-config.component.html

@ -160,7 +160,7 @@
</div>
<tb-chart-fill-settings
formControlName="barBackgroundSettings"
title="widgets.chart.background"
titleText="widgets.chart.background"
fillNoneTitle="widgets.chart.fill-type-solid">
</tb-chart-fill-settings>
<tb-time-series-no-aggregation-bar-width-settings

24
ui-ngx/src/app/modules/home/components/widget/lib/cards/unread-notification-widget.component.ts

@ -203,23 +203,29 @@ export class UnreadNotificationWidgetComponent implements OnInit, OnDestroy {
}
markAsRead(id: string) {
const cmd = NotificationSubscriber.createMarkAsReadCommand(this.notificationWsService, [id]);
cmd.subscribe();
if (!this.ctx.isEdit && !this.ctx.isPreview) {
const cmd = NotificationSubscriber.createMarkAsReadCommand(this.notificationWsService, [id]);
cmd.subscribe();
}
}
markAsAllRead($event: Event) {
if ($event) {
$event.stopPropagation();
if (!this.ctx.isEdit && !this.ctx.isPreview) {
if ($event) {
$event.stopPropagation();
}
const cmd = NotificationSubscriber.createMarkAllAsReadCommand(this.notificationWsService);
cmd.subscribe();
}
const cmd = NotificationSubscriber.createMarkAllAsReadCommand(this.notificationWsService);
cmd.subscribe();
}
viewAll($event: Event) {
if ($event) {
$event.stopPropagation();
if (!this.ctx.isEdit && !this.ctx.isPreview) {
if ($event) {
$event.stopPropagation();
}
this.router.navigateByUrl(this.router.parseUrl('/notification/inbox')).then(() => {});
}
this.router.navigateByUrl(this.router.parseUrl('/notification/inbox')).then(() => {});
}
trackById(index: number, item: NotificationRequest): string {

2
ui-ngx/src/app/modules/home/components/widget/lib/chart/time-series-chart-widget.component.ts

@ -169,6 +169,6 @@ export class TimeSeriesChartWidgetComponent implements OnInit, OnDestroy, AfterV
}
public toggleLegendKey(legendKey: LegendKey) {
this.timeSeriesChart.toggleKey(legendKey.dataKey);
this.timeSeriesChart.toggleKey(legendKey.dataKey, legendKey.dataIndex);
}
}

14
ui-ngx/src/app/modules/home/components/widget/lib/chart/time-series-chart.ts

@ -56,7 +56,14 @@ import {
measureAxisNameSize
} from '@home/components/widget/lib/chart/echarts-widget.models';
import { DateFormatProcessor, ValueSourceType } from '@shared/models/widget-settings.models';
import { formattedDataFormDatasourceData, formatValue, isDefinedAndNotNull, isEqual, mergeDeep } from '@core/utils';
import {
formattedDataFormDatasourceData,
formatValue,
isDefined,
isDefinedAndNotNull,
isEqual,
mergeDeep
} from '@core/utils';
import { DataKey, Datasource, DatasourceType, FormattedData, widgetType } from '@shared/models/widget.models';
import * as echarts from 'echarts/core';
import { CallbackDataParams, PiecewiseVisualMapOption } from 'echarts/types/dist/shared';
@ -300,7 +307,7 @@ export class TbTimeSeriesChart {
}
}
public toggleKey(dataKey: DataKey): void {
public toggleKey(dataKey: DataKey, dataIndex?: number): void {
const enable = dataKey.hidden;
const dataItem = this.dataItems.find(d => d.dataKey === dataKey);
if (dataItem) {
@ -320,6 +327,9 @@ export class TbTimeSeriesChart {
this.timeSeriesChart.setOption(this.timeSeriesChartOptions, this.stackMode ? {notMerge: true} : {replaceMerge: mergeList});
this.updateAxes();
dataKey.hidden = !enable;
if (isDefined(dataIndex)) {
this.ctx.defaultSubscription.updateDataVisibility(dataIndex);
}
if (enable) {
this.timeSeriesChart.dispatchAction({
type: 'highlight',

2
ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/bar-chart-with-labels-widget-settings.component.html

@ -79,7 +79,7 @@
</div>
<tb-chart-fill-settings
formControlName="barBackgroundSettings"
title="widgets.chart.background"
titleText="widgets.chart.background"
fillNoneTitle="widgets.chart.fill-type-solid">
</tb-chart-fill-settings>
<tb-time-series-no-aggregation-bar-width-settings

2
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/chart-bar-settings.component.html

@ -77,7 +77,7 @@
</div>
<tb-chart-fill-settings
formControlName="backgroundSettings"
title="widgets.chart.background"
titleText="widgets.chart.background"
fillNoneTitle="widgets.chart.fill-type-solid">
</tb-chart-fill-settings>
</ng-container>

2
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/chart-fill-settings.component.html

@ -18,7 +18,7 @@
<ng-container [formGroup]="fillSettingsFormGroup">
<div class="tb-form-row column">
<div class="tb-form-row no-border no-padding space-between">
<div>{{ title | translate }}</div>
<div>{{ titleText | translate }}</div>
<tb-toggle-select formControlName="type">
<tb-toggle-option *ngFor="let type of chartFillTypes" [value]="type">{{ chartFillTypeTranslationMap.get(type) | translate }}</tb-toggle-option>
</tb-toggle-select>

2
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/chart-fill-settings.component.ts

@ -55,7 +55,7 @@ export class ChartFillSettingsComponent implements OnInit, ControlValueAccessor
disabled: boolean;
@Input()
title = 'widgets.chart.fill';
titleText = 'widgets.chart.fill';
@Input()
fillNoneTitle = 'widgets.chart.fill-type-none';

1
ui-ngx/src/app/modules/home/components/widget/widget.component.ts

@ -487,6 +487,7 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
}
if (!this.widgetContext.inited && this.isReady()) {
this.widgetContext.inited = true;
this.widgetContext.destroyed = false;
this.dashboardWidget.updateWidgetParams();
this.widgetContext.detectContainerChanges();
if (this.cafs.init) {

2
ui-ngx/src/app/modules/home/models/widget-component.models.ts

@ -449,6 +449,8 @@ export class WidgetContext {
labelPattern.destroy();
}
this.labelPatterns.clear();
this.width = undefined;
this.height = undefined;
this.destroyed = true;
}

49
ui-ngx/src/app/shared/components/entity/entity-list.component.ts

@ -25,11 +25,17 @@ import {
SimpleChanges,
ViewChild
} from '@angular/core';
import { ControlValueAccessor, UntypedFormBuilder, UntypedFormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms';
import {
ControlValueAccessor,
NG_VALIDATORS,
NG_VALUE_ACCESSOR,
UntypedFormBuilder,
UntypedFormGroup,
ValidationErrors,
Validators
} from '@angular/forms';
import { Observable } from 'rxjs';
import { filter, map, mergeMap, share, tap } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { AppState } from '@app/core/core.state';
import { TranslateService } from '@ngx-translate/core';
import { EntityType } from '@shared/models/entity-type.models';
import { BaseData } from '@shared/models/base-data';
@ -49,6 +55,11 @@ import { SubscriptSizing } from '@angular/material/form-field';
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => EntityListComponent),
multi: true
},
{
provide: NG_VALIDATORS,
useExisting: forwardRef(() => EntityListComponent),
multi: true
}
]
})
@ -56,7 +67,7 @@ export class EntityListComponent implements ControlValueAccessor, OnInit, AfterV
entityListFormGroup: UntypedFormGroup;
modelValue: Array<string> | null;
private modelValue: Array<string> | null;
@Input()
entityType: EntityType;
@ -108,17 +119,16 @@ export class EntityListComponent implements ControlValueAccessor, OnInit, AfterV
private propagateChange = (v: any) => { };
constructor(private store: Store<AppState>,
public translate: TranslateService,
constructor(public translate: TranslateService,
private entityService: EntityService,
private fb: UntypedFormBuilder) {
this.entityListFormGroup = this.fb.group({
entities: [this.entities, this.required ? [Validators.required] : []],
entities: [this.entities],
entity: [null]
});
}
updateValidators() {
private updateValidators() {
this.entityListFormGroup.get('entities').setValidators(this.required ? [Validators.required] : []);
this.entityListFormGroup.get('entities').updateValueAndValidity();
}
@ -189,7 +199,13 @@ export class EntityListComponent implements ControlValueAccessor, OnInit, AfterV
this.dirty = true;
}
reset() {
validate(): ValidationErrors | null {
return this.entityListFormGroup.valid ? null : {
entities: {valid: false}
};
}
private reset() {
this.entities = [];
this.entityListFormGroup.get('entities').setValue(this.entities);
this.modelValue = null;
@ -201,7 +217,7 @@ export class EntityListComponent implements ControlValueAccessor, OnInit, AfterV
this.dirty = true;
}
add(entity: BaseData<EntityId>): void {
private add(entity: BaseData<EntityId>): void {
if (!this.modelValue || this.modelValue.indexOf(entity.id.id) === -1) {
if (!this.modelValue) {
this.modelValue = [];
@ -214,7 +230,7 @@ export class EntityListComponent implements ControlValueAccessor, OnInit, AfterV
this.clear();
}
remove(entity: BaseData<EntityId>) {
public remove(entity: BaseData<EntityId>) {
let index = this.entities.indexOf(entity);
if (index >= 0) {
this.entities.splice(index, 1);
@ -229,11 +245,11 @@ export class EntityListComponent implements ControlValueAccessor, OnInit, AfterV
}
}
displayEntityFn(entity?: BaseData<EntityId>): string | undefined {
public displayEntityFn(entity?: BaseData<EntityId>): string | undefined {
return entity ? entity.name : undefined;
}
fetchEntities(searchText?: string): Observable<Array<BaseData<EntityId>>> {
private fetchEntities(searchText?: string): Observable<Array<BaseData<EntityId>>> {
this.searchText = searchText;
return this.entityService.getEntitiesByNameFilter(this.entityType, searchText,
@ -241,14 +257,14 @@ export class EntityListComponent implements ControlValueAccessor, OnInit, AfterV
map((data) => data ? data : []));
}
onFocus() {
public onFocus() {
if (this.dirty) {
this.entityListFormGroup.get('entity').updateValueAndValidity({onlySelf: true, emitEvent: true});
this.dirty = false;
}
}
clear(value: string = '') {
private clear(value: string = '') {
this.entityInput.nativeElement.value = value;
this.entityListFormGroup.get('entity').patchValue(value, {emitEvent: true});
setTimeout(() => {
@ -257,8 +273,7 @@ export class EntityListComponent implements ControlValueAccessor, OnInit, AfterV
}, 0);
}
textIsNotEmpty(text: string): boolean {
public textIsNotEmpty(text: string): boolean {
return (text && text.length > 0);
}
}

Loading…
Cancel
Save