@@ -2015,24 +2015,94 @@ function clearAlert() {
20152015 $('#alert-placeholder').removeClass('glyphicon-refresh');
20162016}
20172017
2018- function enableType(element, node, type) {
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">×</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+ function enableType(element, node, type, tabletName) {
20192052 $(element).css('color', 'gray');
2020- $.ajax({url:'?TabletID=' + hiveId + '&node=' + node + '&page=TabletAvailability&resettype=' + type});
2053+
2054+ showConfirmationModal(
2055+ 'Are you sure you want to proceed? Allow starting tablets with type <b>' + tabletName + '</b> on node <b>' + node + '</b>.',
2056+ function () {
2057+ $.ajax({url:'?TabletID=' + hiveId + '&node=' + node + '&page=TabletAvailability&resettype=' + type});
2058+ },
2059+ function () {
2060+ $(element).css('color', '');
2061+ }
2062+ );
20212063}
20222064
2023- function disableType(element, node, type) {
2065+ function disableType(element, node, type, tabletName ) {
20242066 $(element).css('color', 'gray');
2025- $.ajax({url:'?TabletID=' + hiveId + '&node=' + node + '&page=TabletAvailability&maxcount=0&changetype=' + type});
2067+
2068+ showConfirmationModal(
2069+ 'Are you sure you want to proceed? Prohibit starting tablets with type <b>' + tabletName + '</b> on node <b>' + node + '</b>.',
2070+ function () {
2071+ $.ajax({url:'?TabletID=' + hiveId + '&node=' + node + '&page=TabletAvailability&maxcount=0&changetype=' + type});
2072+ },
2073+ function () {
2074+ $(element).css('color', '');
2075+ }
2076+ );
20262077}
20272078
2028- function applySetting(button, name, val) {
2029- $(button).css('color', 'gray');
2030- if (name == "DefaultTabletLimit") {
2031- should_refresh_types = true;
2079+ function changeDefaultTabletLimit(button, val, tabletTypeName) {
2080+ let text = '';
2081+ if (val.endsWith('0')) {
2082+ text = 'Prohibit starting tablets of type <b>' + tabletTypeName + '</b> on every node';
2083+ } else {
2084+ text = 'Allow starting tablets of type <b>' + tabletTypeName + '</b> on every node';
20322085 }
2033- $.ajax({
2034- url: document.URL + '&page=Settings&' + name + '=' + val,
2035- });
2086+ applySetting(button, 'DefaultTabletLimit', val, text);
2087+ }
2088+
2089+ function applySetting(button, name, val, text) {
2090+ $(button).css('color', 'gray');
2091+
2092+ showConfirmationModal(
2093+ 'Are you sure you want to proceed? ' + text,
2094+ function () {
2095+ if (name == "DefaultTabletLimit") {
2096+ should_refresh_types = true;
2097+ }
2098+ $.ajax({
2099+ url: document.URL + '&page=Settings&' + name + '=' + val,
2100+ });
2101+ },
2102+ function () {
2103+ $(button).css('color', '');
2104+ }
2105+ );
20362106}
20372107
20382108var Empty = true;
@@ -2329,6 +2399,8 @@ class TTxMonEvent_LandingData : public TTransactionBase<THive> {
23292399 TString ToHTML () const {
23302400 auto totalCount = LeaderCount + FollowerCount;
23312401 TStringBuilder str;
2402+ auto shortTypeName = GetTabletTypeShortName (TabletType);
2403+ auto longTypeName = TTabletTypes::TypeToStr (TabletType);
23322404 if (MaxCount > 0 ) {
23332405 str << " <span class='box' " ;
23342406 } else {
@@ -2338,9 +2410,9 @@ class TTxMonEvent_LandingData : public TTransactionBase<THive> {
23382410 str << " style='color: red' " ;
23392411 }
23402412 str << " onclick='" << (MaxCount == 0 ? " enableType" : " disableType" )
2341- << " (this," << NodeId << " ," << (ui32)TabletType << " )" ;
2413+ << " (this," << NodeId << " ," << (ui32)TabletType << " , \" " << longTypeName << " \" )" ;
23422414 str << " '>" ;
2343- str << GetTabletTypeShortName (TabletType) ;
2415+ str << shortTypeName ;
23442416 str << " " ;
23452417 str << LeaderCount;
23462418 if (FollowerCount > 0 ) {
0 commit comments