# All files / src/app/core/navigation/dashboard-help dashboard-help.component.ts

72.41% Statements 21/29
73.33% Branches 11/15
50% Functions 3/6
69.23% Lines 18/26

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    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
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    535x

    5x

    5x
    5x
    5x
    5x

    5x

    5x

    1x
    1x
    1x
    1x

    5x
    1x

    1x

    5x

    5x

    5x
     import { Component, OnInit, ViewChild } from '@angular/core';

    import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';

    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 { AboutComponent } from '../about/about.component';

    @Component({
      selector: 'cd-dashboard-help',
      template: require('./dashboard-help.component.html'),
      styles: []
    })
    export class DashboardHelpComponent implements OnInit {
      @ViewChild('docsForm')
      docsFormElement;
      docsUrl: string;
      modalRef: BsModalRef;

      constructor(
        private summaryService: SummaryService,
        private cephReleaseNamePipe: CephReleaseNamePipe,
        private modalService: BsModalService,
        private authStorageService: AuthStorageService
      ) {}

      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/dashboard/`;

          setTimeout(() => {
            subs.unsubscribe();
          }, 0);
        });
      }

      openAboutModal() {
        this.modalRef = this.modalService.show(AboutComponent);
      }

      goToApiDocs() {
        const tokenInput = this.docsFormElement.nativeElement.children[0];
        tokenInput.value = this.authStorageService.getToken();
        this.docsFormElement.nativeElement.submit();
      }
    }