File

src/app/core/navigation/dashboard-help/dashboard-help.component.ts

Implements

OnInit

Metadata

selector cd-dashboard-help
styleUrls ./dashboard-help.component.scss
templateUrl ./dashboard-help.component.html

Index

Properties
Methods

Constructor

constructor(summaryService: SummaryService, cephReleaseNamePipe: CephReleaseNamePipe, modalService: BsModalService, authStorageService: AuthStorageService)
Parameters :
Name Type Optional
summaryService SummaryService No
cephReleaseNamePipe CephReleaseNamePipe No
modalService BsModalService No
authStorageService AuthStorageService No

Methods

goToApiDocs
goToApiDocs()
Returns : void
ngOnInit
ngOnInit()
Returns : void
openAboutModal
openAboutModal()
Returns : void

Properties

docsFormElement
Decorators :
@ViewChild('docsForm')
docsUrl
Type : string
modalRef
Type : BsModalRef
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',
  templateUrl: './dashboard-help.component.html',
  styleUrls: ['./dashboard-help.component.scss']
})
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();
  }
}
<form #docsForm action="/docs" target="_blank" method="post">
  <input type="hidden" name="token"/>
</form>

<div dropdown>
  <a dropdownToggle
     class="dropdown-toggle"
     data-toggle="dropdown"
     i18n-title
     title="Help">
    <i class="fa fa-fw fa-question-circle-o"></i>
    <span i18n
          class="visible-xs-inline-block">Help</span>
    <span class="caret"></span>
  </a>
  <ul *dropdownMenu
      class="dropdown-menu dropdown-menu-right">
    <li>
      <a i18n
         class="dropdown-item"
         [ngClass]="{'disabled': !docsUrl}"
         href="{{ docsUrl }}"
         target="_blank">Documentation</a>
    </li>
    <li>
      <a i18n
         class="dropdown-item"
         (click)="goToApiDocs()">API</a>
    </li>
    <li>
      <a i18n
         class="dropdown-item"
         (click)="openAboutModal()">About</a>
    </li>
  </ul>
</div>

./dashboard-help.component.scss

Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""