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