]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/blob
e6821ddf960ff137a01487745975e21023ecb7ac
[ceph-ci.git] /
1 import { Component, OnInit, ViewChild } from '@angular/core';
2
3 import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
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 { SummaryService } from '../../../shared/services/summary.service';
9 import { AboutComponent } from '../about/about.component';
10
11 @Component({
12   selector: 'cd-dashboard-help',
13   templateUrl: './dashboard-help.component.html',
14   styleUrls: ['./dashboard-help.component.scss']
15 })
16 export class DashboardHelpComponent implements OnInit {
17   @ViewChild('docsForm', { static: true })
18   docsFormElement: any;
19   docsUrl: string;
20   modalRef: BsModalRef;
21   icons = Icons;
22
23   constructor(
24     private summaryService: SummaryService,
25     private cephReleaseNamePipe: CephReleaseNamePipe,
26     private modalService: BsModalService,
27     private authStorageService: AuthStorageService
28   ) {}
29
30   ngOnInit() {
31     this.summaryService.subscribeOnce((summary) => {
32       const releaseName = this.cephReleaseNamePipe.transform(summary.version);
33       this.docsUrl = `http://docs.ceph.com/docs/${releaseName}/mgr/dashboard/`;
34     });
35   }
36
37   openAboutModal() {
38     this.modalRef = this.modalService.show(AboutComponent);
39     this.modalRef.setClass('modal-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 }