NIFI-4423 - Add a confirmation of a Counter reset action. This closes #2178

This commit is contained in:
yuri1969 2017-09-26 20:18:39 +02:00 committed by Matt Gilman
parent c29ee4a6fa
commit 5e2fb8cff1
No known key found for this signature in database
GPG Key ID: DF61EC19432AEE37
2 changed files with 28 additions and 17 deletions

View File

@ -58,6 +58,7 @@
<jsp:include page="/WEB-INF/partials/message-pane.jsp"/> <jsp:include page="/WEB-INF/partials/message-pane.jsp"/>
<jsp:include page="/WEB-INF/partials/banners-utility.jsp"/> <jsp:include page="/WEB-INF/partials/banners-utility.jsp"/>
<jsp:include page="/WEB-INF/partials/ok-dialog.jsp"/> <jsp:include page="/WEB-INF/partials/ok-dialog.jsp"/>
<jsp:include page="/WEB-INF/partials/yes-no-dialog.jsp"/>
<jsp:include page="/WEB-INF/partials/counters/counters-content.jsp"/> <jsp:include page="/WEB-INF/partials/counters/counters-content.jsp"/>
</body> </body>
</html> </html>

View File

@ -22,23 +22,26 @@
define(['jquery', define(['jquery',
'Slick', 'Slick',
'nf.Common', 'nf.Common',
'nf.ErrorHandler'], 'nf.ErrorHandler',
function ($, Slick, nfCommon, nfErrorHandler) { 'nf.Dialog'],
return (nf.CountersTable = factory($, Slick, nfCommon, nfErrorHandler)); function ($, Slick, nfCommon, nfErrorHandler, nfDialog) {
return (nf.CountersTable = factory($, Slick, nfCommon, nfErrorHandler, nfDialog));
}); });
} else if (typeof exports === 'object' && typeof module === 'object') { } else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.CountersTable = module.exports = (nf.CountersTable =
factory(require('jquery'), factory(require('jquery'),
require('Slick'), require('Slick'),
require('nf.Common'), require('nf.Common'),
require('nf.ErrorHandler'))); require('nf.ErrorHandler'),
require('nf.Dialog')));
} else { } else {
nf.CountersTable = factory(root.$, nf.CountersTable = factory(root.$,
root.Slick, root.Slick,
root.nf.Common, root.nf.Common,
root.nf.ErrorHandler); root.nf.ErrorHandler,
root.nf.Dialog);
} }
}(this, function ($, Slick, nfCommon, nfErrorHandler) { }(this, function ($, Slick, nfCommon, nfErrorHandler, nfDialog) {
'use strict'; 'use strict';
/** /**
@ -133,18 +136,25 @@
* @argument {object} item The counter item * @argument {object} item The counter item
*/ */
var resetCounter = function (item) { var resetCounter = function (item) {
$.ajax({ // prompt reset confirmation
type: 'PUT', nfDialog.showYesNoDialog({
url: config.urls.counters + '/' + encodeURIComponent(item.id), headerText: 'Reset Counter',
dataType: 'json' dialogContent: 'Reset counter \'' + nfCommon.escapeHtml(item.name) + '\' to default value?',
}).done(function (response) { yesHandler: function () {
var counter = response.counter; $.ajax({
type: 'PUT',
url: config.urls.counters + '/' + encodeURIComponent(item.id),
dataType: 'json'
}).done(function (response) {
var counter = response.counter;
// get the table and update the row accordingly // get the table and update the row accordingly
var countersGrid = $('#counters-table').data('gridInstance'); var countersGrid = $('#counters-table').data('gridInstance');
var countersData = countersGrid.getData(); var countersData = countersGrid.getData();
countersData.updateItem(counter.id, counter); countersData.updateItem(counter.id, counter);
}).fail(nfErrorHandler.handleAjaxError); }).fail(nfErrorHandler.handleAjaxError);
}
});
}; };
return { return {