]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/smart-list/smart-list.component.ts
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / shared / smart-list / smart-list.component.ts
index 5f228a8f886240a11c4bd09465a0fa6703f343ed..298e22b86d02fb75aa304535ec4e6ca575cf5397 100644 (file)
@@ -1,19 +1,18 @@
 import { Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild } from '@angular/core';
 
-import { I18n } from '@ngx-translate/i18n-polyfill';
-import * as _ from 'lodash';
-import { TabsetComponent } from 'ngx-bootstrap/tabs';
+import { NgbNav } from '@ng-bootstrap/ng-bootstrap';
+import _ from 'lodash';
 
-import { HostService } from '../../../shared/api/host.service';
-import { OsdService } from '../../../shared/api/osd.service';
-import { CdTableColumn } from '../../../shared/models/cd-table-column';
+import { HostService } from '~/app/shared/api/host.service';
+import { OsdService } from '~/app/shared/api/osd.service';
+import { CdTableColumn } from '~/app/shared/models/cd-table-column';
 import {
   HddSmartDataV1,
   NvmeSmartDataV1,
   SmartDataResult,
   SmartError,
   SmartErrorResult
-} from '../../../shared/models/smart';
+} from '~/app/shared/models/smart';
 
 @Component({
   selector: 'cd-smart-list',
@@ -21,8 +20,8 @@ import {
   styleUrls: ['./smart-list.component.scss']
 })
 export class SmartListComponent implements OnInit, OnChanges {
-  @ViewChild('innerTabset', { static: false })
-  innerTabset: TabsetComponent;
+  @ViewChild('innerNav')
+  nav: NgbNav;
 
   @Input()
   osdId: number = null;
@@ -39,11 +38,7 @@ export class SmartListComponent implements OnInit, OnChanges {
 
   isEmpty = _.isEmpty;
 
-  constructor(
-    private i18n: I18n,
-    private osdService: OsdService,
-    private hostService: HostService
-  ) {}
+  constructor(private osdService: OsdService, private hostService: HostService) {}
 
   isSmartError(data: any): data is SmartError {
     return _.get(data, 'error') !== undefined;
@@ -63,16 +58,12 @@ export class SmartListComponent implements OnInit, OnChanges {
       if (this.isSmartError(smartData)) {
         let userMessage = '';
         if (smartData.smartctl_error_code === -22) {
-          userMessage = this.i18n(
-            `Smartctl has received an unknown argument (error code {{code}}). \
+          userMessage = $localize`Smartctl has received an unknown argument \
+(error code ${smartData.smartctl_error_code}). \
 You may be using an incompatible version of smartmontools. Version >= 7.0 of \
-smartmontools is required to successfully retrieve data.`,
-            { code: smartData.smartctl_error_code }
-          );
+smartmontools is required to successfully retrieve data.`;
         } else {
-          userMessage = this.i18n('An error with error code {{code}} occurred.', {
-            code: smartData.smartctl_error_code
-          });
+          userMessage = $localize`An error with error code ${smartData.smartctl_error_code} occurred.`;
         }
         const _result: SmartErrorResult = {
           error: smartData.error,
@@ -136,29 +127,35 @@ smartmontools is required to successfully retrieve data.`,
     this.loading = true;
 
     if (this.osdId !== null) {
-      this.osdService.getSmartData(this.osdId).subscribe(this.fetchData.bind(this), (error) => {
-        error.preventDefault();
-        this.error = error;
-        this.loading = false;
+      this.osdService.getSmartData(this.osdId).subscribe({
+        next: this.fetchData.bind(this),
+        error: (error) => {
+          error.preventDefault();
+          this.error = error;
+          this.loading = false;
+        }
       });
     } else if (this.hostname !== null) {
-      this.hostService.getSmartData(this.hostname).subscribe(this.fetchData.bind(this), (error) => {
-        error.preventDefault();
-        this.error = error;
-        this.loading = false;
+      this.hostService.getSmartData(this.hostname).subscribe({
+        next: this.fetchData.bind(this),
+        error: (error) => {
+          error.preventDefault();
+          this.error = error;
+          this.loading = false;
+        }
       });
     }
   }
 
   ngOnInit() {
     this.smartDataColumns = [
-      { prop: 'id', name: this.i18n('ID') },
-      { prop: 'name', name: this.i18n('Name') },
-      { prop: 'raw.value', name: this.i18n('Raw') },
-      { prop: 'thresh', name: this.i18n('Threshold') },
-      { prop: 'value', name: this.i18n('Value') },
-      { prop: 'when_failed', name: this.i18n('When Failed') },
-      { prop: 'worst', name: this.i18n('Worst') }
+      { prop: 'id', name: $localize`ID` },
+      { prop: 'name', name: $localize`Name` },
+      { prop: 'raw.value', name: $localize`Raw` },
+      { prop: 'thresh', name: $localize`Threshold` },
+      { prop: 'value', name: $localize`Value` },
+      { prop: 'when_failed', name: $localize`When Failed` },
+      { prop: 'worst', name: $localize`Worst` }
     ];
   }