summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/src/app/shared/components/doc/doc.component.ts
blob: 6dffc360b6657b0d33a887ede81fabe90686a28b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { Component, Input, OnInit } from '@angular/core';

import { DocService } from '~/app/shared/services/doc.service';

@Component({
  selector: 'cd-doc',
  templateUrl: './doc.component.html',
  styleUrls: ['./doc.component.scss']
})
export class DocComponent implements OnInit {
  @Input() section: string;
  @Input() docText = $localize`documentation`;
  @Input() noSubscribe: boolean;

  docUrl: string;

  constructor(private docService: DocService) {}

  ngOnInit() {
    if (this.noSubscribe) {
      this.docUrl = this.docService.urlGenerator(this.section);
    } else {
      this.docService.subscribeOnce(this.section, (url: string) => {
        this.docUrl = url;
      });
    }
  }
}