Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { Component, Input, OnChanges, OnInit, TemplateRef, ViewChild } from '@angular/core'; import { I18n } from '@ngx-translate/i18n-polyfill'; import * as _ from 'lodash'; import { BsModalService } from 'ngx-bootstrap/modal'; import { RgwUserService } from '../../../shared/api/rgw-user.service'; import { CdTableColumn } from '../../../shared/models/cd-table-column'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; import { RgwUserS3Key } from '../models/rgw-user-s3-key'; import { RgwUserSwiftKey } from '../models/rgw-user-swift-key'; import { RgwUserS3KeyModalComponent } from '../rgw-user-s3-key-modal/rgw-user-s3-key-modal.component'; import { RgwUserSwiftKeyModalComponent } from '../rgw-user-swift-key-modal/rgw-user-swift-key-modal.component'; @Component({ selector: 'cd-rgw-user-details', template: require('./rgw-user-details.component.html'), styles: [] }) export class RgwUserDetailsComponent implements OnChanges, OnInit { @ViewChild('accessKeyTpl') public accessKeyTpl: TemplateRef<any>; @ViewChild('secretKeyTpl') public secretKeyTpl: TemplateRef<any>; @Input() selection: CdTableSelection; // Details tab user: any; // Keys tab keys: any = []; keysColumns: CdTableColumn[] = []; keysSelection: CdTableSelection = new CdTableSelection(); constructor( private rgwUserService: RgwUserService, private bsModalService: BsModalService, private i18n: I18n ) {} ngOnInit() { this.keysColumns = [ { name: this.i18n('Username'), prop: 'username', flexGrow: 1 }, { name: this.i18n('Type'), prop: 'type', flexGrow: 1 } ]; } ngOnChanges() { if (this.selection.hasSelection) { this.user = this.selection.first(); // Sort subusers and capabilities. this.user.subusers = _.sortBy(this.user.subusers, 'id'); this.user.caps = _.sortBy(this.user.caps, 'type'); // Load the user/bucket quota of the selected user. this.rgwUserService.getQuota(this.user.uid).subscribe((resp: object) => { _.extend(this.user, resp); }); // Process the keys. this.keys = []; this.user.keys.forEach((key: RgwUserS3Key) => { this.keys.push({ id: this.keys.length + 1, // Create an unique identifier type: 'S3', username: key.user, ref: key }); }); this.user.swift_keys.forEach((key: RgwUserSwiftKey) => { this.keys.push({ id: this.keys.length + 1, // Create an unique identifier type: 'Swift', username: key.user, ref: key }); }); this.keys = _.sortBy(this.keys, 'user'); } } updateKeysSelection(selection: CdTableSelection) { this.keysSelection = selection; } showKeyModal() { const key = this.keysSelection.first(); const modalRef = this.bsModalService.show( key.type === 'S3' ? RgwUserS3KeyModalComponent : RgwUserSwiftKeyModalComponent ); switch (key.type) { case 'S3': modalRef.content.setViewing(); modalRef.content.setValues(key.ref.user, key.ref.access_key, key.ref.secret_key); break; case 'Swift': modalRef.content.setValues(key.ref.user, key.ref.secret_key); break; } } } |