Skip to content

Commit

Permalink
Document email target
Browse files Browse the repository at this point in the history
  • Loading branch information
sjelfull committed Mar 5, 2019
1 parent d8a9ba8 commit 84940db
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,24 @@ To generate a list of users that has logged in the last 30 days:
{% endif %}
```

### Report Target Example

Report targets makes it possible to send the result of a report to target channels.

For now, email is supported, with Slack and more coming soon.

Example email body:
```twig
Report generated for {{ target.name }}<br>
This report includes:<br><br>
{% for report in reports %}
- {{ report.name }}<br>
{% endfor %}
```

Note that you have access to both the reports attached to the target and the target itself.

## Reports Roadmap

Some things to do, and ideas for potential features:
Expand Down
4 changes: 3 additions & 1 deletion src/models/ReportTarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public function init()
$this->targetClass = Reports::$plugin->getTarget()->getDefaultTargetType();
}

$this->settings = Json::decodeIfJson($this->settings);
if (\is_string($this->settings)) {
$this->settings = Json::decodeIfJson($this->settings);
}
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/targets/EmailTarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function send(\superbig\reports\models\ReportTarget $target, array $repor
$message->setSubject($this->subject);

$variables = [
'target' => $target,
'reports' => $reports,
];
$body = $view->renderString($this->body, $variables);
Expand Down Expand Up @@ -108,8 +109,6 @@ public function rules()
$rules = parent::rules();
$rules = array_merge($rules, [
[['subject'], 'required'],
//[['apiKey'], 'default', 'value' => ''],
//[['apiKey'], 'string'],
]);

return $rules;
Expand Down
3 changes: 1 addition & 2 deletions src/templates/_targets/edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
{% if currentUser.can('reports-create') %}
<div class="buttons right">
{% if target.id is not null %}
{# <a href="{{ url("reports/export/#{target.id}") }}" class="btn">{{ "Export"|t('reports') }}</a>#}
<a href="{{ url("reports/run/#{target.id}") }}" class="btn">{{ "Run"|t('reports') }}</a>
<a href="{{ url("reports/targets/run/#{target.id}") }}" class="btn">{{ "Run"|t('reports') }}</a>
{% endif %}
<input type="submit" class="btn submit" value="{{ 'Save'|t }}">
</div>
Expand Down

0 comments on commit 84940db

Please sign in to comment.