]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: cleanup codes
authorKiefer Chang <kiefer.chang@suse.com>
Mon, 23 Dec 2019 08:20:37 +0000 (16:20 +0800)
committerKiefer Chang <kiefer.chang@suse.com>
Wed, 11 Mar 2020 06:19:43 +0000 (14:19 +0800)
Remove redundant codes for detecting Orchestrator.

Signed-off-by: Kiefer Chang <kiefer.chang@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/inventory/inventory.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/inventory/inventory.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-form/osd-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-form/osd-form.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/services.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/services.component.ts

index de8a1145bd2002f2f31cfcf4b661c3ceddd5e9aa..70a0d0ef50e1a3eab1d2c48170d58f8ba569a7b7 100644 (file)
@@ -1,11 +1,5 @@
-<cd-alert-panel type="info"
-                *ngIf="!orchestratorExist && !checkingOrchestrator"
-                i18n>Please consult the
-  <a href="{{ docsUrl }}"
-     target="_blank">documentation</a> on how to
-  configure and enable the orchestrator functionality.</cd-alert-panel>
-
-<ng-container *ngIf="orchestratorExist">
+<cd-orchestrator-doc-panel *ngIf="!hasOrchestrator"></cd-orchestrator-doc-panel>
+<ng-container *ngIf="hasOrchestrator">
   <legend i18n>Devices</legend>
   <div class="row">
     <div class="col-md-12">
index 2d5fd4ac5a11e72a9c49c88e26bb8d5c5f30e49e..a529924d93e53b3805fbeebe0b005dba9cecccb9 100644 (file)
@@ -2,8 +2,6 @@ import { Component, Input, OnChanges, OnInit } from '@angular/core';
 
 import { OrchestratorService } from '../../../shared/api/orchestrator.service';
 import { Icons } from '../../../shared/enum/icons.enum';
-import { CephReleaseNamePipe } from '../../../shared/pipes/ceph-release-name.pipe';
-import { SummaryService } from '../../../shared/services/summary.service';
 import { InventoryDevice } from './inventory-devices/inventory-device.model';
 
 @Component({
@@ -17,41 +15,24 @@ export class InventoryComponent implements OnChanges, OnInit {
 
   icons = Icons;
 
-  checkingOrchestrator = true;
-  orchestratorExist = false;
+  hasOrchestrator = false;
   docsUrl: string;
 
   devices: Array<InventoryDevice> = [];
 
-  constructor(
-    private cephReleaseNamePipe: CephReleaseNamePipe,
-    private orchService: OrchestratorService,
-    private summaryService: SummaryService
-  ) {}
+  constructor(private orchService: OrchestratorService) {}
 
   ngOnInit() {
-    // duplicated code with grafana
-    const subs = this.summaryService.subscribe((summary: any) => {
-      if (!summary) {
-        return;
+    this.orchService.status().subscribe((status) => {
+      this.hasOrchestrator = status.available;
+      if (status.available) {
+        this.getInventory();
       }
-
-      const releaseName = this.cephReleaseNamePipe.transform(summary.version);
-      this.docsUrl = `http://docs.ceph.com/docs/${releaseName}/mgr/orchestrator/`;
-
-      setTimeout(() => {
-        subs.unsubscribe();
-      }, 0);
-    });
-
-    this.orchService.status().subscribe((data: { available: boolean }) => {
-      this.orchestratorExist = data.available;
-      this.checkingOrchestrator = false;
     });
   }
 
   ngOnChanges() {
-    if (this.orchestratorExist) {
+    if (this.hasOrchestrator) {
       this.devices = [];
       this.getInventory();
     }
index 132795dd52b679041e2b239efd3d097dd8c10e6a..f2dc381c5c218e1d8cb432693173c9d98d5e7e7d 100644 (file)
@@ -1,13 +1,6 @@
-<cd-loading-panel *ngIf="loading"
-                  i18n>Loading...</cd-loading-panel>
-<cd-alert-panel type="info"
-                *ngIf="!orchestratorExist && !checkingOrchestrator"
-                i18n>Please consult the
-  <a href="{{ docsUrl }}"
-     target="_blank">documentation</a> on how to
-  configure and enable the orchestrator functionality.</cd-alert-panel>
+<cd-orchestrator-doc-panel *ngIf="!hasOrchestrator"></cd-orchestrator-doc-panel>
 <div class="cd-col-form"
-     *ngIf="!loading && orchestratorExist">
+     *ngIf="!loading && hasOrchestrator">
   <form name="form"
         #formDir="ngForm"
         [formGroup]="form"
index 56187719bc845fd00f92bb2e55decc451244040e..5defdbeecc5ba5cddd8cf2d740234eb1e00089da 100644 (file)
@@ -12,9 +12,7 @@ import { ActionLabelsI18n } from '../../../../shared/constants/app.constants';
 import { Icons } from '../../../../shared/enum/icons.enum';
 import { CdFormGroup } from '../../../../shared/forms/cd-form-group';
 import { CdTableColumn } from '../../../../shared/models/cd-table-column';
-import { CephReleaseNamePipe } from '../../../../shared/pipes/ceph-release-name.pipe';
 import { AuthStorageService } from '../../../../shared/services/auth-storage.service';
-import { SummaryService } from '../../../../shared/services/summary.service';
 import { InventoryDevice } from '../../inventory/inventory-devices/inventory-device.model';
 import { OsdCreationPreviewModalComponent } from '../osd-creation-preview-modal/osd-creation-preview-modal.component';
 import { DevicesSelectionChangeEvent } from '../osd-devices-selection-groups/devices-selection-change-event.interface';
@@ -63,8 +61,7 @@ export class OsdFormComponent implements OnInit {
   features: { [key: string]: OsdFeature };
   featureList: OsdFeature[] = [];
 
-  checkingOrchestrator = true;
-  orchestratorExist = false;
+  hasOrchestrator = false;
   docsUrl: string;
 
   constructor(
@@ -73,9 +70,7 @@ export class OsdFormComponent implements OnInit {
     private i18n: I18n,
     private orchService: OrchestratorService,
     private router: Router,
-    private bsModalService: BsModalService,
-    private summaryService: SummaryService,
-    private cephReleaseNamePipe: CephReleaseNamePipe
+    private bsModalService: BsModalService
   ) {
     this.resource = this.i18n('OSDs');
     this.action = this.actionLabels.CREATE;
@@ -90,23 +85,9 @@ export class OsdFormComponent implements OnInit {
   }
 
   ngOnInit() {
-    const subs = this.summaryService.subscribe((summary: any) => {
-      if (!summary) {
-        return;
-      }
-
-      const releaseName = this.cephReleaseNamePipe.transform(summary.version);
-      this.docsUrl = `http://docs.ceph.com/docs/${releaseName}/mgr/orchestrator/`;
-
-      setTimeout(() => {
-        subs.unsubscribe();
-      }, 0);
-    });
-
-    this.orchService.status().subscribe((data: { available: boolean }) => {
-      this.orchestratorExist = data.available;
-      this.checkingOrchestrator = false;
-      if (this.orchestratorExist) {
+    this.orchService.status().subscribe((status) => {
+      this.hasOrchestrator = status.available;
+      if (this.hasOrchestrator) {
         this.getDataDevices();
       }
     });
index ce3e72bceaba770178eb442052804461e7167440..5749d89d065a918d1b71935b3eb1401227392574 100644 (file)
@@ -1,11 +1,5 @@
-<cd-alert-panel type="info"
-                *ngIf="!orchestratorExist && !checkingOrchestrator"
-                i18n>Please consult the
-  <a href="{{ docsUrl }}"
-     target="_blank">documentation</a> on how to
-  configure and enable the orchestrator functionality.</cd-alert-panel>
-
-<ng-container *ngIf="orchestratorExist">
+<cd-orchestrator-doc-panel *ngIf="!hasOrchestrator"></cd-orchestrator-doc-panel>
+<ng-container *ngIf="hasOrchestrator">
   <cd-table [data]="services"
             [columns]="columns"
             identifier="service_name"
index 226a9df37291749e3a6ae7bbd4825f3fbf9a3f95..d2cfde2068a33873a150c8411c8701d79415cfb5 100644 (file)
@@ -9,9 +9,7 @@ import { CdTableFetchDataContext } from '../../../shared/models/cd-table-fetch-d
 import { CdTableSelection } from '../../../shared/models/cd-table-selection';
 import { Permissions } from '../../../shared/models/permissions';
 import { CephService } from '../../../shared/models/service.interface';
-import { CephReleaseNamePipe } from '../../../shared/pipes/ceph-release-name.pipe';
 import { AuthStorageService } from '../../../shared/services/auth-storage.service';
-import { SummaryService } from '../../../shared/services/summary.service';
 
 @Component({
   selector: 'cd-services',
@@ -31,6 +29,7 @@ export class ServicesComponent implements OnChanges, OnInit {
 
   checkingOrchestrator = true;
   orchestratorExist = false;
+  hasOrchestrator = false;
   docsUrl: string;
 
   columns: Array<CdTableColumn> = [];
@@ -40,11 +39,9 @@ export class ServicesComponent implements OnChanges, OnInit {
 
   constructor(
     private authStorageService: AuthStorageService,
-    private cephReleaseNamePipe: CephReleaseNamePipe,
     private i18n: I18n,
     private orchService: OrchestratorService,
-    private cephServiceService: CephServiceService,
-    private summaryService: SummaryService
+    private cephServiceService: CephServiceService
   ) {
     this.permissions = this.authStorageService.getPermissions();
   }
@@ -87,23 +84,8 @@ export class ServicesComponent implements OnChanges, OnInit {
       return !this.hiddenColumns.includes(col.prop);
     });
 
-    // duplicated code with grafana
-    const subs = this.summaryService.subscribe((summary: any) => {
-      if (!summary) {
-        return;
-      }
-
-      const releaseName = this.cephReleaseNamePipe.transform(summary.version);
-      this.docsUrl = `http://docs.ceph.com/docs/${releaseName}/mgr/orchestrator/`;
-
-      setTimeout(() => {
-        subs.unsubscribe();
-      }, 0);
-    });
-
-    this.orchService.status().subscribe((data: { available: boolean }) => {
-      this.orchestratorExist = data.available;
-      this.checkingOrchestrator = false;
+    this.orchService.status().subscribe((status) => {
+      this.hasOrchestrator = status.available;
     });
   }