11 } from '@angular/core';
12 import { I18n } from '@ngx-translate/i18n-polyfill';
14 import * as _ from 'lodash';
16 import { Observable, Subscription } from 'rxjs';
17 import { CephServiceService } from '../../../../shared/api/ceph-service.service';
18 import { HostService } from '../../../../shared/api/host.service';
19 import { OrchestratorService } from '../../../../shared/api/orchestrator.service';
20 import { TableComponent } from '../../../../shared/datatable/table/table.component';
21 import { CellTemplate } from '../../../../shared/enum/cell-template.enum';
22 import { CdTableColumn } from '../../../../shared/models/cd-table-column';
23 import { CdTableFetchDataContext } from '../../../../shared/models/cd-table-fetch-data-context';
24 import { Daemon } from '../../../../shared/models/daemon.interface';
27 selector: 'cd-service-daemon-list',
28 templateUrl: './service-daemon-list.component.html',
29 styleUrls: ['./service-daemon-list.component.scss']
31 export class ServiceDaemonListComponent implements OnInit, OnChanges, AfterViewInit, OnDestroy {
32 @ViewChildren('daemonsTable')
33 daemonsTableTpls: QueryList<TemplateRef<TableComponent>>;
41 daemons: Daemon[] = [];
42 columns: CdTableColumn[] = [];
44 hasOrchestrator = false;
46 private daemonsTable: TableComponent;
47 private daemonsTableTplsSub: Subscription;
51 private hostService: HostService,
52 private cephServiceService: CephServiceService,
53 private orchService: OrchestratorService
59 name: this.i18n('Hostname'),
65 name: this.i18n('Daemon type'),
71 name: this.i18n('Daemon ID'),
77 name: this.i18n('Container ID'),
81 cellTransformation: CellTemplate.truncate,
82 customTemplateConfig: {
87 name: this.i18n('Container Image name'),
88 prop: 'container_image_name',
93 name: this.i18n('Container Image ID'),
94 prop: 'container_image_id',
97 cellTransformation: CellTemplate.truncate,
98 customTemplateConfig: {
103 name: this.i18n('Version'),
109 name: this.i18n('Status'),
115 name: this.i18n('Status Description'),
121 name: this.i18n('Last Refreshed'),
122 prop: 'last_refresh',
127 this.orchService.status().subscribe((data: { available: boolean }) => {
128 this.hasOrchestrator = data.available;
133 if (!_.isUndefined(this.daemonsTable)) {
134 this.daemonsTable.reloadData();
139 this.daemonsTableTplsSub = this.daemonsTableTpls.changes.subscribe(
140 (tableRefs: QueryList<TableComponent>) => {
141 this.daemonsTable = tableRefs.first;
147 if (this.daemonsTableTplsSub) {
148 this.daemonsTableTplsSub.unsubscribe();
152 getDaemons(context: CdTableFetchDataContext) {
153 let observable: Observable<Daemon[]>;
155 observable = this.hostService.getDaemons(this.hostname);
156 } else if (this.serviceName) {
157 observable = this.cephServiceService.getDaemons(this.serviceName);
162 observable.subscribe(
163 (daemons: Daemon[]) => {
164 this.daemons = daemons;