1 import { Component, OnDestroy, OnInit, TemplateRef, ViewChild } from '@angular/core';
3 import { I18n } from '@ngx-translate/i18n-polyfill';
4 import { Subscription } from 'rxjs';
6 import { RbdMirroringService } from '../../../../shared/api/rbd-mirroring.service';
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 constructor(private rbdMirroringService: RbdMirroringService, private i18n: I18n) {}
39 this.image_error.columns = [
40 { prop: 'pool_name', name: this.i18n('Pool'), flexGrow: 2 },
41 { prop: 'name', name: this.i18n('Image'), flexGrow: 2 },
42 { prop: 'description', name: this.i18n('Issue'), flexGrow: 4 },
45 name: this.i18n('State'),
46 cellTemplate: this.stateTmpl,
51 this.image_syncing.columns = [
52 { prop: 'pool_name', name: this.i18n('Pool'), flexGrow: 2 },
53 { prop: 'name', name: this.i18n('Image'), flexGrow: 2 },
56 name: this.i18n('Progress'),
57 cellTemplate: this.progressTmpl,
62 name: this.i18n('State'),
63 cellTemplate: this.syncTmpl,
68 this.image_ready.columns = [
69 { prop: 'pool_name', name: this.i18n('Pool'), flexGrow: 2 },
70 { prop: 'name', name: this.i18n('Image'), flexGrow: 2 },
71 { prop: 'description', name: this.i18n('Description'), flexGrow: 4 },
74 name: this.i18n('State'),
75 cellTemplate: this.stateTmpl,
80 this.subs = this.rbdMirroringService.subscribeSummary((data: any) => {
84 this.image_error.data = data.content_data.image_error;
85 this.image_syncing.data = data.content_data.image_syncing;
86 this.image_ready.data = data.content_data.image_ready;
91 this.subs.unsubscribe();
95 this.rbdMirroringService.refresh();