Merge remote-tracking branch 'upstream/master' into code-review

This commit is contained in:
Volodymyr Babak 2022-01-19 17:17:36 +02:00
commit e1df82f086
30 changed files with 229 additions and 144 deletions

View File

@ -128,7 +128,7 @@ export class AlarmTableConfig extends EntityTableConfig<AlarmInfo, TimePageLink>
}).afterClosed().subscribe(
(res) => {
if (res) {
this.table.updateData();
this.updateData();
}
}
);

View File

@ -43,6 +43,6 @@ export class AlarmTableHeaderComponent extends EntityTableHeaderComponent<AlarmI
searchStatusChanged(searchStatus: AlarmSearchStatus) {
this.alarmTableConfig.searchStatus = searchStatus;
this.alarmTableConfig.table.resetSortAndFilter(true, true);
this.alarmTableConfig.getTable().resetSortAndFilter(true, true);
}
}

View File

@ -48,7 +48,7 @@ import { AttributeScope } from '@shared/models/telemetry/telemetry.models';
import { EdgeDownlinkTableHeaderComponent } from '@home/components/edge/edge-downlink-table-header.component';
import { EdgeService } from '@core/http/edge.service';
import { concatMap, map } from 'rxjs/operators';
import { EntityService } from "@core/http/entity.service";
import { EntityService } from '@core/http/entity.service';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { ActionNotificationShow } from '@core/notification/notification.actions';
@ -94,9 +94,9 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig<EdgeEvent, TimePa
private onUpdate(attributes: any): void {
this.queueStartTs = 0;
let edge = attributes.reduce(function (map, attribute) {
map[attribute.key] = attribute;
return map;
const edge = attributes.reduce((attrMap, attribute) => {
attrMap[attribute.key] = attribute;
return attrMap;
}, {});
this.queueStartTs = edge.queueStartTs && edge.queueStartTs.value ? edge.queueStartTs.value : 0;
}
@ -114,7 +114,8 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig<EdgeEvent, TimePa
new EntityTableColumn<EdgeEvent>('status', 'event.status', '10%',
(entity) => this.updateEdgeEventStatus(entity.createdTime),
entity => ({
color: this.isPending(entity.createdTime) ? edgeEventStatusColor.get(EdgeEventStatus.PENDING) : edgeEventStatusColor.get(EdgeEventStatus.DEPLOYED)
color: this.isPending(entity.createdTime) ? edgeEventStatusColor.get(EdgeEventStatus.PENDING) :
edgeEventStatusColor.get(EdgeEventStatus.DEPLOYED)
}), false),
new EntityActionTableColumn<EdgeEvent>('data', 'event.data',
{
@ -124,7 +125,7 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig<EdgeEvent, TimePa
onAction: ($event, entity) =>
{
this.prepareEdgeEventContent(entity).subscribe(
(content) => this.showEdgeEventContent($event, content,'event.data'),
(content) => this.showEdgeEventContent($event, content, 'event.data'),
() => this.showEntityNotFoundError()
);
}
@ -132,7 +133,7 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig<EdgeEvent, TimePa
'40px'),
);
if (updateTableColumns) {
this.table.columnsUpdated(true);
this.getTable().columnsUpdated(true);
}
}

View File

@ -23,8 +23,9 @@
position="end"
[opened]="isDetailsOpen">
<tb-entity-details-panel
#entityDetailsPanel
[entitiesTableConfig]="entitiesTableConfig"
[entityId]="dataSource.currentEntity?.id"
[entityId]="isDetailsOpen ? dataSource.currentEntity?.id : null"
(closeEntityDetails)="isDetailsOpen = false; detailsPanelOpened.emit(isDetailsOpen);"
(entityUpdated)="onEntityUpdated($event)"
(entityAction)="onEntityAction($event)"

View File

@ -64,6 +64,7 @@ import { HasUUID } from '@shared/models/id/has-uuid';
import { ResizeObserver } from '@juggle/resize-observer';
import { hidePageSizePixelValue } from '@shared/models/constants';
import { IEntitiesTableComponent } from '@home/models/entity/entity-table-component.models';
import { EntityDetailsPanelComponent } from '@home/components/entity/entity-details-panel.component';
@Component({
selector: 'tb-entities-table',
@ -118,6 +119,8 @@ export class EntitiesTableComponent extends PageComponent implements IEntitiesTa
@ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
@ViewChild('entityDetailsPanel') entityDetailsPanel: EntityDetailsPanelComponent;
private updateDataSubscription: Subscription;
private viewInited = false;
@ -182,7 +185,7 @@ export class EntitiesTableComponent extends PageComponent implements IEntitiesTa
headerComponent.entitiesTableConfig = this.entitiesTableConfig;
}
this.entitiesTableConfig.table = this;
this.entitiesTableConfig.setTable(this);
this.translations = this.entitiesTableConfig.entityTranslations;
this.headerActionDescriptors = [...this.entitiesTableConfig.headerActionDescriptors];
@ -392,6 +395,9 @@ export class EntitiesTableComponent extends PageComponent implements IEntitiesTa
}
}
this.dataSource.loadEntities(this.pageLink);
if (this.isDetailsOpen && this.entityDetailsPanel) {
this.entityDetailsPanel.reloadEntity();
}
}
private dataLoaded(col?: number, row?: number) {

View File

@ -32,10 +32,11 @@ import { ActivatedRoute, Router } from '@angular/router';
import { FormGroup } from '@angular/forms';
import { AssetId } from '@shared/models/id/asset-id';
import { TranslateService } from '@ngx-translate/core';
import { deepClone, mergeDeep } from '@core/utils';
import { deepClone } from '@core/utils';
import { BroadcastService } from '@core/services/broadcast.service';
import { EntityDetailsPanelComponent } from '@home/components/entity/entity-details-panel.component';
import { DialogService } from '@core/services/dialog.service';
import { IEntityDetailsPageComponent } from '@home/models/entity/entity-details-page-component.models';
@Component({
selector: 'tb-entity-details-page',
@ -43,7 +44,7 @@ import { DialogService } from '@core/services/dialog.service';
styleUrls: ['./entity-details-page.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class EntityDetailsPageComponent extends EntityDetailsPanelComponent implements OnInit, OnDestroy {
export class EntityDetailsPageComponent extends EntityDetailsPanelComponent implements IEntityDetailsPageComponent, OnInit, OnDestroy {
headerTitle: string;
headerSubtitle: string;
@ -54,6 +55,7 @@ export class EntityDetailsPageComponent extends EntityDetailsPanelComponent impl
if (this.entitiesTableConfigValue !== entitiesTableConfig) {
this.entitiesTableConfigValue = entitiesTableConfig;
if (this.entitiesTableConfigValue) {
this.entitiesTableConfigValue.setEntityDetailsPage(this);
this.isEdit = false;
this.entity = null;
}
@ -81,9 +83,6 @@ export class EntityDetailsPageComponent extends EntityDetailsPanelComponent impl
ngOnInit() {
this.headerSubtitle = '';
this.route.paramMap.subscribe( paramMap => {
this.entityId = new AssetId(paramMap.get('entityId'));
});
this.headerSubtitle = this.translate.instant(this.entitiesTableConfig.entityTranslations.details);
super.init();
this.entityComponent.isDetailsPage = true;
@ -92,6 +91,15 @@ export class EntityDetailsPageComponent extends EntityDetailsPanelComponent impl
this.deleteEntity(action.event, action.entity);
}
}));
this.subscriptions.push(this.route.paramMap.subscribe( paramMap => {
if (this.entitiesTableConfig) {
const entityType = this.entitiesTableConfig.entityType;
const id = paramMap.get('entityId');
this.currentEntityId = { id, entityType };
this.reload();
this.selectedTab = 0;
}
}));
}
ngOnDestroy() {
@ -99,20 +107,9 @@ export class EntityDetailsPageComponent extends EntityDetailsPanelComponent impl
}
reload(): void {
this.isEdit = false;
this.entitiesTableConfig.loadEntity(this.currentEntityId).subscribe(
(entity) => {
this.entity = entity;
this.broadcast.broadcast('updateBreadcrumb');
this.isReadOnly = this.entitiesTableConfig.detailsReadonly(entity);
this.headerTitle = this.entitiesTableConfig.entityTitle(entity);
this.entityComponent.entity = entity;
this.entityComponent.isEdit = false;
if (this.entityTabsComponent) {
this.entityTabsComponent.entity = entity;
}
}
);
this.reloadEntity().subscribe(() => {
this.onUpdateEntity();
});
}
onToggleDetailsEditMode() {
@ -136,29 +133,23 @@ export class EntityDetailsPageComponent extends EntityDetailsPanelComponent impl
}
onApplyDetails() {
if (this.detailsForm && this.detailsForm.valid) {
const editingEntity = {...this.editingEntity, ...this.entityComponent.entityFormValue()};
if (this.editingEntity.hasOwnProperty('additionalInfo')) {
editingEntity.additionalInfo =
mergeDeep((this.editingEntity as any).additionalInfo, this.entityComponent.entityFormValue()?.additionalInfo);
this.saveEntity(false).subscribe((entity) => {
if (entity) {
this.onUpdateEntity();
}
this.entitiesTableConfig.saveEntity(editingEntity, this.editingEntity).subscribe(
(entity) => {
this.entity = entity;
this.entityComponent.entity = entity;
if (this.entityTabsComponent) {
this.entityTabsComponent.entity = entity;
}
this.isEdit = false;
}
);
}
});
}
confirmForm(): FormGroup {
return this.detailsForm;
}
private onUpdateEntity() {
this.broadcast.broadcast('updateBreadcrumb');
this.isReadOnly = this.entitiesTableConfig.detailsReadonly(this.entity);
this.headerTitle = this.entitiesTableConfig.entityTitle(this.entity);
}
private deleteEntity($event: Event, entity: BaseData<HasId>) {
if ($event) {
$event.stopPropagation();

View File

@ -34,16 +34,17 @@ import { PageComponent } from '@shared/components/page.component';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { EntityTableConfig } from '@home/models/entity/entities-table-config.models';
import { BaseData, HasId } from '@shared/models/base-data';
import { BaseData, HasId, hasIdEquals } from '@shared/models/base-data';
import { EntityType, EntityTypeResource, EntityTypeTranslation } from '@shared/models/entity-type.models';
import { FormGroup } from '@angular/forms';
import { EntityComponent } from './entity.component';
import { TbAnchorComponent } from '@shared/components/tb-anchor.component';
import { EntityAction } from '@home/models/entity/entity-component.models';
import { Subscription } from 'rxjs';
import { Observable, ReplaySubject, Subscription } from 'rxjs';
import { MatTab, MatTabGroup } from '@angular/material/tabs';
import { EntityTabsComponent } from '@home/components/entity/entity-tabs.component';
import { deepClone, mergeDeep } from '@core/utils';
import { entityIdEquals } from '@shared/models/id/entity-id';
@Component({
selector: 'tb-entity-details-panel',
@ -102,9 +103,11 @@ export class EntityDetailsPanelComponent extends PageComponent implements AfterV
@Input()
set entityId(entityId: HasId) {
if (entityId && entityId !== this.currentEntityId) {
if (!hasIdEquals(entityId, this.currentEntityId)) {
this.currentEntityId = entityId;
this.reload();
if (this.currentEntityId) {
this.reloadEntity();
}
}
}
@ -228,7 +231,8 @@ export class EntityDetailsPanelComponent extends PageComponent implements AfterV
return this.isEditValue && this.entitiesTableConfig.hideDetailsTabsOnEdit;
}
reload(): void {
reloadEntity(): Observable<BaseData<HasId>> {
const loadEntitySubject = new ReplaySubject<BaseData<HasId>>();
this.isEdit = false;
this.entitiesTableConfig.loadEntity(this.currentEntityId).subscribe(
(entity) => {
@ -237,8 +241,11 @@ export class EntityDetailsPanelComponent extends PageComponent implements AfterV
if (this.entityTabsComponent) {
this.entityTabsComponent.entity = entity;
}
loadEntitySubject.next(entity);
loadEntitySubject.complete();
}
);
return loadEntitySubject;
}
onCloseEntityDetails() {
@ -273,7 +280,8 @@ export class EntityDetailsPanelComponent extends PageComponent implements AfterV
}
}
saveEntity() {
saveEntity(emitEntityUpdated = true): Observable<BaseData<HasId>> {
const saveEntitySubject = new ReplaySubject<BaseData<HasId>>();
if (this.detailsForm.valid) {
const editingEntity = {...this.editingEntity, ...this.entityComponent.entityFormValue()};
if (this.editingEntity.hasOwnProperty('additionalInfo')) {
@ -288,10 +296,18 @@ export class EntityDetailsPanelComponent extends PageComponent implements AfterV
this.entityTabsComponent.entity = entity;
}
this.isEdit = false;
this.entityUpdated.emit(this.entity);
if (emitEntityUpdated) {
this.entityUpdated.emit(this.entity);
}
saveEntitySubject.next(entity);
saveEntitySubject.complete();
}
);
} else {
saveEntitySubject.next(null);
saveEntitySubject.complete();
}
return saveEntitySubject;
}
ngAfterViewInit(): void {

View File

@ -142,10 +142,11 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
icon: 'delete',
isEnabled: () => true,
onAction: ($event) => {
this.eventService.clearEvents(this.entityId, this.eventType, this.filterParams, this.tenantId, this.table.pageLink as TimePageLink).subscribe(
this.eventService.clearEvents(this.entityId, this.eventType, this.filterParams, this.tenantId,
this.getTable().pageLink as TimePageLink).subscribe(
() => {
this.table.paginator.pageIndex = 0;
this.table.updateData();
this.getTable().paginator.pageIndex = 0;
this.updateData();
}
);
}
@ -275,7 +276,7 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
break;
}
if (updateTableColumns) {
this.table.columnsUpdated(true);
this.getTable().columnsUpdated(true);
}
}
@ -345,8 +346,8 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
}
this.filterParams = {};
this.table.paginator.pageIndex = 0;
this.table.updateData();
this.getTable().paginator.pageIndex = 0;
this.updateData();
}
private editEventFilter($event: MouseEvent) {
@ -389,8 +390,8 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
componentRef.onDestroy(() => {
if (componentRef.instance.result && !isEqual(this.filterParams, componentRef.instance.result.filterParams)) {
this.filterParams = componentRef.instance.result.filterParams;
this.table.paginator.pageIndex = 0;
this.table.updateData();
this.getTable().paginator.pageIndex = 0;
this.updateData();
}
});
this.cd.detectChanges();

View File

@ -40,6 +40,6 @@ export class EventTableHeaderComponent extends EntityTableHeaderComponent<Event>
eventTypeChanged(eventType: EventType | DebugEventType) {
this.eventTableConfig.eventType = eventType;
this.eventTableConfig.table.resetSortAndFilter(true, true);
this.eventTableConfig.getTable().resetSortAndFilter(true, true);
}
}

View File

@ -31,6 +31,8 @@ import { ActivatedRoute } from '@angular/router';
import { EntityTabsComponent } from '../../components/entity/entity-tabs.component';
import { DAY, historyInterval } from '@shared/models/time/time.models';
import { IEntitiesTableComponent } from '@home/models/entity/entity-table-component.models';
import { IEntityDetailsPageComponent } from '@home/models/entity/entity-details-page-component.models';
import { templateJitUrl } from '@angular/compiler';
export type EntityBooleanFunction<T extends BaseData<HasId>> = (entity: T) => boolean;
export type EntityStringFunction<T extends BaseData<HasId>> = (entity: T) => string;
@ -136,11 +138,13 @@ export class EntityTableConfig<T extends BaseData<HasId>, P extends PageLink = P
constructor() {}
private table: IEntitiesTableComponent = null;
private entityDetailsPage: IEntityDetailsPageComponent = null;
componentsData: any = null;
loadDataOnInit = true;
onLoadAction: (route: ActivatedRoute) => void = null;
table: IEntitiesTableComponent = null;
useTimePageLink = false;
defaultTimewindowInterval = historyInterval(DAY);
entityType: EntityType = null;
@ -189,6 +193,40 @@ export class EntityTableConfig<T extends BaseData<HasId>, P extends PageLink = P
entityAdded: EntityVoidFunction<T> = () => {};
entityUpdated: EntityVoidFunction<T> = () => {};
entitiesDeleted: EntityIdsVoidFunction<T> = () => {};
getTable(): IEntitiesTableComponent {
return this.table;
}
setTable(table: IEntitiesTableComponent) {
this.table = table;
this.entityDetailsPage = null;
}
getEntityDetailsPage(): IEntityDetailsPageComponent {
return this.entityDetailsPage;
}
setEntityDetailsPage(entityDetailsPage: IEntityDetailsPageComponent) {
this.entityDetailsPage = entityDetailsPage;
this.table = null;
}
updateData(closeDetails = false) {
if (this.table) {
this.table.updateData(closeDetails);
} else if (this.entityDetailsPage) {
this.entityDetailsPage.reload();
}
}
getActivatedRoute(): ActivatedRoute {
if (this.table) {
return this.table.route;
} else {
return null;
}
}
}
export function checkBoxCell(value: boolean): string {

View File

@ -0,0 +1,19 @@
///
/// Copyright © 2016-2022 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.
///
export interface IEntityDetailsPageComponent {
reload(): void;
}

View File

@ -36,7 +36,7 @@ export class AssetTableHeaderComponent extends EntityTableHeaderComponent<AssetI
assetTypeChanged(assetType: string) {
this.entitiesTableConfig.componentsData.assetType = assetType;
this.entitiesTableConfig.table.resetSortAndFilter(true);
this.entitiesTableConfig.getTable().resetSortAndFilter(true);
}
}

View File

@ -104,7 +104,8 @@ export class AssetsTableConfigResolver implements Resolve<EntityTableConfig<Asse
));
};
this.config.onEntityAction = action => this.onAssetAction(action, this.config);
this.config.detailsReadonly = () => (this.config.componentsData.assetScope === 'customer_user' || this.config.componentsData.assetScope === 'edge_customer_user');
this.config.detailsReadonly = () => (this.config.componentsData.assetScope === 'customer_user' ||
this.config.componentsData.assetScope === 'edge_customer_user');
this.config.headerComponent = AssetTableHeaderComponent;
@ -295,7 +296,7 @@ export class AssetsTableConfigResolver implements Resolve<EntityTableConfig<Asse
name: this.translate.instant('asset.add-asset-text'),
icon: 'insert_drive_file',
isEnabled: () => true,
onAction: ($event) => this.config.table.addEntity($event)
onAction: ($event) => this.config.getTable().addEntity($event)
},
{
name: this.translate.instant('asset.import'),
@ -332,7 +333,7 @@ export class AssetsTableConfigResolver implements Resolve<EntityTableConfig<Asse
this.homeDialogs.importEntities(EntityType.ASSET).subscribe((res) => {
if (res) {
this.broadcast.broadcast('assetSaved');
this.config.table.updateData();
this.config.updateData();
}
});
}
@ -341,7 +342,7 @@ export class AssetsTableConfigResolver implements Resolve<EntityTableConfig<Asse
if ($event) {
$event.stopPropagation();
}
const url = this.router.createUrlTree([asset.id.id], {relativeTo: config.table.route});
const url = this.router.createUrlTree([asset.id.id], {relativeTo: config.getActivatedRoute()});
this.router.navigateByUrl(url);
}
@ -360,7 +361,7 @@ export class AssetsTableConfigResolver implements Resolve<EntityTableConfig<Asse
}).afterClosed()
.subscribe((res) => {
if (res) {
this.config.table.updateData();
this.config.updateData();
}
});
}
@ -379,7 +380,7 @@ export class AssetsTableConfigResolver implements Resolve<EntityTableConfig<Asse
if (res) {
this.assetService.makeAssetPublic(asset.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}
@ -402,7 +403,7 @@ export class AssetsTableConfigResolver implements Resolve<EntityTableConfig<Asse
}).afterClosed()
.subscribe((res) => {
if (res) {
this.config.table.updateData();
this.config.updateData();
}
});
}
@ -431,7 +432,7 @@ export class AssetsTableConfigResolver implements Resolve<EntityTableConfig<Asse
if (res) {
this.assetService.unassignAssetFromCustomer(asset.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData(this.config.componentsData.assetScope !== 'tenant');
}
);
}
@ -459,7 +460,7 @@ export class AssetsTableConfigResolver implements Resolve<EntityTableConfig<Asse
);
forkJoin(tasks).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}
@ -503,7 +504,7 @@ export class AssetsTableConfigResolver implements Resolve<EntityTableConfig<Asse
}).afterClosed()
.subscribe((res) => {
if (res) {
this.config.table.updateData();
this.config.updateData();
}
});
}
@ -522,7 +523,7 @@ export class AssetsTableConfigResolver implements Resolve<EntityTableConfig<Asse
if (res) {
this.assetService.unassignAssetFromEdge(this.config.componentsData.edgeId, asset.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData(this.config.componentsData.assetScope !== 'tenant');
}
);
}
@ -550,7 +551,7 @@ export class AssetsTableConfigResolver implements Resolve<EntityTableConfig<Asse
);
forkJoin(tasks).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}

View File

@ -141,7 +141,7 @@ export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<C
if ($event) {
$event.stopPropagation();
}
const url = this.router.createUrlTree([customer.id.id], {relativeTo: config.table.route});
const url = this.router.createUrlTree([customer.id.id], {relativeTo: config.getActivatedRoute()});
this.router.navigateByUrl(url);
}

View File

@ -103,7 +103,8 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
return this.dashboardService.saveDashboard(dashboard as Dashboard);
};
this.config.onEntityAction = action => this.onDashboardAction(action);
this.config.detailsReadonly = () => (this.config.componentsData.dashboardScope === 'customer_user' || this.config.componentsData.dashboardScope === 'edge_customer_user');
this.config.detailsReadonly = () => (this.config.componentsData.dashboardScope === 'customer_user' ||
this.config.componentsData.dashboardScope === 'edge_customer_user');
}
resolve(route: ActivatedRouteSnapshot): Observable<EntityTableConfig<DashboardInfo | Dashboard>> {
@ -147,7 +148,8 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
this.config.cellActionDescriptors = this.configureCellActions(this.config.componentsData.dashboardScope);
this.config.groupActionDescriptors = this.configureGroupActions(this.config.componentsData.dashboardScope);
this.config.addActionDescriptors = this.configureAddActions(this.config.componentsData.dashboardScope);
this.config.addEnabled = !(this.config.componentsData.dashboardScope === 'customer_user' || this.config.componentsData.dashboardScope === 'edge_customer_user');
this.config.addEnabled = !(this.config.componentsData.dashboardScope === 'customer_user' ||
this.config.componentsData.dashboardScope === 'edge_customer_user');
this.config.entitiesDeleteEnabled = this.config.componentsData.dashboardScope === 'tenant';
this.config.deleteEnabled = () => this.config.componentsData.dashboardScope === 'tenant';
return this.config;
@ -322,7 +324,7 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
name: this.translate.instant('dashboard.create-new-dashboard'),
icon: 'insert_drive_file',
isEnabled: () => true,
onAction: ($event) => this.config.table.addEntity($event)
onAction: ($event) => this.config.getTable().addEntity($event)
},
{
name: this.translate.instant('dashboard.import'),
@ -372,7 +374,7 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
this.importExport.importDashboard().subscribe(
(dashboard) => {
if (dashboard) {
this.config.table.updateData();
this.config.updateData();
}
}
);
@ -400,7 +402,7 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
}).afterClosed()
.subscribe((res) => {
if (res) {
this.config.table.updateData();
this.config.updateData();
}
});
}
@ -420,7 +422,7 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
}
}).afterClosed()
.subscribe(() => {
this.config.table.updateData();
this.config.updateData();
});
}
);
@ -440,7 +442,7 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
if (res) {
this.dashboardService.makeDashboardPrivate(dashboard.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}
@ -480,7 +482,7 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
}).afterClosed()
.subscribe((res) => {
if (res) {
this.config.table.updateData();
this.config.updateData();
}
});
}
@ -499,7 +501,7 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
if (res) {
this.dashboardService.unassignDashboardFromCustomer(customerId, dashboard.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData(this.config.componentsData.dashboardScope !== 'tenant');
}
);
}
@ -527,7 +529,7 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
);
forkJoin(tasks).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}
@ -577,7 +579,7 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
}).afterClosed()
.subscribe((res) => {
if (res) {
this.config.table.updateData();
this.config.updateData();
}
});
}
@ -596,7 +598,7 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
if (res) {
this.dashboardService.unassignDashboardFromEdge(this.config.componentsData.edgeId, dashboard.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData(this.config.componentsData.dashboardScope !== 'tenant');
}
);
}
@ -624,7 +626,7 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
);
forkJoin(tasks).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}

View File

@ -151,7 +151,7 @@ export class DeviceProfilesTableConfigResolver implements Resolve<EntityTableCon
}).afterClosed().subscribe(
(res) => {
if (res) {
this.config.table.updateData();
this.config.updateData();
}
}
);
@ -171,7 +171,7 @@ export class DeviceProfilesTableConfigResolver implements Resolve<EntityTableCon
if (res) {
this.deviceProfileService.setDefaultDeviceProfile(deviceProfile.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}
@ -191,7 +191,7 @@ export class DeviceProfilesTableConfigResolver implements Resolve<EntityTableCon
this.importExport.importDeviceProfile().subscribe(
(deviceProfile) => {
if (deviceProfile) {
this.config.table.updateData();
this.config.updateData();
}
}
);

View File

@ -37,7 +37,7 @@ export class DeviceTableHeaderComponent extends EntityTableHeaderComponent<Devic
deviceProfileChanged(deviceProfileId: DeviceProfileId) {
this.entitiesTableConfig.componentsData.deviceProfileId = deviceProfileId;
this.entitiesTableConfig.table.resetSortAndFilter(true);
this.entitiesTableConfig.getTable().resetSortAndFilter(true);
}
}

View File

@ -140,7 +140,7 @@ export class DeviceComponent extends EntityComponent<DeviceInfo> {
}
onDeviceProfileUpdated() {
this.entitiesTableConfig.table.updateData(false);
this.entitiesTableConfig.updateData(false);
}
onDeviceProfileChanged(deviceProfile: DeviceProfileInfo) {

View File

@ -375,7 +375,7 @@ export class DevicesTableConfigResolver implements Resolve<EntityTableConfig<Dev
if ($event) {
$event.stopPropagation();
}
const url = this.router.createUrlTree([device.id.id], {relativeTo: config.table.route});
const url = this.router.createUrlTree([device.id.id], {relativeTo: config.getActivatedRoute()});
this.router.navigateByUrl(url);
}
@ -383,7 +383,7 @@ export class DevicesTableConfigResolver implements Resolve<EntityTableConfig<Dev
this.homeDialogs.importEntities(EntityType.DEVICE).subscribe((res) => {
if (res) {
this.broadcast.broadcast('deviceSaved');
this.config.table.updateData();
this.config.updateData();
}
});
}
@ -394,12 +394,12 @@ export class DevicesTableConfigResolver implements Resolve<EntityTableConfig<Dev
disableClose: true,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
data: {
entitiesTableConfig: this.config.table.entitiesTableConfig
entitiesTableConfig: this.config
}
}).afterClosed().subscribe(
(res) => {
if (res) {
this.config.table.updateData();
this.config.updateData();
}
}
);
@ -420,7 +420,7 @@ export class DevicesTableConfigResolver implements Resolve<EntityTableConfig<Dev
}).afterClosed()
.subscribe((res) => {
if (res) {
this.config.table.updateData();
this.config.updateData();
}
});
}
@ -439,7 +439,7 @@ export class DevicesTableConfigResolver implements Resolve<EntityTableConfig<Dev
if (res) {
this.deviceService.makeDevicePublic(device.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}
@ -462,7 +462,7 @@ export class DevicesTableConfigResolver implements Resolve<EntityTableConfig<Dev
}).afterClosed()
.subscribe((res) => {
if (res) {
this.config.table.updateData();
this.config.updateData();
}
});
}
@ -491,7 +491,7 @@ export class DevicesTableConfigResolver implements Resolve<EntityTableConfig<Dev
if (res) {
this.deviceService.unassignDeviceFromCustomer(device.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData(this.config.componentsData.deviceScope !== 'tenant');
}
);
}
@ -519,7 +519,7 @@ export class DevicesTableConfigResolver implements Resolve<EntityTableConfig<Dev
);
forkJoin(tasks).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}
@ -586,7 +586,7 @@ export class DevicesTableConfigResolver implements Resolve<EntityTableConfig<Dev
}).afterClosed()
.subscribe((res) => {
if (res) {
this.config.table.updateData();
this.config.updateData();
}
});
}
@ -605,7 +605,7 @@ export class DevicesTableConfigResolver implements Resolve<EntityTableConfig<Dev
if (res) {
this.deviceService.unassignDeviceFromEdge(this.config.componentsData.edgeId, device.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData(this.config.componentsData.deviceScope !== 'tenant');
}
);
}
@ -633,7 +633,7 @@ export class DevicesTableConfigResolver implements Resolve<EntityTableConfig<Dev
);
forkJoin(tasks).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}

View File

@ -36,7 +36,7 @@ export class EdgeTableHeaderComponent extends EntityTableHeaderComponent<EdgeInf
edgeTypeChanged(edgeType: string) {
this.entitiesTableConfig.componentsData.edgeType = edgeType;
this.entitiesTableConfig.table.resetSortAndFilter(true);
this.entitiesTableConfig.getTable().resetSortAndFilter(true);
}
}

View File

@ -318,7 +318,7 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
name: this.translate.instant('edge.add-edge-text'),
icon: 'insert_drive_file',
isEnabled: () => true,
onAction: ($event) => this.config.table.addEntity($event)
onAction: ($event) => this.config.getTable().addEntity($event)
},
{
name: this.translate.instant('edge.import'),
@ -345,7 +345,7 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
this.homeDialogs.importEntities(EntityType.EDGE).subscribe((res) => {
if (res) {
this.broadcast.broadcast('edgeSaved');
this.config.table.updateData();
this.config.updateData();
}
});
}
@ -365,7 +365,7 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
}).afterClosed()
.subscribe((res) => {
if (res) {
this.config.table.updateData();
this.config.updateData();
}
});
}
@ -374,7 +374,7 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
if ($event) {
$event.stopPropagation();
}
const url = this.router.createUrlTree([edge.id.id], {relativeTo: config.table.route});
const url = this.router.createUrlTree([edge.id.id], {relativeTo: config.getActivatedRoute()});
this.router.navigateByUrl(url);
}
@ -392,7 +392,7 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
if (res) {
this.edgeService.makeEdgePublic(edge.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}
@ -443,7 +443,7 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
}).afterClosed()
.subscribe((res) => {
if (res) {
this.config.table.updateData();
this.config.updateData();
}
});
}
@ -472,7 +472,7 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
if (res) {
this.edgeService.unassignEdgeFromCustomer(edge.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData(this.config.componentsData.edgeScope !== 'tenant');
}
);
}
@ -500,7 +500,7 @@ export class EdgesTableConfigResolver implements Resolve<EntityTableConfig<EdgeI
);
forkJoin(tasks).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}

View File

@ -36,7 +36,7 @@ export class EntityViewTableHeaderComponent extends EntityTableHeaderComponent<E
entityViewTypeChanged(entityViewType: string) {
this.entitiesTableConfig.componentsData.entityViewType = entityViewType;
this.entitiesTableConfig.table.resetSortAndFilter(true);
this.entitiesTableConfig.getTable().resetSortAndFilter(true);
}
}

View File

@ -328,7 +328,7 @@ export class EntityViewsTableConfigResolver implements Resolve<EntityTableConfig
}).afterClosed()
.subscribe((res) => {
if (res) {
this.config.table.updateData();
this.config.updateData();
}
});
}
@ -337,7 +337,7 @@ export class EntityViewsTableConfigResolver implements Resolve<EntityTableConfig
if ($event) {
$event.stopPropagation();
}
const url = this.router.createUrlTree([entityView.id.id], {relativeTo: config.table.route});
const url = this.router.createUrlTree([entityView.id.id], {relativeTo: config.getActivatedRoute()});
this.router.navigateByUrl(url);
}
@ -355,7 +355,7 @@ export class EntityViewsTableConfigResolver implements Resolve<EntityTableConfig
if (res) {
this.entityViewService.makeEntityViewPublic(entityView.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}
@ -378,7 +378,7 @@ export class EntityViewsTableConfigResolver implements Resolve<EntityTableConfig
}).afterClosed()
.subscribe((res) => {
if (res) {
this.config.table.updateData();
this.config.updateData();
}
});
}
@ -407,7 +407,7 @@ export class EntityViewsTableConfigResolver implements Resolve<EntityTableConfig
if (res) {
this.entityViewService.unassignEntityViewFromCustomer(entityView.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData(this.config.componentsData.entityViewScope !== 'tenant');
}
);
}
@ -435,7 +435,7 @@ export class EntityViewsTableConfigResolver implements Resolve<EntityTableConfig
);
forkJoin(tasks).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}
@ -479,7 +479,7 @@ export class EntityViewsTableConfigResolver implements Resolve<EntityTableConfig
}).afterClosed()
.subscribe((res) => {
if (res) {
this.config.table.updateData();
this.config.updateData();
}
});
}
@ -498,7 +498,7 @@ export class EntityViewsTableConfigResolver implements Resolve<EntityTableConfig
if (res) {
this.entityViewService.unassignEntityViewFromEdge(this.config.componentsData.edgeId, entityView.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData(this.config.componentsData.entityViewScope !== 'tenant');
}
);
}
@ -526,7 +526,7 @@ export class EntityViewsTableConfigResolver implements Resolve<EntityTableConfig
);
forkJoin(tasks).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}

View File

@ -151,7 +151,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
name: this.translate.instant('rulechain.create-new-rulechain'),
icon: 'insert_drive_file',
isEnabled: () => true,
onAction: ($event) => this.config.table.addEntity($event)
onAction: ($event) => this.config.getTable().addEntity($event)
},
{
name: this.translate.instant('rulechain.import'),
@ -343,13 +343,13 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
this.ruleChainService.setEdgeRootRuleChain(this.config.componentsData.edgeId, ruleChain.id.id).subscribe(
(edge) => {
this.config.componentsData.edge = edge;
this.config.table.updateData();
this.config.updateData();
}
);
} else {
this.ruleChainService.setRootRuleChain(ruleChain.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}
@ -399,7 +399,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
if (res) {
this.ruleChainService.setEdgeTemplateRootRuleChain(ruleChain.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}
@ -436,11 +436,11 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
this.dialogService.alert(this.translate.instant('edge.missing-related-rule-chains-title'),
message, this.translate.instant('action.close'), true).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
} else {
this.config.table.updateData();
this.config.updateData();
}
}
);
@ -463,7 +463,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
if (res) {
this.ruleChainService.unassignRuleChainFromEdge(this.config.componentsData.edgeId, ruleChain.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData(this.config.componentsData.ruleChainScope !== 'tenant');
}
);
}
@ -491,7 +491,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
);
forkJoin(tasks).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}
@ -513,7 +513,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
if (res) {
this.ruleChainService.setAutoAssignToEdgeRuleChain(ruleChain.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}
@ -535,7 +535,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
if (res) {
this.ruleChainService.unsetAutoAssignToEdgeRuleChain(ruleChain.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}

View File

@ -106,7 +106,7 @@ export class TenantProfilesTableConfigResolver implements Resolve<EntityTableCon
name: this.translate.instant('tenant-profile.create-tenant-profile'),
icon: 'insert_drive_file',
isEnabled: () => true,
onAction: ($event) => this.config.table.addEntity($event)
onAction: ($event) => this.config.getTable().addEntity($event)
},
{
name: this.translate.instant('tenant-profile.import'),
@ -140,7 +140,7 @@ export class TenantProfilesTableConfigResolver implements Resolve<EntityTableCon
if (res) {
this.tenantProfileService.setDefaultTenantProfile(tenantProfile.id.id).subscribe(
() => {
this.config.table.updateData();
this.config.updateData();
}
);
}
@ -152,7 +152,7 @@ export class TenantProfilesTableConfigResolver implements Resolve<EntityTableCon
this.importExport.importTenantProfile().subscribe(
(deviceProfile) => {
if (deviceProfile) {
this.config.table.updateData();
this.config.updateData();
}
}
);

View File

@ -99,6 +99,6 @@ export class TenantComponent extends ContactBasedComponent<TenantInfo> {
}
onTenantProfileUpdated() {
this.entitiesTableConfig.table.updateData(false);
this.entitiesTableConfig.updateData(false);
}
}

View File

@ -91,7 +91,7 @@ export class TenantsTableConfigResolver implements Resolve<EntityTableConfig<Ten
if ($event) {
$event.stopPropagation();
}
const url = this.router.createUrlTree([tenant.id.id], {relativeTo: config.table.route});
const url = this.router.createUrlTree([tenant.id.id], {relativeTo: config.getActivatedRoute()});
this.router.navigateByUrl(url);
}

View File

@ -178,7 +178,7 @@ export class UsersTableConfigResolver implements Resolve<EntityTableConfig<User>
if ($event) {
$event.stopPropagation();
}
const url = this.router.createUrlTree([user.id.id], {relativeTo: config.table.route});
const url = this.router.createUrlTree([user.id.id], {relativeTo: config.getActivatedRoute()});
this.router.navigateByUrl(url);
}

View File

@ -76,7 +76,7 @@ export class WidgetsBundlesTableConfigResolver implements Resolve<EntityTableCon
name: this.translate.instant('widgets-bundle.create-new-widgets-bundle'),
icon: 'insert_drive_file',
isEnabled: () => true,
onAction: ($event) => this.config.table.addEntity($event)
onAction: ($event) => this.config.getTable().addEntity($event)
},
{
name: this.translate.instant('widgets-bundle.import'),
@ -137,7 +137,7 @@ export class WidgetsBundlesTableConfigResolver implements Resolve<EntityTableCon
this.importExport.importWidgetsBundle().subscribe(
(widgetsBundle) => {
if (widgetsBundle) {
this.config.table.updateData();
this.config.updateData();
}
}
);

View File

@ -16,6 +16,7 @@
import { EntityId } from '@shared/models/id/entity-id';
import { HasUUID } from '@shared/models/id/has-uuid';
import { isDefinedAndNotNull } from '@core/utils';
export declare type HasId = EntityId | HasUUID;
@ -25,3 +26,11 @@ export interface BaseData<T extends HasId> {
name?: string;
label?: string;
}
export function hasIdEquals(id1: HasId, id2: HasId): boolean {
if (isDefinedAndNotNull(id1) && isDefinedAndNotNull(id2)) {
return id1.id === id2.id;
} else {
return id1 === id2;
}
}