diff --git a/config.json b/config.json index 6bbed36..01d59cb 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,8 @@ { - "version": "1.3.1", + "version": "2.0.0", "name": "WebhooksPlugin.name", "description": "WebhooksPlugin.description", + "icon": "bi bi-plug-fill", "authors": [ { "name": "Phillips Data, Inc.", diff --git a/views/default/admin_main.pdt b/views/default/admin_main.pdt index 5b2fa3c..416045b 100644 --- a/views/default/admin_main.pdt +++ b/views/default/admin_main.pdt @@ -1,106 +1,118 @@ - + + $this->_('AdminMain.index.category_outgoing', true) . ' (' . (isset($type_count['outgoing']) ? $this->Html->safe($type_count['outgoing']) : null) . ')', 'current' => ((isset($type) ? $type : null) == 'outgoing' ? true : false), 'attributes' => ['href' => $this->base_uri . 'plugin/webhooks/admin_main/index/outgoing/', 'class' => 'ajax']], - ['name' => $this->_('AdminMain.index.category_incoming', true) . ' (' . (isset($type_count['incoming']) ? $this->Html->safe($type_count['incoming']) : null) . ')', 'current' => ((isset($type) ? $type : null) == 'incoming' ? true : false), 'attributes' => ['href' => $this->base_uri . 'plugin/webhooks/admin_main/index/incoming/', 'class' => 'ajax']] - ]; - $link_buttons = [ - [ - 'icon' => 'fas fa-plus', - 'name' => '', - 'attributes' => [ - 'title' => $this->_('AdminMain.index.categorylink_addwebhook', true), - 'href' => $this->Html->safe($this->base_uri . 'plugin/webhooks/admin_main/add/') - ] - ], - [ - 'icon' => 'fas fa-list', - 'name' => $this->_('AdminMain.index.categorylink_viewlogs', true), - 'attributes' => [ - 'title' => $this->_('AdminMain.index.categorylink_viewlogs', true), - 'href' => $this->Html->safe($this->base_uri . 'plugin/webhooks/admin_main/logs/') - ] - ] - ]; +$links = [ + [ + 'name' => $this->_('AdminMain.index.category_outgoing', true) . '' . ($type_count['outgoing'] ?? 0) . '', + 'current' => ($type ?? null) == 'outgoing', + 'attributes' => ['href' => $this->base_uri . 'plugin/webhooks/admin_main/index/outgoing/', 'class' => 'ajax'] + ], + [ + 'name' => $this->_('AdminMain.index.category_incoming', true) . '' . ($type_count['incoming'] ?? 0) . '', + 'current' => ($type ?? null) == 'incoming', + 'attributes' => ['href' => $this->base_uri . 'plugin/webhooks/admin_main/index/incoming/', 'class' => 'ajax'] + ] +]; +$link_buttons = [ + [ + 'icon' => 'bi bi-plus-lg me-1', + 'name' => $this->_('AdminMain.index.categorylink_addwebhook', true), + 'attributes' => [ + 'title' => $this->_('AdminMain.index.categorylink_addwebhook', true), + 'href' => $this->Html->safe($this->base_uri . 'plugin/webhooks/admin_main/add/') + ] + ], + [ + 'icon' => 'bi bi-list me-1', + 'name' => $this->_('AdminMain.index.categorylink_viewlogs', true), + 'attributes' => [ + 'title' => $this->_('AdminMain.index.categorylink_viewlogs', true), + 'href' => $this->Html->safe($this->base_uri . 'plugin/webhooks/admin_main/logs/') + ] + ] +]; - $this->Widget->clear(); - $this->Widget->setLinks($links); - $this->Widget->setLinkButtons($link_buttons); - $this->Widget->create($this->_('AdminMain.index.boxtitle_webhooks', true), ['id' => 'admin_main'], ($render_section ?? null)); +$this->Widget->clear(); +$this->Widget->setLinks($links); +$this->Widget->setLinkButtons($link_buttons); +$this->Widget->setBodyWrapper(false); +$this->Widget->create($this->_('AdminMain.index.boxtitle_webhooks', true), ['id' => 'admin_main'], ($render_section ?? null)); - if (($webhooks ?? false) && ($num_tickets = count($webhooks)) > 0) { +if (($webhooks ?? false) && ($num_tickets = count($webhooks)) > 0) { +?> +
| _('AdminMain.index.heading_callback');?> | +_('AdminMain.index.heading_event');?> | +_('AdminMain.index.heading_method');?> | +_('AdminMain.index.heading_options');?> | +
|---|
| _('AdminMain.index.heading_callback');?> | -_('AdminMain.index.heading_event');?> | -_('AdminMain.index.heading_method');?> | -_('AdminMain.index.heading_options');?> | -
| - Html->safe('http://' . Configure::get('Blesta.company')->hostname . $this->base_uri . 'plugin/webhooks/trigger/index/' . ($webhook->callback ?? '')); - } else { - echo $this->Html->safe($webhook->callback ?? ''); - } - ?> - | -
- events ?? [] as $event) {
- ?>
- Html->safe($event);?>
-
- |
- Html->safe(strtoupper($webhook->method ?? ''));?> | -- _('AdminMain.index.option_logs');?>, - _('AdminMain.index.option_edit');?>, + |
| + Html->safe('http://' . Configure::get('Blesta.company')->hostname . $this->base_uri . 'plugin/webhooks/trigger/index/' . ($webhook->callback ?? '')); + } else { + echo $this->Html->safe($webhook->callback ?? ''); + } + ?> + | ++ events ?? [] as $event) { + ?> + Html->safe($event);?> + + | +Html->safe(strtoupper($webhook->method ?? ''));?> | +
+
+ _('AdminMain.index.option_logs');?>
+ _('AdminMain.index.option_edit');?>
Form->create($this->base_uri . 'plugin/webhooks/admin_main/delete/');
+ $this->Form->create($this->base_uri . 'plugin/webhooks/admin_main/delete/', ['class' => 'd-inline']);
$this->Form->fieldHidden('id', ($webhook->id ?? null));
?>
- _('AdminMain.index.option_delete');?>
+
Form->end();
?>
- |
-
_('AdminMain.index.no_results');?>
+_('AdminMain.add.text_fields_map');?>
+ + + +| _('AdminMain.add.heading_field');?> | +_('AdminMain.add.heading_parameter');?> | +_('AdminMain.add.heading_options');?> | +||||||
|---|---|---|---|---|---|---|---|---|
|
$name) {
+ $this->Form->fieldText('fields[' . $i . '][field]', ($field['field'] ?? null), ['class' => 'form-control']);
?>
-
-
+
- Form->fieldCheckbox('events[]', $event, in_array($event, $vars->events ?? []), ['id' => 'events_' . $event]);
- $this->Form->label($name, 'events_' . $event, ['class' => 'inline']);
- ?>
-
- |
+
Form->fieldText('fields[' . $i . '][parameter]', ($field['parameter'] ?? null), ['class' => 'form-control']);
?>
-
-
-
-
- _('AdminMain.add.heading_fields_map');?>-
-
-
-
- Form->end();?>
-
+ _('AdminMain.add.text_fields_map');?> - - - -
|
_('AdminMain.edit.text_fields_map');?>
+ + + +| _('AdminMain.edit.heading_field');?> | +_('AdminMain.edit.heading_parameter');?> | +_('AdminMain.edit.heading_options');?> | +||||||
|---|---|---|---|---|---|---|---|---|
|
$name) {
+ $this->Form->fieldText('fields[' . $i . '][field]', ($field['field'] ?? null), ['class' => 'form-control']);
?>
-
-
+
- Form->fieldCheckbox('events[]', $event, in_array($event, $vars->events ?? []), ['id' => 'events_' . $event]);
- $this->Form->label($name, 'events_' . $event, ['class' => 'inline']);
- ?>
-
- |
+
Form->fieldText('fields[' . $i . '][parameter]', ($field['parameter'] ?? null), ['class' => 'form-control']);
?>
-
-
-
-
- _('AdminMain.edit.heading_fields_map');?>-
-
-
-
- Form->end();?>
-
+ _('AdminMain.edit.text_fields_map');?> - - - -
|
| _('AdminMain.logs.heading_webhook');?> | -_('AdminMain.logs.heading_event');?> | -_('AdminMain.logs.heading_response');?> | -_('AdminMain.logs.heading_method');?> | -_('AdminMain.logs.heading_http_response');?> | -_('AdminMain.logs.heading_date_triggered');?> | -_('AdminMain.logs.heading_date_last_retry');?> | -_('AdminMain.logs.heading_options');?> | -
| _('AdminMain.logs.heading_webhook');?> | +_('AdminMain.logs.heading_event');?> | +_('AdminMain.logs.heading_response');?> | +_('AdminMain.logs.heading_method');?> | +_('AdminMain.logs.heading_http_response');?> | +_('AdminMain.logs.heading_date_triggered');?> | +_('AdminMain.logs.heading_date_last_retry');?> | +_('AdminMain.logs.heading_options');?> | +
|---|---|---|---|---|---|---|---|
| + Html->safe($log->callback ?? '');?> + | +Html->safe($log->event ?? '');?> | +Form->fieldTextarea('response', ($log->response ?? ''), ['class' => 'form-control', 'rows' => 4]); ?> - | |||||
| - Html->safe($log->callback ?? '');?> - | -Html->safe($log->event ?? '');?> | -- Form->fieldTextarea('response', ($log->response ?? ''), ['class' => 'w-100', 'rows' => 4]); - ?> - | -Html->safe(strtoupper($log->method ?? ''));?> | -Html->safe($log->http_response ?? '');?> | -Date->cast($log->date_triggered, 'date_time');?> | -date_last_retry) ? $this->Date->cast($log->date_last_retry, 'date_time') : '';?> | -- Form->create($this->base_uri . 'plugin/webhooks/admin_main/retry/'); - $this->Form->fieldHidden('id', ($log->id ?? null)); - ?> - _('AdminMain.logs.option_resend');?> - Form->end(); - ?> - | -Html->safe(strtoupper($log->method ?? ''));?> | +Html->safe($log->http_response ?? '');?> | +Date->cast($log->date_triggered, 'date_time');?> | +date_last_retry) ? $this->Date->cast($log->date_last_retry, 'date_time') : '';?> | +Form->create($this->base_uri . 'plugin/webhooks/admin_main/retry/', ['class' => 'd-inline']); + $this->Form->fieldHidden('id', ($log->id ?? null)); ?> - |
_('AdminMain.logs.no_results');?>
+| _('AdminMain.view.heading_callback');?> | -_('AdminMain.view.heading_type');?> | -_('AdminMain.view.heading_method');?> | -
| - Html->safe($webhook->callback ?? null);?> - | -- Html->safe($types[$webhook->type] ?? null);?> - | -- Html->safe($methods[$webhook->method] ?? null);?> - | -
| _('AdminMain.view.heading_event');?> | -
| - Html->safe($event ?? null);?> - | -
| _('AdminMain.view.heading_callback');?> | +_('AdminMain.view.heading_type');?> | +_('AdminMain.view.heading_method');?> | +
|---|---|---|
| Html->safe($webhook->callback ?? null);?> | +Html->safe($types[$webhook->type] ?? null);?> | +Html->safe($methods[$webhook->method] ?? null);?> | +
| _('AdminMain.view.heading_field');?> | -_('AdminMain.view.heading_parameter');?> | +
| _('AdminMain.view.heading_event');?> | |
|---|---|
| - Html->safe($field['field'] ?? '');?> - | -- Html->safe($field['parameter'] ?? '');?> - | +
| Html->safe($event ?? null);?> |
| _('AdminMain.view.heading_event');?> | -_('AdminMain.view.heading_response');?> | -_('AdminMain.view.heading_http_response');?> | -_('AdminMain.view.heading_date_triggered');?> | -_('AdminMain.view.heading_date_last_retry');?> | -_('AdminMain.view.heading_options');?> | + + + fields ?? [])) { + ?> +
| _('AdminMain.view.heading_field');?> | +_('AdminMain.view.heading_parameter');?> | ||||
|---|---|---|---|---|---|
| - Html->safe($log->event ?? '');?> - | -- Form->fieldTextarea('response', ($log->response ?? ''), ['class' => 'w-100', 'rows' => 4]); - ?> - | -- Html->safe($log->http_response ?? '');?> - | -- Date->cast($log->date_triggered, 'date_time');?> - | -- date_last_retry) ? $this->Date->cast($log->date_last_retry, 'date_time') : '';?> - | -- Form->create($this->base_uri . 'plugin/webhooks/admin_main/retry/'); - $this->Form->fieldHidden('id', ($log->id ?? null)); - ?> - _('AdminMain.view.option_retry');?> - Form->end(); - ?> - | +
| Html->safe($field['field'] ?? '');?> | +Html->safe($field['parameter'] ?? '');?> |
| _('AdminMain.view.heading_event');?> | +_('AdminMain.view.heading_response');?> | +_('AdminMain.view.heading_http_response');?> | +_('AdminMain.view.heading_date_triggered');?> | +_('AdminMain.view.heading_date_last_retry');?> | +_('AdminMain.view.heading_options');?> | +
|---|---|---|---|---|---|
| Html->safe($log->event ?? '');?> | ++ Form->fieldTextarea('response', ($log->response ?? ''), ['class' => 'form-control', 'rows' => 4]); + ?> + | +Html->safe($log->http_response ?? '');?> | +Date->cast($log->date_triggered, 'date_time');?> | +date_last_retry) ? $this->Date->cast($log->date_last_retry, 'date_time') : '';?> | ++ Form->create($this->base_uri . 'plugin/webhooks/admin_main/retry/', ['class' => 'd-inline']); + $this->Form->fieldHidden('id', ($log->id ?? null)); + ?> + + Form->end(); + ?> + | +