Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset progress meter when same job is run again. #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Perform batch jobs inside of WordPress.",
"type": "wordpress-plugin",
"license": "GPL v3",
"version": "1.2.0",
"version": "1.2.1",
"authors": [
{
"name": "Philip Downer",
Expand Down
2 changes: 1 addition & 1 deletion js/dist/ramsey-batch.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 19 additions & 13 deletions js/src/ramsey-batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,6 @@ jQuery(document).ready($ => {
function startBatch(trigger) {
return new Promise((resolve, reject) => {
currentButton = $(trigger);
ramseyBatch.batchName = currentButton.data("batchName");
const batchNameClean = ramseyBatch.batchName.replace(
new RegExp("\\\\", "g"),
""
);

progressMeter = $(
`tr.progressMeter[data-batch-name="${batchNameClean}"]`
);
progressBar = progressMeter.find(".meter");
statusMsg = progressMeter.find(".status");

progressMeter.show();
currentButton.prop("disabled", true);

Expand All @@ -196,7 +184,11 @@ jQuery(document).ready($ => {
return reject(response.data.reason);
}

console.log("Starting batch!", batchNameClean, response.data.items);
console.log(
"Starting batch!",
ramseyBatch.batchName,
response.data.items
);

updateItems(response.data.items);

Expand All @@ -220,6 +212,20 @@ jQuery(document).ready($ => {

// Handle the initial trigger
$(buttons).on("click", e => {
ramseyBatch.batchName = $(e.target).data("batchName");
let cleanBatchName = ramseyBatch.batchName.replace(
new RegExp("\\\\", "g"),
""
);

progressMeter = $(`tr.progressMeter[data-batch-name="${cleanBatchName}"]`);
progressBar = progressMeter.find(".meter");
progressBar.css({
width: `0%`
});
statusMsg = progressMeter.find(".status");
statusMsg.text("");

startBatch(e.target).then(processBatchItems, response => {
throw new Error(response);
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wp-ramsey-batch",
"version": "1.2.0",
"version": "1.2.1",
"description": "Provides a framework to handle large data processing jobs by breaking it into smaller chunks and running each job individually via AJAX requests. ",
"main": "wp-ramsey-batch.php",
"repository": "https://github.com/RamseyInHouse/wp-ramsey-batch",
Expand Down
2 changes: 1 addition & 1 deletion wp-ramsey-batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Ramsey Batch
Plugin URI: https://www.daveramsey.com
Description: Provides a framework and UI for running batch jobs inside of WordPress.
Version: 1.2.0
Version: 1.2.1
Author: Philip Downer<[email protected]>, Alex MacArthur<[email protected]>
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Expand Down