1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-03 04:45:21 +02:00

feat(ACI): add UAC to ACI

This commit is contained in:
Felix Han 2021-03-30 10:58:56 +13:00
parent ad2910f3f0
commit e3e7e84821
18 changed files with 410 additions and 18 deletions

View file

@ -49,6 +49,13 @@
<th>
Published Ports
</th>
<th>
<a ng-click="$ctrl.changeOrderBy('ResourceControl.Ownership')">
Ownership
<i class="fa fa-sort-alpha-down" aria-hidden="true" ng-if="$ctrl.state.orderBy === 'ResourceControl.Ownership' && !$ctrl.state.reverseOrder"></i>
<i class="fa fa-sort-alpha-up" aria-hidden="true" ng-if="$ctrl.state.orderBy === 'ResourceControl.Ownership' && $ctrl.state.reverseOrder"></i>
</a>
</th>
</tr>
</thead>
<tbody>
@ -70,6 +77,12 @@
</a>
<span ng-if="item.Ports.length == 0">-</span>
</td>
<td>
<span>
<i ng-class="item.ResourceControl.Ownership | ownershipicon" aria-hidden="true"></i>
{{ item.ResourceControl.Ownership ? item.ResourceControl.Ownership : item.ResourceControl.Ownership = $ctrl.RCO.ADMINISTRATORS }}
</span>
</td>
</tr>
<tr ng-if="!$ctrl.dataset">
<td colspan="3" class="text-center text-muted">Loading...</td>

View file

@ -2,7 +2,7 @@ angular.module('portainer.azure').component('containergroupsDatatable', {
templateUrl: './containerGroupsDatatable.html',
controller: 'GenericDatatableController',
bindings: {
title: '@',
titleText: '@',
titleIcon: '@',
dataset: '<',
tableKey: '@',

View file

@ -1,3 +1,6 @@
import { AccessControlFormData } from 'Portainer/components/accessControlForm/porAccessControlFormModel';
import { ResourceControlViewModel } from 'Portainer/models/resourceControl/resourceControl';
export function ContainerGroupDefaultModel() {
this.Location = '';
this.OSType = 'Linux';
@ -13,6 +16,7 @@ export function ContainerGroupDefaultModel() {
];
this.CPU = 1;
this.Memory = 1;
this.AccessControlData = new AccessControlFormData();
}
export function ContainerGroupViewModel(data) {
@ -30,6 +34,10 @@ export function ContainerGroupViewModel(data) {
this.AllocatePublicIP = data.properties.ipAddress.type === 'Public';
this.CPU = container.properties.resources.requests.cpu;
this.Memory = container.properties.resources.requests.memoryInGB;
if (data.Portainer && data.Portainer.ResourceControl) {
this.ResourceControl = new ResourceControlViewModel(data.Portainer.ResourceControl);
}
}
export function CreateContainerGroupRequest(model) {

View file

@ -131,4 +131,8 @@
</rd-widget-body>
</rd-widget>
</div>
<!-- access-control-panel -->
<por-access-control-panel ng-if="$ctrl.container" resource-id="$ctrl.container.Id" resource-control="$ctrl.container.ResourceControl" resource-type="'container-group'">
</por-access-control-panel>
<!-- !access-control-panel -->
</div>

View file

@ -6,7 +6,9 @@ angular.module('portainer.azure').controller('AzureCreateContainerInstanceContro
'$state',
'AzureService',
'Notifications',
function ($q, $scope, $state, AzureService, Notifications) {
'Authentication',
'ResourceControlService',
function ($q, $scope, $state, AzureService, Notifications, Authentication, ResourceControlService) {
var allResourceGroups = [];
var allProviders = [];
@ -42,12 +44,12 @@ angular.module('portainer.azure').controller('AzureCreateContainerInstanceContro
$scope.state.actionInProgress = true;
AzureService.createContainerGroup(model, subscriptionId, resourceGroupName)
.then(function success() {
.then(applyResourceControl)
.then(() => {
Notifications.success('Container successfully created', model.Name);
$state.go('azure.containerinstances');
})
.catch(function error(err) {
err = err.data ? err.data.error : err;
Notifications.error('Failure', err, 'Unable to create container');
})
.finally(function final() {
@ -55,6 +57,14 @@ angular.module('portainer.azure').controller('AzureCreateContainerInstanceContro
});
};
function applyResourceControl(newResourceGroup) {
const userId = Authentication.getUserDetails().ID;
const resourceControl = newResourceGroup.Portainer.ResourceControl;
const accessControlData = $scope.model.AccessControlData;
return ResourceControlService.applyResourceControl(userId, accessControlData, resourceControl);
}
function validateForm(model) {
if (!model.Ports || !model.Ports.length || model.Ports.every((port) => !port.host || !port.container)) {
return 'At least one port binding is required';
@ -73,7 +83,7 @@ angular.module('portainer.azure').controller('AzureCreateContainerInstanceContro
}
function initView() {
var model = new ContainerGroupDefaultModel();
$scope.model = new ContainerGroupDefaultModel();
AzureService.subscriptions()
.then(function success(data) {
@ -93,8 +103,6 @@ angular.module('portainer.azure').controller('AzureCreateContainerInstanceContro
var containerInstancesProviders = data.containerInstancesProviders;
allProviders = containerInstancesProviders;
$scope.model = model;
var selectedSubscription = $scope.state.selectedSubscription;
updateResourceGroupsAndLocations(selectedSubscription, resourceGroups, containerInstancesProviders);
})

View file

@ -157,6 +157,9 @@
</div>
</div>
<!-- !memory-input -->
<!-- access-control -->
<por-access-control-form form-data="model.AccessControlData"></por-access-control-form>
<!-- !access-control -->
<!-- actions -->
<div class="col-sm-12 form-section-title">
Actions