|
|
|
import { RestService, CoreModule } from '@abp/ng.core';
|
|
|
|
import { ThemeSharedModule } from '@abp/ng.theme.shared';
|
|
|
|
import {
|
|
|
|
Injectable,
|
|
|
|
ɵɵdefineInjectable,
|
|
|
|
ɵɵinject,
|
|
|
|
EventEmitter,
|
|
|
|
Component,
|
|
|
|
Renderer2,
|
|
|
|
Input,
|
|
|
|
Output,
|
|
|
|
NgModule,
|
|
|
|
} from '@angular/core';
|
|
|
|
import { Action, Selector, State, Store, Select, NgxsModule } from '@ngxs/store';
|
|
|
|
import { __decorate, __metadata, __assign, __spread } from 'tslib';
|
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
import { tap, map, take, pluck } from 'rxjs/operators';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @fileoverview added by tsickle
|
|
|
|
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
|
|
*/
|
|
|
|
var GetPermissions = /** @class */ (function() {
|
|
|
|
function GetPermissions(payload) {
|
|
|
|
this.payload = payload;
|
|
|
|
}
|
|
|
|
GetPermissions.type = '[PermissionManagement] Get Permissions';
|
|
|
|
return GetPermissions;
|
|
|
|
})();
|
|
|
|
if (false) {
|
|
|
|
/** @type {?} */
|
|
|
|
GetPermissions.type;
|
|
|
|
/** @type {?} */
|
|
|
|
GetPermissions.prototype.payload;
|
|
|
|
}
|
|
|
|
var UpdatePermissions = /** @class */ (function() {
|
|
|
|
function UpdatePermissions(payload) {
|
|
|
|
this.payload = payload;
|
|
|
|
}
|
|
|
|
UpdatePermissions.type = '[PermissionManagement] Update Permissions';
|
|
|
|
return UpdatePermissions;
|
|
|
|
})();
|
|
|
|
if (false) {
|
|
|
|
/** @type {?} */
|
|
|
|
UpdatePermissions.type;
|
|
|
|
/** @type {?} */
|
|
|
|
UpdatePermissions.prototype.payload;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @fileoverview added by tsickle
|
|
|
|
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
|
|
*/
|
|
|
|
var PermissionManagementService = /** @class */ (function() {
|
|
|
|
function PermissionManagementService(rest) {
|
|
|
|
this.rest = rest;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @param {?} params
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
PermissionManagementService.prototype.getPermissions
|
|
|
|
/**
|
|
|
|
* @param {?} params
|
|
|
|
* @return {?}
|
|
|
|
*/ = function(params) {
|
|
|
|
/** @type {?} */
|
|
|
|
var request = {
|
|
|
|
method: 'GET',
|
|
|
|
url: '/api/abp/permissions',
|
|
|
|
params: params,
|
|
|
|
};
|
|
|
|
return this.rest.request(request);
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* @param {?} __0
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
PermissionManagementService.prototype.updatePermissions
|
|
|
|
/**
|
|
|
|
* @param {?} __0
|
|
|
|
* @return {?}
|
|
|
|
*/ = function(_a) {
|
|
|
|
var permissions = _a.permissions,
|
|
|
|
providerKey = _a.providerKey,
|
|
|
|
providerName = _a.providerName;
|
|
|
|
/** @type {?} */
|
|
|
|
var request = {
|
|
|
|
method: 'PUT',
|
|
|
|
url: '/api/abp/permissions',
|
|
|
|
body: { permissions: permissions },
|
|
|
|
params: { providerKey: providerKey, providerName: providerName },
|
|
|
|
};
|
|
|
|
return this.rest.request(request);
|
|
|
|
};
|
|
|
|
PermissionManagementService.decorators = [
|
|
|
|
{
|
|
|
|
type: Injectable,
|
|
|
|
args: [
|
|
|
|
{
|
|
|
|
providedIn: 'root',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
/** @nocollapse */
|
|
|
|
PermissionManagementService.ctorParameters = function() {
|
|
|
|
return [{ type: RestService }];
|
|
|
|
};
|
|
|
|
/** @nocollapse */ PermissionManagementService.ngInjectableDef = ɵɵdefineInjectable({
|
|
|
|
factory: function PermissionManagementService_Factory() {
|
|
|
|
return new PermissionManagementService(ɵɵinject(RestService));
|
|
|
|
},
|
|
|
|
token: PermissionManagementService,
|
|
|
|
providedIn: 'root',
|
|
|
|
});
|
|
|
|
return PermissionManagementService;
|
|
|
|
})();
|
|
|
|
if (false) {
|
|
|
|
/**
|
|
|
|
* @type {?}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
PermissionManagementService.prototype.rest;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @fileoverview added by tsickle
|
|
|
|
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
|
|
*/
|
|
|
|
var PermissionManagementState = /** @class */ (function() {
|
|
|
|
function PermissionManagementState(permissionManagementService) {
|
|
|
|
this.permissionManagementService = permissionManagementService;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @param {?} __0
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
PermissionManagementState.getPermissionGroups
|
|
|
|
/**
|
|
|
|
* @param {?} __0
|
|
|
|
* @return {?}
|
|
|
|
*/ = function(_a) {
|
|
|
|
var permissionRes = _a.permissionRes;
|
|
|
|
return permissionRes.groups || [];
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* @param {?} __0
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
PermissionManagementState.getEntitiyDisplayName
|
|
|
|
/**
|
|
|
|
* @param {?} __0
|
|
|
|
* @return {?}
|
|
|
|
*/ = function(_a) {
|
|
|
|
var permissionRes = _a.permissionRes;
|
|
|
|
return permissionRes.entityDisplayName;
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* @param {?} __0
|
|
|
|
* @param {?} __1
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
PermissionManagementState.prototype.permissionManagementGet
|
|
|
|
/**
|
|
|
|
* @param {?} __0
|
|
|
|
* @param {?} __1
|
|
|
|
* @return {?}
|
|
|
|
*/ = function(_a, _b) {
|
|
|
|
var patchState = _a.patchState;
|
|
|
|
var payload = _b.payload;
|
|
|
|
return this.permissionManagementService.getPermissions(payload).pipe(
|
|
|
|
tap(
|
|
|
|
/**
|
|
|
|
* @param {?} permissionResponse
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function(permissionResponse) {
|
|
|
|
return patchState({
|
|
|
|
permissionRes: permissionResponse,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* @param {?} _
|
|
|
|
* @param {?} __1
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
PermissionManagementState.prototype.permissionManagementUpdate
|
|
|
|
/**
|
|
|
|
* @param {?} _
|
|
|
|
* @param {?} __1
|
|
|
|
* @return {?}
|
|
|
|
*/ = function(_, _a) {
|
|
|
|
var payload = _a.payload;
|
|
|
|
return this.permissionManagementService.updatePermissions(payload);
|
|
|
|
};
|
|
|
|
PermissionManagementState.ctorParameters = function() {
|
|
|
|
return [{ type: PermissionManagementService }];
|
|
|
|
};
|
|
|
|
__decorate(
|
|
|
|
[
|
|
|
|
Action(GetPermissions),
|
|
|
|
__metadata('design:type', Function),
|
|
|
|
__metadata('design:paramtypes', [Object, GetPermissions]),
|
|
|
|
__metadata('design:returntype', void 0),
|
|
|
|
],
|
|
|
|
PermissionManagementState.prototype,
|
|
|
|
'permissionManagementGet',
|
|
|
|
null,
|
|
|
|
);
|
|
|
|
__decorate(
|
|
|
|
[
|
|
|
|
Action(UpdatePermissions),
|
|
|
|
__metadata('design:type', Function),
|
|
|
|
__metadata('design:paramtypes', [Object, UpdatePermissions]),
|
|
|
|
__metadata('design:returntype', void 0),
|
|
|
|
],
|
|
|
|
PermissionManagementState.prototype,
|
|
|
|
'permissionManagementUpdate',
|
|
|
|
null,
|
|
|
|
);
|
|
|
|
__decorate(
|
|
|
|
[
|
|
|
|
Selector(),
|
|
|
|
__metadata('design:type', Function),
|
|
|
|
__metadata('design:paramtypes', [Object]),
|
|
|
|
__metadata('design:returntype', void 0),
|
|
|
|
],
|
|
|
|
PermissionManagementState,
|
|
|
|
'getPermissionGroups',
|
|
|
|
null,
|
|
|
|
);
|
|
|
|
__decorate(
|
|
|
|
[
|
|
|
|
Selector(),
|
|
|
|
__metadata('design:type', Function),
|
|
|
|
__metadata('design:paramtypes', [Object]),
|
|
|
|
__metadata('design:returntype', String),
|
|
|
|
],
|
|
|
|
PermissionManagementState,
|
|
|
|
'getEntitiyDisplayName',
|
|
|
|
null,
|
|
|
|
);
|
|
|
|
PermissionManagementState = __decorate(
|
|
|
|
[
|
|
|
|
State({
|
|
|
|
name: 'PermissionManagementState',
|
|
|
|
defaults: /** @type {?} */ ({ permissionRes: {} }),
|
|
|
|
}),
|
|
|
|
__metadata('design:paramtypes', [PermissionManagementService]),
|
|
|
|
],
|
|
|
|
PermissionManagementState,
|
|
|
|
);
|
|
|
|
return PermissionManagementState;
|
|
|
|
})();
|
|
|
|
if (false) {
|
|
|
|
/**
|
|
|
|
* @type {?}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
PermissionManagementState.prototype.permissionManagementService;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @fileoverview added by tsickle
|
|
|
|
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
|
|
*/
|
|
|
|
var PermissionManagementComponent = /** @class */ (function() {
|
|
|
|
function PermissionManagementComponent(store, renderer) {
|
|
|
|
this.store = store;
|
|
|
|
this.renderer = renderer;
|
|
|
|
this.visibleChange = new EventEmitter();
|
|
|
|
this.permissions = [];
|
|
|
|
this.selectThisTab = false;
|
|
|
|
this.selectAllTab = false;
|
|
|
|
this.modalBusy = false;
|
|
|
|
this.trackByFn
|
|
|
|
/**
|
|
|
|
* @param {?} _
|
|
|
|
* @param {?} item
|
|
|
|
* @return {?}
|
|
|
|
*/ = function(_, item) {
|
|
|
|
return item.name;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
Object.defineProperty(PermissionManagementComponent.prototype, 'visible', {
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
get: function() {
|
|
|
|
return this._visible;
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @param {?} value
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
set: function(value) {
|
|
|
|
if (!this.selectedGroup) return;
|
|
|
|
this._visible = value;
|
|
|
|
this.visibleChange.emit(value);
|
|
|
|
if (!value) {
|
|
|
|
this.selectedGroup = null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
enumerable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
Object.defineProperty(PermissionManagementComponent.prototype, 'selectedGroupPermissions$', {
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
get: function() {
|
|
|
|
var _this = this;
|
|
|
|
return this.groups$.pipe(
|
|
|
|
map(
|
|
|
|
/**
|
|
|
|
* @param {?} groups
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function(groups) {
|
|
|
|
return _this.selectedGroup
|
|
|
|
? groups.find(
|
|
|
|
/**
|
|
|
|
* @param {?} group
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function(group) {
|
|
|
|
return group.name === _this.selectedGroup.name;
|
|
|
|
},
|
|
|
|
).permissions
|
|
|
|
: [];
|
|
|
|
},
|
|
|
|
),
|
|
|
|
map(
|
|
|
|
/**
|
|
|
|
* @param {?} permissions
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function(permissions) {
|
|
|
|
return permissions.map(
|
|
|
|
/**
|
|
|
|
* @param {?} permission
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function(permission) {
|
|
|
|
return /** @type {?} */ /** @type {?} */ (__assign({}, permission, {
|
|
|
|
margin: findMargin(permissions, permission),
|
|
|
|
isGranted: _this.permissions.find(
|
|
|
|
/**
|
|
|
|
* @param {?} per
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function(per) {
|
|
|
|
return per.name === permission.name;
|
|
|
|
},
|
|
|
|
).isGranted,
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
enumerable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
PermissionManagementComponent.prototype.ngOnInit
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/ = function() {};
|
|
|
|
/**
|
|
|
|
* @param {?} name
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
PermissionManagementComponent.prototype.getChecked
|
|
|
|
/**
|
|
|
|
* @param {?} name
|
|
|
|
* @return {?}
|
|
|
|
*/ = function(name) {
|
|
|
|
return (
|
|
|
|
this.permissions.find(
|
|
|
|
/**
|
|
|
|
* @param {?} per
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function(per) {
|
|
|
|
return per.name === name;
|
|
|
|
},
|
|
|
|
) || { isGranted: false }
|
|
|
|
).isGranted;
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* @param {?} grantedProviders
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
PermissionManagementComponent.prototype.isGrantedByRole
|
|
|
|
/**
|
|
|
|
* @param {?} grantedProviders
|
|
|
|
* @return {?}
|
|
|
|
*/ = function(grantedProviders) {
|
|
|
|
if (grantedProviders.length) {
|
|
|
|
return (
|
|
|
|
grantedProviders.findIndex(
|
|
|
|
/**
|
|
|
|
* @param {?} p
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function(p) {
|
|
|
|
return p.providerName === 'Role';
|
|
|
|
},
|
|
|
|
) > -1
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* @param {?} clickedPermission
|
|
|
|
* @param {?} value
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
PermissionManagementComponent.prototype.onClickCheckbox
|
|
|
|
/**
|
|
|
|
* @param {?} clickedPermission
|
|
|
|
* @param {?} value
|
|
|
|
* @return {?}
|
|
|
|
*/ = function(clickedPermission, value) {
|
|
|
|
var _this = this;
|
|
|
|
if (clickedPermission.isGranted && this.isGrantedByRole(clickedPermission.grantedProviders)) return;
|
|
|
|
setTimeout(
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function() {
|
|
|
|
_this.permissions = _this.permissions.map(
|
|
|
|
/**
|
|
|
|
* @param {?} per
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function(per) {
|
|
|
|
if (clickedPermission.name === per.name) {
|
|
|
|
return __assign({}, per, { isGranted: !per.isGranted });
|
|
|
|
} else if (clickedPermission.name === per.parentName && clickedPermission.isGranted) {
|
|
|
|
return __assign({}, per, { isGranted: false });
|
|
|
|
} else if (clickedPermission.parentName === per.name && !clickedPermission.isGranted) {
|
|
|
|
return __assign({}, per, { isGranted: true });
|
|
|
|
}
|
|
|
|
return per;
|
|
|
|
},
|
|
|
|
);
|
|
|
|
_this.setTabCheckboxState();
|
|
|
|
_this.setGrantCheckboxState();
|
|
|
|
},
|
|
|
|
0,
|
|
|
|
);
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
PermissionManagementComponent.prototype.setTabCheckboxState
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/ = function() {
|
|
|
|
var _this = this;
|
|
|
|
this.selectedGroupPermissions$.pipe(take(1)).subscribe(
|
|
|
|
/**
|
|
|
|
* @param {?} permissions
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function(permissions) {
|
|
|
|
/** @type {?} */
|
|
|
|
var selectedPermissions = permissions.filter(
|
|
|
|
/**
|
|
|
|
* @param {?} per
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
(function(per) {
|
|
|
|
return per.isGranted;
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
/** @type {?} */
|
|
|
|
var element = /** @type {?} */ (document.querySelector('#select-all-in-this-tabs'));
|
|
|
|
if (selectedPermissions.length === permissions.length) {
|
|
|
|
element.indeterminate = false;
|
|
|
|
_this.selectThisTab = true;
|
|
|
|
} else if (selectedPermissions.length === 0) {
|
|
|
|
element.indeterminate = false;
|
|
|
|
_this.selectThisTab = false;
|
|
|
|
} else {
|
|
|
|
element.indeterminate = true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
PermissionManagementComponent.prototype.setGrantCheckboxState
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/ = function() {
|
|
|
|
/** @type {?} */
|
|
|
|
var selectedAllPermissions = this.permissions.filter(
|
|
|
|
/**
|
|
|
|
* @param {?} per
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
(function(per) {
|
|
|
|
return per.isGranted;
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
/** @type {?} */
|
|
|
|
var checkboxElement = /** @type {?} */ (document.querySelector('#select-all-in-all-tabs'));
|
|
|
|
if (selectedAllPermissions.length === this.permissions.length) {
|
|
|
|
checkboxElement.indeterminate = false;
|
|
|
|
this.selectAllTab = true;
|
|
|
|
} else if (selectedAllPermissions.length === 0) {
|
|
|
|
checkboxElement.indeterminate = false;
|
|
|
|
this.selectAllTab = false;
|
|
|
|
} else {
|
|
|
|
checkboxElement.indeterminate = true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
PermissionManagementComponent.prototype.onClickSelectThisTab
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/ = function() {
|
|
|
|
var _this = this;
|
|
|
|
this.selectedGroupPermissions$.pipe(take(1)).subscribe(
|
|
|
|
/**
|
|
|
|
* @param {?} permissions
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function(permissions) {
|
|
|
|
permissions.forEach(
|
|
|
|
/**
|
|
|
|
* @param {?} permission
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function(permission) {
|
|
|
|
if (permission.isGranted && _this.isGrantedByRole(permission.grantedProviders)) return;
|
|
|
|
/** @type {?} */
|
|
|
|
var index = _this.permissions.findIndex(
|
|
|
|
/**
|
|
|
|
* @param {?} per
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
(function(per) {
|
|
|
|
return per.name === permission.name;
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
_this.permissions = __spread(
|
|
|
|
_this.permissions.slice(0, index),
|
|
|
|
[__assign({}, _this.permissions[index], { isGranted: !_this.selectThisTab })],
|
|
|
|
_this.permissions.slice(index + 1),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
this.setGrantCheckboxState();
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
PermissionManagementComponent.prototype.onClickSelectAll
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/ = function() {
|
|
|
|
var _this = this;
|
|
|
|
this.permissions = this.permissions.map(
|
|
|
|
/**
|
|
|
|
* @param {?} permission
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function(permission) {
|
|
|
|
return __assign({}, permission, { isGranted: !_this.selectAllTab });
|
|
|
|
},
|
|
|
|
);
|
|
|
|
this.selectThisTab = !this.selectAllTab;
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* @param {?} group
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
PermissionManagementComponent.prototype.onChangeGroup
|
|
|
|
/**
|
|
|
|
* @param {?} group
|
|
|
|
* @return {?}
|
|
|
|
*/ = function(group) {
|
|
|
|
this.selectedGroup = group;
|
|
|
|
this.setTabCheckboxState();
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
PermissionManagementComponent.prototype.submit
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/ = function() {
|
|
|
|
var _this = this;
|
|
|
|
this.modalBusy = true;
|
|
|
|
/** @type {?} */
|
|
|
|
var unchangedPermissions = getPermissions(this.store.selectSnapshot(PermissionManagementState.getPermissionGroups));
|
|
|
|
/** @type {?} */
|
|
|
|
var changedPermissions = this.permissions
|
|
|
|
.filter(
|
|
|
|
/**
|
|
|
|
* @param {?} per
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
(function(per) {
|
|
|
|
return unchangedPermissions.find(
|
|
|
|
/**
|
|
|
|
* @param {?} unchanged
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function(unchanged) {
|
|
|
|
return unchanged.name === per.name;
|
|
|
|
},
|
|
|
|
).isGranted === per.isGranted
|
|
|
|
? false
|
|
|
|
: true;
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
.map(
|
|
|
|
/**
|
|
|
|
* @param {?} __0
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
(function(_a) {
|
|
|
|
var name = _a.name,
|
|
|
|
isGranted = _a.isGranted;
|
|
|
|
return { name: name, isGranted: isGranted };
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
if (changedPermissions.length) {
|
|
|
|
this.store
|
|
|
|
.dispatch(
|
|
|
|
new UpdatePermissions({
|
|
|
|
providerKey: this.providerKey,
|
|
|
|
providerName: this.providerName,
|
|
|
|
permissions: changedPermissions,
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
.subscribe(
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function() {
|
|
|
|
_this.modalBusy = false;
|
|
|
|
_this.visible = false;
|
|
|
|
},
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
this.modalBusy = false;
|
|
|
|
this.visible = false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
PermissionManagementComponent.prototype.openModal
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/ = function() {
|
|
|
|
var _this = this;
|
|
|
|
if (!this.providerKey || !this.providerName) {
|
|
|
|
throw new Error('Provider Key and Provider Name are required.');
|
|
|
|
}
|
|
|
|
this.store
|
|
|
|
.dispatch(
|
|
|
|
new GetPermissions({
|
|
|
|
providerKey: this.providerKey,
|
|
|
|
providerName: this.providerName,
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
.pipe(pluck('PermissionManagementState', 'permissionRes'))
|
|
|
|
.subscribe(
|
|
|
|
/**
|
|
|
|
* @param {?} permissionRes
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function(permissionRes) {
|
|
|
|
_this.selectedGroup = permissionRes.groups[0];
|
|
|
|
_this.permissions = getPermissions(permissionRes.groups);
|
|
|
|
_this.visible = true;
|
|
|
|
},
|
|
|
|
);
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
PermissionManagementComponent.prototype.initModal
|
|
|
|
/**
|
|
|
|
* @return {?}
|
|
|
|
*/ = function() {
|
|
|
|
this.setTabCheckboxState();
|
|
|
|
this.setGrantCheckboxState();
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* @param {?} __0
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
PermissionManagementComponent.prototype.ngOnChanges
|
|
|
|
/**
|
|
|
|
* @param {?} __0
|
|
|
|
* @return {?}
|
|
|
|
*/ = function(_a) {
|
|
|
|
var visible = _a.visible;
|
|
|
|
if (!visible) return;
|
|
|
|
if (visible.currentValue) {
|
|
|
|
this.openModal();
|
|
|
|
} else if (visible.currentValue === false && this.visible) {
|
|
|
|
this.visible = false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
PermissionManagementComponent.decorators = [
|
|
|
|
{
|
|
|
|
type: Component,
|
|
|
|
args: [
|
|
|
|
{
|
|
|
|
selector: 'abp-permission-management',
|
|
|
|
template:
|
|
|
|
'<abp-modal [(visible)]="visible" (init)="initModal()" [busy]="modalBusy">\n <ng-container *ngIf="{ entityName: entityName$ | async } as data">\n <ng-template #abpHeader>\n <h4>{{ \'AbpPermissionManagement::Permissions\' | abpLocalization }} - {{ data.entityName }}</h4>\n </ng-template>\n <ng-template #abpBody>\n <div class="custom-checkbox custom-control mb-2">\n <input\n type="checkbox"\n id="select-all-in-all-tabs"\n name="select-all-in-all-tabs"\n class="custom-control-input"\n [(ngModel)]="selectAllTab"\n (click)="onClickSelectAll()"\n />\n <label class="custom-control-label" for="select-all-in-all-tabs">{{\n \'AbpPermissionManagement::SelectAllInAllTabs\' | abpLocalization\n }}</label>\n </div>\n\n <hr class="mt-2 mb-2" />\n <div class="row">\n <div class="col-4">\n <ul class="nav nav-pills flex-column">\n <li *ngFor="let group of groups$ | async; trackBy: trackByFn" class="nav-item">\n <a\n class="nav-link pointer"\n [class.active]="selectedGroup?.name === group?.name"\n (click)="onChangeGroup(group)"\n >{{ group?.displayName }}</a\n >\n </li>\n </ul>\n </div>\n <div class="col-8">\n <h4>{{ selectedGroup?.displayName }}</h4>\n <hr class="mt-2 mb-3" />\n <div class="pl-1 pt-1">\n <div class="custom-checkbox custom-control mb-2">\n <input\n type="checkbox"\n id="select-all-in-this-tabs"\n name="select-all-in-this-tabs"\n class="custom-control-input"\n [(ngModel)]="selectThisTab"\n (click)="onClickSelectThisTab()"\n />\n <label class="custom-control-label" for="select-all-in-this-tabs">{{\n \'AbpPermissionManagement::SelectAllInThisTab\' | abpLocalization\n }}</label>\n </div>\n <hr class="mb-3" />\n <div\n *ngFor="let permission of selectedGroupPermissions$ | async; let i = index; trackBy: trackByFn"\n [style.margin-left]="permission.margin + \'px\'"\n class="custom-checkbox custom-control mb-2"\n >\n <input\n #permissionCheckbox\n type="checkbox"\n [checked]="getChecked(permission.name)"\n [value]="getChecked(permission.name)"\n [attr.id]="permission.name"\n class="custom-control-input"\n [disabled]="isGrantedByRole(permission.grantedProviders)"\n />\n <label\n class="custom-control-label"\n [attr.for]="permission.name"\n (click)="onClickCheckbox(permission, permissionCheckbox.value)"\n >{{ permission.displayName }}\n <span *ngFor="let provider of permission.grantedProviders" class="badge badge-light"\n >{{ provider.providerName }}: {{ provider.providerKey }}</span\n ></label\n >\n </div>\n </div>\n </div>\n </div>\n </ng-template>\n <ng-template #abpFooter>\n <button type="button" class="btn btn-secondary" #abpClose>\n {{ \'AbpIdentity::Cancel\' | abpLocalization }}\n </button>\n <abp-button iconClass="fa fa-check" (click)="submit()">{{ \'AbpIdentity::Save\' | abpLocalization }}</abp-button>\n </ng-template>\n </ng-container>\n</abp-modal>\n',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
/** @nocollapse */
|
|
|
|
PermissionManagementComponent.ctorParameters = function() {
|
|
|
|
return [{ type: Store }, { type: Renderer2 }];
|
|
|
|
};
|
|
|
|
PermissionManagementComponent.propDecorators = {
|
|
|
|
providerName: [{ type: Input }],
|
|
|
|
providerKey: [{ type: Input }],
|
|
|
|
visible: [{ type: Input }],
|
|
|
|
visibleChange: [{ type: Output }],
|
|
|
|
};
|
|
|
|
__decorate(
|
|
|
|
[Select(PermissionManagementState.getPermissionGroups), __metadata('design:type', Observable)],
|
|
|
|
PermissionManagementComponent.prototype,
|
|
|
|
'groups$',
|
|
|
|
void 0,
|
|
|
|
);
|
|
|
|
__decorate(
|
|
|
|
[Select(PermissionManagementState.getEntitiyDisplayName), __metadata('design:type', Observable)],
|
|
|
|
PermissionManagementComponent.prototype,
|
|
|
|
'entityName$',
|
|
|
|
void 0,
|
|
|
|
);
|
|
|
|
return PermissionManagementComponent;
|
|
|
|
})();
|
|
|
|
if (false) {
|
|
|
|
/** @type {?} */
|
|
|
|
PermissionManagementComponent.prototype.providerName;
|
|
|
|
/** @type {?} */
|
|
|
|
PermissionManagementComponent.prototype.providerKey;
|
|
|
|
/**
|
|
|
|
* @type {?}
|
|
|
|
* @protected
|
|
|
|
*/
|
|
|
|
PermissionManagementComponent.prototype._visible;
|
|
|
|
/** @type {?} */
|
|
|
|
PermissionManagementComponent.prototype.visibleChange;
|
|
|
|
/** @type {?} */
|
|
|
|
PermissionManagementComponent.prototype.groups$;
|
|
|
|
/** @type {?} */
|
|
|
|
PermissionManagementComponent.prototype.entityName$;
|
|
|
|
/** @type {?} */
|
|
|
|
PermissionManagementComponent.prototype.selectedGroup;
|
|
|
|
/** @type {?} */
|
|
|
|
PermissionManagementComponent.prototype.permissions;
|
|
|
|
/** @type {?} */
|
|
|
|
PermissionManagementComponent.prototype.selectThisTab;
|
|
|
|
/** @type {?} */
|
|
|
|
PermissionManagementComponent.prototype.selectAllTab;
|
|
|
|
/** @type {?} */
|
|
|
|
PermissionManagementComponent.prototype.modalBusy;
|
|
|
|
/** @type {?} */
|
|
|
|
PermissionManagementComponent.prototype.trackByFn;
|
|
|
|
/**
|
|
|
|
* @type {?}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
PermissionManagementComponent.prototype.store;
|
|
|
|
/**
|
|
|
|
* @type {?}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
PermissionManagementComponent.prototype.renderer;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @param {?} permissions
|
|
|
|
* @param {?} permission
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function findMargin(permissions, permission) {
|
|
|
|
/** @type {?} */
|
|
|
|
var parentPermission = permissions.find(
|
|
|
|
/**
|
|
|
|
* @param {?} per
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
(function(per) {
|
|
|
|
return per.name === permission.parentName;
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
if (parentPermission && parentPermission.parentName) {
|
|
|
|
/** @type {?} */
|
|
|
|
var margin = 20;
|
|
|
|
return (margin += findMargin(permissions, parentPermission));
|
|
|
|
}
|
|
|
|
return parentPermission ? 20 : 0;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @param {?} groups
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function getPermissions(groups) {
|
|
|
|
return groups.reduce(
|
|
|
|
/**
|
|
|
|
* @param {?} acc
|
|
|
|
* @param {?} val
|
|
|
|
* @return {?}
|
|
|
|
*/
|
|
|
|
function(acc, val) {
|
|
|
|
return __spread(acc, val.permissions);
|
|
|
|
},
|
|
|
|
[],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @fileoverview added by tsickle
|
|
|
|
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
|
|
*/
|
|
|
|
var PermissionManagementModule = /** @class */ (function() {
|
|
|
|
function PermissionManagementModule() {}
|
|
|
|
PermissionManagementModule.decorators = [
|
|
|
|
{
|
|
|
|
type: NgModule,
|
|
|
|
args: [
|
|
|
|
{
|
|
|
|
declarations: [PermissionManagementComponent],
|
|
|
|
imports: [CoreModule, ThemeSharedModule, NgxsModule.forFeature([PermissionManagementState])],
|
|
|
|
exports: [PermissionManagementComponent],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
return PermissionManagementModule;
|
|
|
|
})();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @fileoverview added by tsickle
|
|
|
|
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @fileoverview added by tsickle
|
|
|
|
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @fileoverview added by tsickle
|
|
|
|
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
|
|
*/
|
|
|
|
var PermissionManagement;
|
|
|
|
(function(PermissionManagement) {
|
|
|
|
/**
|
|
|
|
* @record
|
|
|
|
*/
|
|
|
|
function State() {}
|
|
|
|
PermissionManagement.State = State;
|
|
|
|
if (false) {
|
|
|
|
/** @type {?} */
|
|
|
|
State.prototype.permissionRes;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @record
|
|
|
|
*/
|
|
|
|
function Response() {}
|
|
|
|
PermissionManagement.Response = Response;
|
|
|
|
if (false) {
|
|
|
|
/** @type {?} */
|
|
|
|
Response.prototype.entityDisplayName;
|
|
|
|
/** @type {?} */
|
|
|
|
Response.prototype.groups;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @record
|
|
|
|
*/
|
|
|
|
function Group() {}
|
|
|
|
PermissionManagement.Group = Group;
|
|
|
|
if (false) {
|
|
|
|
/** @type {?} */
|
|
|
|
Group.prototype.name;
|
|
|
|
/** @type {?} */
|
|
|
|
Group.prototype.displayName;
|
|
|
|
/** @type {?} */
|
|
|
|
Group.prototype.permissions;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @record
|
|
|
|
*/
|
|
|
|
function MinimumPermission() {}
|
|
|
|
PermissionManagement.MinimumPermission = MinimumPermission;
|
|
|
|
if (false) {
|
|
|
|
/** @type {?} */
|
|
|
|
MinimumPermission.prototype.name;
|
|
|
|
/** @type {?} */
|
|
|
|
MinimumPermission.prototype.isGranted;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @record
|
|
|
|
*/
|
|
|
|
function Permission() {}
|
|
|
|
PermissionManagement.Permission = Permission;
|
|
|
|
if (false) {
|
|
|
|
/** @type {?} */
|
|
|
|
Permission.prototype.displayName;
|
|
|
|
/** @type {?} */
|
|
|
|
Permission.prototype.parentName;
|
|
|
|
/** @type {?} */
|
|
|
|
Permission.prototype.allowedProviders;
|
|
|
|
/** @type {?} */
|
|
|
|
Permission.prototype.grantedProviders;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @record
|
|
|
|
*/
|
|
|
|
function GrantedProvider() {}
|
|
|
|
PermissionManagement.GrantedProvider = GrantedProvider;
|
|
|
|
if (false) {
|
|
|
|
/** @type {?} */
|
|
|
|
GrantedProvider.prototype.providerName;
|
|
|
|
/** @type {?} */
|
|
|
|
GrantedProvider.prototype.providerKey;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @record
|
|
|
|
*/
|
|
|
|
function UpdateRequest() {}
|
|
|
|
PermissionManagement.UpdateRequest = UpdateRequest;
|
|
|
|
if (false) {
|
|
|
|
/** @type {?} */
|
|
|
|
UpdateRequest.prototype.permissions;
|
|
|
|
}
|
|
|
|
})(PermissionManagement || (PermissionManagement = {}));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @fileoverview added by tsickle
|
|
|
|
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @fileoverview added by tsickle
|
|
|
|
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @fileoverview added by tsickle
|
|
|
|
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @fileoverview added by tsickle
|
|
|
|
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @fileoverview added by tsickle
|
|
|
|
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
|
|
*/
|
|
|
|
|
|
|
|
export {
|
|
|
|
GetPermissions,
|
|
|
|
PermissionManagementComponent,
|
|
|
|
PermissionManagementModule,
|
|
|
|
PermissionManagementService,
|
|
|
|
PermissionManagementState,
|
|
|
|
UpdatePermissions,
|
|
|
|
PermissionManagementComponent as ɵa,
|
|
|
|
PermissionManagementState as ɵb,
|
|
|
|
PermissionManagementService as ɵc,
|
|
|
|
GetPermissions as ɵd,
|
|
|
|
UpdatePermissions as ɵe,
|
|
|
|
};
|
|
|
|
//# sourceMappingURL=abp-ng.permission-management.js.map
|