]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-daemon-list/service-daemon-list.component.ts
import ceph pacific 16.2.5
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / services / service-daemon-list / service-daemon-list.component.ts
index c6d0a0a0561a82bc71846a8cbe163fcd34191924..1a17fdb61ccddd2d07187f528a5cc7f952029239 100644 (file)
@@ -19,9 +19,11 @@ import { HostService } from '~/app/shared/api/host.service';
 import { OrchestratorService } from '~/app/shared/api/orchestrator.service';
 import { TableComponent } from '~/app/shared/datatable/table/table.component';
 import { CellTemplate } from '~/app/shared/enum/cell-template.enum';
+import { Icons } from '~/app/shared/enum/icons.enum';
 import { CdTableColumn } from '~/app/shared/models/cd-table-column';
 import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context';
 import { Daemon } from '~/app/shared/models/daemon.interface';
+import { CephServiceSpec } from '~/app/shared/models/service.interface';
 import { RelativeDatePipe } from '~/app/shared/pipes/relative-date.pipe';
 
 @Component({
@@ -33,6 +35,9 @@ export class ServiceDaemonListComponent implements OnInit, OnChanges, AfterViewI
   @ViewChild('statusTpl', { static: true })
   statusTpl: TemplateRef<any>;
 
+  @ViewChild('listTpl', { static: true })
+  listTpl: TemplateRef<any>;
+
   @ViewChildren('daemonsTable')
   daemonsTableTpls: QueryList<TemplateRef<TableComponent>>;
 
@@ -42,14 +47,22 @@ export class ServiceDaemonListComponent implements OnInit, OnChanges, AfterViewI
   @Input()
   hostname?: string;
 
+  @Input()
+  flag?: string;
+
+  icons = Icons;
+
   daemons: Daemon[] = [];
+  services: Array<CephServiceSpec> = [];
   columns: CdTableColumn[] = [];
+  serviceColumns: CdTableColumn[] = [];
 
   hasOrchestrator = false;
   showDocPanel = false;
 
   private daemonsTable: TableComponent;
   private daemonsTableTplsSub: Subscription;
+  private serviceSub: Subscription;
 
   constructor(
     private hostService: HostService,
@@ -63,7 +76,7 @@ export class ServiceDaemonListComponent implements OnInit, OnChanges, AfterViewI
       {
         name: $localize`Hostname`,
         prop: 'hostname',
-        flexGrow: 1,
+        flexGrow: 2,
         filterable: true
       },
       {
@@ -81,7 +94,7 @@ export class ServiceDaemonListComponent implements OnInit, OnChanges, AfterViewI
       {
         name: $localize`Container ID`,
         prop: 'container_id',
-        flexGrow: 3,
+        flexGrow: 2,
         filterable: true,
         cellTransformation: CellTemplate.truncate,
         customTemplateConfig: {
@@ -97,7 +110,7 @@ export class ServiceDaemonListComponent implements OnInit, OnChanges, AfterViewI
       {
         name: $localize`Container Image ID`,
         prop: 'container_image_id',
-        flexGrow: 3,
+        flexGrow: 2,
         filterable: true,
         cellTransformation: CellTemplate.truncate,
         customTemplateConfig: {
@@ -121,7 +134,34 @@ export class ServiceDaemonListComponent implements OnInit, OnChanges, AfterViewI
         name: $localize`Last Refreshed`,
         prop: 'last_refresh',
         pipe: this.relativeDatePipe,
-        flexGrow: 2
+        flexGrow: 1
+      },
+      {
+        name: $localize`Daemon Events`,
+        prop: 'events',
+        flexGrow: 5,
+        cellTemplate: this.listTpl
+      }
+    ];
+
+    this.serviceColumns = [
+      {
+        name: $localize`Service Name`,
+        prop: 'service_name',
+        flexGrow: 2,
+        filterable: true
+      },
+      {
+        name: $localize`Service Type`,
+        prop: 'service_type',
+        flexGrow: 1,
+        filterable: true
+      },
+      {
+        name: $localize`Service Events`,
+        prop: 'events',
+        flexGrow: 5,
+        cellTemplate: this.listTpl
       }
     ];
 
@@ -149,6 +189,9 @@ export class ServiceDaemonListComponent implements OnInit, OnChanges, AfterViewI
     if (this.daemonsTableTplsSub) {
       this.daemonsTableTplsSub.unsubscribe();
     }
+    if (this.serviceSub) {
+      this.serviceSub.unsubscribe();
+    }
   }
 
   getStatusClass(row: Daemon): string {
@@ -183,4 +226,20 @@ export class ServiceDaemonListComponent implements OnInit, OnChanges, AfterViewI
       }
     );
   }
+
+  getServices(context: CdTableFetchDataContext) {
+    this.serviceSub = this.cephServiceService.list(this.serviceName).subscribe(
+      (services: CephServiceSpec[]) => {
+        this.services = services;
+      },
+      () => {
+        this.services = [];
+        context.error();
+      }
+    );
+  }
+
+  trackByFn(_index: any, item: any) {
+    return item.created;
+  }
 }