]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/blob
f1840235057213d2be413de7229b632d815c9d22
[ceph.git] /
1 import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
2 import { DimlessBinaryPipe } from '~/app/shared/pipes/dimless-binary.pipe';
3
4 @Component({
5   selector: 'cd-rgw-user-accounts-details',
6   templateUrl: './rgw-user-accounts-details.component.html',
7   styleUrls: ['./rgw-user-accounts-details.component.scss']
8 })
9 export class RgwUserAccountsDetailsComponent implements OnChanges {
10   @Input()
11   selection: any;
12   quota = {};
13   bucket_quota = {};
14
15   constructor(private dimlessBinary: DimlessBinaryPipe) {}
16
17   ngOnChanges(changes: SimpleChanges): void {
18     if (changes.selection && changes.selection.currentValue) {
19       this.quota = this.createDisplayValues('quota');
20       this.bucket_quota = this.createDisplayValues('bucket_quota');
21     }
22   }
23
24   createDisplayValues(quota_type: string) {
25     return {
26       Enabled: this.selection[quota_type].enabled ? 'Yes' : 'No',
27       'Maximum size': this.selection[quota_type].enabled
28         ? this.selection[quota_type].max_size <= -1
29           ? 'Unlimited'
30           : this.dimlessBinary.transform(this.selection[quota_type].max_size)
31         : '-',
32       'Maximum objects': this.selection[quota_type].enabled
33         ? this.selection[quota_type].max_objects <= -1
34           ? 'Unlimited'
35           : this.selection[quota_type].max_objects
36         : '-'
37     };
38   }
39 }