[TikiWiki-commits] [Git][tikiwiki/tiki][master] [NEW] [UI/UX] Add multiple remove option for Schedulers and Jobs
"Elifeleti Mukisa Dan \(@Danelif\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <6922de7ae2a6b_2a17f18841e3@gitlab-sidekiq-low-urgency-cpu-bound-v2-5d57c968f-pjg42.mail> |
Elifeleti Mukisa Dan pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
11106746 by Elifeleti Mukisa Dan at 2025-11-23T10:06:27+00:00
[NEW] [UI/UX] Add multiple remove option for Schedulers and Jobs
---
* [NEW] UX Add Scheduler and Jobs removal
See merge request tikiwiki/tiki!9066
- - - - -
5 changed files:
- lib/core/Services/Scheduler/Controller.php
- + templates/scheduler/remove_jobs.tpl
- + templates/scheduler/remove_schedulers.tpl
- templates/tiki-admin_schedulers.tpl
- tiki-admin_schedulers.php
Changes:
=====================================
lib/core/Services/Scheduler/Controller.php
=====================================
@@ -213,4 +213,142 @@ class Services_Scheduler_Controller
$access = TikiLib::lib('access');
$access->redirect('tiki-admin_schedulers.php#contenttabs_admin_schedulers-3');
}
+
+ /**
+ * Remove schedulers
+ *
+ * @param $input JitFilter
+ * @return array
+ * @throws Services_Exception_Denied
+ */
+ public function actionRemoveSchedulers($input)
+ {
+ Services_Exception_Denied::checkGlobal('admin_users');
+
+ $util = new Services_Utilities();
+
+ // First pass - show confirmation modal
+ if ($util->notConfirmPost()) {
+ $util->setVars($input, [], 'checked');
+
+ if ($util->itemsCount > 0) {
+ // Get scheduler names for the confirmation dialog
+ $schedulerItems = [];
+ foreach ($util->items as $schedulerId) {
+ $scheduler = $this->lib->get_scheduler((int)$schedulerId);
+ if ($scheduler) {
+ $schedulerItems[$schedulerId] = $scheduler['name'];
+ }
+ }
+
+ return [
+ 'title' => $util->itemsCount === 1 ? tra('Remove Scheduler') : tra('Remove Schedulers'),
+ 'items' => $schedulerItems,
+ ];
+ } else {
+ Services_Utilities::modalException(tra('No schedulers were selected. Please select one or more schedulers.'));
+ }
+
+ // Second pass - perform the deletion
+ } elseif ($util->checkCsrf()) {
+ $util->setVars($input, [], 'items');
+
+ $deletedCount = 0;
+ $deletedSchedulers = [];
+
+ foreach ($util->items as $schedulerId) {
+ $scheduler = $this->lib->get_scheduler((int)$schedulerId);
+ if ($scheduler) {
+ $this->lib->remove_scheduler((int)$schedulerId);
+ $deletedSchedulers[] = $scheduler['name'];
+ $deletedCount++;
+ }
+ }
+
+ if ($deletedCount > 0) {
+ if ($deletedCount === 1) {
+ $feedback = sprintf(tra('Scheduler %s was deleted.'), $deletedSchedulers[0]);
+ } else {
+ $feedback = sprintf(tra('%d schedulers were deleted.'), $deletedCount);
+ }
+ Feedback::success($feedback);
+ }
+
+ return Services_Utilities::refresh();
+ }
+ }
+
+ /**
+ * Remove jobs
+ *
+ * @param $input JitFilter
+ * @return array
+ * @throws Services_Exception_Denied
+ */
+ public function actionRemoveJobs($input)
+ {
+ Services_Exception_Denied::checkGlobal('admin_users');
+
+ $util = new Services_Utilities();
+
+ // First pass - show confirmation modal
+ if ($util->notConfirmPost()) {
+ $util->setVars($input, [], 'checked_jobs');
+
+ if ($util->itemsCount > 0) {
+ // Get job names for the confirmation dialog
+ $jobItems = [];
+ foreach ($util->items as $jobId) {
+ $job = $this->lib->get_scheduler((int)$jobId);
+ if ($job) {
+ $jobItems[$jobId] = $job['name'];
+ }
+ }
+
+ return [
+ 'title' => $util->itemsCount === 1 ? tra('Remove Job') : tra('Remove Jobs'),
+ 'items' => $jobItems,
+ ];
+ } else {
+ Services_Utilities::modalException(tra('No jobs were selected. Please select one or more jobs.'));
+ }
+
+ // Second pass - perform the deletion
+ } elseif ($util->checkCsrf()) {
+ $util->setVars($input, [], 'items');
+
+ $deletedCount = 0;
+ $deletedJobs = [];
+
+ foreach ($util->items as $jobId) {
+ $job = $this->lib->get_scheduler((int)$jobId);
+ if ($job) {
+ $this->lib->remove_scheduler((int)$jobId);
+ $deletedJobs[] = $job['name'];
+ $deletedCount++;
+ }
+ }
+
+ if ($deletedCount > 0) {
+ if ($deletedCount === 1) {
+ $feedback = sprintf(tra('Job %s was deleted.'), $deletedJobs[0]);
+ } else {
+ $feedback = sprintf(tra('%d jobs were deleted.'), $deletedCount);
+ }
+ Feedback::success($feedback);
+ }
+
+ return Services_Utilities::refresh();
+ }
+ }
+
+ /**
+ * Handle no action selected for bulk operations
+ *
+ * @throws Services_Exception
+ */
+ public function actionNoAction()
+ {
+ Services_Utilities::modalException(tra('No action was selected. Please select an action before clicking OK.'));
+ }
}
=====================================
templates/scheduler/remove_jobs.tpl
=====================================
@@ -0,0 +1,33 @@
+{extends $global_extend_layout|default:'layout_view.tpl'}
+
+{block name="title"}
+ {title}{$title|escape}{/title}
+{/block}
+
+{block name="content"}
+{if $items|count > 0}
+ <form class="simple" method="post" action="{service controller=scheduler action=remove_jobs}">
+ {if $items|count == 1}
+ <p>{tr}Do you really want to remove the following job?{/tr}</p>
+ {else}
+ <p>{tr _0=$items|count}Do you really want to remove the following %0 jobs?{/tr}</p>
+ {/if}
+
+ <ul class="list-group mb-3">
+ {foreach from=$items key=id item=name}
+ <li class="list-group-item">{$name|escape}</li>
+ {/foreach}
+ </ul>
+
+ <div class="submit">
+ {foreach from=$items key=id item=name}
+ <input type="hidden" name="items[]" value="{$id|escape}">
+ {/foreach}
+ <input type="submit" class="btn btn-primary" value="{tr}Remove{/tr}">
+ {ticket mode='confirm'}
+ </div>
+ </form>
+{else}
+ <a href="tiki-admin_schedulers.php">{tr}Back to schedulers{/tr}</a>
+{/if}
+{/block}
=====================================
templates/scheduler/remove_schedulers.tpl
=====================================
@@ -0,0 +1,34 @@
+{extends $global_extend_layout|default:'layout_view.tpl'}
+
+{block name="title"}
+ {title}{$title|escape}{/title}
+{/block}
+
+{block name="content"}
+{if $items|count > 0}
+ <form class="simple" method="post" action="{service controller=scheduler action=remove_schedulers}">
+ {if $items|count == 1}
+ <p>{tr}Do you really want to remove the following scheduler?{/tr}</p>
+ {else}
+ <p>{tr _0=$items|count}Do you really want to remove the following %0 schedulers?{/tr}</p>
+ {/if}
+
+ <ul class="list-group mb-3">
+ {foreach from=$items key=id item=name}
+ <li class="list-group-item">{$name|escape}</li>
+ {/foreach}
+ </ul>
+
+ <div class="submit">
+ {foreach from=$items key=id item=name}
+ <input type="hidden" name="items[]" value="{$id|escape}">
+ {/foreach}
+ <input type="submit" class="btn btn-primary" value="{tr}Remove{/tr}">
+ {ticket mode='confirm'}
+ </div>
+ </form>
+{else}
+ <p>{tr}No schedulers selected.{/tr}</p>
+ <a href="tiki-admin_schedulers.php" class="btn btn-primary">{tr}Back to schedulers{/tr}</a>
+{/if}
+{/block}
=====================================
templates/tiki-admin_schedulers.tpl
=====================================
@@ -87,15 +87,19 @@
</div>
<div id="admin_schedulers-div">
- <div class="{if $js}table-responsive {/if}ts-wrapperdiv">
- {* Use css menus as fallback for item dropdown action menu if javascript is not being used *}
- <table id="admin_schedulers" class="table normal table-striped table-hover" data-count="{$schedulers|count}">
- <thead>
- <tr>
-
- <th>
- {tr}Name{/tr}
- </th>
+ <form name="schedulerform" id="schedulerform" method="post">
+ {ticket}
+ <div class="{if $js}table-responsive {/if}ts-wrapperdiv">
+ {* Use css menus as fallback for item dropdown action menu if javascript is not being used *}
+ <table id="admin_schedulers" class="table normal table-striped table-hover" data-count="{$schedulers|count}">
+ <thead>
+ <tr>
+ <th>
+ {select_all checkbox_names='checked[]'}
+ </th>
+ <th>
+ {tr}Name{/tr}
+ </th>
<th>
{tr}Description{/tr}
</th>
@@ -129,6 +133,9 @@
{section name=scheduler loop=$schedulers}
{$scheduler_name = $schedulers[scheduler].name|escape}
<tr>
+ <td class="checkbox-cell">
+ <input type="checkbox" class="form-check-input" aria-label="{tr}Select{/tr}" name="checked[]" value="{$schedulers[scheduler].id|escape}">
+ </td>
<td class="scheduler_name">
<a class="link tips"
href="tiki-admin_schedulers.php?scheduler={$schedulers[scheduler].id}{if $prefs.feature_tabs ne 'y'}#2{/if}"
@@ -219,6 +226,29 @@
</tbody>
</table>
</div>
+
+ {if $schedulers|count > 0}
+ <div class="input-group col-sm-8">
+ <select class="form-select" name="action">
+ <option value="no_action" selected disabled>
+ {tr}Select action to perform with checked{/tr}...
+ </option>
+ <option value="remove_schedulers">
+ {tr}Remove schedulers...{/tr}
+ </option>
+ </select>
+ <button
+ type="submit"
+ form="schedulerform"
+ formaction="{bootstrap_modal controller=scheduler action=remove_schedulers}"
+ class="btn btn-primary"
+ id="bulk-action-submit"
+ >
+ {tr}OK{/tr}
+ </button>
+ </div>
+ {/if}
+ </form>
</div>
{/tab}
{/if}
@@ -418,11 +448,16 @@
{remarksbox type="note" title="{tr}Information{/tr}"}
{tr}This page lists all scheduled background jobs along with their processing status. You can re-run a job or see a log of the job executions. Note that Tiki Scheduler must be executed periodically by a cron job in order to execute the background jobs. If you see a job in Active status below for too long interval, then your cron job is most probably not running. {/tr}
{/remarksbox}
- <div class="{if $js}table-responsive {/if}ts-wrapperdiv">
- {* Use css menus as fallback for item dropdown action menu if javascript is not being used *}
- <table id="admin_jobs" class="table normal table-striped table-hover" data-count="{$jobs|count}">
- <thead>
- <tr>
+ <form name="jobsform" id="jobsform" method="post">
+ {ticket}
+ <div class="{if $js}table-responsive {/if}ts-wrapperdiv">
+ {* Use css menus as fallback for item dropdown action menu if javascript is not being used *}
+ <table id="admin_jobs" class="table normal table-striped table-hover" data-count="{$jobs|count}">
+ <thead>
+ <tr>
+ <th>
+ {select_all checkbox_names='checked_jobs[]'}
+ </th>
<th>
{tr}Name{/tr}
@@ -459,6 +494,9 @@
{section name=job loop=$jobs}
{$job = $jobs[job]}
<tr>
+ <td class="checkbox-cell">
+ <input type="checkbox" class="form-check-input" aria-label="{tr}Select{/tr}" name="checked_jobs[]" value="{$job.id|escape}">
+ </td>
<td class="scheduler_name">
<a class="link tips"
href="tiki-admin_schedulers.php?scheduler={$job.id}{if $prefs.feature_tabs ne 'y'}#2{/if}"
@@ -524,6 +562,29 @@
</tbody>
</table>
</div>
+
+ {if $jobs|count > 0}
+ <div class="input-group col-sm-8">
+ <select class="form-select" name="job_action">
+ <option value="no_action" selected disabled>
+ {tr}Select action to perform with checked{/tr}...
+ </option>
+ <option value="remove_jobs">
+ {tr}Remove jobs...{/tr}
+ </option>
+ </select>
+ <button
+ type="submit"
+ form="jobsform"
+ formaction="{bootstrap_modal controller=scheduler action=remove_jobs}"
+ class="btn btn-primary"
+ id="bulk-job-action-submit"
+ >
+ {tr}OK{/tr}
+ </button>
+ </div>
+ {/if}
+ </form>
</div>
{/tab}
{/if}
@@ -634,4 +695,44 @@
$('#notificationUsersCollapse').on('hide.bs.collapse', function() {
$(this).prev().find('.fa-chevron-up').removeClass('fa-chevron-up').addClass('fa-chevron-down');
});
+
+ // Handle bulk action submission
+ $('#bulk-action-submit').on('click', function(e) {
+ var selectedAction = $('select[name="action"]').val();
+ var checkedBoxes = $('input[name="checked[]"]:checked');
+
+ if (!selectedAction || selectedAction === 'no_action') {
+ e.preventDefault();
+ alert('{tr}Please select an action first.{/tr}');
+ return false;
+ }
+
+ if (checkedBoxes.length === 0) {
+ e.preventDefault();
+ alert('{tr}Please select at least one scheduler.{/tr}');
+ return false;
+ }
+
+ // Validation passed - let form submit
+ });
+
+ // Handle bulk job action submission
+ $('#bulk-job-action-submit').on('click', function(e) {
+ var selectedAction = $('select[name="job_action"]').val();
+ var checkedBoxes = $('input[name="checked_jobs[]"]:checked');
+
+ if (!selectedAction || selectedAction === 'no_action') {
+ e.preventDefault();
+ alert('{tr}Please select an action first.{/tr}');
+ return false;
+ }
+
+ if (checkedBoxes.length === 0) {
+ e.preventDefault();
+ alert('{tr}Please select at least one job.{/tr}');
+ return false;
+ }
+
+ // Validation passed - let form submit
+ });
{/jq}
=====================================
tiki-admin_schedulers.php
=====================================
@@ -33,6 +33,8 @@ $inputConfiguration = [
'run_time' => 'string', //get
'status' => 'string', //get
're_run' => 'string', //get
+ 'action' => 'alpha', //post
+ 'checked' => 'array', //post
],
],
];
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/11106746a780bff092cc354e6e238d9ff9fd7f1d
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/11106746a780bff092cc354e6e238d9ff9fd7f1d
You're receiving this email because of your account on gitlab.com.
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs