@@ -2015,24 +2015,94 @@ function clearAlert() {
2015
2015
$('#alert-placeholder').removeClass('glyphicon-refresh');
2016
2016
}
2017
2017
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) {
2019
2052
$(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? Resetting maxcount on node <b>' + node + '</b> for tablet type <b>' + type + '</b>.',
2056
+ function () {
2057
+ $.ajax({url:'?TabletID=' + hiveId + '&node=' + node + '&page=TabletAvailability&resettype=' + type});
2058
+ },
2059
+ function () {
2060
+ $(element).css('color', '');
2061
+ }
2062
+ );
2021
2063
}
2022
2064
2023
- function disableType(element, node, type) {
2065
+ function disableType(element, node, type, tabletName ) {
2024
2066
$(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? Setting maxcount=0 on node <b>' + node + '</b> for tablet type <b>' + type + '</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
+ );
2026
2077
}
2027
2078
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 ' + tabletTypeName + ' on every node';
2083
+ } else {
2084
+ text = 'Allow starting tablets of type ' + tabletTypeName + ' on every node';
2032
2085
}
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
+ );
2036
2106
}
2037
2107
2038
2108
var Empty = true;
@@ -2329,6 +2399,8 @@ class TTxMonEvent_LandingData : public TTransactionBase<THive> {
2329
2399
TString ToHTML () const {
2330
2400
auto totalCount = LeaderCount + FollowerCount;
2331
2401
TStringBuilder str;
2402
+ auto shortTypeName = GetTabletTypeShortName (TabletType);
2403
+ auto longTypeName = TTabletTypes::TypeToStr (TabletType);
2332
2404
if (MaxCount > 0 ) {
2333
2405
str << " <span class='box' " ;
2334
2406
} else {
@@ -2338,9 +2410,9 @@ class TTxMonEvent_LandingData : public TTransactionBase<THive> {
2338
2410
str << " style='color: red' " ;
2339
2411
}
2340
2412
str << " onclick='" << (MaxCount == 0 ? " enableType" : " disableType" )
2341
- << " (this," << NodeId << " ," << (ui32)TabletType << " )" ;
2413
+ << " (this," << NodeId << " ," << (ui32)TabletType << " \" , " << longTypeName << " \" )" ;
2342
2414
str << " '>" ;
2343
- str << GetTabletTypeShortName (TabletType) ;
2415
+ str << shortTypeName ;
2344
2416
str << " " ;
2345
2417
str << LeaderCount;
2346
2418
if (FollowerCount > 0 ) {
0 commit comments