summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/src/app/shared/classes/list-with-details.class.ts
blob: 2eaeeb35eecf85f6f31b7e7805e671ffdd59dfe1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { NgZone } from '@angular/core';

import { TableStatus } from './table-status';

export class ListWithDetails {
  expandedRow: any;
  staleTimeout: number;
  tableStatus: TableStatus;

  constructor(protected ngZone?: NgZone) {}

  setExpandedRow(expandedRow: any) {
    this.expandedRow = expandedRow;
  }

  setTableRefreshTimeout() {
    clearTimeout(this.staleTimeout);
    this.ngZone.runOutsideAngular(() => {
      this.staleTimeout = window.setTimeout(() => {
        this.ngZone.run(() => {
          this.tableStatus = new TableStatus(
            'warning',
            $localize`The user list data might be stale. If needed, you can manually reload it.`
          );
        });
      }, 10000);
    });
  }
}