]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/blob
f5cef494366341adb1df25d312736aae0f13e48f
[ceph-ci.git] /
1 import { Component, Input, OnInit } from '@angular/core';
2
3 import * as _ from 'lodash';
4
5 import { RgwDaemonService } from '../services/rgw-daemon.service';
6
7 @Component({
8   selector: 'cd-rgw-daemon-details',
9   templateUrl: './rgw-daemon-details.component.html',
10   styleUrls: ['./rgw-daemon-details.component.scss']
11 })
12 export class RgwDaemonDetailsComponent implements OnInit {
13
14   metadata: Array<object> = [];
15   serviceId = '';
16
17   @Input() selected?: Array<any> = [];
18
19   constructor(private rgwDaemonService: RgwDaemonService) { }
20
21   ngOnInit() {
22     this.getMetaData();
23   }
24
25   private getMetaData() {
26     if (this.selected.length < 1) {
27       return;
28     }
29
30     // Get the service id of the first selected row.
31     this.serviceId = this.selected[0].id;
32
33     this.rgwDaemonService.get(this.serviceId)
34       .then((resp) => {
35         const metadata = [];
36         const keys = _.keys(resp['rgw_metadata']);
37         keys.sort();
38         _.map(keys, (key) => {
39           metadata.push({
40             'key': key,
41             'value': resp['rgw_metadata'][key]
42           });
43         });
44         this.metadata = metadata;
45       });
46   }
47 }