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 | 7x 7x 7x 7x 7x 7x 7x 7x 20x 20x 7x 20x 19x 2x 2x 2x 5x 5x 3x 9x 5x 2x 7x | import { Component, Input, OnChanges, OnInit } from '@angular/core';
import { I18n } from '@ngx-translate/i18n-polyfill';
import * as _ from 'lodash';
import { CellTemplate } from '../../../shared/enum/cell-template.enum';
import { CdTableColumn } from '../../../shared/models/cd-table-column';
import { CdTableSelection } from '../../../shared/models/cd-table-selection';
@Component({
selector: 'cd-role-details',
template: require('./role-details.component.html'),
styles: []
})
export class RoleDetailsComponent implements OnChanges, OnInit {
@Input()
selection: CdTableSelection;
@Input()
scopes: Array<string>;
selectedItem: any;
columns: CdTableColumn[];
scopes_permissions: Array<any> = [];
constructor(private i18n: I18n) {}
ngOnInit() {
this.columns = [
{
prop: 'scope',
name: this.i18n('Scope'),
flexGrow: 2
},
{
prop: 'read',
name: this.i18n('Read'),
flexGrow: 1,
cellClass: 'text-center',
cellTransformation: CellTemplate.checkIcon
},
{
prop: 'create',
name: this.i18n('Create'),
flexGrow: 1,
cellClass: 'text-center',
cellTransformation: CellTemplate.checkIcon
},
{
prop: 'update',
name: this.i18n('Update'),
flexGrow: 1,
cellClass: 'text-center',
cellTransformation: CellTemplate.checkIcon
},
{
prop: 'delete',
name: this.i18n('Delete'),
flexGrow: 1,
cellClass: 'text-center',
cellTransformation: CellTemplate.checkIcon
}
];
}
ngOnChanges() {
if (this.selection.hasSelection) {
this.selectedItem = this.selection.first();
// Build the scopes/permissions data used by the data table.
const scopes_permissions = [];
_.each(this.scopes, (scope) => {
const scope_permission = { read: false, create: false, update: false, delete: false };
scope_permission['scope'] = scope;
if (scope in this.selectedItem['scopes_permissions']) {
_.each(this.selectedItem['scopes_permissions'][scope], (permission) => {
scope_permission[permission] = true;
});
}
scopes_permissions.push(scope_permission);
});
this.scopes_permissions = scopes_permissions;
}
}
}
|