Skip to content

Commit becdb93

Browse files
https://perconadev.atlassian.net/issues/DISTMYSQL-370
Problem: When the instance has tags and the user hits 'Refresh' button in the instance config modal window, tags disappear. Problem: When we query for the instance detais it does not contain tags info. There is a separate API endpoint to retrieve a single instance tags. So these two things has to be done separately. Before the fix the information about tags related to the particular instance were retrieved and cached during instance rendering on the cluster view in renderInstanceElement() function. It is an asynchronous process, but it worked fine as it was very unlikely that the user opens the instance's config modal dialog before tags were retrieved. Then, the config window used already cached tags. However, when the user hits 'Refresh' button, the config modal window is rendered immediately, before tags are retrieved, which results in empty tags after refresh. Solution: Do not cache tags during renderInstanceElement(). Just request and render the proper icon asynchronously. Do the same for the config modal window. Just request tags and render them asynchronously. Possible improvement: Probably it would be better if instances returned by the API already contained related tags (like /api/cluster/clusterHint), or if we had a dedicated API for retrieving tags related for a given set of instances. For now, let's leave it as it is, improve if needed.
1 parent 41f55e8 commit becdb93

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

resources/public/js/orchestrator.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,16 @@ function openNodeModal(node) {
385385
addNodeModalDataAttribute("Agent",
386386
'<a href="' + appUrl('/web/agent/' + node.Key.Hostname) + '">' + node.Key.Hostname + '</a>');
387387

388-
var tagsText = "";
389-
if (node.hasOwnProperty('tagStrings') && node.tagStrings.length) {
390-
node.tagStrings.forEach(function(tag){
391-
tagsText = tagsText.concat(tag, '<br>');
392-
});
393-
}
394-
addNodeModalDataAttribute("Tags", tagsText);
388+
$.get(appUrl("/api/tags/" + node.Key.Hostname + "/" + node.Key.Port), function(tagStrings) {
389+
var tagsText = "";
390+
if (tagStrings.length) {
391+
tagStrings.forEach(function(tag){
392+
tagsText = tagsText.concat(tag, '<br>');
393+
})
394+
addNodeModalDataAttribute("Tags", tagsText);
395+
}
396+
}, "json");
397+
395398

396399
$('#node_modal [data-btn]').unbind("click");
397400

@@ -975,10 +978,8 @@ function renderInstanceElement(popoverElement, instance, renderType) {
975978

976979
$.get(appUrl("/api/tags/" + instance.Key.Hostname + "/" + instance.Key.Port), function(tagStrings) {
977980
if (tagStrings.length) {
978-
// Need to remember this. It is used in instance's modal window.
979-
instance.tagStrings = tagStrings;
980981
var tagsText = "";
981-
instance.tagStrings.forEach(function(tag) {
982+
tagStrings.forEach(function(tag) {
982983
tagsText = tagsText.concat(tag, '&#10;');
983984
});
984985
popoverElement.find("h3 div.pull-right").prepend('<span class="glyphicon glyphicon-tags" title="' + tagsText +'"></span> ');

0 commit comments

Comments
 (0)