Skip to content

Commit b803756

Browse files
DISTMYSQL-169: Make tags visible in the GUI
https://jira.percona.com/browse/DISTMYSQL-169 Problem: Instance tags are not visible in Orchestrator's web GUI. Solution: 1. If instance tags are present, 'tags' icon is displayed on the top bar of the instance. When the mouse is hovered on, tags are displayed. 2. Added new row 'Tags' to instance modal view. Additionally fixed handling of /api/recently-active-cluster-recovery endpoint result.
1 parent d93e74f commit b803756

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

resources/public/css/orchestrator.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ body {
143143
cursor: default;
144144
}
145145

146+
.instance h3 .glyphicon-tags {
147+
margin-right: 0.4em;
148+
}
149+
146150
.instance h3 .instance-glyphs {
147151
cursor: pointer;
148152
}

resources/public/js/cluster.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,6 +1633,15 @@ function Cluster() {
16331633
}
16341634
}
16351635

1636+
function showInstanceTags(instance) {
1637+
if (instance.hasOwnProperty('tagStrings') && instance.tagStrings.length) {
1638+
var tagsText = "";
1639+
instance.tagStrings.forEach(function(tag){
1640+
tagsText = tagsText.concat(tag, '
');
1641+
});
1642+
getInstanceDiv(instance.id).find("h3 div.pull-right").prepend('<span class="glyphicon glyphicon-tags" title="' + tagsText +'"></span> ');
1643+
}
1644+
}
16361645

16371646
function indicateClusterPoolInstances(clusterPoolInstances) {
16381647
var instancesMap = _instancesMap;
@@ -1673,10 +1682,19 @@ function Cluster() {
16731682

16741683
reviewReplicationAnalysis(replicationAnalysis);
16751684

1685+
// Tags are displayed only for not aggregated instances
1686+
for (var instanceId in _instancesMap) {
1687+
let instance = _instancesMap[instanceId];
1688+
getData("/api/tags/" + instance.Key.Hostname + "/" + instance.Key.Port, function(tagStrings) {
1689+
instance.tagStrings = tagStrings;
1690+
showInstanceTags(instance)
1691+
});
1692+
}
1693+
16761694
instances.forEach(function(instance) {
16771695
if (instance.isMaster) {
16781696
getData("/api/recently-active-instance-recovery/" + instance.Key.Hostname + "/" + instance.Key.Port, function(recoveries) {
1679-
if (!recoveries) {
1697+
if (!recoveries || !recoveries.length) {
16801698
return
16811699
}
16821700
// Result is an array: either empty (no active recovery) or with multiple entries
@@ -1767,7 +1785,7 @@ function Cluster() {
17671785
});
17681786
});
17691787
getData("/api/recently-active-cluster-recovery/" + currentClusterName(), function(recoveries) {
1770-
if (!recoveries) {
1788+
if (!recoveries || !recoveries.length) {
17711789
return
17721790
}
17731791
// Result is an array: either empty (no active recovery) or with multiple entries

resources/public/js/orchestrator.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,14 @@ 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);
395+
388396
$('#node_modal [data-btn]').unbind("click");
389397

390398
$("#beginDowntimeOwner").val(getUserId());

0 commit comments

Comments
 (0)