]> git.apps.os.sepia.ceph.com Git - ceph.git/blob
bf7f1b574e1d880df7231a9884f6e50b76494f52
[ceph.git] /
1 import { Component, OnInit, ViewChild } from '@angular/core';
2
3 import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
4
5 import { CephReleaseNamePipe } from '../../../shared/pipes/ceph-release-name.pipe';
6 import { AuthStorageService } from '../../../shared/services/auth-storage.service';
7 import { SummaryService } from '../../../shared/services/summary.service';
8 import { AboutComponent } from '../about/about.component';
9
10 @Component({
11   selector: 'cd-dashboard-help',
12   templateUrl: './dashboard-help.component.html',
13   styleUrls: ['./dashboard-help.component.scss']
14 })
15 export class DashboardHelpComponent implements OnInit {
16   @ViewChild('docsForm')
17   docsFormElement;
18   docsUrl: string;
19   modalRef: BsModalRef;
20
21   constructor(
22     private summaryService: SummaryService,
23     private cephReleaseNamePipe: CephReleaseNamePipe,
24     private modalService: BsModalService,
25     private authStorageService: AuthStorageService
26   ) {}
27
28   ngOnInit() {
29     const subs = this.summaryService.subscribe((summary: any) => {
30       if (!summary) {
31         return;
32       }
33
34       const releaseName = this.cephReleaseNamePipe.transform(summary.version);
35       this.docsUrl = `http://docs.ceph.com/docs/${releaseName}/mgr/dashboard/`;
36
37       setTimeout(() => {
38         subs.unsubscribe();
39       }, 0);
40     });
41   }
42
43   openAboutModal() {
44     this.modalRef = this.modalService.show(AboutComponent);
45   }
46
47   goToApiDocs() {
48     const tokenInput = this.docsFormElement.nativeElement.children[0];
49     tokenInput.value = this.authStorageService.getToken();
50     this.docsFormElement.nativeElement.submit();
51   }
52 }