Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | 6x 6x 6x 6x 6x 6x 6x 2x 2x 2x 2x 2x 6x 2x 2x 2x 2x 2x 6x 2x 6x 6x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 1x 1x 1x 6x | import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core'; import { I18n } from '@ngx-translate/i18n-polyfill'; import { HostService } from '../../../shared/api/host.service'; import { CdTableColumn } from '../../../shared/models/cd-table-column'; import { CdTableFetchDataContext } from '../../../shared/models/cd-table-fetch-data-context'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; import { Permissions } from '../../../shared/models/permissions'; import { CephShortVersionPipe } from '../../../shared/pipes/ceph-short-version.pipe'; import { AuthStorageService } from '../../../shared/services/auth-storage.service'; @Component({ selector: 'cd-hosts', template: require('./hosts.component.html'), styles: [] }) export class HostsComponent implements OnInit { permissions: Permissions; columns: Array<CdTableColumn> = []; hosts: Array<object> = []; isLoadingHosts = false; cdParams = { fromLink: '/hosts' }; selection = new CdTableSelection(); @ViewChild('servicesTpl') public servicesTpl: TemplateRef<any>; constructor( private authStorageService: AuthStorageService, private hostService: HostService, private cephShortVersionPipe: CephShortVersionPipe, private i18n: I18n ) { this.permissions = this.authStorageService.getPermissions(); } ngOnInit() { this.columns = [ { name: this.i18n('Hostname'), prop: 'hostname', flexGrow: 1 }, { name: this.i18n('Services'), prop: 'services', flexGrow: 3, cellTemplate: this.servicesTpl }, { name: this.i18n('Version'), prop: 'ceph_version', flexGrow: 1, pipe: this.cephShortVersionPipe } ]; } updateSelection(selection: CdTableSelection) { this.selection = selection; } getHosts(context: CdTableFetchDataContext) { Iif (this.isLoadingHosts) { return; } const typeToPermissionKey = { mds: 'cephfs', mon: 'monitor', osd: 'osd', rgw: 'rgw', 'rbd-mirror': 'rbdMirroring', mgr: 'manager', 'tcmu-runner': 'iscsi' }; this.isLoadingHosts = true; this.hostService .list() .then((resp) => { resp.map((host) => { host.services.map((service) => { service.cdLink = `/perf_counters/${service.type}/${encodeURIComponent(service.id)}`; const permission = this.permissions[typeToPermissionKey[service.type]]; service.canRead = permission ? permission.read : false; return service; }); return host; }); this.hosts = resp; this.isLoadingHosts = false; }) .catch(() => { this.isLoadingHosts = false; context.error(); }); } } |