Adapt the changes in https://github.com/ceph/ceph/pull/32747.
Fixes: https://tracker.ceph.com/issues/45106
Signed-off-by: Kiefer Chang <kiefer.chang@suse.com>
[autoReload]="60000"
(fetchData)="getDaemons($event)">
</cd-table>
+
+<ng-template #statusTpl
+ let-row="row">
+ <span class="badge"
+ [ngClass]="getStatusClass(row.status)">
+ {{ row.status_desc }}
+ </span>
+</ng-template>
OnInit,
QueryList,
TemplateRef,
+ ViewChild,
ViewChildren
} from '@angular/core';
import { I18n } from '@ngx-translate/i18n-polyfill';
styleUrls: ['./service-daemon-list.component.scss']
})
export class ServiceDaemonListComponent implements OnInit, OnChanges, AfterViewInit, OnDestroy {
+ @ViewChild('statusTpl', { static: true })
+ statusTpl: TemplateRef<any>;
+
@ViewChildren('daemonsTable')
daemonsTableTpls: QueryList<TemplateRef<TableComponent>>;
},
{
name: this.i18n('Status'),
- prop: 'status',
- flexGrow: 1,
- filterable: true
- },
- {
- name: this.i18n('Status Description'),
prop: 'status_desc',
flexGrow: 1,
- filterable: true
+ filterable: true,
+ cellTemplate: this.statusTpl
},
{
name: this.i18n('Last Refreshed'),
}
}
+ getStatusClass(status: number) {
+ return _.get(
+ {
+ '-1': 'badge-danger',
+ '0': 'badge-warning',
+ '1': 'badge-success'
+ },
+ status,
+ 'badge-dark'
+ );
+ }
+
getDaemons(context: CdTableFetchDataContext) {
let observable: Observable<Daemon[]>;
if (this.hostname) {
-<tabset *ngIf="selection.hasSingleSelection">
+<tabset *ngIf="selection">
<tab i18n-heading
heading="Daemons">
- <cd-service-daemon-list [serviceName]="selection.first()['service_name']">
+ <cd-service-daemon-list [serviceName]="selection['service_name']">
</cd-service-daemon-list>
</tab>
</tabset>
selectionType="single"
[autoReload]="60000"
(fetchData)="getServices($event)"
- (updateSelection)="updateSelection($event)">
+ [hasDetails]="true"
+ (setExpandedRow)="setExpandedRow($event)">
<cd-service-details cdTableDetail
[permissions]="permissions"
- [selection]="selection">
+ [selection]="expandedRow">
</cd-service-details>
</cd-table>
</ng-container>
});
it('should have columns that are sortable', () => {
- expect(component.columns.every((column) => Boolean(column.prop))).toBeTruthy();
+ expect(
+ component.columns
+ .filter((column) => !(column.cellClass === 'cd-datatable-expand-collapse'))
+ .every((column) => Boolean(column.prop))
+ ).toBeTruthy();
});
it('should return all services', () => {
import { CephServiceService } from '../../../shared/api/ceph-service.service';
import { OrchestratorService } from '../../../shared/api/orchestrator.service';
+import { ListWithDetails } from '../../../shared/classes/list-with-details.class';
import { TableComponent } from '../../../shared/datatable/table/table.component';
import { CellTemplate } from '../../../shared/enum/cell-template.enum';
import { CdTableColumn } from '../../../shared/models/cd-table-column';
templateUrl: './services.component.html',
styleUrls: ['./services.component.scss']
})
-export class ServicesComponent implements OnChanges, OnInit {
+export class ServicesComponent extends ListWithDetails implements OnChanges, OnInit {
@ViewChild(TableComponent, { static: false })
table: TableComponent;
private orchService: OrchestratorService,
private cephServiceService: CephServiceService
) {
+ super();
this.permissions = this.authStorageService.getPermissions();
}
}
}
- updateSelection(selection: CdTableSelection) {
- this.selection = selection;
- }
-
getServices(context: CdTableFetchDataContext) {
if (this.isLoadingServices) {
return;