]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / core / navigation / dashboard-help / dashboard-help.component.ts
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 const subs = this.summaryService.subscribe((summary: any) => {
32 if (!summary) {
33 return;
34 }
35
36 const releaseName = this.cephReleaseNamePipe.transform(summary.version);
37 this.docsUrl = `http://docs.ceph.com/docs/${releaseName}/mgr/dashboard/`;
38
39 setTimeout(() => {
40 subs.unsubscribe();
41 }, 0);
42 });
43 }
44
45 openAboutModal() {
46 this.modalRef = this.modalService.show(AboutComponent);
47 this.modalRef.setClass('modal-lg');
48 }
49
50 goToApiDocs() {
51 const tokenInput = this.docsFormElement.nativeElement.children[0];
52 tokenInput.value = this.authStorageService.getToken();
53 this.docsFormElement.nativeElement.submit();
54 }
55 }