Skip to content

Commit 508e93d

Browse files
authored
Show modal dialog in Hive UI before disabling/enabling tablets starting (#15152)
1 parent 3abd02a commit 508e93d

File tree

2 files changed

+64
-11
lines changed

2 files changed

+64
-11
lines changed

ydb/core/mind/hive/hive_statics.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,12 +453,12 @@ TString GetTypesHtml(const std::set<TTabletTypes::EType>& typesToShow, const std
453453
auto longTypeName = TTabletTypes::TypeToStr(type);
454454
if (it == tabletLimits.end() || it->second.GetMaxCount() > 0) {
455455
str << "<span class='box' title='" << longTypeName
456-
<< "' onclick='applySetting(this,\"DefaultTabletLimit\",\"" << shortTypeName
457-
<< ":0\")'>";
456+
<< "' onclick='changeDefaultTabletLimit(this, \"" << shortTypeName
457+
<< ":0\", \"" << longTypeName << "\")'>";
458458
} else {
459459
str << "<span class='box box-disabled' title='" << longTypeName
460-
<< "' onclick='applySetting(this, \"DefaultTabletLimit\", \"" << shortTypeName
461-
<< ":" << TNodeInfo::MAX_TABLET_COUNT_DEFAULT_VALUE << "\")'>";
460+
<< "' onclick='changeDefaultTabletLimit(this, \"" << shortTypeName
461+
<< ":" << TNodeInfo::MAX_TABLET_COUNT_DEFAULT_VALUE << "\", \"" << longTypeName << "\")'>";
462462
}
463463
str << shortTypeName;
464464
str << "</span>";

ydb/core/mind/hive/monitoring.cpp

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,6 +2015,40 @@ function clearAlert() {
20152015
$('#alert-placeholder').removeClass('glyphicon-refresh');
20162016
}
20172017
2018+
2019+
function showConfirmationModal(message, onConfirm, onDismiss) {
2020+
var modal = $('<div class="modal fade" tabindex="-1" role="dialog" data-backdrop="static">'
2021+
+ '<div class="modal-dialog" role="document">'
2022+
+ '<div class="modal-content">'
2023+
+ '<div class="modal-header">'
2024+
+ '<button type="button" class="close" data-dismiss="modal">&times;</button>'
2025+
+ '<h4 class="modal-title">Confirmation</h4>'
2026+
+ '</div>'
2027+
+ '<div class="modal-body">' + message + '</div>'
2028+
+ '<div class="modal-footer">'
2029+
+ '<button type="button" class="btn btn-default cancel-btn" data-dismiss="modal">Cancel</button>'
2030+
+ '<button type="button" class="btn btn-danger confirm-btn">OK</button>'
2031+
+ '</div>'
2032+
+ '</div>'
2033+
+ '</div>'
2034+
+ '</div>');
2035+
2036+
$('.modal').remove();
2037+
$('body').append(modal);
2038+
modal.modal('show');
2039+
2040+
modal.find('.confirm-btn').click(function () {
2041+
if (onConfirm) onConfirm();
2042+
modal.modal('hide').remove();
2043+
});
2044+
2045+
modal.on('hidden.bs.modal', function () {
2046+
if (onDismiss) onDismiss();
2047+
modal.remove();
2048+
});
2049+
}
2050+
2051+
20182052
function enableType(element, node, type) {
20192053
$(element).css('color', 'gray');
20202054
$.ajax({url:'?TabletID=' + hiveId + '&node=' + node + '&page=TabletAvailability&resettype=' + type});
@@ -2025,14 +2059,33 @@ function disableType(element, node, type) {
20252059
$.ajax({url:'?TabletID=' + hiveId + '&node=' + node + '&page=TabletAvailability&maxcount=0&changetype=' + type});
20262060
}
20272061
2028-
function applySetting(button, name, val) {
2029-
$(button).css('color', 'gray');
2030-
if (name == "DefaultTabletLimit") {
2031-
should_refresh_types = true;
2062+
function changeDefaultTabletLimit(button, val, tabletTypeName) {
2063+
let text = '';
2064+
if (val.split(':')[1] == '0') {
2065+
text = 'Prohibit starting tablets of type <b>' + tabletTypeName + '</b> on every node';
2066+
} else {
2067+
text = 'Allow starting tablets of type <b>' + tabletTypeName + '</b> on every node';
20322068
}
2033-
$.ajax({
2034-
url: document.URL + '&page=Settings&' + name + '=' + val,
2035-
});
2069+
applySetting(button, 'DefaultTabletLimit', val, text);
2070+
}
2071+
2072+
function applySetting(button, name, val, text) {
2073+
$(button).css('color', 'gray');
2074+
2075+
showConfirmationModal(
2076+
'Are you sure you want to proceed? ' + text,
2077+
function () {
2078+
if (name == "DefaultTabletLimit") {
2079+
should_refresh_types = true;
2080+
}
2081+
$.ajax({
2082+
url: document.URL + '&page=Settings&' + name + '=' + val,
2083+
});
2084+
},
2085+
function () {
2086+
$(button).css('color', '');
2087+
}
2088+
);
20362089
}
20372090
20382091
var Empty = true;

0 commit comments

Comments
 (0)