From 5e2fb8cff1f74fba8c354157475fe0edaf4b2ec9 Mon Sep 17 00:00:00 2001 From: yuri1969 <1969yuri1969@gmail.com> Date: Tue, 26 Sep 2017 20:18:39 +0200 Subject: [PATCH] NIFI-4423 - Add a confirmation of a Counter reset action. This closes #2178 --- .../main/webapp/WEB-INF/pages/counters.jsp | 1 + .../js/nf/counters/nf-counters-table.js | 44 ++++++++++++------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/counters.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/counters.jsp index 1d5f1ab339..769b809890 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/counters.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/counters.jsp @@ -58,6 +58,7 @@ + diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/counters/nf-counters-table.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/counters/nf-counters-table.js index b76b4dfefa..ab549bb227 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/counters/nf-counters-table.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/counters/nf-counters-table.js @@ -22,23 +22,26 @@ define(['jquery', 'Slick', 'nf.Common', - 'nf.ErrorHandler'], - function ($, Slick, nfCommon, nfErrorHandler) { - return (nf.CountersTable = factory($, Slick, nfCommon, nfErrorHandler)); + 'nf.ErrorHandler', + 'nf.Dialog'], + function ($, Slick, nfCommon, nfErrorHandler, nfDialog) { + return (nf.CountersTable = factory($, Slick, nfCommon, nfErrorHandler, nfDialog)); }); } else if (typeof exports === 'object' && typeof module === 'object') { module.exports = (nf.CountersTable = factory(require('jquery'), require('Slick'), require('nf.Common'), - require('nf.ErrorHandler'))); + require('nf.ErrorHandler'), + require('nf.Dialog'))); } else { nf.CountersTable = factory(root.$, root.Slick, 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'; /** @@ -133,18 +136,25 @@ * @argument {object} item The counter item */ var resetCounter = function (item) { - $.ajax({ - type: 'PUT', - url: config.urls.counters + '/' + encodeURIComponent(item.id), - dataType: 'json' - }).done(function (response) { - var counter = response.counter; + // prompt reset confirmation + nfDialog.showYesNoDialog({ + headerText: 'Reset Counter', + dialogContent: 'Reset counter \'' + nfCommon.escapeHtml(item.name) + '\' to default value?', + yesHandler: function () { + $.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 - var countersGrid = $('#counters-table').data('gridInstance'); - var countersData = countersGrid.getData(); - countersData.updateItem(counter.id, counter); - }).fail(nfErrorHandler.handleAjaxError); + // get the table and update the row accordingly + var countersGrid = $('#counters-table').data('gridInstance'); + var countersData = countersGrid.getData(); + countersData.updateItem(counter.id, counter); + }).fail(nfErrorHandler.handleAjaxError); + } + }); }; return {