feat: M4 in-admin manual generation on chained-cron checkpoints + IA/perf pass (v0.21.0) (#166)
Final Phase 2 admin milestone. Board "New Article" runs through the M3 chained-cron checkpoint state machine (one stage/idea per tick, queue persisted before generate, lock released on every exit path) so generation survives Hostinger background-kill; retires the SSH-only do_action workaround (WP-CLI routes through the same entry). IA/perf: settings-backed board/ideas pagination + db 1.4.0 indexes. Folds guard P2s (--self-test + window doc). QA: APPROVE-WITH-P2-NOTES @f2a00d4+ delta APPROVE @0c8071f. Deferred (tracked): class-admin-page.php 353-line split + pagination Settings-UI fields. Agent-Session: phase2-admin-m4-20260614
This commit is contained in:
53
assets/js/board-generate.js
Normal file
53
assets/js/board-generate.js
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* PRAutoBlogger Board -- "New Article" generate button handler (v0.21.0, M4).
|
||||
*
|
||||
* Loaded on the board page alongside board.js. Depends on the prabBoard config
|
||||
* object and jQuery, both already present when board.js loads.
|
||||
*
|
||||
* @see assets/js/board.js -- Board poller (loads first).
|
||||
* @see includes/admin/class-board-page.php -- Enqueues + localizes prabBoard.
|
||||
*/
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
var cfg = window.prabBoard || {};
|
||||
|
||||
/**
|
||||
* Handle click on the "New Article" button. Fires the existing generate_now
|
||||
* AJAX action and triggers board backoff reset so the new card appears fast.
|
||||
*/
|
||||
function onBoardGenerateNow() {
|
||||
var $btn = $( '#prab-board-generate-now' );
|
||||
if ( ! $btn.length || $btn.prop( 'disabled' ) ) {
|
||||
return;
|
||||
}
|
||||
$btn.prop( 'disabled', true ).text( cfg.strings && cfg.strings.generatingBtn || 'Generating\u2026' );
|
||||
var $status = $( '#prab-board-gen-status' );
|
||||
$status.text( '' ).hide();
|
||||
|
||||
$.ajax( {
|
||||
url: cfg.ajaxUrl,
|
||||
method: 'POST',
|
||||
data: { action: 'prautoblogger_generate_now', nonce: cfg.generateNonce },
|
||||
success: function ( response ) {
|
||||
if ( response && response.success ) {
|
||||
$status.text( cfg.strings && cfg.strings.genStarted || 'Generation started.' ).show();
|
||||
// Notify board poller to reset backoff (run is now active).
|
||||
$( document ).trigger( 'prab:generation-started' );
|
||||
} else {
|
||||
$status.text( cfg.strings && cfg.strings.genError || 'Generation failed.' ).show();
|
||||
$btn.prop( 'disabled', false ).text( cfg.strings && cfg.strings.newArticle || 'New Article' );
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$status.text( cfg.strings && cfg.strings.genError || 'Generation failed.' ).show();
|
||||
$btn.prop( 'disabled', false ).text( cfg.strings && cfg.strings.newArticle || 'New Article' );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
$( function () {
|
||||
$( document ).on( 'click', '#prab-board-generate-now', onBoardGenerateNow );
|
||||
} );
|
||||
|
||||
}( jQuery ) );
|
||||
Reference in New Issue
Block a user