mirror of https://github.com/portainer/portainer
24 lines
601 B
JavaScript
24 lines
601 B
JavaScript
|
export default class ContainerCapabilitiesController {
|
||
|
/* @ngInject */
|
||
|
constructor($scope) {
|
||
|
this.$scope = $scope;
|
||
|
|
||
|
this.oldCapabilities = [];
|
||
|
}
|
||
|
|
||
|
createOnChangeHandler(capability) {
|
||
|
return (checked) => {
|
||
|
this.$scope.$evalAsync(() => {
|
||
|
capability.allowed = checked;
|
||
|
});
|
||
|
};
|
||
|
}
|
||
|
|
||
|
$doCheck() {
|
||
|
if (this.oldCapabilities.length !== this.capabilities.length) {
|
||
|
this.oldCapabilities = this.capabilities;
|
||
|
this.capabilitiesOnChange = Object.fromEntries(this.capabilities.map((cap) => [cap.capability, this.createOnChangeHandler(cap)]));
|
||
|
}
|
||
|
}
|
||
|
}
|