1 import { Component, OnDestroy, OnInit, TemplateRef, ViewChild } from '@angular/core';
3 import { Subscription } from 'rxjs';
5 import { RbdMirroringService } from '~/app/shared/api/rbd-mirroring.service';
6 import { TableStatusViewCache } from '~/app/shared/classes/table-status-view-cache';
9 selector: 'cd-mirroring-images',
10 templateUrl: './image-list.component.html',
11 styleUrls: ['./image-list.component.scss']
13 export class ImageListComponent implements OnInit, OnDestroy {
14 @ViewChild('stateTmpl', { static: true })
15 stateTmpl: TemplateRef<any>;
16 @ViewChild('syncTmpl', { static: true })
17 syncTmpl: TemplateRef<any>;
18 @ViewChild('progressTmpl', { static: true })
19 progressTmpl: TemplateRef<any>;
23 image_error: Record<string, any> = {
27 image_syncing: Record<string, any> = {
31 image_ready: Record<string, any> = {
36 tableStatus = new TableStatusViewCache();
38 constructor(private rbdMirroringService: RbdMirroringService) {}
41 this.image_error.columns = [
42 { prop: 'pool_name', name: $localize`Pool`, flexGrow: 2 },
43 { prop: 'name', name: $localize`Image`, flexGrow: 2 },
46 name: $localize`State`,
47 cellTemplate: this.stateTmpl,
50 { prop: 'description', name: $localize`Issue`, flexGrow: 4 }
53 this.image_syncing.columns = [
54 { prop: 'pool_name', name: $localize`Pool`, flexGrow: 2 },
55 { prop: 'name', name: $localize`Image`, flexGrow: 2 },
58 name: $localize`State`,
59 cellTemplate: this.stateTmpl,
63 prop: 'syncing_percent',
64 name: $localize`Progress`,
65 cellTemplate: this.progressTmpl,
68 { prop: 'bytes_per_second', name: $localize`Bytes per second`, flexGrow: 2 },
69 { prop: 'entries_behind_primary', name: $localize`Entries behind primary`, flexGrow: 2 }
72 this.image_ready.columns = [
73 { prop: 'pool_name', name: $localize`Pool`, flexGrow: 2 },
74 { prop: 'name', name: $localize`Image`, flexGrow: 2 },
77 name: $localize`State`,
78 cellTemplate: this.stateTmpl,
81 { prop: 'description', name: $localize`Description`, flexGrow: 4 }
84 this.subs = this.rbdMirroringService.subscribeSummary((data) => {
85 this.image_error.data = data.content_data.image_error;
86 this.image_syncing.data = data.content_data.image_syncing;
87 this.image_ready.data = data.content_data.image_ready;
88 this.tableStatus = new TableStatusViewCache(data.status);
93 this.subs.unsubscribe();
97 this.rbdMirroringService.refresh();