File

widgets/implementations/datapoints-table/datapoints-table-view/datapoints-reload/datapoints-reload.component.ts

Extends

IntervalBasedReload

Implements

OnChanges

Metadata

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor(cdRef: ChangeDetectorRef, injector: Injector, translateService: TranslateService)
Parameters :
Name Type Optional
cdRef ChangeDetectorRef No
injector Injector No
translateService TranslateService No

Inputs

isAutoRefreshEnabled
Type : boolean
isDisabled
Type : boolean
isExportModalOpen
Type : boolean
isLoading
Type : Signal<boolean>
isScrolling
Type : boolean
refreshInterval
Type : number

Outputs

onCountdownEnded
Type : EventEmitter

Methods

countdownEnded
countdownEnded()
Returns : void
enableCountdown
enableCountdown()
Returns : void
ngOnChanges
ngOnChanges(changes: SimpleChanges)
Parameters :
Name Type Optional
changes SimpleChanges No
Returns : void
reload
reload()
Returns : void
Protected updateCountdownButtonTooltipText
updateCountdownButtonTooltipText()
Returns : void
autoRefreshList
autoRefreshList()

Stops the countdown and triggers a refresh action. This function is responsible for halting the countdown interval component's operation. After stopping the countdown, it emits an onCountdownEnded event. This event is used to inform external components that the countdown has ended, typically prompting them to reload or refresh their data.

Returns : void
disableCountdown
disableCountdown()

Disables and hides the countdown timer.

This method stops the ongoing countdown process by stopping the countdownIntervalComponent if it exists. It then hides the countdown timer by setting hideCountdown to true. This method encapsulates the logic required to halt and conceal the countdown timer.

Returns : void
handleScrolling
handleScrolling()

Manages the countdown timer's visibility and state in response to user scrolling.

This method toggles the countdown timer based on the user's scrolling behavior. It uses the disableCountdown and enableCountdown methods for handling the countdown state.

  • If the user is scrolling down while the countdown is visible (isScrolling is true and hideCountdown is false), disableCountdown is called to stop and hide the countdown, and isIntervalRefreshToggleOn is set to false.

  • If the user has stopped scrolling, the countdown subscription is closed, and the countdown is hidden (!isScrolling, countdownSubscription?.closed, hideCountdown), enableCountdown is called to show and restart the countdown, and isIntervalRefreshToggleOn is set to true.

Returns : void
onToggleCountdownButtonState
onToggleCountdownButtonState($event: MouseEvent)

Handles the toggle state of the countdown on button click.

This method is triggered by a mouse event, typically a click on the countdown toggle button. It toggles isIntervalRefreshToggleOn to reflect the current state of the countdown timer.

  • If isIntervalRefreshToggleOn is set to false, indicating that the countdown should be stopped, disableCountdown is called, and manuallyDisabledCountdown is set to true.

  • If isIntervalRefreshToggleOn is true and the countdown subscription is closed, indicating that the countdown can be started, enableCountdown is called, and manuallyDisabledCountdown is set to false.

Parameters :
Name Type Optional Description
$event MouseEvent No
  • The MouseEvent that triggered this method.
Returns : void
startCountdown
startCountdown(injector: Injector)

This function listens for changes in the isLoading observable, filtering out any truthy values. Once a falsy value is detected (indicating that loading has finished), it attempts to start the countdown.

IMPORTANT: If the widget's configuration (refreshInterval, check template) is not set prior to executing countdownIntervalComponent?.start, the countdown interval will not start!

Example :
              within the `runInInjectionContext`.
Parameters :
Name Type Optional Description
injector Injector No
  • The injector used to provide necessary dependencies within the runInInjectionContext.
Returns : void

Properties

countdownIntervalComponent
Type : CountdownIntervalComponent
Decorators :
@ViewChild(CountdownIntervalComponent, {static: false})
Protected hideCountdown
Type : boolean
isIntervalRefreshToggleOn
Type : boolean
Protected manuallyDisabledCountdown
Default value : false
toggleCountdownButtonTooltipText
Type : string
isAutoRefreshEnabled
Type : boolean

Indicates whether auto-refresh is enabled for the datapoints reload component that is set in widget config.

Abstract isLoading
Type : Signal<boolean>

Current isLoading state. Based on it next countdown cycle is being started.

Abstract isScrolling
Type : boolean

Indicates whether the alarm list is being scrolled or not.

Abstract onCountdownEnded
Type : EventEmitter<void>

Indicates that a countdown cycle has ended.

Abstract refreshInterval
Type : number

Current refresh interval set in a widget config.

<div class="d-flex a-i-center p-t-4 p-b-4">
  <label
    class="m-b-0 m-r-8 text-label-small text-truncate flex-no-shrink"
    title=" {{ 'Auto refresh' | translate }}"
    *ngIf="refreshInterval && isAutoRefreshEnabled"
  >
    {{ 'Auto refresh' | translate }}
  </label>
  <div class="input-group">
    <label
      class="toggle-countdown"
      [class.toggle-countdown-disabled]="isDisabled"
      [attr.aria-label]="toggleCountdownButtonTooltipText"
      [tooltip]="toggleCountdownButtonTooltipText"
      placement="bottom"
      *ngIf="refreshInterval && isAutoRefreshEnabled"
      [adaptivePosition]="false"
      [container]="'body'"
      [delay]="500"
    >
      <input
        type="checkbox"
        [checked]="isIntervalRefreshToggleOn"
        [disabled]="isDisabled"
        data-cy="c8y-data-points-table-widget--interval-toggle-button"
        (click)="onToggleCountdownButtonState($event)"
      />

      <c8y-countdown-interval
        *ngIf="isIntervalRefreshToggleOn"
        [countdownInterval]="refreshInterval"
        (countdownEnded)="countdownEnded()"
      ></c8y-countdown-interval>
      <i
        c8yIcon="pause"
        *ngIf="!isIntervalRefreshToggleOn"
      ></i>
    </label>

    <div class="input-group-btn">
      <button
        class="btn btn-default"
        [attr.aria-label]="'Refresh' | translate"
        [tooltip]="'Refresh' | translate"
        placement="bottom"
        type="button"
        [adaptivePosition]="false"
        [container]="'body'"
        [delay]="500"
        [disabled]="isLoading()"
        (click)="reload()"
        data-cy="c8y-data-points-table-widget--reload-button"
      >
        <i
          c8yIcon="refresh"
          [ngClass]="{ 'icon-spin': isLoading() }"
        ></i>
      </button>
    </div>
  </div>
</div>

results matching ""

    No results matching ""