AdminUI: Scheduled Jobs page
authorAidan Saunders <aidan.saunders@squiffle.uk>
Thu, 13 Apr 2023 16:09:28 +0000 (17:09 +0100)
committerAidan Saunders <aidan.saunders@squiffle.uk>
Wed, 24 May 2023 12:45:42 +0000 (13:45 +0100)
ext/civicrm_admin_ui/ang/afsearchManageScheduledJobs.aff.html [new file with mode: 0644]
ext/civicrm_admin_ui/ang/afsearchManageScheduledJobs.aff.json [new file with mode: 0644]
ext/civicrm_admin_ui/managed/SavedSearch_Manage_Scheduled_Jobs.mgd.php [new file with mode: 0644]

diff --git a/ext/civicrm_admin_ui/ang/afsearchManageScheduledJobs.aff.html b/ext/civicrm_admin_ui/ang/afsearchManageScheduledJobs.aff.html
new file mode 100644 (file)
index 0000000..15cfe16
--- /dev/null
@@ -0,0 +1,21 @@
+<div class="af-markup">
+  <div class="help">{{:: ts('You can configure scheduled jobs (cron tasks) for your CiviCRM installation. For most sites, your system administrator should set up one or more "cron" tasks to run the enabled jobs. However, you can also run all scheduled jobs manually using the button below, or specific jobs from this screen using the "Execute Now" buttons.')}} <a class="crm-doc-link no-popup" href="https://docs.civicrm.org/sysadmin/en/latest/setup/jobs" target="_blank" title="Opens documentation in a new window.">(Job parameters and command line syntax documentation...)</a></div>
+</div>
+<div af-fieldset="">
+  <div class="af-container af-layout-inline">
+    <af-field name="name" />
+    <af-field name="description" defn="{input_type: 'Text', input_attrs: {}}" />
+    <af-field name="is_active" defn="{input_type: 'Radio', input_attrs: {}}" />
+  </div>
+  <div class="btn-group pull-right">
+    <a class="btn btn-primary" ng-href="{{:: crmUrl('civicrm/admin/runjobs', {reset: 1}) }}">
+      <i class="crm-i fa-forward"/>
+      {{:: ts('Execute All Scheduled Jobs Now') }}
+    </a>
+    <a class="btn btn-primary" ng-href="{{:: crmUrl('civicrm/admin/joblog', {reset: 1}) }}">
+      <i class="crm-i fa-list-alt"/>
+      {{:: ts('View Log (all jobs)') }}
+    </a>
+  </div>
+  <crm-search-display-table search-name="Scheduled_Jobs" display-name="Scheduled_Jobs_Table_2"></crm-search-display-table>
+</div>
diff --git a/ext/civicrm_admin_ui/ang/afsearchManageScheduledJobs.aff.json b/ext/civicrm_admin_ui/ang/afsearchManageScheduledJobs.aff.json
new file mode 100644 (file)
index 0000000..4aebf05
--- /dev/null
@@ -0,0 +1,7 @@
+{
+    "type": "search",
+    "title": "Manage Scheduled Jobs",
+    "icon": "fa-list-alt",
+    "server_route": "civicrm/admin/job",
+    "permission": "access CiviCRM"
+}
diff --git a/ext/civicrm_admin_ui/managed/SavedSearch_Manage_Scheduled_Jobs.mgd.php b/ext/civicrm_admin_ui/managed/SavedSearch_Manage_Scheduled_Jobs.mgd.php
new file mode 100644 (file)
index 0000000..6f759bd
--- /dev/null
@@ -0,0 +1,231 @@
+<?php
+use CRM_CivicrmAdminUi_ExtensionUtil as E;
+
+return [
+  [
+    'name' => 'SavedSearch_Scheduled_Jobs',
+    'entity' => 'SavedSearch',
+    'cleanup' => 'always',
+    'update' => 'unmodified',
+    'params' => [
+      'version' => 4,
+      'values' => [
+        'name' => 'Scheduled_Jobs',
+        'label' => E::ts('Scheduled Jobs'),
+        'form_values' => NULL,
+        'mapping_id' => NULL,
+        'search_custom_id' => NULL,
+        'api_entity' => 'Job',
+        'api_params' => [
+          'version' => 4,
+          'select' => [
+            'id',
+            'name',
+            'description',
+            'run_frequency:label',
+            'parameters',
+            'last_run',
+            'is_active',
+            'api_entity',
+            'api_action',
+          ],
+          'orderBy' => [],
+          'where' => [],
+          'groupBy' => [],
+          'join' => [],
+          'having' => [],
+        ],
+        'expires_date' => NULL,
+        'description' => NULL,
+      ],
+      'match' => [
+        'name',
+      ],
+    ],
+  ],
+  [
+    'name' => 'SavedSearch_Scheduled_Jobs_SearchDisplay_Scheduled_Jobs_Table_2',
+    'entity' => 'SearchDisplay',
+    'cleanup' => 'always',
+    'update' => 'unmodified',
+    'params' => [
+      'version' => 4,
+      'values' => [
+        'name' => 'Scheduled_Jobs_Table_2',
+        'label' => E::ts('Scheduled Jobs Table 2'),
+        'saved_search_id.name' => 'Scheduled_Jobs',
+        'type' => 'table',
+        'settings' => [
+          'description' => NULL,
+          'sort' => [
+            [
+              'is_active',
+              'DESC',
+            ],
+            [
+              'name',
+              'ASC',
+            ],
+          ],
+          'limit' => 50,
+          'pager' => [],
+          'placeholder' => 5,
+          'columns' => [
+            [
+              'type' => 'html',
+              'key' => 'name',
+              'dataType' => 'String',
+              'label' => E::ts('Job'),
+              'sortable' => TRUE,
+              'cssRules' => [
+                [
+                  'disabled',
+                  'is_active',
+                  '=',
+                  FALSE,
+                ],
+              ],
+              'rewrite' => '<b>[name]</b><br>[description]',
+            ],
+            [
+              'type' => 'field',
+              'key' => 'run_frequency:label',
+              'dataType' => 'String',
+              'label' => E::ts('Frequency'),
+              'sortable' => TRUE,
+              'cssRules' => [
+                [
+                  'disabled',
+                  'is_active',
+                  '=',
+                  FALSE,
+                ],
+              ],
+            ],
+            [
+              'type' => 'field',
+              'key' => 'last_run',
+              'dataType' => 'Timestamp',
+              'label' => E::ts('Last Run'),
+              'sortable' => TRUE,
+              'cssRules' => [
+                [
+                  'disabled',
+                  'is_active',
+                  '=',
+                  FALSE,
+                ],
+              ],
+            ],
+            [
+              'type' => 'field',
+              'key' => 'is_active',
+              'dataType' => 'Boolean',
+              'label' => E::ts('Enabled'),
+              'sortable' => TRUE,
+              'editable' => TRUE,
+              'cssRules' => [
+                [
+                  'disabled',
+                  'is_active',
+                  '=',
+                  FALSE,
+                ],
+              ],
+            ],
+            [
+              'type' => 'field',
+              'key' => 'api_entity',
+              'dataType' => 'String',
+              'label' => E::ts('API'),
+              'sortable' => TRUE,
+              'cssRules' => [
+                [
+                  'disabled',
+                  'is_active',
+                  '=',
+                  FALSE,
+                ],
+              ],
+              'rewrite' => '[api_entity].[api_action]',
+            ],
+            [
+              'text' => E::ts(''),
+              'style' => 'default',
+              'size' => 'btn-sm',
+              'icon' => 'fa-bars',
+              'links' => [
+                [
+                  'entity' => '',
+                  'action' => '',
+                  'join' => '',
+                  'target' => '',
+                  'icon' => 'fa-file-o',
+                  'text' => E::ts('View joblog'),
+                  'style' => 'default',
+                  'path' => 'civicrm/admin/joblog?jid=[id]&reset=1',
+                  'condition' => [],
+                ],
+                [
+                  'entity' => '',
+                  'action' => '',
+                  'join' => '',
+                  'target' => '',
+                  'icon' => 'fa-play',
+                  'text' => E::ts('Execute now'),
+                  'style' => 'default',
+                  'path' => 'civicrm/admin/job/edit?action=view&id=[id]&reset=1',
+                  'condition' => [],
+                ],
+                [
+                  'entity' => 'Job',
+                  'action' => 'update',
+                  'join' => '',
+                  'target' => 'crm-popup',
+                  'icon' => 'fa-pencil',
+                  'text' => E::ts('Edit Job'),
+                  'style' => 'default',
+                  'path' => '',
+                  'condition' => [],
+                ],
+                [
+                  'entity' => '',
+                  'action' => '',
+                  'join' => '',
+                  'target' => '',
+                  'icon' => 'fa-clone',
+                  'text' => E::ts('Clone'),
+                  'style' => 'secondary',
+                  'path' => 'civicrm/admin/job/edit?action=copy&id=[id]',
+                  'condition' => [],
+                ],
+                [
+                  'entity' => 'Job',
+                  'action' => 'delete',
+                  'join' => '',
+                  'target' => 'crm-popup',
+                  'icon' => 'fa-trash',
+                  'text' => E::ts('Delete Job'),
+                  'style' => 'danger',
+                  'path' => '',
+                  'condition' => [],
+                ],
+              ],
+              'type' => 'menu',
+              'alignment' => 'text-right',
+            ],
+          ],
+          'actions' => FALSE,
+          'classes' => [
+            'table',
+            'table-striped',
+          ],
+        ],
+        'acl_bypass' => FALSE,
+      ],
+      'match' => [
+        'name',
+      ],
+    ],
+  ],
+];