@ -1,5 +1,6 @@
// SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
import {
ComponentRef ,
Directive ,
@ -71,13 +72,20 @@ export class StatesComponentDirective implements OnInit, OnDestroy, OnChanges {
ngOnChanges ( changes : SimpleChanges ) : void {
let reInitController = false ;
let initController = false ;
const dashboardIdChange = changes . dashboardId ;
const dashboardChanged = ! ! dashboardIdChange && ! dashboardIdChange . firstChange &&
dashboardIdChange . currentValue !== dashboardIdChange . previousValue ;
for ( const propName of Object . keys ( changes ) ) {
const change = changes [ propName ] ;
if ( ! change . firstChange && change . currentValue !== change . previousValue ) {
if ( propName === 'statesControllerId' ) {
this . reInit ( ) ;
} else if ( propName === 'states' ) {
this . stateControllerComponent . states = this . states ;
if ( dashboardChanged ) {
this . stateControllerComponent . replaceStates ( this . states ) ;
} else {
this . stateControllerComponent . states = this . states ;
}
} else if ( propName === 'dashboardId' ) {
this . stateControllerComponent . dashboardId = this . dashboardId ;
reInitController = true ;