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

refactor(docker/networks): migrate macvlan nodes selector to react [EE-4669] (#10183)

This commit is contained in:
Chaim Lev-Ari 2023-09-11 15:27:04 +01:00 committed by GitHub
parent 09aa1d35a8
commit 60477ae287
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 315 additions and 220 deletions

View file

@ -37,23 +37,14 @@
<!-- network-card-input -->
<!-- nodes-selector -->
<div ng-if="$ctrl.applicationState.endpoint.mode.agentProxy && $ctrl.applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE'">
<div class="form-group">
<div class="col-sm-12">
<macvlan-nodes-datatable
title-text="Select the nodes where you want to deploy the local configuration"
title-icon="hard-drive"
dataset="$ctrl.nodes"
table-key="nodes"
state="$ctrl.data.DatatableState"
order-by="Hostname"
show-ip-address-column="$ctrl.applicationState.endpoint.apiVersion >= 1.25"
access-to-node-details="$ctrl.isAdmin"
name="node_selector"
ng-model="tmp"
ng-required="$ctrl.requiredNodeSelection()"
></macvlan-nodes-datatable>
</div>
</div>
<macvlan-nodes-selector
dataset="$ctrl.nodes"
is-ip-column-visible="$ctrl.applicationState.endpoint.apiVersion >= 1.25"
have-access-to-node="$ctrl.isAdmin"
value="$ctrl.data.DatatableState.selectedItems"
on-change="($ctrl.onChangeSelectedNodes)"
></macvlan-nodes-selector>
<div class="form-group" ng-show="macvlanConfigurationForm.node_selector.$invalid">
<div class="col-sm-12 small text-warning">
<div ng-messages="macvlanConfigurationForm.node_selector.$error">

View file

@ -12,11 +12,18 @@ angular.module('portainer.docker').controller('NetworkMacvlanFormController', [
this.options = [];
ctrl.onChangeSelectedNodes = onChangeSelectedNodes.bind(ctrl);
function onChangeSelectedNodes(nodes) {
return $scope.$evalAsync(() => {
ctrl.data.DatatableState.selectedItems = nodes;
});
}
ctrl.requiredNodeSelection = function () {
if (ctrl.data.Scope !== 'local' || ctrl.data.DatatableState === undefined) {
return false;
}
return ctrl.data.DatatableState.selectedItemCount === 0;
return ctrl.data.DatatableState.selectedItems.length;
};
ctrl.requiredConfigSelection = function () {