summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/src/app/shared/classes/table-status-view-cache.ts
blob: 91c53a0aa06e036f4d8923a1ee54e7aa1404f158 (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
30
31
32
33
34
35
36
37
import { ViewCacheStatus } from '../enum/view-cache-status.enum';
import { TableStatus } from './table-status';

export class TableStatusViewCache extends TableStatus {
  constructor(status: ViewCacheStatus = ViewCacheStatus.ValueOk, statusFor: string = '') {
    super();

    switch (status) {
      case ViewCacheStatus.ValueOk:
        this.type = 'light';
        this.msg = '';
        break;
      case ViewCacheStatus.ValueNone:
        this.type = 'info';
        this.msg =
          (statusFor ? $localize`Retrieving data for ${statusFor}.` : $localize`Retrieving data.`) +
          ' ' +
          $localize`Please wait...`;
        break;
      case ViewCacheStatus.ValueStale:
        this.type = 'warning';
        this.msg = statusFor
          ? $localize`Displaying previously cached data for ${statusFor}.`
          : $localize`Displaying previously cached data.`;
        break;
      case ViewCacheStatus.ValueException:
        this.type = 'danger';
        this.msg =
          (statusFor
            ? $localize`Could not load data for ${statusFor}.`
            : $localize`Could not load data.`) +
          ' ' +
          $localize`Please check the cluster health.`;
        break;
    }
  }
}