@@ -2015,6 +2015,40 @@ function clearAlert() {
2015
2015
$('#alert-placeholder').removeClass('glyphicon-refresh');
2016
2016
}
2017
2017
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
+
2018
2052
function enableType(element, node, type) {
2019
2053
$(element).css('color', 'gray');
2020
2054
$.ajax({url:'?TabletID=' + hiveId + '&node=' + node + '&page=TabletAvailability&resettype=' + type});
@@ -2025,14 +2059,33 @@ function disableType(element, node, type) {
2025
2059
$.ajax({url:'?TabletID=' + hiveId + '&node=' + node + '&page=TabletAvailability&maxcount=0&changetype=' + type});
2026
2060
}
2027
2061
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';
2032
2068
}
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
+ );
2036
2089
}
2037
2090
2038
2091
var Empty = true;
0 commit comments