From 8f1ac3896373053dc1446fe1855db94f1910abca Mon Sep 17 00:00:00 2001 From: matias-portainer <104775949+matias-portainer@users.noreply.github.com> Date: Thu, 13 Oct 2022 11:03:19 -0300 Subject: [PATCH] fix(tags): get tags when loading associated endpoints selector EE-4140 (#7857) --- .../associatedEndpointsSelectorController.js | 10 ++++++++++ app/portainer/helpers/tagHelper.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/portainer/components/associated-endpoints-selector/associatedEndpointsSelectorController.js b/app/portainer/components/associated-endpoints-selector/associatedEndpointsSelectorController.js index 940573b95..923485188 100644 --- a/app/portainer/components/associated-endpoints-selector/associatedEndpointsSelectorController.js +++ b/app/portainer/components/associated-endpoints-selector/associatedEndpointsSelectorController.js @@ -3,6 +3,7 @@ import _ from 'lodash-es'; import { EdgeTypes } from '@/portainer/environments/types'; import { getEnvironments } from '@/portainer/environments/environment.service'; +import { getTags } from '@/portainer/tags/tags.service'; class AssoicatedEndpointsSelectorController { /* @ngInject */ @@ -47,6 +48,7 @@ class AssoicatedEndpointsSelectorController { } loadData() { + this.getTags(); this.getAvailableEndpoints(); this.getAssociatedEndpoints(); } @@ -79,6 +81,14 @@ class AssoicatedEndpointsSelectorController { this.setTableData('associated', response.value, response.totalCount); }); } + + getTags() { + return this.$async(async () => { + let tags = { value: [], totalCount: 0 }; + tags = await getTags(); + this.tags = tags; + }); + } /* #endregion */ /* #region On endpoint click (either available or associated) */ diff --git a/app/portainer/helpers/tagHelper.js b/app/portainer/helpers/tagHelper.js index 133d56a61..555a3ffa2 100644 --- a/app/portainer/helpers/tagHelper.js +++ b/app/portainer/helpers/tagHelper.js @@ -1,7 +1,7 @@ import _ from 'lodash'; export function idsToTagNames(tags, ids) { - const filteredTags = _.filter(tags, (tag) => _.includes(ids, tag.Id)); + const filteredTags = _.filter(tags, (tag) => _.includes(ids, tag.ID)); const tagNames = _.map(filteredTags, 'Name'); return tagNames; }