mirror of
https://github.com/cachethq/cachet.git
synced 2026-03-05 12:37:02 +00:00
Compare commits
306 Commits
v2.3.0-RC3
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5d92f5a3d | ||
|
|
247c1565a4 | ||
|
|
8f5afff4a2 | ||
|
|
b045028c7b | ||
|
|
16189da222 | ||
|
|
7596966e6c | ||
|
|
dcea947973 | ||
|
|
d8ea3c59e3 | ||
|
|
a2f8f4540e | ||
|
|
4031c42958 | ||
|
|
8348f48692 | ||
|
|
6c22c52e3a | ||
|
|
faf91470aa | ||
|
|
58039634bd | ||
|
|
ecfa9b1f01 | ||
|
|
915ea0d0bd | ||
|
|
380048dd53 | ||
|
|
ac57936b62 | ||
|
|
962b008fb2 | ||
|
|
5b1dd8ad00 | ||
|
|
c1d8203602 | ||
|
|
dc73f62803 | ||
|
|
a019d82010 | ||
|
|
0f029702d4 | ||
|
|
fdbde63143 | ||
|
|
9a9ec833eb | ||
|
|
136cce2d6d | ||
|
|
880a2d9cd9 | ||
|
|
71b5d446ba | ||
|
|
aea18a51c2 | ||
|
|
84bedf5c60 | ||
|
|
309a3f96ef | ||
|
|
6246f20506 | ||
|
|
9dcc5d6896 | ||
|
|
acd1ac496d | ||
|
|
8c273b8579 | ||
|
|
b30a774bed | ||
|
|
3ea1428c23 | ||
|
|
d6ab5efd14 | ||
|
|
235e3281b0 | ||
|
|
a94be2efca | ||
|
|
04b96e7dec | ||
|
|
e15af44449 | ||
|
|
ef9f7d23a0 | ||
|
|
ef694b027a | ||
|
|
f53e466500 | ||
|
|
1e24138d7a | ||
|
|
9120dba237 | ||
|
|
7f261a218a | ||
|
|
5b5db06ce3 | ||
|
|
b6635d30ee | ||
|
|
5ae23b64d2 | ||
|
|
0d90f0459b | ||
|
|
f8505a866d | ||
|
|
27235abab2 | ||
|
|
f70bc7a42f | ||
|
|
6cf622ae21 | ||
|
|
bcbbee22d9 | ||
|
|
9750191bff | ||
|
|
52c4901a78 | ||
|
|
587555c2d4 | ||
|
|
b4c7fb2ab0 | ||
|
|
e61d24f685 | ||
|
|
88e85d2dfb | ||
|
|
5b72f2febc | ||
|
|
dd1a14a438 | ||
|
|
387818dbb2 | ||
|
|
5d70d244ce | ||
|
|
ddc846d959 | ||
|
|
6fb6641499 | ||
|
|
d5eb087eca | ||
|
|
fd25edb2f0 | ||
|
|
7583fedaec | ||
|
|
eecd78496c | ||
|
|
4703aeadb2 | ||
|
|
5879a2cb1a | ||
|
|
48dc39122f | ||
|
|
3aacfb7849 | ||
|
|
ef304950bb | ||
|
|
2101b829bb | ||
|
|
ad8f098ec1 | ||
|
|
df5b9b89e6 | ||
|
|
2551a1a038 | ||
|
|
3874b533be | ||
|
|
85c0e94408 | ||
|
|
1793f5588a | ||
|
|
46ff13c7fb | ||
|
|
da8c8fae74 | ||
|
|
ff9eb123c6 | ||
|
|
895d1ea1b6 | ||
|
|
503252c3a2 | ||
|
|
ec0f0768f0 | ||
|
|
68cc6eb93c | ||
|
|
fdfebc18fb | ||
|
|
0cd3ea0e92 | ||
|
|
47a5569f02 | ||
|
|
ca4a72c518 | ||
|
|
6e45b5ae88 | ||
|
|
0f10522e9c | ||
|
|
3913ab65ac | ||
|
|
2048e0899c | ||
|
|
83e1013771 | ||
|
|
99dbc2cd6c | ||
|
|
7d4bab478f | ||
|
|
2f2ed53b58 | ||
|
|
7e1ead91ed | ||
|
|
28578474b9 | ||
|
|
18d7af2b35 | ||
|
|
e3cfb47d66 | ||
|
|
d4e332bf55 | ||
|
|
13f0f67a7b | ||
|
|
716d357738 | ||
|
|
cee336fd7c | ||
|
|
b3497820f9 | ||
|
|
67152806d7 | ||
|
|
5298ad241a | ||
|
|
709cac9332 | ||
|
|
e17196d4c9 | ||
|
|
e2da8ee1fa | ||
|
|
b6c22c1029 | ||
|
|
5c54830b0f | ||
|
|
80be140c1f | ||
|
|
4f9af8bca0 | ||
|
|
af3b7836ff | ||
|
|
cc4a960ea6 | ||
|
|
467d29ca11 | ||
|
|
ac1355771c | ||
|
|
c41adc1019 | ||
|
|
5b74b2d625 | ||
|
|
d7835f68ed | ||
|
|
a1f1a2b969 | ||
|
|
77394995e4 | ||
|
|
9953557497 | ||
|
|
4dc175b2be | ||
|
|
4a2fe00c89 | ||
|
|
db55283b85 | ||
|
|
5c6440e890 | ||
|
|
6b299b0a90 | ||
|
|
9b5d4aa7c4 | ||
|
|
1fdda03199 | ||
|
|
7c846d06ff | ||
|
|
e34e4381d4 | ||
|
|
b255f71958 | ||
|
|
9560b2a0dc | ||
|
|
1a6c22a8a9 | ||
|
|
f8491ceead | ||
|
|
823fe6e9e2 | ||
|
|
b7e9c07a05 | ||
|
|
a9d83e1337 | ||
|
|
86cfcb501a | ||
|
|
8f68b2a347 | ||
|
|
690290449e | ||
|
|
cb5badefcc | ||
|
|
1423a9bbd0 | ||
|
|
39d302175c | ||
|
|
fffb4d964c | ||
|
|
7ba12960dd | ||
|
|
440f45ed4a | ||
|
|
549eaa3382 | ||
|
|
5305f71c2b | ||
|
|
bf749c54ee | ||
|
|
f1e2c1ef68 | ||
|
|
4ab9807cbe | ||
|
|
9f9c9a10c5 | ||
|
|
a5ed3c40a9 | ||
|
|
1fe4789760 | ||
|
|
9c1e94c550 | ||
|
|
958c9eadc7 | ||
|
|
ca3f516457 | ||
|
|
e326381604 | ||
|
|
c25437871a | ||
|
|
04215fc37a | ||
|
|
8d90357f40 | ||
|
|
46add8d841 | ||
|
|
1e695d51b5 | ||
|
|
65f864d743 | ||
|
|
bc51aac622 | ||
|
|
3c39ccd5df | ||
|
|
cd4a96983e | ||
|
|
c0d3602a91 | ||
|
|
08175b89e9 | ||
|
|
ece696d7db | ||
|
|
e7052f5aff | ||
|
|
ff97327803 | ||
|
|
8dda99c499 | ||
|
|
947aa27e40 | ||
|
|
1425c15ee8 | ||
|
|
cdbd2db8e9 | ||
|
|
ef02d77439 | ||
|
|
662fff9edf | ||
|
|
e96088fc0f | ||
|
|
7472657812 | ||
|
|
88ce241785 | ||
|
|
6becaf2acd | ||
|
|
c5c21cd8db | ||
|
|
b64dd1e87e | ||
|
|
a0b9856d61 | ||
|
|
d6552982a3 | ||
|
|
42eac92737 | ||
|
|
a2cee97f33 | ||
|
|
0541a662ff | ||
|
|
b960146512 | ||
|
|
6c9b7a6fde | ||
|
|
ff9a2802f8 | ||
|
|
06ca0ffb21 | ||
|
|
80e5655be9 | ||
|
|
0b7ca97e53 | ||
|
|
812160839f | ||
|
|
27e46d77e6 | ||
|
|
a10d12e589 | ||
|
|
ac7652f3aa | ||
|
|
c63fedefe9 | ||
|
|
3b6fb9f64e | ||
|
|
acfb32bf1d | ||
|
|
c17ef87651 | ||
|
|
846f77b054 | ||
|
|
d5c29a6c4b | ||
|
|
31861f020f | ||
|
|
abf83361e8 | ||
|
|
3e8801d8d4 | ||
|
|
bbc9eb1f81 | ||
|
|
c8b602d349 | ||
|
|
715eb02844 | ||
|
|
c8f7e92124 | ||
|
|
eae44ee6cb | ||
|
|
3fde593a86 | ||
|
|
1527ec8ddc | ||
|
|
f9946928c1 | ||
|
|
5176fca8f0 | ||
|
|
4852f5558a | ||
|
|
c90584bda5 | ||
|
|
aea3b40c54 | ||
|
|
d394e108bd | ||
|
|
0df9f01ffe | ||
|
|
9745bb7543 | ||
|
|
cab030237b | ||
|
|
439ac9fe44 | ||
|
|
7eef9467aa | ||
|
|
15387b1da8 | ||
|
|
c33d297fa4 | ||
|
|
c8af103498 | ||
|
|
0e2610eee0 | ||
|
|
e201a6ed06 | ||
|
|
1e4d616b88 | ||
|
|
2de01671e9 | ||
|
|
dd26a3af34 | ||
|
|
4b41395144 | ||
|
|
2dacc71e8a | ||
|
|
4869c7ee21 | ||
|
|
9293dcf0df | ||
|
|
150057ef50 | ||
|
|
c81f18c3bc | ||
|
|
42aa437ac2 | ||
|
|
6a780314fb | ||
|
|
ffae9cf3d4 | ||
|
|
091f59c241 | ||
|
|
288fa6180b | ||
|
|
7ecb546a86 | ||
|
|
f7c8dd6254 | ||
|
|
2adc9d032a | ||
|
|
f53075ec4f | ||
|
|
0190813012 | ||
|
|
b0c75a2319 | ||
|
|
73d7303b6e | ||
|
|
2d8f2cbd63 | ||
|
|
cb2ce8f67f | ||
|
|
d6d103cf15 | ||
|
|
20d187d642 | ||
|
|
91bd9288f5 | ||
|
|
24df32e9a9 | ||
|
|
fb75ad6902 | ||
|
|
aa87274378 | ||
|
|
696a1126c7 | ||
|
|
7c4787a1a7 | ||
|
|
74d24b6809 | ||
|
|
22226c666f | ||
|
|
b3244a4639 | ||
|
|
6cf3c4c109 | ||
|
|
8f47bd4a4f | ||
|
|
c03f01ca44 | ||
|
|
7f36783582 | ||
|
|
ab0ed775e1 | ||
|
|
5a600c0e17 | ||
|
|
601a863fc4 | ||
|
|
366eab9cae | ||
|
|
021c2890d2 | ||
|
|
ed851c232a | ||
|
|
2eff325a23 | ||
|
|
920a3ef6a9 | ||
|
|
15816c56bb | ||
|
|
e5e4b04151 | ||
|
|
283d343dd6 | ||
|
|
aa85c8708e | ||
|
|
f93506fed9 | ||
|
|
b92f9d30fc | ||
|
|
3673e57c6f | ||
|
|
9fb6ae4fc0 | ||
|
|
583601644c | ||
|
|
5ea816ce2b | ||
|
|
541d410e41 | ||
|
|
03348b8ff2 | ||
|
|
2e8743eb6b | ||
|
|
66ff1cca65 | ||
|
|
64ff9b7d40 | ||
|
|
446aed6b9a | ||
|
|
0281c44933 |
19
.github/ISSUE_TEMPLATE
vendored
19
.github/ISSUE_TEMPLATE
vendored
@@ -1,16 +1,8 @@
|
||||
Before submitting your issue, please make sure that you've checked all of the checkboxes below.
|
||||
Before submitting your issue, please make sure that you've checked the checkboxes below.
|
||||
|
||||
- [ ] You're running the [latest release](https://github.com/CachetHQ/Cachet/releases/latest) version of Cachet.
|
||||
- [ ] Ensure that you're running at least PHP 5.5.9, you can check this by running `php -v`
|
||||
- [ ] You've ran `rm -rf bootstrap/cache/*` from the root of your Cachet installation.
|
||||
|
||||
To help us better understand your issue, please answer the following — cheers!
|
||||
|
||||
### Your setup
|
||||
|
||||
- *What version of Cachet?*
|
||||
- *What database driver? MySQL? Postgres? SQLite?*
|
||||
- *What version of PHP?*
|
||||
- [ ] I am running the [latest release](https://github.com/CachetHQ/Cachet/releases/latest) version of Cachet.
|
||||
- [ ] I am running at least PHP 5.6.4. *You can check this by running `php -v`.*
|
||||
- [ ] I have ran `rm -rf bootstrap/cache/*`.
|
||||
|
||||
### Expected behaviour
|
||||
|
||||
@@ -23,3 +15,6 @@ To help us better understand your issue, please answer the following — cheers!
|
||||
### Steps to reproduce
|
||||
|
||||
*If your issue requires any specific steps to reproduce, please outline them here.*
|
||||
|
||||
1. First step
|
||||
2. Second step
|
||||
|
||||
13
.travis.yml
13
.travis.yml
@@ -1,21 +1,12 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.5.9
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- hhvm
|
||||
|
||||
sudo: false
|
||||
|
||||
install:
|
||||
- travis_retry composer install --no-interaction --no-scripts --prefer-source
|
||||
install: travis_retry composer install --no-interaction --no-scripts --prefer-source
|
||||
|
||||
script:
|
||||
- if [ "$TRAVIS_PHP_VERSION" != "5.6" ] || [ "$TRAVIS_PULL_REQUEST" != false ]; then vendor/bin/phpunit; fi
|
||||
- if [ "$TRAVIS_PHP_VERSION" == "5.6" ] && [ "$TRAVIS_PULL_REQUEST" == false ]; then vendor/bin/phpunit --coverage-clover build/logs/clover.xml; fi
|
||||
|
||||
after_script:
|
||||
- if [ "$TRAVIS_PHP_VERSION" == "5.6" ] && [ "$TRAVIS_PULL_REQUEST" == false ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
|
||||
- if [ "$TRAVIS_PHP_VERSION" == "5.6" ] && [ "$TRAVIS_PULL_REQUEST" == false ]; then php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml; fi
|
||||
script: vendor/bin/phpunit
|
||||
|
||||
30
README.md
30
README.md
@@ -2,18 +2,17 @@
|
||||
|
||||
[](https://styleci.io/repos/26730195/)
|
||||
[](https://travis-ci.org/CachetHQ/Cachet)
|
||||
[](https://scrutinizer-ci.com/g/CachetHQ/Cachet)
|
||||
[](LICENSE)
|
||||
[](http://translate.cachethq.io/project/cachet)
|
||||
[](http://translate.cachethq.io/project/cachet)
|
||||
[](https://packagist.org/packages/cachethq/cachet)
|
||||
|
||||

|
||||
|
||||
Cachet is a beautiful and powerful open source status page system, a free replacement to services such as StatusPage.io, Status.io and others.
|
||||
|
||||
## Supporting Cachet
|
||||
## Show your support
|
||||
|
||||
Cachet is a BSD-3-licensed open source project. If you'd like to support future development, check out the [Cachet Patreon campaign](https://patreon.com/jbrooksuk).
|
||||
Cachet is a BSD-3-licensed open source project. If you'd like to support future development, check out the [Patreon campaign](https://patreon.com/jbrooksuk).
|
||||
|
||||
## Features
|
||||
|
||||
@@ -30,11 +29,11 @@ Cachet is a BSD-3-licensed open source project. If you'd like to support future
|
||||
|
||||
## Usage in production
|
||||
|
||||
The `master` branch of this repository is a development branch and **should not** be used in production. Instead, please check out the latest tag release.
|
||||
Use of `master` in a production environment is not recommended as it may change at any time.
|
||||
|
||||
## Requirements
|
||||
|
||||
- PHP 5.5.9+ or newer
|
||||
- PHP 5.6.4+ or newer
|
||||
- Apache or Nginx server
|
||||
- [Composer](https://getcomposer.org)
|
||||
|
||||
@@ -44,9 +43,9 @@ We're always looking for contributions that improve Cachet. It's easy to get sta
|
||||
|
||||
### Contributing as a non-developer/non-designer
|
||||
|
||||
If you're one of the more linguistically talented people in the world who can speak and write more than just English, we're always looking for new [translations](#translations).
|
||||
We're always looking for new [translations](#translations).
|
||||
|
||||
Of course bug reports, feature requests and [documentation](https://docs.cachethq.io) are always being sought after.
|
||||
Of course bug reports, feature requests and [documentation](https://docs.cachethq.io) are always appreciated.
|
||||
|
||||
### Contributing as a designer
|
||||
|
||||
@@ -57,22 +56,22 @@ You'll need to install Node.js, Bower and Gulp.
|
||||
To get started you can do the following:
|
||||
|
||||
1. Install Node.js and our dev dependencies.
|
||||
2. Modify the SCSS files in `./resources/assets/sass/`
|
||||
2. Make your changes to the SCSS files in `./resources/assets/sass/`
|
||||
3. Run `gulp`
|
||||
|
||||
If you're making a lot of changes, you'll find that running `gulp watch` will really help you out!
|
||||
If you're making a lot of changes, you'll find that running `gulp watch` will make life easier for you!
|
||||
|
||||
### Contributing as a developer
|
||||
|
||||
Built using [Laravel](https://laravel.com), Cachet is very easy to jump into. Have a look around you'll find it surprisingly easy!
|
||||
Built using [Laravel](https://laravel.com).
|
||||
|
||||
These extra dependencies are required to develop Cachet:
|
||||
We use these extra dependencies to develop Cachet:
|
||||
|
||||
- Node.js
|
||||
- Gulp
|
||||
- Git
|
||||
|
||||
Once cloned to your local machine, you'll need some demo data! Simply run `php artisan cachet:seed` to get the demo installation on the go.
|
||||
Once cloned to your local machine, you'll need some demo data! Run `php artisan cachet:seed` to get the demo installation on the go.
|
||||
|
||||
## Installation, Upgrades and Documentation
|
||||
|
||||
@@ -80,7 +79,6 @@ You can now find our documentation at [https://docs.cachethq.io](https://docs.ca
|
||||
|
||||
- [Installing Cachet](https://docs.cachethq.io/docs/installing-cachet)
|
||||
- [Getting started with Docker](https://docs.cachethq.io/docs/get-started-with-docker)
|
||||
- [Getting started with Vagrant](https://docs.cachethq.io/docs/get-started-with-vagrant)
|
||||
|
||||
### Demo Account
|
||||
|
||||
@@ -93,7 +91,7 @@ The demo is reset every half hour.
|
||||
|
||||
### Release Notes
|
||||
|
||||
All releases are listed on the [Releases page](https://github.com/CachetHQ/Cachet/releases) of the [Cachet GitHub repository](https://github.com/CachetHQ/Cachet). On the Releases page, you can also find the release notes for each release.
|
||||
We list releases on the [Releases page](https://github.com/CachetHQ/Cachet/releases) of the [Cachet GitHub repository](https://github.com/CachetHQ/Cachet). On the Releases page, you can also find the release notes for each release.
|
||||
|
||||
## Translations
|
||||
|
||||
@@ -101,7 +99,7 @@ A special thank you to our [translators](https://crowdin.com/project/cachet/acti
|
||||
|
||||
## Security Vulnerabilities
|
||||
|
||||
If you discover a security vulnerability within Cachet, please send an e-mail to us at support@alt-three.com. All security vulnerabilities will be promptly addressed.
|
||||
If you discover a security vulnerability within Cachet, please send an e-mail to us at support@alt-three.com. We handle all security vulnerabilities on a case-by-case basis.
|
||||
|
||||
## Installations
|
||||
|
||||
|
||||
61
app/Bus/Commands/ComponentTag/AddComponentTagCommand.php
Normal file
61
app/Bus/Commands/ComponentTag/AddComponentTagCommand.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Commands\ComponentTag;
|
||||
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\Tag;
|
||||
|
||||
/**
|
||||
* This is the add component tag command.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class AddComponentTagCommand
|
||||
{
|
||||
/**
|
||||
* The component to add the tag to.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Component
|
||||
*/
|
||||
public $component;
|
||||
|
||||
/**
|
||||
* The tag to add to the component.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Tag
|
||||
*/
|
||||
public $tag;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $rules = [
|
||||
'component' => 'required',
|
||||
'tag' => 'required',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a add component tag command instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Component $component
|
||||
* @param \CachetHQ\Cachet\Models\Tag $tag
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Component $component, Tag $tag)
|
||||
{
|
||||
$this->component = $component;
|
||||
$this->tag = $tag;
|
||||
}
|
||||
}
|
||||
61
app/Bus/Commands/ComponentTag/DeleteComponentTagCommand.php
Normal file
61
app/Bus/Commands/ComponentTag/DeleteComponentTagCommand.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Commands\ComponentTag;
|
||||
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\Tag;
|
||||
|
||||
/**
|
||||
* This is the delete component tag command.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class DeleteComponentTagCommand
|
||||
{
|
||||
/**
|
||||
* The component to delete the tag from.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Component
|
||||
*/
|
||||
public $component;
|
||||
|
||||
/**
|
||||
* The tag to delete.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Tag
|
||||
*/
|
||||
public $tag;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $rules = [
|
||||
'component' => 'required',
|
||||
'tag' => 'required',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a delete component tag command instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Component $component
|
||||
* @param \CachetHQ\Cachet\Models\Tag $tag
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Component $component, Tag $tag)
|
||||
{
|
||||
$this->component = $component;
|
||||
$this->tag = $tag;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Commands\IncidentUpdate;
|
||||
|
||||
use CachetHQ\Cachet\Models\IncidentUpdate;
|
||||
|
||||
/**
|
||||
* This is the remove incident update command.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class RemoveIncidentUpdateCommand
|
||||
{
|
||||
/**
|
||||
* The incident update to remove.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\IncidentUpdate
|
||||
*/
|
||||
public $incidentUpdate;
|
||||
|
||||
/**
|
||||
* Create a new remove incident update command instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\IncidentUpdate $incidentUpdate
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(IncidentUpdate $incidentUpdate)
|
||||
{
|
||||
$this->incidentUpdate = $incidentUpdate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Commands\IncidentUpdate;
|
||||
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the report incident update command.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class ReportIncidentUpdateCommand
|
||||
{
|
||||
/**
|
||||
* The incident.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Incident
|
||||
*/
|
||||
public $incident;
|
||||
|
||||
/**
|
||||
* The incident status.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $status;
|
||||
|
||||
/**
|
||||
* The incident message.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $message;
|
||||
|
||||
/**
|
||||
* The user.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $rules = [
|
||||
'incident' => 'required',
|
||||
'status' => 'required|int|min:1|max:4',
|
||||
'message' => 'required|string',
|
||||
'user' => 'required',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new report incident update command instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Incident $incident
|
||||
* @param string $status
|
||||
* @param string $message
|
||||
* @param \CachetHQ\Cachet\Models\User $user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Incident $incident, $status, $message, User $user)
|
||||
{
|
||||
$this->incident = $incident;
|
||||
$this->status = $status;
|
||||
$this->message = $message;
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Commands\IncidentUpdate;
|
||||
|
||||
use CachetHQ\Cachet\Models\IncidentUpdate;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the update incident update command.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class UpdateIncidentUpdateCommand
|
||||
{
|
||||
/**
|
||||
* The incident update.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\IncidentUpdate
|
||||
*/
|
||||
public $update;
|
||||
|
||||
/**
|
||||
* The incident status.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $status;
|
||||
|
||||
/**
|
||||
* The incident message.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $message;
|
||||
|
||||
/**
|
||||
* The user.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $rules = [
|
||||
'update' => 'required',
|
||||
'status' => 'int|min:1|max:4',
|
||||
'message' => 'string',
|
||||
'user' => 'required',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new update incident update command instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\IncidentUpdate $update
|
||||
* @param string $status
|
||||
* @param string $message
|
||||
* @param \CachetHQ\Cachet\Models\User $user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(IncidentUpdate $update, $status, $message, User $user)
|
||||
{
|
||||
$this->update = $update;
|
||||
$this->status = $status;
|
||||
$this->message = $message;
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
@@ -76,6 +76,13 @@ final class AddMetricCommand
|
||||
*/
|
||||
public $threshold;
|
||||
|
||||
/**
|
||||
* The order of which to place the metric in.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $order;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
*
|
||||
@@ -92,6 +99,7 @@ final class AddMetricCommand
|
||||
'places' => 'int|between:0,4',
|
||||
'default_view' => 'int|between:0,3',
|
||||
'threshold' => 'numeric|between:0,10',
|
||||
'order' => 'int',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -106,10 +114,11 @@ final class AddMetricCommand
|
||||
* @param int $places
|
||||
* @param int $default_view
|
||||
* @param int $threshold
|
||||
* @param int $order
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($name, $suffix, $description, $default_value, $calc_type, $display_chart, $places, $default_view, $threshold)
|
||||
public function __construct($name, $suffix, $description, $default_value, $calc_type, $display_chart, $places, $default_view, $threshold, $order = 0)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->suffix = $suffix;
|
||||
@@ -120,5 +129,6 @@ final class AddMetricCommand
|
||||
$this->places = $places;
|
||||
$this->default_view = $default_view;
|
||||
$this->threshold = $threshold;
|
||||
$this->order = $order;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ final class AddMetricPointCommand
|
||||
* @var string[]
|
||||
*/
|
||||
public $rules = [
|
||||
'value' => 'int',
|
||||
'value' => 'numeric',
|
||||
'created_at' => 'string',
|
||||
];
|
||||
|
||||
|
||||
@@ -85,6 +85,13 @@ final class UpdateMetricCommand
|
||||
*/
|
||||
public $threshold;
|
||||
|
||||
/**
|
||||
* The order of which to place the metric in.
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
public $order;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
*
|
||||
@@ -101,6 +108,7 @@ final class UpdateMetricCommand
|
||||
'places' => 'numeric|between:0,4',
|
||||
'default_view' => 'numeric|between:0,4',
|
||||
'threshold' => 'numeric|between:0,10',
|
||||
'order' => 'int',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -116,10 +124,11 @@ final class UpdateMetricCommand
|
||||
* @param int $places
|
||||
* @param int $default_view
|
||||
* @param int $threshold
|
||||
* @param int|null $order
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Metric $metric, $name, $suffix, $description, $default_value, $calc_type, $display_chart, $places, $default_view, $threshold)
|
||||
public function __construct(Metric $metric, $name, $suffix, $description, $default_value, $calc_type, $display_chart, $places, $default_view, $threshold, $order = null)
|
||||
{
|
||||
$this->metric = $metric;
|
||||
$this->name = $name;
|
||||
@@ -131,5 +140,6 @@ final class UpdateMetricCommand
|
||||
$this->places = $places;
|
||||
$this->default_view = $default_view;
|
||||
$this->threshold = $threshold;
|
||||
$this->order = $order;
|
||||
}
|
||||
}
|
||||
|
||||
58
app/Bus/Commands/Tag/CreateTagCommand.php
Normal file
58
app/Bus/Commands/Tag/CreateTagCommand.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Commands\Tag;
|
||||
|
||||
/**
|
||||
* This is the create tag command.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class CreateTagCommand
|
||||
{
|
||||
/**
|
||||
* The name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* The slug.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $slug;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $rules = [
|
||||
'name' => 'required|string',
|
||||
'slug' => 'sometimes|string',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new create tag command instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $slug
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($name, $slug)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->slug = $slug;
|
||||
}
|
||||
}
|
||||
50
app/Bus/Commands/Tag/DeleteTagCommand.php
Normal file
50
app/Bus/Commands/Tag/DeleteTagCommand.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Commands\Tag;
|
||||
|
||||
use CachetHQ\Cachet\Models\Tag;
|
||||
|
||||
/**
|
||||
* This is the delete tag command.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class DeleteTagCommand
|
||||
{
|
||||
/**
|
||||
* The tag.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Tag
|
||||
*/
|
||||
public $tag;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $rules = [
|
||||
'tag' => 'required',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new delete tag command instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Tag $tag
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Tag $tag)
|
||||
{
|
||||
$this->tag = $tag;
|
||||
}
|
||||
}
|
||||
70
app/Bus/Commands/Tag/UpdateTagCommand.php
Normal file
70
app/Bus/Commands/Tag/UpdateTagCommand.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Commands\Tag;
|
||||
|
||||
use CachetHQ\Cachet\Models\Tag;
|
||||
|
||||
/**
|
||||
* This is the update tag command.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class UpdateTagCommand
|
||||
{
|
||||
/**
|
||||
* The tag.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Tag
|
||||
*/
|
||||
public $tag;
|
||||
|
||||
/**
|
||||
* The name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* The slug.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $slug;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $rules = [
|
||||
'tag' => 'required',
|
||||
'name' => 'sometimes|string',
|
||||
'slug' => 'sometimes|string',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new update tag command instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Tag $tag
|
||||
* @param string $name
|
||||
* @param string $slug
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Tag $tag, $name, $slug)
|
||||
{
|
||||
$this->tag = $tag;
|
||||
$this->name = $name;
|
||||
$this->slug = $slug;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,12 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Commands\User;
|
||||
|
||||
final class AddTeamMemberCommand
|
||||
/**
|
||||
* This is the add user command.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class AddUserCommand
|
||||
{
|
||||
/**
|
||||
* The user username.
|
||||
@@ -48,8 +53,9 @@ final class AddTeamMemberCommand
|
||||
*/
|
||||
public $rules = [
|
||||
'name' => 'required|string',
|
||||
'password' => 'string',
|
||||
'level' => 'int',
|
||||
'email' => 'required|email',
|
||||
'password' => 'required|string',
|
||||
'level' => 'int|min:1|max:2',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -11,7 +11,12 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Commands\User;
|
||||
|
||||
final class InviteTeamMemberCommand
|
||||
/**
|
||||
* This is the invite user command.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class InviteUserCommand
|
||||
{
|
||||
/**
|
||||
* The invite emails.
|
||||
@@ -30,7 +35,7 @@ final class InviteTeamMemberCommand
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new invite team member command instance.
|
||||
* Create a new invite user command instance.
|
||||
*
|
||||
* @param string[] $emails
|
||||
*
|
||||
90
app/Bus/Commands/User/UpdateTeamMemberCommand.php
Normal file
90
app/Bus/Commands/User/UpdateTeamMemberCommand.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Commands\User;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the update team member command.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class UpdateTeamMemberCommand
|
||||
{
|
||||
/**
|
||||
* The user to update.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* The user username.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $username;
|
||||
|
||||
/**
|
||||
* The user password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $password;
|
||||
|
||||
/**
|
||||
* The user email.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $email;
|
||||
|
||||
/**
|
||||
* The user level.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $level;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $rules = [
|
||||
'user' => 'required',
|
||||
'name' => 'required|string',
|
||||
'email' => 'required|email',
|
||||
'password' => 'required|string',
|
||||
'level' => 'int|min:1|max:2',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new add team member command instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\User $user
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param string $email
|
||||
* @param int $level
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(User $user, $username, $password, $email, $level)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->username = $username;
|
||||
$this->password = $password;
|
||||
$this->email = $email;
|
||||
$this->level = $level;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Events\IncidentUpdate;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\EventInterface;
|
||||
|
||||
/**
|
||||
* This is the incident update event interface.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
interface IncidentUpdateEventInterface extends EventInterface
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Events\IncidentUpdate;
|
||||
|
||||
use CachetHQ\Cachet\Models\IncidentUpdate;
|
||||
|
||||
/**
|
||||
* This is the incident update was removed event.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class IncidentUpdateWasRemovedEvent implements IncidentUpdateEventInterface
|
||||
{
|
||||
/**
|
||||
* The incident update that has been removed.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\IncidentUpdate
|
||||
*/
|
||||
public $update;
|
||||
|
||||
/**
|
||||
* Create a new incident update was removed event instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\IncidentUpdate $update
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(IncidentUpdate $update)
|
||||
{
|
||||
$this->update = $update;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Events\IncidentUpdate;
|
||||
|
||||
use CachetHQ\Cachet\Models\IncidentUpdate;
|
||||
|
||||
/**
|
||||
* This is the incident update was reported event.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class IncidentUpdateWasReportedEvent implements IncidentUpdateEventInterface
|
||||
{
|
||||
/**
|
||||
* The incident update that has been reported.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\IncidentUpdate
|
||||
*/
|
||||
public $update;
|
||||
|
||||
/**
|
||||
* Create a new incident update was reported event instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\IncidentUpdate $update
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(IncidentUpdate $update)
|
||||
{
|
||||
$this->update = $update;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Events\IncidentUpdate;
|
||||
|
||||
use CachetHQ\Cachet\Models\IncidentUpdate;
|
||||
|
||||
/**
|
||||
* This is the incident update was updated event.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class IncidentUpdateWasUpdatedEvent implements IncidentUpdateEventInterface
|
||||
{
|
||||
/**
|
||||
* The incident update that has been updated.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\IncidentUpdate
|
||||
*/
|
||||
public $update;
|
||||
|
||||
/**
|
||||
* Create a new incident update was updated event instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\IncidentUpdate $update
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(IncidentUpdate $update)
|
||||
{
|
||||
$this->update = $update;
|
||||
}
|
||||
}
|
||||
41
app/Bus/Events/User/UserWasUpdatedEvent.php
Normal file
41
app/Bus/Events/User/UserWasUpdatedEvent.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Events\User;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the user was updated event.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class UserWasUpdatedEvent implements UserEventInterface
|
||||
{
|
||||
/**
|
||||
* The user that has been updated.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new user was updated event instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\User $user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Exceptions\Tag;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* This is the tag does not exist on component exception class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class TagDoesNotExistOnComponentException extends Exception implements TagExceptionInterface
|
||||
{
|
||||
//
|
||||
}
|
||||
24
app/Bus/Exceptions/Tag/TagExceptionInterface.php
Normal file
24
app/Bus/Exceptions/Tag/TagExceptionInterface.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Exceptions\Tag;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Exceptions\ExceptionInterface;
|
||||
|
||||
/**
|
||||
* This is the tag exception interface.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
interface TagExceptionInterface extends ExceptionInterface
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Handlers\Commands\ComponentTag;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Commands\ComponentTag\AddComponentTagCommand;
|
||||
use CachetHQ\Cachet\Models\ComponentTag;
|
||||
|
||||
/**
|
||||
* This is the add component tag command handler.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class AddComponentTagCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the add component tag command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Bus\Commands\ComponentTag\AddComponentTagCommand $command
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\ComponentTag
|
||||
*/
|
||||
public function handle(AddComponentTagCommand $command)
|
||||
{
|
||||
$tag = ComponentTag::create([
|
||||
'component_id' => $command->component->id,
|
||||
'tag_id' => $command->tag->id,
|
||||
]);
|
||||
|
||||
return $tag;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Handlers\Commands\ComponentTag;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Commands\ComponentTag\DeleteComponentTagCommand;
|
||||
use CachetHQ\Cachet\Bus\Exceptions\Tag\TagDoesNotExistOnComponentException;
|
||||
use CachetHQ\Cachet\Models\ComponentTag;
|
||||
|
||||
/**
|
||||
* This is the delete component tag command handler.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class DeleteComponentTagCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the add component tag command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Bus\Commands\ComponentTag\DeleteComponentTagCommand $command
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(DeleteComponentTagCommand $command)
|
||||
{
|
||||
// If the tag does not exist on the component, throw an exception.
|
||||
if (!($componentTag = ComponentTag::tagForComponent($command->tag->id, $command->component->id))) {
|
||||
throw new TagDoesNotExistOnComponentException('The given tag <'.$command->tag->id.'> does not exist on this component <'.$command->componnet->id.'>');
|
||||
}
|
||||
|
||||
$componentTag->delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Handlers\Commands\IncidentUpdate;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\RemoveIncidentUpdateCommand;
|
||||
use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasRemovedEvent;
|
||||
|
||||
/**
|
||||
* This is the remove incident update command handler.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class RemoveIncidentUpdateCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the remove incident update command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Bus\Commands\IncidentUpdate\RemoveIncidentUpdateCommand $command
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(RemoveIncidentUpdateCommand $command)
|
||||
{
|
||||
$update = $command->incidentUpdate;
|
||||
|
||||
event(new IncidentUpdateWasRemovedEvent($update));
|
||||
|
||||
$update->delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Handlers\Commands\IncidentUpdate;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\ReportIncidentUpdateCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand;
|
||||
use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasReportedEvent;
|
||||
use CachetHQ\Cachet\Models\IncidentUpdate;
|
||||
|
||||
/**
|
||||
* This is the report incident update command handler.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class ReportIncidentUpdateCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the report incident command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Bus\Commands\IncidentUpdate\ReportIncidentUpdateCommand $command
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\IncidentUpdate
|
||||
*/
|
||||
public function handle(ReportIncidentUpdateCommand $command)
|
||||
{
|
||||
$data = [
|
||||
'incident_id' => $command->incident->id,
|
||||
'status' => $command->status,
|
||||
'message' => $command->message,
|
||||
'user_id' => $command->user->id,
|
||||
];
|
||||
|
||||
// Create the incident update.
|
||||
$update = IncidentUpdate::create($data);
|
||||
|
||||
// Update the original incident with the new status.
|
||||
dispatch(new UpdateIncidentCommand(
|
||||
$incident,
|
||||
null,
|
||||
$command->status,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
));
|
||||
|
||||
event(new IncidentUpdateWasReportedEvent($update));
|
||||
|
||||
return $update;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Handlers\Commands\IncidentUpdate;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\UpdateIncidentUpdateCommand;
|
||||
use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasUpdatedEvent;
|
||||
|
||||
/**
|
||||
* This is the update incident update command handler.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class UpdateIncidentUpdateCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the update incident update command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Bus\Commands\IncidentUpdate\UpdateIncidentUpdateCommand $command
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\IncidentUpdate
|
||||
*/
|
||||
public function handle(UpdateIncidentUpdateCommand $command)
|
||||
{
|
||||
$command->update->update($this->filter($command));
|
||||
|
||||
event(new IncidentUpdateWasUpdatedEvent($command->update));
|
||||
|
||||
return $command->update;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the command data.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Bus\Commands\IncidentUpdate\UpdateIncidentUpdateCommand $command
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function filter(UpdateIncidentUpdateCommand $command)
|
||||
{
|
||||
$params = [
|
||||
'status' => $command->status,
|
||||
'message' => $command->message,
|
||||
'user_id' => $command->user->id,
|
||||
];
|
||||
|
||||
return array_filter($params, function ($val) {
|
||||
return $val !== null;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@ class AddMetricCommandHandler
|
||||
'places' => $command->places,
|
||||
'default_view' => $command->default_view,
|
||||
'threshold' => $command->threshold,
|
||||
'order' => $command->order,
|
||||
]);
|
||||
|
||||
event(new MetricWasAddedEvent($metric));
|
||||
|
||||
@@ -54,6 +54,7 @@ class UpdateMetricCommandHandler
|
||||
'places' => $command->places,
|
||||
'default_view' => $command->default_view,
|
||||
'threshold' => $command->threshold,
|
||||
'order' => $command->order,
|
||||
];
|
||||
|
||||
return array_filter($params, function ($val) {
|
||||
|
||||
35
app/Bus/Handlers/Commands/Tag/CreateTagCommandHandler.php
Normal file
35
app/Bus/Handlers/Commands/Tag/CreateTagCommandHandler.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Handlers\Commands\Tag;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Commands\Tag\CreateTagCommand;
|
||||
use CachetHQ\Cachet\Models\Tag;
|
||||
|
||||
class CreateTagCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the create tag command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Bus\Commands\Tag\CreateTagCommand $command
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\Tag
|
||||
*/
|
||||
public function handle(CreateTagCommand $command)
|
||||
{
|
||||
$tag = Tag::create([
|
||||
'name' => $command->name,
|
||||
'slug' => $command->slug,
|
||||
]);
|
||||
|
||||
return $tag;
|
||||
}
|
||||
}
|
||||
30
app/Bus/Handlers/Commands/Tag/DeleteTagCommandHandler.php
Normal file
30
app/Bus/Handlers/Commands/Tag/DeleteTagCommandHandler.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Handlers\Commands\Tag;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Commands\Tag\DeleteTagCommand;
|
||||
use CachetHQ\Cachet\Models\Tag;
|
||||
|
||||
class DeleteTagCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the delete tag command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Bus\Commands\Tag\DeleteTagCommand $command
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(DeleteTagCommand $command)
|
||||
{
|
||||
$command->tag->delete();
|
||||
}
|
||||
}
|
||||
51
app/Bus/Handlers/Commands/Tag/UpdateTagCommandHandler.php
Normal file
51
app/Bus/Handlers/Commands/Tag/UpdateTagCommandHandler.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Handlers\Commands\Tag;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Commands\Tag\UpdateTagCommand;
|
||||
use CachetHQ\Cachet\Models\Tag;
|
||||
|
||||
class UpdateTagCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the update tag command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Bus\Commands\Tag\UpdateTagCommand $command
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\Tag
|
||||
*/
|
||||
public function handle(UpdateTagCommand $command)
|
||||
{
|
||||
$command->tag->update($this->filter($command));
|
||||
|
||||
return $command->tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the command data.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Bus\Commands\Tag\UpdateTagCommand $command
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function filter(UpdateTagCommand $command)
|
||||
{
|
||||
$params = [
|
||||
'name' => $command->name,
|
||||
'slug' => $command->slug,
|
||||
];
|
||||
|
||||
return array_filter($params, function ($val) {
|
||||
return $val !== null;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -11,20 +11,25 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Handlers\Commands\User;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Commands\User\AddTeamMemberCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\User\AddUserCommand;
|
||||
use CachetHQ\Cachet\Bus\Events\User\UserWasAddedEvent;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
class AddTeamMemberCommandHandler
|
||||
/**
|
||||
* This is the add user command handler.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class AddUserCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the add team member command.
|
||||
* Handle the add user command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Bus\Commands\User\AddTeamMemberCommand $command
|
||||
* @param \CachetHQ\Cachet\Bus\Commands\User\AddUserCommand $command
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public function handle(AddTeamMemberCommand $command)
|
||||
public function handle(AddUserCommand $command)
|
||||
{
|
||||
$user = User::create([
|
||||
'username' => $command->username,
|
||||
@@ -11,20 +11,25 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Handlers\Commands\User;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Commands\User\InviteTeamMemberCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\User\InviteUserCommand;
|
||||
use CachetHQ\Cachet\Bus\Events\User\UserWasInvitedEvent;
|
||||
use CachetHQ\Cachet\Models\Invite;
|
||||
|
||||
class InviteTeamMemberCommandHandler
|
||||
/**
|
||||
* This is the invite user command handler.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class InviteUserCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the invite team member command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Bus\Commands\User\InviteTeamMemberCommand $command
|
||||
* @param \CachetHQ\Cachet\Bus\Commands\User\InviteUserCommand $command
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(InviteTeamMemberCommand $command)
|
||||
public function handle(InviteUserCommand $command)
|
||||
{
|
||||
foreach ($command->emails as $email) {
|
||||
$invite = Invite::create([
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Handlers\Commands\User;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Commands\User\UpdateTeamMemberCommand;
|
||||
use CachetHQ\Cachet\Bus\Events\User\UserWasUpdatedEvent;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the update team member command handler.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class UpdateTeamMemberCommandHandler
|
||||
{
|
||||
/**
|
||||
* Handle the add team member command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Bus\Commands\User\UpdateTeamMemberCommand $command
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public function handle(UpdateTeamMemberCommand $command)
|
||||
{
|
||||
$user = $command->user;
|
||||
|
||||
$user->update($this->filter($command));
|
||||
|
||||
event(new UserWasUpdatedEvent($user));
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the command data.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Bus\Commands\User\UpdateTeamMemberCommand $command
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function filter(UpdateTeamMemberCommand $command)
|
||||
{
|
||||
$params = [
|
||||
'username' => $command->username,
|
||||
'password' => $command->password,
|
||||
'email' => $command->email,
|
||||
'level' => $command->level,
|
||||
];
|
||||
|
||||
return array_filter($params, function ($val) {
|
||||
return $val !== null;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -46,9 +46,9 @@ class SendSubscriberVerificationEmailHandler
|
||||
public function handle(SubscriberHasSubscribedEvent $event)
|
||||
{
|
||||
$mail = [
|
||||
'email' => $event->subscriber->email,
|
||||
'subject' => 'Confirm your subscription.',
|
||||
'link' => route('subscribe.verify', ['code' => $event->subscriber->verify_code]),
|
||||
'email' => $event->subscriber->email,
|
||||
'subject' => 'Confirm your subscription.',
|
||||
'link' => route('subscribe.verify', ['code' => $event->subscriber->verify_code]),
|
||||
];
|
||||
|
||||
$this->mailer->queue([
|
||||
|
||||
@@ -11,12 +11,41 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Composers;
|
||||
|
||||
use CachetHQ\Cachet\Dates\DateFactory;
|
||||
use GrahamCampbell\Markdown\Facades\Markdown;
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class AppComposer
|
||||
{
|
||||
/**
|
||||
* The date factory instance.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Dates\DateFactory
|
||||
*/
|
||||
protected $dates;
|
||||
|
||||
/**
|
||||
* The illuminate config instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Create a new app composer instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Dates\DateFactory $dates
|
||||
* @param \Illuminate\Contracts\Config\Repository $config
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DateFactory $dates, Repository $config)
|
||||
{
|
||||
$this->dates = $dates;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Index page view composer.
|
||||
*
|
||||
@@ -26,25 +55,28 @@ class AppComposer
|
||||
*/
|
||||
public function compose(View $view)
|
||||
{
|
||||
$view->withAboutApp(Markdown::convertToHtml(Config::get('setting.app_about')));
|
||||
$view->withAppAnalytics(Config::get('setting.app_analytics'));
|
||||
$view->withAppAnalyticsGoSquared(Config::get('setting.app_analytics_gs'));
|
||||
$view->withAppAnalyticsPiwikUrl(Config::get('setting.app_analytics_piwik_url'));
|
||||
$view->withAppAnalyticsPiwikSiteId(Config::get('setting.app_analytics_piwik_site_id'));
|
||||
$view->withAppBanner(Config::get('setting.app_banner'));
|
||||
$view->withAppBannerStyleFullWidth(Config::get('setting.style_fullwidth_header'));
|
||||
$view->withAppBannerType(Config::get('setting.app_banner_type'));
|
||||
$view->withAppDomain(Config::get('setting.app_domain'));
|
||||
$view->withAppGraphs(Config::get('setting.display_graphs'));
|
||||
$view->withAppLocale(Config::get('setting.app_locale'));
|
||||
$view->withAppStylesheet(Config::get('setting.stylesheet'));
|
||||
$view->withAppUrl(Config::get('app.url'));
|
||||
$view->withAppHeader(Config::get('setting.header'));
|
||||
$view->withAppFooter(Config::get('setting.footer'));
|
||||
$view->withAppName(Config::get('setting.app_name'));
|
||||
$view->withShowSupport($support = Config::get('setting.show_support'));
|
||||
$view->withAutomaticLocalization(Config::get('setting.automatic_localization'));
|
||||
$view->withSiteTitle(Config::get('setting.app_name'));
|
||||
$view->withFontSubset(Config::get('langs.'.Config::get('app.locale').'.subset', 'latin'));
|
||||
$view->withAboutApp(Markdown::convertToHtml($this->config->get('setting.app_about')));
|
||||
$view->withAppAnalytics($this->config->get('setting.app_analytics'));
|
||||
$view->withAppAnalyticsGoSquared($this->config->get('setting.app_analytics_gs'));
|
||||
$view->withAppAnalyticsPiwikUrl($this->config->get('setting.app_analytics_piwik_url'));
|
||||
$view->withAppAnalyticsPiwikSiteId($this->config->get('setting.app_analytics_piwik_site_id'));
|
||||
$view->withAppBanner($this->config->get('setting.app_banner'));
|
||||
$view->withAppBannerStyleFullWidth($this->config->get('setting.style_fullwidth_header'));
|
||||
$view->withAppBannerType($this->config->get('setting.app_banner_type'));
|
||||
$view->withAppDomain($this->config->get('setting.app_domain'));
|
||||
$view->withAppGraphs($this->config->get('setting.display_graphs'));
|
||||
$view->withAppLocale($this->config->get('setting.app_locale'));
|
||||
$view->withAppStylesheet($this->config->get('setting.stylesheet'));
|
||||
$view->withAppUrl($this->config->get('app.url'));
|
||||
$view->withAppHeader($this->config->get('setting.header'));
|
||||
$view->withAppFooter($this->config->get('setting.footer'));
|
||||
$view->withAppName($this->config->get('setting.app_name'));
|
||||
$view->withShowSupport($this->config->get('setting.show_support'));
|
||||
$view->withAutomaticLocalization($this->config->get('setting.automatic_localization'));
|
||||
$view->withEnableExternalDependencies($this->config->get('setting.enable_external_dependencies'));
|
||||
$view->withShowTimezone($this->config->get('setting.show_timezone'));
|
||||
$view->withTimezone($this->dates->getTimezone());
|
||||
$view->withSiteTitle($this->config->get('setting.app_name'));
|
||||
$view->withFontSubset($this->config->get('langs.'.$this->config->get('app.locale').'.subset', 'latin'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,30 @@
|
||||
namespace CachetHQ\Cachet\Composers;
|
||||
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class MetricsComposer
|
||||
{
|
||||
/**
|
||||
* The illuminate config instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Create a new metrics composer.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Config\Repository $config
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Repository $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Metrics view composer.
|
||||
*
|
||||
@@ -27,8 +46,8 @@ class MetricsComposer
|
||||
public function compose(View $view)
|
||||
{
|
||||
$metrics = null;
|
||||
if ($displayMetrics = Config::get('setting.display_graphs')) {
|
||||
$metrics = Metric::where('display_chart', 1)->orderBy('id')->get();
|
||||
if ($displayMetrics = $this->config->get('setting.display_graphs')) {
|
||||
$metrics = Metric::displayable()->orderBy('order')->orderBy('id')->get();
|
||||
}
|
||||
|
||||
$view->withDisplayMetrics($displayMetrics)
|
||||
|
||||
@@ -11,13 +11,38 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Composers;
|
||||
|
||||
use CachetHQ\Cachet\Integrations\Core\System;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
/**
|
||||
* This is the status page composer.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class StatusPageComposer
|
||||
{
|
||||
/**
|
||||
* The system instance.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Integrations\Contracts\System
|
||||
*/
|
||||
protected $system;
|
||||
|
||||
/**
|
||||
* Create a new status page composer instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Integrations\Contracts\System $system
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(System $system)
|
||||
{
|
||||
$this->system = $system;
|
||||
}
|
||||
|
||||
/**
|
||||
* Index page view composer.
|
||||
*
|
||||
@@ -27,40 +52,7 @@ class StatusPageComposer
|
||||
*/
|
||||
public function compose(View $view)
|
||||
{
|
||||
$totalComponents = Component::enabled()->count();
|
||||
$majorOutages = Component::enabled()->status(4)->count();
|
||||
$isMajorOutage = $totalComponents ? ($majorOutages / $totalComponents) >= 0.5 : false;
|
||||
|
||||
// Default data
|
||||
$withData = [
|
||||
'system_status' => 'info',
|
||||
'system_message' => trans_choice('cachet.service.bad', $totalComponents),
|
||||
'favicon' => 'favicon-high-alert',
|
||||
];
|
||||
|
||||
if ($isMajorOutage) {
|
||||
$withData = [
|
||||
'system_status' => 'danger',
|
||||
'system_message' => trans_choice('cachet.service.major', $totalComponents),
|
||||
'favicon' => 'favicon-high-alert',
|
||||
];
|
||||
} elseif (Component::enabled()->notStatus(1)->count() === 0) {
|
||||
// If all our components are ok, do we have any non-fixed incidents?
|
||||
$incidents = Incident::notScheduled()->orderBy('created_at', 'desc')->get();
|
||||
$incidentCount = $incidents->count();
|
||||
|
||||
if ($incidentCount === 0 || ($incidentCount >= 1 && (int) $incidents->first()->status === 4)) {
|
||||
$withData = [
|
||||
'system_status' => 'success',
|
||||
'system_message' => trans_choice('cachet.service.good', $totalComponents),
|
||||
'favicon' => 'favicon',
|
||||
];
|
||||
}
|
||||
} else {
|
||||
if (Component::enabled()->whereIn('status', [2, 3])->count() > 0) {
|
||||
$withData['favicon'] = 'favicon-medium-alert';
|
||||
}
|
||||
}
|
||||
$status = $this->system->getStatus();
|
||||
|
||||
// Scheduled maintenance code.
|
||||
$scheduledMaintenance = Incident::scheduled()->orderBy('scheduled_at')->get();
|
||||
@@ -70,7 +62,7 @@ class StatusPageComposer
|
||||
$componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get();
|
||||
$ungroupedComponents = Component::enabled()->where('group_id', 0)->orderBy('order')->orderBy('created_at')->get();
|
||||
|
||||
$view->with($withData)
|
||||
$view->with($status)
|
||||
->withComponentGroups($componentGroups)
|
||||
->withUngroupedComponents($ungroupedComponents)
|
||||
->withScheduledMaintenance($scheduledMaintenance);
|
||||
|
||||
@@ -11,11 +11,30 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Composers;
|
||||
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class ThemeComposer
|
||||
{
|
||||
/**
|
||||
* The illuminate config instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Create a new theme composer.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Config\Repository $config
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Repository $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind data to the view.
|
||||
*
|
||||
@@ -26,17 +45,17 @@ class ThemeComposer
|
||||
public function compose(View $view)
|
||||
{
|
||||
// Theme colors.
|
||||
$view->withThemeBackgroundColor(Config::get('setting.style_background_color', '#F0F3F4'));
|
||||
$view->withThemeBackgroundFills(Config::get('setting.style_background_fills', '#FFFFFF'));
|
||||
$view->withThemeBannerBackgroundColor(Config::get('setting.style_banner_background_color', ''));
|
||||
$view->withThemeBannerPadding(Config::get('setting.style_banner_padding', '40px 0'));
|
||||
$view->withThemeTextColor(Config::get('setting.style_text_color', '#333333'));
|
||||
$view->withThemeReds(Config::get('setting.style_reds', '#ff6f6f'));
|
||||
$view->withThemeBlues(Config::get('setting.style_blues', '#3498db'));
|
||||
$view->withThemeGreens(Config::get('setting.style_greens', '#7ED321'));
|
||||
$view->withThemeYellows(Config::get('setting.style_yellows', '#F7CA18'));
|
||||
$view->withThemeOranges(Config::get('setting.style_oranges', '#FF8800'));
|
||||
$view->withThemeMetrics(Config::get('setting.style_metrics', '#0dccc0'));
|
||||
$view->withThemeLinks(Config::get('setting.style_links', '#7ED321'));
|
||||
$view->withThemeBackgroundColor($this->config->get('setting.style_background_color', '#F0F3F4'));
|
||||
$view->withThemeBackgroundFills($this->config->get('setting.style_background_fills', '#FFFFFF'));
|
||||
$view->withThemeBannerBackgroundColor($this->config->get('setting.style_banner_background_color', ''));
|
||||
$view->withThemeBannerPadding($this->config->get('setting.style_banner_padding', '40px 0'));
|
||||
$view->withThemeTextColor($this->config->get('setting.style_text_color', '#333333'));
|
||||
$view->withThemeReds($this->config->get('setting.style_reds', '#ff6f6f'));
|
||||
$view->withThemeBlues($this->config->get('setting.style_blues', '#3498db'));
|
||||
$view->withThemeGreens($this->config->get('setting.style_greens', '#7ED321'));
|
||||
$view->withThemeYellows($this->config->get('setting.style_yellows', '#F7CA18'));
|
||||
$view->withThemeOranges($this->config->get('setting.style_oranges', '#FF8800'));
|
||||
$view->withThemeMetrics($this->config->get('setting.style_metrics', '#0dccc0'));
|
||||
$view->withThemeLinks($this->config->get('setting.style_links', '#7ED321'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,11 +13,30 @@ namespace CachetHQ\Cachet\Composers;
|
||||
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class TimezoneLocaleComposer
|
||||
{
|
||||
/**
|
||||
* The illuminate config instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Create a new timezone locale composer.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Config\Repository $config
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Repository $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Timezones and Locales composer.
|
||||
*
|
||||
@@ -27,7 +46,7 @@ class TimezoneLocaleComposer
|
||||
*/
|
||||
public function compose(View $view)
|
||||
{
|
||||
$enabledLangs = Config::get('langs');
|
||||
$enabledLangs = $this->config->get('langs');
|
||||
|
||||
$langs = array_map(function ($lang) use ($enabledLangs) {
|
||||
$locale = basename($lang);
|
||||
|
||||
@@ -15,6 +15,7 @@ use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use CachetHQ\Cachet\Models\IncidentTemplate;
|
||||
use CachetHQ\Cachet\Models\IncidentUpdate;
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
use CachetHQ\Cachet\Models\MetricPoint;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
@@ -163,6 +164,13 @@ class DemoSeederCommand extends Command
|
||||
'order' => 1,
|
||||
'group_id' => 2,
|
||||
'link' => 'https://styleci.io',
|
||||
], [
|
||||
'name' => 'Patreon Page',
|
||||
'description' => 'Support future development of Cachet.',
|
||||
'status' => 1,
|
||||
'order' => 0,
|
||||
'group_id' => 0,
|
||||
'link' => 'https://patreon.com/jbrooksuk',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -180,71 +188,31 @@ class DemoSeederCommand extends Command
|
||||
*/
|
||||
protected function seedIncidents()
|
||||
{
|
||||
$incidentMessage = <<<'EINCIDENT'
|
||||
# Of course it does!
|
||||
|
||||
What kind of web application doesn't these days?
|
||||
|
||||
## Headers are fun aren't they
|
||||
|
||||
It's _exactly_ why we need Markdown. For **emphasis** and such.
|
||||
EINCIDENT;
|
||||
|
||||
$defaultIncidents = [
|
||||
[
|
||||
'name' => 'Cachet supports Markdown!',
|
||||
'message' => $incidentMessage,
|
||||
'status' => 4,
|
||||
'name' => 'Our monkeys aren\'t performing',
|
||||
'message' => 'We\'re investigating an issue with our monkeys not performing as they should be.',
|
||||
'status' => Incident::INVESTIGATING,
|
||||
'component_id' => 0,
|
||||
'scheduled_at' => null,
|
||||
'visible' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'Awesome',
|
||||
'message' => ':+1: We totally nailed the fix.',
|
||||
'status' => 4,
|
||||
], [
|
||||
'name' => 'This is an unresolved incident',
|
||||
'message' => 'Unresolved incidents are left without a **Fixed** update.',
|
||||
'status' => Incident::INVESTIGATING,
|
||||
'component_id' => 0,
|
||||
'scheduled_at' => null,
|
||||
'visible' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'Monitoring the fix',
|
||||
'message' => ":ship: We've deployed a fix.",
|
||||
'status' => 3,
|
||||
'component_id' => 0,
|
||||
'scheduled_at' => null,
|
||||
'visible' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'Update',
|
||||
'message' => "We've identified the problem. Our engineers are currently looking at it.",
|
||||
'status' => 2,
|
||||
'component_id' => 0,
|
||||
'scheduled_at' => null,
|
||||
'visible' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'Test Incident',
|
||||
'message' => 'Something went wrong, with something or another.',
|
||||
'status' => 1,
|
||||
'component_id' => 0,
|
||||
'scheduled_at' => null,
|
||||
'visible' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'Investigating the API',
|
||||
'message' => ':zap: We\'ve seen high response times from our API. It looks to be fixing itself as time goes on.',
|
||||
'status' => 1,
|
||||
'component_id' => 1,
|
||||
'scheduled_at' => null,
|
||||
'visible' => 1,
|
||||
],
|
||||
];
|
||||
|
||||
Incident::truncate();
|
||||
IncidentUpdate::truncate();
|
||||
|
||||
foreach ($defaultIncidents as $incident) {
|
||||
Incident::create($incident);
|
||||
foreach ($defaultIncidents as $defaultIncident) {
|
||||
$incident = Incident::create($defaultIncident);
|
||||
|
||||
$this->seedIncidentUpdates($incident);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,6 +226,47 @@ EINCIDENT;
|
||||
IncidentTemplate::truncate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Seed the incident updates table for a given incident.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function seedIncidentUpdates($incident)
|
||||
{
|
||||
$defaultUpdates = [
|
||||
1 => [
|
||||
[
|
||||
'status' => Incident::FIXED,
|
||||
'message' => 'The monkeys are back and rested!',
|
||||
'user_id' => 1,
|
||||
], [
|
||||
'status' => Incident::WATCHED,
|
||||
'message' => 'Our monkeys need a break from performing. They\'ll be back after a good rest.',
|
||||
'user_id' => 1,
|
||||
], [
|
||||
'status' => Incident::IDENTIFIED,
|
||||
'message' => 'We have identified the issue with our lovely performing monkeys.',
|
||||
'user_id' => 1,
|
||||
],
|
||||
],
|
||||
2 => [
|
||||
[
|
||||
'status' => Incident::WATCHED,
|
||||
'message' => 'We\'re actively watching this issue, so it remains unresolved.',
|
||||
'user_id' => 1,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$updates = $defaultUpdates[$incident->id];
|
||||
|
||||
foreach ($updates as $updateId => $update) {
|
||||
$update['incident_id'] = $incident->id;
|
||||
|
||||
IncidentUpdate::create($update);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Seed the metric points table.
|
||||
*
|
||||
@@ -314,42 +323,45 @@ EINCIDENT;
|
||||
{
|
||||
$defaultSettings = [
|
||||
[
|
||||
'name' => 'app_name',
|
||||
'key' => 'app_name',
|
||||
'value' => 'Cachet Demo',
|
||||
], [
|
||||
'name' => 'app_domain',
|
||||
'key' => 'app_domain',
|
||||
'value' => 'https://demo.cachethq.io',
|
||||
], [
|
||||
'name' => 'show_support',
|
||||
'key' => 'show_support',
|
||||
'value' => '1',
|
||||
], [
|
||||
'name' => 'app_locale',
|
||||
'key' => 'app_locale',
|
||||
'value' => 'en',
|
||||
], [
|
||||
'name' => 'app_timezone',
|
||||
'key' => 'app_timezone',
|
||||
'value' => 'Europe/London',
|
||||
], [
|
||||
'name' => 'app_incident_days',
|
||||
'key' => 'app_incident_days',
|
||||
'value' => '7',
|
||||
], [
|
||||
'name' => 'app_analytics',
|
||||
'key' => 'app_analytics',
|
||||
'value' => 'UA-58442674-3',
|
||||
], [
|
||||
'name' => 'app_analytics_gs',
|
||||
'key' => 'app_analytics_gs',
|
||||
'value' => 'GSN-712462-P',
|
||||
], [
|
||||
'name' => 'display_graphs',
|
||||
'key' => 'display_graphs',
|
||||
'value' => '1',
|
||||
], [
|
||||
'name' => 'app_about',
|
||||
'key' => 'app_about',
|
||||
'value' => 'This is the demo instance of [Cachet](https://cachethq.io?ref=demo). The open source status page system, for everyone. An [Alt Three](https://alt-three.com) product.',
|
||||
], [
|
||||
'key' => 'enable_subscribers',
|
||||
'value' => '0',
|
||||
],
|
||||
];
|
||||
|
||||
$this->settings->clear();
|
||||
|
||||
foreach ($defaultSettings as $setting) {
|
||||
$this->settings->set($setting['name'], $setting['value']);
|
||||
$this->settings->set($setting['key'], $setting['value']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Dates;
|
||||
|
||||
use DateTimeZone;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
class DateFactory
|
||||
@@ -88,4 +89,17 @@ class DateFactory
|
||||
{
|
||||
return (new Date($time))->setTimezone($this->cachetTimezone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the abbreviated timezone.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTimezone()
|
||||
{
|
||||
$dateTime = new Date();
|
||||
$dateTime->setTimeZone(new DateTimeZone($this->cachetTimezone));
|
||||
|
||||
return $dateTime->format('T');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ namespace CachetHQ\Cachet\Foundation\Providers;
|
||||
use AltThree\Bus\Dispatcher;
|
||||
use CachetHQ\Cachet\Bus\Middleware\UseDatabaseTransactions;
|
||||
use CachetHQ\Cachet\Dates\DateFactory;
|
||||
use CachetHQ\Cachet\GitHub\Release;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@@ -53,7 +52,6 @@ class AppServiceProvider extends ServiceProvider
|
||||
public function register()
|
||||
{
|
||||
$this->registerDateFactory();
|
||||
$this->registerRelease();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,19 +68,4 @@ class AppServiceProvider extends ServiceProvider
|
||||
return new DateFactory($appTimezone, $cacheTimezone);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the releases class.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerRelease()
|
||||
{
|
||||
$this->app->singleton(Release::class, function ($app) {
|
||||
$cache = $app['cache.store'];
|
||||
$token = $app['config']->get('services.github.token');
|
||||
|
||||
return new Release($cache, $token);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ use CachetHQ\Cachet\Settings\Cache;
|
||||
use CachetHQ\Cachet\Settings\Repository;
|
||||
use Exception;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
/**
|
||||
* This is the config service provider class.
|
||||
@@ -64,6 +65,7 @@ class ConfigServiceProvider extends ServiceProvider
|
||||
if ($appLocale = $this->app->config->get('setting.app_locale')) {
|
||||
$this->app->config->set('app.locale', $appLocale);
|
||||
$this->app->translator->setLocale($appLocale);
|
||||
Date::setLocale($appLocale);
|
||||
}
|
||||
|
||||
if ($appTimezone = $this->app->config->get('setting.app_timezone')) {
|
||||
|
||||
@@ -39,9 +39,18 @@ class EventServiceProvider extends ServiceProvider
|
||||
'CachetHQ\Cachet\Bus\Events\Component\ComponentWasUpdatedEvent' => [
|
||||
'CachetHQ\Cachet\Bus\Handlers\Events\Component\SendComponentUpdateEmailNotificationHandler',
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\Incident\IncidentWasRemovedEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\Incident\IncidentWasReportedEvent' => [
|
||||
'CachetHQ\Cachet\Bus\Handlers\Events\Incident\SendIncidentEmailNotificationHandler',
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\Incident\IncidentWasUpdatedEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\Incident\IncidentWasRemovedEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\Incident\MaintenanceWasScheduledEvent' => [
|
||||
'CachetHQ\Cachet\Bus\Handlers\Events\Incident\SendMaintenanceEmailNotificationHandler',
|
||||
],
|
||||
@@ -84,5 +93,11 @@ class EventServiceProvider extends ServiceProvider
|
||||
'CachetHQ\Cachet\Bus\Events\User\UserWasInvitedEvent' => [
|
||||
'CachetHQ\Cachet\Bus\Handlers\Events\User\SendInviteUserEmailHandler',
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\User\UserWasUpdatedEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\User\UserWasRemovedEvent' => [
|
||||
//
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
100
app/Foundation/Providers/IntegrationServiceProvider.php
Normal file
100
app/Foundation/Providers/IntegrationServiceProvider.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Foundation\Providers;
|
||||
|
||||
use CachetHQ\Cachet\Integrations\Contracts\Credits as CreditsContract;
|
||||
use CachetHQ\Cachet\Integrations\Contracts\Feed as FeedContract;
|
||||
use CachetHQ\Cachet\Integrations\Contracts\Releases as ReleasesContract;
|
||||
use CachetHQ\Cachet\Integrations\Contracts\System as SystemContract;
|
||||
use CachetHQ\Cachet\Integrations\Core\Credits;
|
||||
use CachetHQ\Cachet\Integrations\Core\Feed;
|
||||
use CachetHQ\Cachet\Integrations\Core\System;
|
||||
use CachetHQ\Cachet\Integrations\GitHub\Releases;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
/**
|
||||
* This is the integration service provider.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class IntegrationServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->registerCredits();
|
||||
$this->registerFeed();
|
||||
$this->registerSystem();
|
||||
|
||||
$this->registerReleases();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the credits class.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerCredits()
|
||||
{
|
||||
$this->app->singleton(CreditsContract::class, function ($app) {
|
||||
$cache = $app['cache.store'];
|
||||
|
||||
return new Credits($cache);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the feed class.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerFeed()
|
||||
{
|
||||
$this->app->singleton(FeedContract::class, function ($app) {
|
||||
$cache = $app['cache.store'];
|
||||
|
||||
return new Feed($cache);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the system class.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerSystem()
|
||||
{
|
||||
$this->app->singleton(SystemContract::class, function (Container $app) {
|
||||
return new System();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the releases class.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerReleases()
|
||||
{
|
||||
$this->app->singleton(ReleasesContract::class, function ($app) {
|
||||
$cache = $app['cache.store'];
|
||||
$token = $app['config']->get('services.github.token');
|
||||
|
||||
return new Releases($cache, $token);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,15 @@ use CachetHQ\Cachet\Repositories\Metric\MetricRepository;
|
||||
use CachetHQ\Cachet\Repositories\Metric\MySqlRepository as MetricMySqlRepository;
|
||||
use CachetHQ\Cachet\Repositories\Metric\PgSqlRepository as MetricPgSqlRepository;
|
||||
use CachetHQ\Cachet\Repositories\Metric\SqliteRepository as MetricSqliteRepository;
|
||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
/**
|
||||
* This is the repository service provider.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class RepositoryServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
@@ -37,15 +44,16 @@ class RepositoryServiceProvider extends ServiceProvider
|
||||
*/
|
||||
protected function registerMetricRepository()
|
||||
{
|
||||
$this->app->singleton(MetricRepository::class, function ($app) {
|
||||
$dbDriver = $app['config']->get('database.default');
|
||||
$this->app->singleton(MetricRepository::class, function (Container $app) {
|
||||
$config = $app->make(ConfigRepository::class);
|
||||
$driver = $config->get('database.default');
|
||||
|
||||
if ($dbDriver == 'mysql') {
|
||||
$repository = new MetricMySqlRepository();
|
||||
} elseif ($dbDriver == 'pgsql') {
|
||||
$repository = new MetricPgSqlRepository();
|
||||
} elseif ($dbDriver == 'sqlite') {
|
||||
$repository = new MetricSqliteRepository();
|
||||
if ($driver == 'mysql') {
|
||||
$repository = new MetricMySqlRepository($config);
|
||||
} elseif ($driver == 'pgsql') {
|
||||
$repository = new MetricPgSqlRepository($config);
|
||||
} elseif ($driver == 'sqlite') {
|
||||
$repository = new MetricSqliteRepository($config);
|
||||
}
|
||||
|
||||
$dates = $app->make(DateFactory::class);
|
||||
|
||||
@@ -28,34 +28,36 @@ class RouteServiceProvider extends ServiceProvider
|
||||
/**
|
||||
* Define the route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
$this->app->call([$this, 'bind']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the bindings for the application.
|
||||
*
|
||||
* @param \Illuminate\Routing\Router $router
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot(Router $router)
|
||||
public function bind(Router $router)
|
||||
{
|
||||
parent::boot($router);
|
||||
|
||||
$this->registerBindings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register model bindings.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerBindings()
|
||||
{
|
||||
$this->app->router->model('component', 'CachetHQ\Cachet\Models\Component');
|
||||
$this->app->router->model('component_group', 'CachetHQ\Cachet\Models\ComponentGroup');
|
||||
$this->app->router->model('incident', 'CachetHQ\Cachet\Models\Incident');
|
||||
$this->app->router->model('incident_template', 'CachetHQ\Cachet\Models\IncidentTemplate');
|
||||
$this->app->router->model('metric', 'CachetHQ\Cachet\Models\Metric');
|
||||
$this->app->router->model('metric_point', 'CachetHQ\Cachet\Models\MetricPoint');
|
||||
$this->app->router->model('setting', 'CachetHQ\Cachet\Models\Setting');
|
||||
$this->app->router->model('subscriber', 'CachetHQ\Cachet\Models\Subscriber');
|
||||
$this->app->router->model('subscription', 'CachetHQ\Cachet\Models\Subscription');
|
||||
$this->app->router->model('user', 'CachetHQ\Cachet\Models\User');
|
||||
$router->model('component', 'CachetHQ\Cachet\Models\Component');
|
||||
$router->model('component_group', 'CachetHQ\Cachet\Models\ComponentGroup');
|
||||
$router->model('component_tag', 'CachetHQ\Cachet\Models\ComponentTag');
|
||||
$router->model('incident', 'CachetHQ\Cachet\Models\Incident');
|
||||
$router->model('incident_template', 'CachetHQ\Cachet\Models\IncidentTemplate');
|
||||
$router->model('metric', 'CachetHQ\Cachet\Models\Metric');
|
||||
$router->model('metric_point', 'CachetHQ\Cachet\Models\MetricPoint');
|
||||
$router->model('setting', 'CachetHQ\Cachet\Models\Setting');
|
||||
$router->model('subscriber', 'CachetHQ\Cachet\Models\Subscriber');
|
||||
$router->model('subscription', 'CachetHQ\Cachet\Models\Subscription');
|
||||
$router->model('tag', 'CachetHQ\Cachet\Models\Tag');
|
||||
$router->model('user', 'CachetHQ\Cachet\Models\User');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\GitHub;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Contracts\Cache\Repository as CacheRepository;
|
||||
|
||||
class Release
|
||||
{
|
||||
/**
|
||||
* The cache repository instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Cache\Repository
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* The github authentication token.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $token;
|
||||
|
||||
/**
|
||||
* Creates a new release instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Cache\Repository $cache
|
||||
* @param string $token
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(CacheRepository $cache, $token)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest GitHub release.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function latest()
|
||||
{
|
||||
$release = $this->cache->remember('version', 720, function () {
|
||||
$headers = ['Accept' => 'application/vnd.github.v3+json'];
|
||||
|
||||
// We can re-use the Emoji token here, if we have it.
|
||||
if ($this->token) {
|
||||
$headers['OAUTH-TOKEN'] = $this->token;
|
||||
}
|
||||
|
||||
return json_decode((new Client())->get('https://api.github.com/repos/cachethq/cachet/releases/latest', [
|
||||
'headers' => $headers,
|
||||
])->getBody(), true);
|
||||
});
|
||||
|
||||
return $release['tag_name'];
|
||||
}
|
||||
}
|
||||
117
app/Http/Controllers/Api/ComponentTagController.php
Normal file
117
app/Http/Controllers/Api/ComponentTagController.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Commands\ComponentTag\AddComponentTagCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\ComponentTag\DeleteComponentTagCommand;
|
||||
use CachetHQ\Cachet\Bus\Exceptions\Tag\TagDoesNotExistOnComponentException;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\ComponentTag;
|
||||
use CachetHQ\Cachet\Models\Tag;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
/**
|
||||
* This is the component tag controller class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class ComponentTagController extends AbstractApiController
|
||||
{
|
||||
/**
|
||||
* Get all tags.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function getTags()
|
||||
{
|
||||
$tags = Tag::query();
|
||||
|
||||
$tags->search(Binput::except(['sort', 'order', 'per_page']));
|
||||
|
||||
if ($sortBy = Binput::get('sort')) {
|
||||
$direction = Binput::has('order') && Binput::get('order') == 'desc';
|
||||
|
||||
$tags->sort($sortBy, $direction);
|
||||
}
|
||||
|
||||
$tags = $tags->paginate(Binput::get('per_page', 20));
|
||||
|
||||
return $this->paginator($tags, Request::instance());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single component tag.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\ComponentTag $componentTag
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function getTag(ComponentTag $componentTag)
|
||||
{
|
||||
return $this->item($componentTag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new component tag.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function postTags()
|
||||
{
|
||||
$component = Component::find(Binput::get('component_id'));
|
||||
$tag = Tag::find(Binput::get('tag_id'));
|
||||
|
||||
if (!($component && $tag)) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
try {
|
||||
$tag = dispatch(new AddComponentTagCommand(
|
||||
$component,
|
||||
$tag
|
||||
));
|
||||
} catch (QueryException $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
return $this->item($tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an existing tag.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function deleteTag()
|
||||
{
|
||||
$component = Component::find(Binput::get('component_id'));
|
||||
$tag = Tag::find(Binput::get('tag_id'));
|
||||
|
||||
if (!($component && $tag)) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
try {
|
||||
dispatch(new DeleteComponentTagCommand(
|
||||
$component,
|
||||
$tag
|
||||
));
|
||||
} catch (TagDoesNotExistOnComponentException $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
return $this->noContent();
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,14 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Integrations\Contracts\Releases;
|
||||
use CachetHQ\Cachet\Integrations\Contracts\System;
|
||||
|
||||
/**
|
||||
* This is the general api controller.
|
||||
*
|
||||
* @author James Brooks <james@bluebaytravel.co.uk>
|
||||
*/
|
||||
class GeneralController extends AbstractApiController
|
||||
{
|
||||
/**
|
||||
@@ -30,6 +38,23 @@ class GeneralController extends AbstractApiController
|
||||
*/
|
||||
public function version()
|
||||
{
|
||||
return $this->item(CACHET_VERSION);
|
||||
$latest = app()->make(Releases::class)->latest();
|
||||
|
||||
return $this->setMetaData([
|
||||
'on_latest' => version_compare(CACHET_VERSION, $latest['tag_name']) === 1,
|
||||
'latest' => $latest,
|
||||
])->item(CACHET_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the system status message.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function status()
|
||||
{
|
||||
$system = app()->make(System::class)->getStatus();
|
||||
|
||||
return $this->item($system['system_message']);
|
||||
}
|
||||
}
|
||||
|
||||
132
app/Http/Controllers/Api/IncidentUpdateController.php
Normal file
132
app/Http/Controllers/Api/IncidentUpdateController.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\RemoveIncidentUpdateCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\ReportIncidentUpdateCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\UpdateIncidentUpdateCommand;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use CachetHQ\Cachet\Models\IncidentUpdate;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
/**
|
||||
* This is the incident update controller.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class IncidentUpdateController extends AbstractApiController
|
||||
{
|
||||
/**
|
||||
* Return all updates on the incident.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Incident $incident
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function getIncidentUpdates(Incident $incident)
|
||||
{
|
||||
$updates = IncidentUpdate::orderBy('created_at', 'desc');
|
||||
|
||||
if ($sortBy = Binput::get('sort')) {
|
||||
$direction = Binput::has('order') && Binput::get('order') == 'desc';
|
||||
|
||||
$updates->sort($sortBy, $direction);
|
||||
}
|
||||
|
||||
$updates = $updates->paginate(Binput::get('per_page', 20));
|
||||
|
||||
return $this->paginator($updates, Request::instance());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a single incident update.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Incident $incident
|
||||
* @param \CachetHQ\Cachet\Models\IncidentUpdate $update
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function getIncidentUpdate(Incident $incident, IncidentUpdate $update)
|
||||
{
|
||||
return $this->item($update);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new incident update.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Incident $incident
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function postIncidentUpdate(Incident $incident)
|
||||
{
|
||||
try {
|
||||
$update = dispatch(new ReportIncidentUpdateCommand(
|
||||
$incident,
|
||||
Binput::get('status'),
|
||||
Binput::get('message'),
|
||||
Auth::user()
|
||||
));
|
||||
} catch (QueryException $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
return $this->item($update);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an incident update.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Incident $incident
|
||||
* @param \CachetHQ\Cachet\Models\IncidentUpdate $update
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function putIncidentUpdate(Incident $incident, IncidentUpdate $update)
|
||||
{
|
||||
try {
|
||||
$update = dispatch(new UpdateIncidentUpdateCommand(
|
||||
$update,
|
||||
Binput::get('status'),
|
||||
Binput::get('message'),
|
||||
Auth::user()
|
||||
));
|
||||
} catch (QueryException $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
return $this->item($update);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new incident update.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Incident $incident
|
||||
* @param \CachetHQ\Cachet\Models\IncidentUpdate $update
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function deleteIncidentUpdate(Incident $incident, IncidentUpdate $update)
|
||||
{
|
||||
try {
|
||||
dispatch(new RemoveIncidentUpdateCommand($update));
|
||||
} catch (QueryException $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
return $this->noContent();
|
||||
}
|
||||
}
|
||||
@@ -84,8 +84,9 @@ class MetricController extends AbstractApiController
|
||||
Binput::get('calc_type', 0),
|
||||
Binput::get('display_chart', true),
|
||||
Binput::get('places', 2),
|
||||
Binput::get('view', 1),
|
||||
Binput::get('threshold', 5)
|
||||
Binput::get('default_view', Binput::get('view', 1)),
|
||||
Binput::get('threshold', 5),
|
||||
Binput::get('order', 0)
|
||||
));
|
||||
} catch (QueryException $e) {
|
||||
throw new BadRequestHttpException();
|
||||
@@ -113,8 +114,9 @@ class MetricController extends AbstractApiController
|
||||
Binput::get('calc_type'),
|
||||
Binput::get('display_chart'),
|
||||
Binput::get('places'),
|
||||
Binput::get('view'),
|
||||
Binput::get('threshold', 5)
|
||||
Binput::get('default_view', Binput::get('view')),
|
||||
Binput::get('threshold'),
|
||||
Binput::get('order')
|
||||
));
|
||||
} catch (QueryException $e) {
|
||||
throw new BadRequestHttpException();
|
||||
|
||||
@@ -17,6 +17,7 @@ use CachetHQ\Cachet\Bus\Commands\Subscriber\UnsubscribeSubscriptionCommand;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use CachetHQ\Cachet\Models\Subscription;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
@@ -48,12 +49,10 @@ class SubscriberController extends AbstractApiController
|
||||
*/
|
||||
public function postSubscribers()
|
||||
{
|
||||
$verified = Binput::get('verify', app(Repository::class)->get('setting.skip_subscriber_verification'));
|
||||
|
||||
try {
|
||||
$subscriber = dispatch(new SubscribeSubscriberCommand(
|
||||
Binput::get('email'),
|
||||
Binput::get('verify', false),
|
||||
Binput::get('components', null)
|
||||
));
|
||||
$subscriber = dispatch(new SubscribeSubscriberCommand(Binput::get('email'), $verified, Binput::get('components')));
|
||||
} catch (QueryException $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
113
app/Http/Controllers/Api/TagController.php
Normal file
113
app/Http/Controllers/Api/TagController.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Commands\Tag\CreateTagCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\Tag\DeleteTagCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\Tag\UpdateTagCommand;
|
||||
use CachetHQ\Cachet\Models\Tag;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
class TagController extends AbstractApiController
|
||||
{
|
||||
/**
|
||||
* Get all tags.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function getTags()
|
||||
{
|
||||
$tags = Tag::query();
|
||||
|
||||
$tags->search(Binput::except(['sort', 'order', 'per_page']));
|
||||
|
||||
if ($sortBy = Binput::get('sort')) {
|
||||
$direction = Binput::has('order') && Binput::get('order') == 'desc';
|
||||
|
||||
$tags->sort($sortBy, $direction);
|
||||
}
|
||||
|
||||
$tags = $tags->paginate(Binput::get('per_page', 20));
|
||||
|
||||
return $this->paginator($tags, Request::instance());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single tag.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Tag $tag
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function getTag(Tag $tag)
|
||||
{
|
||||
return $this->item($tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new tag.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function postTags()
|
||||
{
|
||||
try {
|
||||
$tag = dispatch(new CreateTagCommand(
|
||||
Binput::get('name'),
|
||||
Binput::get('slug')
|
||||
));
|
||||
} catch (QueryException $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
return $this->item($tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing tag.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Tag $tag
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function putTag(Tag $tag)
|
||||
{
|
||||
try {
|
||||
$tag = dispatch(new UpdateTagCommand(
|
||||
$tag,
|
||||
Binput::get('name'),
|
||||
Binput::get('slug')
|
||||
));
|
||||
} catch (QueryException $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
return $this->item($tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an existing tag.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Tag $tag
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function deleteTag(Tag $tag)
|
||||
{
|
||||
dispatch(new DeleteTagCommand($tag));
|
||||
|
||||
return $this->noContent();
|
||||
}
|
||||
}
|
||||
87
app/Http/Controllers/Api/UserController.php
Normal file
87
app/Http/Controllers/Api/UserController.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Commands\User\AddTeamMemberCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\User\RemoveUserCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\User\UpdateTeamMemberCommand;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
/**
|
||||
* This is the user controller class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class UserController extends AbstractApiController
|
||||
{
|
||||
/**
|
||||
* Create a new user.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function postUsers()
|
||||
{
|
||||
try {
|
||||
$user = dispatch(new AddTeamMemberCommand(
|
||||
Binput::get('username'),
|
||||
Binput::get('password'),
|
||||
Binput::get('email'),
|
||||
Binput::get('level', User::LEVEL_USER)
|
||||
));
|
||||
} catch (QueryException $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
return $this->item($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing user.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\User $user
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function putUser(User $user)
|
||||
{
|
||||
try {
|
||||
dispatch(new UpdateTeamMemberCommand(
|
||||
$user,
|
||||
Binput::get('username'),
|
||||
Binput::get('password'),
|
||||
Binput::get('email'),
|
||||
Binput::get('level')
|
||||
));
|
||||
} catch (QueryException $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
return $this->item($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a user from the system.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\User $user
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function deleteUser(User $user)
|
||||
{
|
||||
dispatch(new RemoveUserCommand($user));
|
||||
|
||||
return $this->noContent();
|
||||
}
|
||||
}
|
||||
@@ -41,11 +41,11 @@ class AuthController extends Controller
|
||||
*/
|
||||
public function postLogin()
|
||||
{
|
||||
$loginData = Binput::only(['login', 'password']);
|
||||
$loginData = Binput::only(['username', 'password']);
|
||||
|
||||
// Login with username or email.
|
||||
$loginKey = Str::contains($loginData['login'], '@') ? 'email' : 'username';
|
||||
$loginData[$loginKey] = array_pull($loginData, 'login');
|
||||
$loginKey = Str::contains($loginData['username'], '@') ? 'email' : 'username';
|
||||
$loginData[$loginKey] = array_pull($loginData, 'username');
|
||||
|
||||
// Validate login credentials.
|
||||
if (Auth::validate($loginData)) {
|
||||
|
||||
@@ -11,34 +11,46 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Dashboard;
|
||||
|
||||
use CachetHQ\Cachet\GitHub\Release;
|
||||
use CachetHQ\Cachet\Bus\Commands\Component\UpdateComponentCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\ComponentGroup\UpdateComponentGroupCommand;
|
||||
use CachetHQ\Cachet\Http\Controllers\Api\AbstractApiController;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
use CachetHQ\Cachet\Models\IncidentTemplate;
|
||||
use Exception;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
class ApiController extends Controller
|
||||
class ApiController extends AbstractApiController
|
||||
{
|
||||
/**
|
||||
* Updates a component with the entered info.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Component $component
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\Component
|
||||
*/
|
||||
public function postUpdateComponent(Component $component)
|
||||
{
|
||||
if (!$component->update(Binput::except(['_token']))) {
|
||||
throw new Exception(trans('dashboard.components.edit.failure'));
|
||||
try {
|
||||
dispatch(new UpdateComponentCommand(
|
||||
$component,
|
||||
$component->name,
|
||||
$component->description,
|
||||
Binput::get('status'),
|
||||
$component->link,
|
||||
$component->order,
|
||||
$component->group_id,
|
||||
$component->enabled
|
||||
));
|
||||
} catch (QueryException $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
return $component;
|
||||
return $this->item($component);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,11 +63,25 @@ class ApiController extends Controller
|
||||
$componentData = Binput::get('ids');
|
||||
|
||||
foreach ($componentData as $order => $componentId) {
|
||||
// Ordering should be 1-based, data comes in 0-based
|
||||
Component::find($componentId)->update(['order' => $order + 1]);
|
||||
try {
|
||||
$component = Component::find($componentId);
|
||||
|
||||
dispatch(new UpdateComponentCommand(
|
||||
$component,
|
||||
$component->name,
|
||||
$component->description,
|
||||
$component->status,
|
||||
$component->link,
|
||||
$order + 1,
|
||||
$component->group_id,
|
||||
$component->enabled
|
||||
));
|
||||
} catch (QueryException $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
}
|
||||
|
||||
return $componentData;
|
||||
return $this->collection(Component::query()->orderBy('order')->get());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,10 +94,17 @@ class ApiController extends Controller
|
||||
$groupData = Binput::get('ids');
|
||||
|
||||
foreach ($groupData as $order => $groupId) {
|
||||
ComponentGroup::find($groupId)->update(['order' => $order + 1]);
|
||||
$group = ComponentGroup::find($groupId);
|
||||
|
||||
dispatch(new UpdateComponentGroupCommand(
|
||||
$group,
|
||||
$group->name,
|
||||
$order + 1,
|
||||
$group->collapsed
|
||||
));
|
||||
}
|
||||
|
||||
return $groupData;
|
||||
return $this->collection(ComponentGroup::query()->orderBy('order')->get());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,20 +124,4 @@ class ApiController extends Controller
|
||||
|
||||
throw new ModelNotFoundException("Incident template for $templateSlug could not be found.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if Cachet is up to date.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function checkVersion()
|
||||
{
|
||||
$latest = app(Release::class)->latest();
|
||||
|
||||
return Response::json([
|
||||
'cachet_version' => CACHET_VERSION,
|
||||
'latest_version' => $latest,
|
||||
'is_latest' => version_compare(CACHET_VERSION, $latest) === 1,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,14 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Dashboard;
|
||||
|
||||
use CachetHQ\Cachet\Integrations\Contracts\Feed;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
@@ -36,16 +39,36 @@ class DashboardController extends Controller
|
||||
protected $timeZone;
|
||||
|
||||
/**
|
||||
* Creates a new dashboard controller.
|
||||
* The feed integration.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Integrations\Feed
|
||||
*/
|
||||
protected $feed;
|
||||
|
||||
/**
|
||||
* Creates a new dashboard controller instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Integrations\Feed $feed
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Feed $feed)
|
||||
{
|
||||
$this->feed = $feed;
|
||||
$this->startDate = new Date();
|
||||
$this->dateTimeZone = Config::get('cachet.timezone');
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect /admin to /dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function redirectAdmin()
|
||||
{
|
||||
return Redirect::route('dashboard.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the dashboard view.
|
||||
*
|
||||
@@ -56,12 +79,23 @@ class DashboardController extends Controller
|
||||
$components = Component::orderBy('order')->get();
|
||||
$incidents = $this->getIncidents();
|
||||
$subscribers = $this->getSubscribers();
|
||||
$usedComponentGroups = Component::enabled()->where('group_id', '>', 0)->groupBy('group_id')->pluck('group_id');
|
||||
$componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get();
|
||||
$ungroupedComponents = Component::enabled()->where('group_id', 0)->orderBy('order')->orderBy('created_at')->get();
|
||||
|
||||
$entries = null;
|
||||
if ($feed = $this->feed->latest()) {
|
||||
$entries = array_slice($feed->channel->item, 0, 5);
|
||||
}
|
||||
|
||||
return View::make('dashboard.index')
|
||||
->withPageTitle(trans('dashboard.dashboard'))
|
||||
->withComponents($components)
|
||||
->withIncidents($incidents)
|
||||
->withSubscribers($subscribers);
|
||||
->withSubscribers($subscribers)
|
||||
->withEntries($entries)
|
||||
->withComponentGroups($componentGroups)
|
||||
->withUngroupedComponents($ungroupedComponents);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,15 +15,22 @@ use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Bus\Commands\Incident\RemoveIncidentCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\Incident\ReportIncidentCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\ReportIncidentUpdateCommand;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use CachetHQ\Cachet\Models\IncidentTemplate;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
/**
|
||||
* This is the incident controller.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class IncidentController extends Controller
|
||||
{
|
||||
/**
|
||||
@@ -33,13 +40,24 @@ class IncidentController extends Controller
|
||||
*/
|
||||
protected $subMenu = [];
|
||||
|
||||
/**
|
||||
* The guard instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Guard
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Creates a new incident controller instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Guard $auth
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
|
||||
$this->subMenu = [
|
||||
'incidents' => [
|
||||
'title' => trans('dashboard.incidents.incidents'),
|
||||
@@ -279,4 +297,43 @@ class IncidentController extends Controller
|
||||
return Redirect::route('dashboard.templates.edit', ['id' => $template->id])
|
||||
->withUpdatedTemplate($template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the incident update form.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Incident $incident
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function showIncidentUpdateAction(Incident $incident)
|
||||
{
|
||||
return View::make('dashboard.incidents.update')->withIncident($incident);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new incident update.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Incident $incident
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function createIncidentUpdateAction(Incident $incident)
|
||||
{
|
||||
try {
|
||||
$incident = dispatch(new ReportIncidentUpdateCommand(
|
||||
$incident,
|
||||
Binput::get('status'),
|
||||
Binput::get('message'),
|
||||
$this->auth->user()
|
||||
));
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::route('dashboard.incidents.update', ['id' => $incident->id])
|
||||
->withInput(Binput::all())
|
||||
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure')))
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
return Redirect::route('dashboard.incidents.index')
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.delete.success')));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class MetricController extends Controller
|
||||
*/
|
||||
public function showMetrics()
|
||||
{
|
||||
$metrics = Metric::orderBy('created_at', 'desc')->get();
|
||||
$metrics = Metric::orderBy('order')->orderBy('id')->get();
|
||||
|
||||
return View::make('dashboard.metrics.index')
|
||||
->withPageTitle(trans('dashboard.metrics.metrics').' - '.trans('dashboard.dashboard'))
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Dashboard;
|
||||
|
||||
use CachetHQ\Cachet\Integrations\Contracts\Credits;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use CachetHQ\Cachet\Settings\Repository;
|
||||
use Exception;
|
||||
@@ -82,6 +83,12 @@ class SettingsController extends Controller
|
||||
'icon' => 'ion-stats-bars',
|
||||
'active' => false,
|
||||
],
|
||||
'credits' => [
|
||||
'title' => trans('dashboard.settings.credits.credits'),
|
||||
'url' => route('dashboard.settings.credits'),
|
||||
'icon' => 'ion-ios-list',
|
||||
'active' => false,
|
||||
],
|
||||
'about' => [
|
||||
'title' => CACHET_VERSION,
|
||||
'url' => 'javascript: void(0);',
|
||||
@@ -212,6 +219,30 @@ class SettingsController extends Controller
|
||||
->withSubMenu($this->subMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the credits view.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function showCreditsView()
|
||||
{
|
||||
$this->subMenu['credits']['active'] = true;
|
||||
|
||||
$credits = app(Credits::class)->latest();
|
||||
|
||||
$backers = $credits['backers'];
|
||||
$contributors = $credits['contributors'];
|
||||
|
||||
shuffle($backers);
|
||||
shuffle($contributors);
|
||||
|
||||
return View::make('dashboard.settings.credits')
|
||||
->withPageTitle(trans('dashboard.settings.credits.credits').' - '.trans('dashboard.dashboard'))
|
||||
->withBackers($backers)
|
||||
->withContributors($contributors)
|
||||
->withSubMenu($this->subMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the status page settings.
|
||||
*
|
||||
@@ -219,8 +250,6 @@ class SettingsController extends Controller
|
||||
*/
|
||||
public function postSettings()
|
||||
{
|
||||
$redirectUrl = Session::get('redirect_to', route('dashboard.settings.setup'));
|
||||
|
||||
$setting = app(Repository::class);
|
||||
|
||||
if (Binput::get('remove_banner') === '1') {
|
||||
@@ -266,14 +295,14 @@ class SettingsController extends Controller
|
||||
$setting->set($settingName, $settingValue);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return Redirect::to($redirectUrl)->withErrors(trans('dashboard.settings.edit.failure'));
|
||||
return Redirect::back()->withErrors(trans('dashboard.settings.edit.failure'));
|
||||
}
|
||||
|
||||
if (Binput::has('app_locale')) {
|
||||
Lang::setLocale(Binput::get('app_locale'));
|
||||
}
|
||||
|
||||
return Redirect::to($redirectUrl)->withSuccess(trans('dashboard.settings.edit.success'));
|
||||
return Redirect::back()->withSuccess(trans('dashboard.settings.edit.success'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@ use CachetHQ\Cachet\Bus\Commands\Subscriber\SubscribeSubscriberCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\Subscriber\UnsubscribeSubscriberCommand;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\View;
|
||||
@@ -52,11 +53,13 @@ class SubscriberController extends Controller
|
||||
*/
|
||||
public function createSubscriberAction()
|
||||
{
|
||||
$verified = app(Repository::class)->get('setting.skip_subscriber_verification');
|
||||
|
||||
try {
|
||||
$subscribers = preg_split("/\r\n|\n|\r/", Binput::get('email'));
|
||||
|
||||
foreach ($subscribers as $subscriber) {
|
||||
dispatch(new SubscribeSubscriberCommand($subscriber));
|
||||
dispatch(new SubscribeSubscriberCommand($subscriber, $verified));
|
||||
}
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::route('dashboard.subscribers.add')
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Dashboard;
|
||||
|
||||
use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Bus\Commands\User\AddTeamMemberCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\User\InviteTeamMemberCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\User\AddUserCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\User\InviteUserCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\User\RemoveUserCommand;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
@@ -81,7 +81,7 @@ class TeamController extends Controller
|
||||
public function postAddUser()
|
||||
{
|
||||
try {
|
||||
dispatch(new AddTeamMemberCommand(
|
||||
dispatch(new AddUserCommand(
|
||||
Binput::get('username'),
|
||||
Binput::get('password'),
|
||||
Binput::get('email'),
|
||||
@@ -130,7 +130,7 @@ class TeamController extends Controller
|
||||
public function postInviteUser()
|
||||
{
|
||||
try {
|
||||
dispatch(new InviteTeamMemberCommand(
|
||||
dispatch(new InviteUserCommand(
|
||||
array_unique(array_filter((array) Binput::get('emails')))
|
||||
));
|
||||
} catch (ValidationException $e) {
|
||||
|
||||
@@ -42,6 +42,22 @@ class SetupController extends Controller
|
||||
'redis' => 'Redis',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of cache drivers.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $mailDrivers = [
|
||||
'smtp' => 'SMTP',
|
||||
'mail' => 'Mail',
|
||||
'sendmail' => 'Sendmail',
|
||||
'mailgun' => 'Mailgun',
|
||||
'mandrill' => 'Mandrill',
|
||||
// 'ses' => 'Amazon SES', this will be available only if aws/aws-sdk-php is installed
|
||||
'sparkpost' => 'SparkPost',
|
||||
'log' => 'Log (Testing)',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of step1 rules.
|
||||
*
|
||||
@@ -73,6 +89,7 @@ class SetupController extends Controller
|
||||
$this->rulesStep1 = [
|
||||
'env.cache_driver' => 'required|in:'.implode(',', array_keys($this->cacheDrivers)),
|
||||
'env.session_driver' => 'required|in:'.implode(',', array_keys($this->cacheDrivers)),
|
||||
'env.mail_driver' => 'required|in:'.implode(',', array_keys($this->mailDrivers)),
|
||||
];
|
||||
|
||||
$this->rulesStep2 = [
|
||||
@@ -112,6 +129,7 @@ class SetupController extends Controller
|
||||
return View::make('setup')
|
||||
->withPageTitle(trans('setup.setup'))
|
||||
->withCacheDrivers($this->cacheDrivers)
|
||||
->withMailDrivers($this->mailDrivers)
|
||||
->withUserLanguage($userLanguage)
|
||||
->withAppUrl(Request::root());
|
||||
}
|
||||
@@ -127,6 +145,14 @@ class SetupController extends Controller
|
||||
|
||||
$v = Validator::make($postData, $this->rulesStep1);
|
||||
|
||||
$v->sometimes('env.mail_host', 'required', function ($input) {
|
||||
return $input->mail_driver === 'smtp';
|
||||
});
|
||||
|
||||
$v->sometimes(['env.mail_address', 'env.mail_username', 'env.mail_password'], 'required', function ($input) {
|
||||
return $input->mail_driver !== 'log';
|
||||
});
|
||||
|
||||
if ($v->passes()) {
|
||||
return Response::json(['status' => 1]);
|
||||
}
|
||||
@@ -224,8 +250,11 @@ class SetupController extends Controller
|
||||
try {
|
||||
(new Dotenv($dir, $file))->load();
|
||||
|
||||
$envKey = strtoupper($key);
|
||||
$envValue = env($envKey) ?: 'null';
|
||||
|
||||
file_put_contents($path, str_replace(
|
||||
env(strtoupper($key)), $value, file_get_contents($path)
|
||||
$envKey.'='.$envValue, $envKey.'='.$value, file_get_contents($path)
|
||||
));
|
||||
} catch (InvalidPathException $e) {
|
||||
//
|
||||
|
||||
@@ -47,7 +47,7 @@ class SignupController extends Controller
|
||||
return View::make('signup')
|
||||
->withCode($invite->code)
|
||||
->withUsername(Binput::old('username'))
|
||||
->withEmail(Binput::old('emai', $invite->email));
|
||||
->withEmail(Binput::old('email', $invite->email));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -85,7 +85,7 @@ class StatusPageController extends AbstractApiController
|
||||
$allIncidents = Incident::notScheduled()->where('visible', '>=', $incidentVisibility)->whereBetween('created_at', [
|
||||
$startDate->copy()->subDays($daysToShow)->format('Y-m-d').' 00:00:00',
|
||||
$startDate->format('Y-m-d').' 23:59:59',
|
||||
])->orderBy('scheduled_at', 'desc')->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) {
|
||||
])->orderBy('scheduled_at', 'desc')->orderBy('created_at', 'desc')->get()->load('updates')->groupBy(function (Incident $incident) {
|
||||
return app(DateFactory::class)->make($incident->is_scheduled ? $incident->scheduled_at : $incident->created_at)->toDateString();
|
||||
});
|
||||
|
||||
|
||||
@@ -18,10 +18,12 @@ use CachetHQ\Cachet\Bus\Commands\Subscriber\UnsubscribeSubscriptionCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\Subscriber\UpdateSubscriberSubscriptionCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\Subscriber\VerifySubscriberCommand;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use CachetHQ\Cachet\Models\Subscription;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use GrahamCampbell\Markdown\Facades\Markdown;
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
@@ -56,10 +58,9 @@ class SubscribeController extends Controller
|
||||
{
|
||||
$email = Binput::get('email');
|
||||
$subscriptions = Binput::get('subscriptions');
|
||||
$verified = app(Repository::class)->get('setting.skip_subscriber_verification');
|
||||
|
||||
try {
|
||||
$verified = false;
|
||||
|
||||
$subscription = dispatch(new SubscribeSubscriberCommand($email, $verified));
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::route('status-page')
|
||||
@@ -147,15 +148,19 @@ class SubscribeController extends Controller
|
||||
}
|
||||
|
||||
$subscriber = Subscriber::where('verify_code', '=', $code)->first();
|
||||
$usedComponentGroups = Component::enabled()->where('group_id', '>', 0)->groupBy('group_id')->pluck('group_id');
|
||||
$componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get();
|
||||
$ungroupedComponents = Component::enabled()->where('group_id', 0)->orderBy('order')->orderBy('created_at')->get();
|
||||
|
||||
if (!$subscriber) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
return View::make('subscribe.manage')
|
||||
->withComponents(Component::all())
|
||||
->withUngroupedComponents($ungroupedComponents)
|
||||
->withSubscriber($subscriber)
|
||||
->withSubscriptions($subscriber->subscriptions->pluck('component_id')->all());
|
||||
->withSubscriptions($subscriber->subscriptions->pluck('component_id')->all())
|
||||
->withComponentGroups($componentGroups);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,11 +37,13 @@ class Kernel extends HttpKernel
|
||||
'Illuminate\Session\Middleware\StartSession',
|
||||
'Illuminate\View\Middleware\ShareErrorsFromSession',
|
||||
'Illuminate\Foundation\Http\Middleware\VerifyCsrfToken',
|
||||
'Illuminate\Routing\Middleware\SubstituteBindings',
|
||||
],
|
||||
'api' => [
|
||||
'Barryvdh\Cors\HandleCors',
|
||||
'CachetHQ\Cachet\Http\Middleware\Acceptable',
|
||||
'CachetHQ\Cachet\Http\Middleware\Timezone',
|
||||
'Illuminate\Routing\Middleware\SubstituteBindings',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class Timezone
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Creates a new release instance.
|
||||
* Creates a new timezone middleware instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Config\Repository $config
|
||||
*
|
||||
|
||||
@@ -33,18 +33,27 @@ class ApiRoutes
|
||||
$router->group(['middleware' => ['auth.api']], function (Registrar $router) {
|
||||
$router->get('ping', 'GeneralController@ping');
|
||||
$router->get('version', 'GeneralController@version');
|
||||
$router->get('status', 'GeneralController@status');
|
||||
|
||||
$router->get('components', 'ComponentController@getComponents');
|
||||
$router->get('components/groups', 'ComponentGroupController@getGroups');
|
||||
$router->get('components/groups/{component_group}', 'ComponentGroupController@getGroup');
|
||||
$router->get('components/tags', 'ComponentTagController@getTags');
|
||||
$router->get('components/tags/{component_tag}', 'ComponentTagController@getTag');
|
||||
$router->get('components/{component}', 'ComponentController@getComponent');
|
||||
|
||||
$router->get('incidents', 'IncidentController@getIncidents');
|
||||
$router->get('incidents/{incident}', 'IncidentController@getIncident');
|
||||
|
||||
$router->get('incidents/{incident}/updates', 'IncidentUpdateController@getIncidentUpdates');
|
||||
$router->get('incidents/{incident}/updates/{update}', 'IncidentUpdateController@getIncidentUpdate');
|
||||
|
||||
$router->get('metrics', 'MetricController@getMetrics');
|
||||
$router->get('metrics/{metric}', 'MetricController@getMetric');
|
||||
$router->get('metrics/{metric}/points', 'MetricController@getMetricPoints');
|
||||
|
||||
$router->get('tags', 'TagController@getTags');
|
||||
$router->get('tags/{tag}', 'TagController@getTag');
|
||||
});
|
||||
|
||||
$router->group(['middleware' => ['auth.api:true']], function (Registrar $router) {
|
||||
@@ -52,24 +61,35 @@ class ApiRoutes
|
||||
|
||||
$router->post('components', 'ComponentController@postComponents');
|
||||
$router->post('components/groups', 'ComponentGroupController@postGroups');
|
||||
$router->post('components/tags', 'ComponentTagController@postTags');
|
||||
$router->post('incidents', 'IncidentController@postIncidents');
|
||||
$router->post('incidents/{incident}/updates', 'IncidentUpdateController@postIncidentUpdate');
|
||||
$router->post('metrics', 'MetricController@postMetrics');
|
||||
$router->post('metrics/{metric}/points', 'MetricPointController@postMetricPoints');
|
||||
$router->post('subscribers', 'SubscriberController@postSubscribers');
|
||||
$router->post('tags', 'TagController@postTags');
|
||||
$router->post('users', 'UserController@postUsers');
|
||||
|
||||
$router->put('components/groups/{component_group}', 'ComponentGroupController@putGroup');
|
||||
$router->put('components/{component}', 'ComponentController@putComponent');
|
||||
$router->put('incidents/{incident}', 'IncidentController@putIncident');
|
||||
$router->put('incidents/{incident}/updates/{update}', 'IncidentUpdateController@putIncidentUpdate');
|
||||
$router->put('metrics/{metric}', 'MetricController@putMetric');
|
||||
$router->put('metrics/{metric}/points/{metric_point}', 'MetricPointController@putMetricPoint');
|
||||
$router->put('tags/{tag}', 'TagController@putTag');
|
||||
$router->put('users/{user}', 'UserController@putUser');
|
||||
|
||||
$router->delete('components/groups/{component_group}', 'ComponentGroupController@deleteGroup');
|
||||
$router->delete('components/tags', 'ComponentTagController@deleteTag');
|
||||
$router->delete('components/{component}', 'ComponentController@deleteComponent');
|
||||
$router->delete('incidents/{incident}', 'IncidentController@deleteIncident');
|
||||
$router->delete('incidents/{incident}/updates/{update}', 'IncidentUpdateController@deleteIncidentUpdate');
|
||||
$router->delete('metrics/{metric}', 'MetricController@deleteMetric');
|
||||
$router->delete('metrics/{metric}/points/{metric_point}', 'MetricPointController@deleteMetricPoint');
|
||||
$router->delete('subscribers/{subscriber}', 'SubscriberController@deleteSubscriber');
|
||||
$router->delete('subscriptions/{subscription}', 'SubscriberController@deleteSubscription');
|
||||
$router->delete('tags/{tag}', 'TagController@deleteTag');
|
||||
$router->delete('users/{user}', 'UserController@deleteUser');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,206 +29,218 @@ class DashboardRoutes
|
||||
*/
|
||||
public function map(Registrar $router)
|
||||
{
|
||||
$router->group(['middleware' => ['web', 'auth'], 'prefix' => 'dashboard', 'namespace' => 'Dashboard', 'as' => 'dashboard.'], function (Registrar $router) {
|
||||
$router->get('/', [
|
||||
'as' => 'index',
|
||||
'uses' => 'DashboardController@showDashboard',
|
||||
]);
|
||||
$router->group(['middleware' => ['web', 'auth'], 'namespace' => 'Dashboard'], function (Registrar $router) {
|
||||
$router->get('admin', 'DashboardController@redirectAdmin');
|
||||
|
||||
$router->group(['as' => 'components.', 'prefix' => 'components'], function (Registrar $router) {
|
||||
$router->group(['prefix' => 'dashboard', 'as' => 'dashboard.'], function (Registrar $router) {
|
||||
$router->get('/', [
|
||||
'as' => 'index',
|
||||
'uses' => 'ComponentController@showComponents',
|
||||
]);
|
||||
$router->get('add', [
|
||||
'as' => 'add',
|
||||
'uses' => 'ComponentController@showAddComponent',
|
||||
]);
|
||||
$router->post('add', 'ComponentController@createComponentAction');
|
||||
$router->get('groups', [
|
||||
'as' => 'groups',
|
||||
'uses' => 'ComponentController@showComponentGroups',
|
||||
]);
|
||||
$router->get('groups/add', [
|
||||
'as' => 'groups.add',
|
||||
'uses' => 'ComponentController@showAddComponentGroup',
|
||||
]);
|
||||
$router->get('groups/edit/{component_group}', [
|
||||
'as' => 'groups.edit',
|
||||
'uses' => 'ComponentController@showEditComponentGroup',
|
||||
]);
|
||||
$router->post('groups/edit/{component_group}', 'ComponentController@updateComponentGroupAction');
|
||||
$router->delete('groups/{component_group}/delete', 'ComponentController@deleteComponentGroupAction');
|
||||
$router->post('groups/add', 'ComponentController@postAddComponentGroup');
|
||||
$router->get('{component}/edit', [
|
||||
'as' => 'edit',
|
||||
'uses' => 'ComponentController@showEditComponent',
|
||||
]);
|
||||
$router->delete('{component}/delete', 'ComponentController@deleteComponentAction');
|
||||
$router->post('{component}/edit', 'ComponentController@updateComponentAction');
|
||||
});
|
||||
|
||||
$router->group(['as' => 'incidents.', 'prefix' => 'incidents'], function (Registrar $router) {
|
||||
$router->get('/', [
|
||||
'as' => 'index',
|
||||
'uses' => 'IncidentController@showIncidents',
|
||||
]);
|
||||
$router->get('add', [
|
||||
'as' => 'add',
|
||||
'uses' => 'IncidentController@showAddIncident',
|
||||
]);
|
||||
$router->post('add', 'IncidentController@createIncidentAction');
|
||||
$router->delete('{incident}/delete', [
|
||||
'as' => 'delete',
|
||||
'uses' => 'IncidentController@deleteIncidentAction',
|
||||
]);
|
||||
$router->get('{incident}/edit', [
|
||||
'as' => 'edit',
|
||||
'uses' => 'IncidentController@showEditIncidentAction',
|
||||
]);
|
||||
$router->post('{incident}/edit', 'IncidentController@editIncidentAction');
|
||||
});
|
||||
|
||||
$router->group(['as' => 'schedule.', 'prefix' => 'schedule'], function (Registrar $router) {
|
||||
$router->get('/', [
|
||||
'as' => 'index',
|
||||
'uses' => 'ScheduleController@showIndex',
|
||||
]);
|
||||
$router->get('add', [
|
||||
'as' => 'add',
|
||||
'uses' => 'ScheduleController@showAddSchedule',
|
||||
]);
|
||||
$router->post('add', 'ScheduleController@addScheduleAction');
|
||||
$router->get('{incident}/edit', [
|
||||
'as' => 'edit',
|
||||
'uses' => 'ScheduleController@showEditSchedule',
|
||||
]);
|
||||
$router->post('{incident}/edit', 'ScheduleController@editScheduleAction');
|
||||
$router->delete('{incident}/delete', [
|
||||
'as' => 'delete',
|
||||
'uses' => 'ScheduleController@deleteScheduleAction',
|
||||
]);
|
||||
});
|
||||
|
||||
$router->group(['as' => 'templates.', 'prefix' => 'templates'], function (Registrar $router) {
|
||||
$router->get('/', [
|
||||
'as' => 'index',
|
||||
'uses' => 'IncidentController@showTemplates',
|
||||
]);
|
||||
$router->get('add', [
|
||||
'as' => 'add',
|
||||
'uses' => 'IncidentController@showAddIncidentTemplate',
|
||||
]);
|
||||
$router->post('add', 'IncidentController@createIncidentTemplateAction');
|
||||
$router->get('{incident_template}/edit', [
|
||||
'as' => 'edit',
|
||||
'uses' => 'IncidentController@showEditTemplateAction',
|
||||
]);
|
||||
$router->post('{incident_template}/edit', 'IncidentController@editTemplateAction');
|
||||
$router->delete('{incident_template}/delete', 'IncidentController@deleteTemplateAction');
|
||||
});
|
||||
|
||||
$router->group(['as' => 'subscribers.', 'prefix' => 'subscribers'], function (Registrar $router) {
|
||||
$router->get('/', [
|
||||
'as' => 'index',
|
||||
'uses' => 'SubscriberController@showSubscribers',
|
||||
]);
|
||||
$router->get('add', [
|
||||
'as' => 'add',
|
||||
'uses' => 'SubscriberController@showAddSubscriber',
|
||||
]);
|
||||
$router->post('add', 'SubscriberController@createSubscriberAction');
|
||||
$router->delete('{subscriber}/delete', 'SubscriberController@deleteSubscriberAction');
|
||||
});
|
||||
|
||||
$router->group(['as' => 'metrics.', 'prefix' => 'metrics'], function (Registrar $router) {
|
||||
$router->get('/', [
|
||||
'as' => 'index',
|
||||
'uses' => 'MetricController@showMetrics',
|
||||
]);
|
||||
$router->get('add', [
|
||||
'as' => 'add',
|
||||
'uses' => 'MetricController@showAddMetric',
|
||||
]);
|
||||
$router->post('add', 'MetricController@createMetricAction');
|
||||
$router->delete('{metric}/delete', 'MetricController@deleteMetricAction');
|
||||
$router->get('{metric}/edit', [
|
||||
'as' => 'edit',
|
||||
'uses' => 'MetricController@showEditMetricAction',
|
||||
]);
|
||||
$router->post('{metric}/edit', 'MetricController@editMetricAction');
|
||||
});
|
||||
|
||||
$router->group(['as' => 'team.', 'prefix' => 'team'], function (Registrar $router) {
|
||||
$router->get('/', [
|
||||
'as' => 'index',
|
||||
'uses' => 'TeamController@showTeamView',
|
||||
'uses' => 'DashboardController@showDashboard',
|
||||
]);
|
||||
|
||||
$router->group(['middleware' => 'admin'], function (Registrar $router) {
|
||||
$router->group(['as' => 'components.', 'prefix' => 'components'], function (Registrar $router) {
|
||||
$router->get('/', [
|
||||
'as' => 'index',
|
||||
'uses' => 'ComponentController@showComponents',
|
||||
]);
|
||||
$router->get('add', [
|
||||
'as' => 'add',
|
||||
'uses' => 'TeamController@showAddTeamMemberView',
|
||||
'uses' => 'ComponentController@showAddComponent',
|
||||
]);
|
||||
$router->get('invite', [
|
||||
'as' => 'invite',
|
||||
'uses' => 'TeamController@showInviteTeamMemberView',
|
||||
$router->post('add', 'ComponentController@createComponentAction');
|
||||
$router->get('groups', [
|
||||
'as' => 'groups',
|
||||
'uses' => 'ComponentController@showComponentGroups',
|
||||
]);
|
||||
$router->get('{user}', ['as' => 'edit', 'uses' => 'TeamController@showTeamMemberView']);
|
||||
$router->post('add', 'TeamController@postAddUser');
|
||||
$router->post('invite', 'TeamController@postInviteUser');
|
||||
$router->post('{user}', 'TeamController@postUpdateUser');
|
||||
$router->delete('{user}/delete', 'TeamController@deleteUser');
|
||||
$router->get('groups/add', [
|
||||
'as' => 'groups.add',
|
||||
'uses' => 'ComponentController@showAddComponentGroup',
|
||||
]);
|
||||
$router->get('groups/edit/{component_group}', [
|
||||
'as' => 'groups.edit',
|
||||
'uses' => 'ComponentController@showEditComponentGroup',
|
||||
]);
|
||||
$router->post('groups/edit/{component_group}', 'ComponentController@updateComponentGroupAction');
|
||||
$router->delete('groups/{component_group}/delete', 'ComponentController@deleteComponentGroupAction');
|
||||
$router->post('groups/add', 'ComponentController@postAddComponentGroup');
|
||||
$router->get('{component}/edit', [
|
||||
'as' => 'edit',
|
||||
'uses' => 'ComponentController@showEditComponent',
|
||||
]);
|
||||
$router->delete('{component}/delete', 'ComponentController@deleteComponentAction');
|
||||
$router->post('{component}/edit', 'ComponentController@updateComponentAction');
|
||||
});
|
||||
});
|
||||
|
||||
$router->group(['as' => 'settings.', 'prefix' => 'settings'], function (Registrar $router) {
|
||||
$router->get('setup', [
|
||||
'as' => 'setup',
|
||||
'uses' => 'SettingsController@showSetupView',
|
||||
]);
|
||||
$router->get('analytics', [
|
||||
'as' => 'analytics',
|
||||
'uses' => 'SettingsController@showAnalyticsView',
|
||||
]);
|
||||
$router->get('localization', [
|
||||
'as' => 'localization',
|
||||
'uses' => 'SettingsController@showLocalizationView',
|
||||
]);
|
||||
$router->get('security', [
|
||||
'as' => 'security',
|
||||
'uses' => 'SettingsController@showSecurityView',
|
||||
]);
|
||||
$router->get('theme', [
|
||||
'as' => 'theme',
|
||||
'uses' => 'SettingsController@showThemeView',
|
||||
]);
|
||||
$router->get('stylesheet', [
|
||||
'as' => 'stylesheet',
|
||||
'uses' => 'SettingsController@showStylesheetView',
|
||||
]);
|
||||
$router->get('customization', [
|
||||
'as' => 'customization',
|
||||
'uses' => 'SettingsController@showCustomizationView',
|
||||
]);
|
||||
$router->post('/', 'SettingsController@postSettings');
|
||||
});
|
||||
$router->group(['as' => 'incidents.', 'prefix' => 'incidents'], function (Registrar $router) {
|
||||
$router->get('/', [
|
||||
'as' => 'index',
|
||||
'uses' => 'IncidentController@showIncidents',
|
||||
]);
|
||||
$router->get('add', [
|
||||
'as' => 'add',
|
||||
'uses' => 'IncidentController@showAddIncident',
|
||||
]);
|
||||
$router->post('add', 'IncidentController@createIncidentAction');
|
||||
$router->delete('{incident}/delete', [
|
||||
'as' => 'delete',
|
||||
'uses' => 'IncidentController@deleteIncidentAction',
|
||||
]);
|
||||
$router->get('{incident}/edit', [
|
||||
'as' => 'edit',
|
||||
'uses' => 'IncidentController@showEditIncidentAction',
|
||||
]);
|
||||
$router->get('{incident}/update', [
|
||||
'as' => 'update',
|
||||
'uses' => 'IncidentController@showIncidentUpdateAction',
|
||||
]);
|
||||
$router->post('{incident}/edit', 'IncidentController@editIncidentAction');
|
||||
$router->post('{incident}/update', 'IncidentController@createIncidentUpdateAction');
|
||||
});
|
||||
|
||||
$router->group(['prefix' => 'user'], function (Registrar $router) {
|
||||
$router->get('/', [
|
||||
'as' => 'user',
|
||||
'uses' => 'UserController@showUser',
|
||||
]);
|
||||
$router->post('/', 'UserController@postUser');
|
||||
$router->get('{user}/api/regen', 'UserController@regenerateApiKey');
|
||||
});
|
||||
$router->group(['as' => 'schedule.', 'prefix' => 'schedule'], function (Registrar $router) {
|
||||
$router->get('/', [
|
||||
'as' => 'index',
|
||||
'uses' => 'ScheduleController@showIndex',
|
||||
]);
|
||||
$router->get('add', [
|
||||
'as' => 'add',
|
||||
'uses' => 'ScheduleController@showAddSchedule',
|
||||
]);
|
||||
$router->post('add', 'ScheduleController@addScheduleAction');
|
||||
$router->get('{incident}/edit', [
|
||||
'as' => 'edit',
|
||||
'uses' => 'ScheduleController@showEditSchedule',
|
||||
]);
|
||||
$router->post('{incident}/edit', 'ScheduleController@editScheduleAction');
|
||||
$router->delete('{incident}/delete', [
|
||||
'as' => 'delete',
|
||||
'uses' => 'ScheduleController@deleteScheduleAction',
|
||||
]);
|
||||
});
|
||||
|
||||
$router->group(['prefix' => 'api'], function (Registrar $router) {
|
||||
$router->get('incidents/templates', 'ApiController@getIncidentTemplate');
|
||||
$router->post('components/groups/order', 'ApiController@postUpdateComponentGroupOrder');
|
||||
$router->post('components/order', 'ApiController@postUpdateComponentOrder');
|
||||
$router->post('components/{component}', 'ApiController@postUpdateComponent');
|
||||
$router->get('system/version', 'ApiController@checkVersion');
|
||||
$router->group(['as' => 'templates.', 'prefix' => 'templates'], function (Registrar $router) {
|
||||
$router->get('/', [
|
||||
'as' => 'index',
|
||||
'uses' => 'IncidentController@showTemplates',
|
||||
]);
|
||||
$router->get('add', [
|
||||
'as' => 'add',
|
||||
'uses' => 'IncidentController@showAddIncidentTemplate',
|
||||
]);
|
||||
$router->post('add', 'IncidentController@createIncidentTemplateAction');
|
||||
$router->get('{incident_template}/edit', [
|
||||
'as' => 'edit',
|
||||
'uses' => 'IncidentController@showEditTemplateAction',
|
||||
]);
|
||||
$router->post('{incident_template}/edit', 'IncidentController@editTemplateAction');
|
||||
$router->delete('{incident_template}/delete', 'IncidentController@deleteTemplateAction');
|
||||
});
|
||||
|
||||
$router->group(['as' => 'subscribers.', 'prefix' => 'subscribers'], function (Registrar $router) {
|
||||
$router->get('/', [
|
||||
'as' => 'index',
|
||||
'uses' => 'SubscriberController@showSubscribers',
|
||||
]);
|
||||
$router->get('add', [
|
||||
'as' => 'add',
|
||||
'uses' => 'SubscriberController@showAddSubscriber',
|
||||
]);
|
||||
$router->post('add', 'SubscriberController@createSubscriberAction');
|
||||
$router->delete('{subscriber}/delete', 'SubscriberController@deleteSubscriberAction');
|
||||
});
|
||||
|
||||
$router->group(['as' => 'metrics.', 'prefix' => 'metrics'], function (Registrar $router) {
|
||||
$router->get('/', [
|
||||
'as' => 'index',
|
||||
'uses' => 'MetricController@showMetrics',
|
||||
]);
|
||||
$router->get('add', [
|
||||
'as' => 'add',
|
||||
'uses' => 'MetricController@showAddMetric',
|
||||
]);
|
||||
$router->post('add', 'MetricController@createMetricAction');
|
||||
$router->delete('{metric}/delete', 'MetricController@deleteMetricAction');
|
||||
$router->get('{metric}/edit', [
|
||||
'as' => 'edit',
|
||||
'uses' => 'MetricController@showEditMetricAction',
|
||||
]);
|
||||
$router->post('{metric}/edit', 'MetricController@editMetricAction');
|
||||
});
|
||||
|
||||
$router->group(['as' => 'team.', 'prefix' => 'team'], function (Registrar $router) {
|
||||
$router->get('/', [
|
||||
'as' => 'index',
|
||||
'uses' => 'TeamController@showTeamView',
|
||||
]);
|
||||
|
||||
$router->group(['middleware' => 'admin'], function (Registrar $router) {
|
||||
$router->get('add', [
|
||||
'as' => 'add',
|
||||
'uses' => 'TeamController@showAddTeamMemberView',
|
||||
]);
|
||||
$router->get('invite', [
|
||||
'as' => 'invite',
|
||||
'uses' => 'TeamController@showInviteTeamMemberView',
|
||||
]);
|
||||
$router->get('{user}', ['as' => 'edit', 'uses' => 'TeamController@showTeamMemberView']);
|
||||
$router->post('add', 'TeamController@postAddUser');
|
||||
$router->post('invite', 'TeamController@postInviteUser');
|
||||
$router->post('{user}', 'TeamController@postUpdateUser');
|
||||
$router->delete('{user}/delete', 'TeamController@deleteUser');
|
||||
});
|
||||
});
|
||||
|
||||
$router->group(['as' => 'settings.', 'prefix' => 'settings'], function (Registrar $router) {
|
||||
$router->get('setup', [
|
||||
'as' => 'setup',
|
||||
'uses' => 'SettingsController@showSetupView',
|
||||
]);
|
||||
$router->get('analytics', [
|
||||
'as' => 'analytics',
|
||||
'uses' => 'SettingsController@showAnalyticsView',
|
||||
]);
|
||||
$router->get('localization', [
|
||||
'as' => 'localization',
|
||||
'uses' => 'SettingsController@showLocalizationView',
|
||||
]);
|
||||
$router->get('security', [
|
||||
'as' => 'security',
|
||||
'uses' => 'SettingsController@showSecurityView',
|
||||
]);
|
||||
$router->get('theme', [
|
||||
'as' => 'theme',
|
||||
'uses' => 'SettingsController@showThemeView',
|
||||
]);
|
||||
$router->get('stylesheet', [
|
||||
'as' => 'stylesheet',
|
||||
'uses' => 'SettingsController@showStylesheetView',
|
||||
]);
|
||||
$router->get('customization', [
|
||||
'as' => 'customization',
|
||||
'uses' => 'SettingsController@showCustomizationView',
|
||||
]);
|
||||
$router->get('credits', [
|
||||
'as' => 'credits',
|
||||
'uses' => 'SettingsController@showCreditsView',
|
||||
]);
|
||||
$router->post('/', 'SettingsController@postSettings');
|
||||
});
|
||||
|
||||
$router->group(['prefix' => 'user'], function (Registrar $router) {
|
||||
$router->get('/', [
|
||||
'as' => 'user',
|
||||
'uses' => 'UserController@showUser',
|
||||
]);
|
||||
$router->post('/', 'UserController@postUser');
|
||||
$router->get('{user}/api/regen', 'UserController@regenerateApiKey');
|
||||
});
|
||||
|
||||
$router->group(['prefix' => 'api'], function (Registrar $router) {
|
||||
$router->get('incidents/templates', 'ApiController@getIncidentTemplate');
|
||||
$router->post('components/groups/order', 'ApiController@postUpdateComponentGroupOrder');
|
||||
$router->post('components/order', 'ApiController@postUpdateComponentOrder');
|
||||
$router->post('components/{component}', 'ApiController@postUpdateComponent');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
27
app/Integrations/Contracts/Credits.php
Normal file
27
app/Integrations/Contracts/Credits.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Integrations\Contracts;
|
||||
|
||||
/**
|
||||
* This is the credits interface.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
interface Credits
|
||||
{
|
||||
/**
|
||||
* Returns the latest credits.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function latest();
|
||||
}
|
||||
27
app/Integrations/Contracts/Feed.php
Normal file
27
app/Integrations/Contracts/Feed.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Integrations\Contracts;
|
||||
|
||||
/**
|
||||
* This is the feed interface.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
interface Feed
|
||||
{
|
||||
/**
|
||||
* Returns the latest entries.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function latest();
|
||||
}
|
||||
27
app/Integrations/Contracts/Releases.php
Normal file
27
app/Integrations/Contracts/Releases.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Integrations\Contracts;
|
||||
|
||||
/**
|
||||
* This is the releases interface.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
interface Releases
|
||||
{
|
||||
/**
|
||||
* Returns the latest release.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function latest();
|
||||
}
|
||||
27
app/Integrations/Contracts/System.php
Normal file
27
app/Integrations/Contracts/System.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Integrations\Contracts;
|
||||
|
||||
/**
|
||||
* This is the system interface.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
interface System
|
||||
{
|
||||
/**
|
||||
* Get the entire system status.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getStatus();
|
||||
}
|
||||
82
app/Integrations/Core/Credits.php
Normal file
82
app/Integrations/Core/Credits.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Integrations\Core;
|
||||
|
||||
use CachetHQ\Cachet\Integrations\Contracts\Credits as CreditsContract;
|
||||
use Exception;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Contracts\Cache\Repository;
|
||||
|
||||
class Credits implements CreditsContract
|
||||
{
|
||||
/**
|
||||
* The default url.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const URL = 'https://cachethq.io/credits';
|
||||
|
||||
/**
|
||||
* The failed status indicator.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const FAILED = 1;
|
||||
|
||||
/**
|
||||
* The cache repository instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Cache\Repository
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* The url to use.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* Creates a new credits instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Cache\Repository $cache
|
||||
* @param string|null $url
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Repository $cache, $url = null)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
$this->url = $url ?: static::URL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest credits.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function latest()
|
||||
{
|
||||
$result = $this->cache->remember('credits', 2880, function () {
|
||||
try {
|
||||
return json_decode((new Client())->get($this->url, [
|
||||
'headers' => ['Accept' => 'application/json', 'User-Agent' => defined('CACHET_VERSION') ? 'cachet/'.constant('CACHET_VERSION') : 'cachet'],
|
||||
])->getBody(), true);
|
||||
} catch (Exception $e) {
|
||||
return self::FAILED;
|
||||
}
|
||||
});
|
||||
|
||||
return $result === self::FAILED ? null : $result;
|
||||
}
|
||||
}
|
||||
89
app/Integrations/Core/Feed.php
Normal file
89
app/Integrations/Core/Feed.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Integrations\Core;
|
||||
|
||||
use CachetHQ\Cachet\Integrations\Contracts\Feed as FeedContract;
|
||||
use Exception;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Contracts\Cache\Repository;
|
||||
|
||||
/**
|
||||
* This is the feed class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class Feed implements FeedContract
|
||||
{
|
||||
/**
|
||||
* The default url.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const URL = 'https://blog.alt-three.com/tag/cachet/rss';
|
||||
|
||||
/**
|
||||
* The failed status indicator.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const FAILED = 1;
|
||||
|
||||
/**
|
||||
* The cache repository instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Cache\Repository
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* The url to use.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* Creates a new feed instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Cache\Repository $cache
|
||||
* @param string|null $url
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Repository $cache, $url = null)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
$this->url = $url ?: static::URL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest entries.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function latest()
|
||||
{
|
||||
$result = $this->cache->remember('feeds', 720, function () {
|
||||
try {
|
||||
$xml = simplexml_load_string((new Client())->get($this->url, [
|
||||
'headers' => ['Accept' => 'application/rss+xml', 'User-Agent' => defined('CACHET_VERSION') ? 'cachet/'.constant('CACHET_VERSION') : 'cachet'],
|
||||
])->getBody()->getContents(), null, LIBXML_NOCDATA);
|
||||
|
||||
return json_decode(json_encode($xml));
|
||||
} catch (Exception $e) {
|
||||
return self::FAILED;
|
||||
}
|
||||
});
|
||||
|
||||
return $result === self::FAILED ? null : $result;
|
||||
}
|
||||
}
|
||||
73
app/Integrations/Core/System.php
Normal file
73
app/Integrations/Core/System.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Integrations\Core;
|
||||
|
||||
use CachetHQ\Cachet\Integrations\Contracts\System as SystemContract;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
|
||||
/**
|
||||
* This is the core system class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class System implements SystemContract
|
||||
{
|
||||
/**
|
||||
* Get the entire system status.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
$enabledScope = Component::enabled();
|
||||
$totalComponents = Component::enabled()->count();
|
||||
$majorOutages = Component::enabled()->status(4)->count();
|
||||
$isMajorOutage = $totalComponents ? ($majorOutages / $totalComponents) >= 0.5 : false;
|
||||
|
||||
// Default data
|
||||
$status = [
|
||||
'system_status' => 'info',
|
||||
'system_message' => trans_choice('cachet.service.bad', $totalComponents),
|
||||
'favicon' => 'favicon-high-alert',
|
||||
];
|
||||
|
||||
if ($isMajorOutage) {
|
||||
$status = [
|
||||
'system_status' => 'danger',
|
||||
'system_message' => trans_choice('cachet.service.major', $totalComponents),
|
||||
'favicon' => 'favicon-high-alert',
|
||||
];
|
||||
} elseif (Component::enabled()->notStatus(1)->count() === 0) {
|
||||
// If all our components are ok, do we have any non-fixed incidents?
|
||||
$incidents = Incident::notScheduled()->orderBy('created_at', 'desc')->get()->filter(function ($incident) {
|
||||
return $incident->status > 0;
|
||||
});
|
||||
$incidentCount = $incidents->count();
|
||||
$unresolvedCount = $incidents->filter(function ($incident) {
|
||||
return !$incident->is_resolved;
|
||||
})->count();
|
||||
|
||||
if ($incidentCount === 0 || ($incidentCount >= 1 && $unresolvedCount === 0)) {
|
||||
$status = [
|
||||
'system_status' => 'success',
|
||||
'system_message' => trans_choice('cachet.service.good', $totalComponents),
|
||||
'favicon' => 'favicon',
|
||||
];
|
||||
}
|
||||
} elseif (Component::enabled()->whereIn('status', [2, 3])->count() > 0) {
|
||||
$status['favicon'] = 'favicon-medium-alert';
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
96
app/Integrations/GitHub/Releases.php
Normal file
96
app/Integrations/GitHub/Releases.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Integrations\GitHub;
|
||||
|
||||
use CachetHQ\Cachet\Integrations\Contracts\Releases as ReleasesContract;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Contracts\Cache\Repository;
|
||||
|
||||
class Releases implements ReleasesContract
|
||||
{
|
||||
/**
|
||||
* The default url.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const URL = 'https://api.github.com/repos/cachethq/cachet/releases/latest';
|
||||
|
||||
/**
|
||||
* The failed status indicator.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const FAILED = 1;
|
||||
|
||||
/**
|
||||
* The cache repository instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Cache\Repository
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* The github authentication token.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $token;
|
||||
|
||||
/**
|
||||
* The url to use.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* Creates a new releases instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Cache\Repository $cache
|
||||
* @param string|null $token
|
||||
* @param string|null $url
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Repository $cache, $token = null, $url = null)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
$this->token = $token;
|
||||
$this->url = $url ?: static::URL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest release.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function latest()
|
||||
{
|
||||
$release = $this->cache->remember('release.latest', 720, function () {
|
||||
$headers = ['Accept' => 'application/vnd.github.v3+json', 'User-Agent' => defined('CACHET_VERSION') ? 'cachet/'.constant('CACHET_VERSION') : 'cachet'];
|
||||
|
||||
if ($this->token) {
|
||||
$headers['OAUTH-TOKEN'] = $this->token;
|
||||
}
|
||||
|
||||
return json_decode((new Client())->get($this->url, [
|
||||
'headers' => $headers,
|
||||
])->getBody(), true);
|
||||
});
|
||||
|
||||
return [
|
||||
'tag_name' => $release['tag_name'],
|
||||
'prelease' => $release['prerelease'],
|
||||
'draft' => $release['draft'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -129,11 +129,11 @@ class Component extends Model implements HasPresenter
|
||||
/**
|
||||
* Components can have many tags.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||
*/
|
||||
public function tags()
|
||||
{
|
||||
return $this->belongsToMany(Tag::class);
|
||||
return $this->hasManyThrough(Tag::class, ComponentTag::class, 'tag_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
74
app/Models/ComponentTag.php
Normal file
74
app/Models/ComponentTag.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* This is the component tag class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class ComponentTag extends Model
|
||||
{
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $casts = [
|
||||
'component_id' => 'int',
|
||||
'tag_id' => 'int',
|
||||
];
|
||||
|
||||
/**
|
||||
* The fillable properties.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $fillable = ['component_id', 'tag_id'];
|
||||
|
||||
/**
|
||||
* Get the component relation.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function component()
|
||||
{
|
||||
return $this->belongsTo(Component::class, 'component_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tag relation.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function tag()
|
||||
{
|
||||
return $this->belongsTo(Tag::class, 'tag_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a given tag for a component.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param int $tagId
|
||||
* @param int $componentId
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeTagForComponent(Builder $query, $tagId, $componentId)
|
||||
{
|
||||
return $query->where('component_id', $componentId)->where('tag_id', $tagId);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ use CachetHQ\Cachet\Models\Traits\SearchableTrait;
|
||||
use CachetHQ\Cachet\Models\Traits\SortableTrait;
|
||||
use CachetHQ\Cachet\Presenters\IncidentPresenter;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use McCool\LaravelAutoPresenter\HasPresenter;
|
||||
@@ -24,6 +25,43 @@ class Incident extends Model implements HasPresenter
|
||||
{
|
||||
use SearchableTrait, SoftDeletes, SortableTrait, ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Status for incident being investigated.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const INVESTIGATING = 1;
|
||||
|
||||
/**
|
||||
* Status for incident having been identified.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const IDENTIFIED = 2;
|
||||
|
||||
/**
|
||||
* Status for incident being watched.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const WATCHED = 3;
|
||||
|
||||
/**
|
||||
* Status for incident now being fixed.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const FIXED = 4;
|
||||
|
||||
/**
|
||||
* The accessors to append to the model's array form.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $appends = [
|
||||
'is_resolved',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
@@ -71,6 +109,7 @@ class Incident extends Model implements HasPresenter
|
||||
*/
|
||||
protected $searchable = [
|
||||
'id',
|
||||
'component_id',
|
||||
'name',
|
||||
'status',
|
||||
'visible',
|
||||
@@ -89,6 +128,13 @@ class Incident extends Model implements HasPresenter
|
||||
'message',
|
||||
];
|
||||
|
||||
/**
|
||||
* The relations to eager load on every query.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $with = ['updates'];
|
||||
|
||||
/**
|
||||
* Finds all visible incidents.
|
||||
*
|
||||
@@ -96,7 +142,7 @@ class Incident extends Model implements HasPresenter
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeVisible($query)
|
||||
public function scopeVisible(Builder $query)
|
||||
{
|
||||
return $query->where('visible', 1);
|
||||
}
|
||||
@@ -108,9 +154,9 @@ class Incident extends Model implements HasPresenter
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeScheduled($query)
|
||||
public function scopeScheduled(Builder $query)
|
||||
{
|
||||
return $query->where('status', 0)->where('scheduled_at', '>=', Carbon::now());
|
||||
return $query->where('status', 0)->where('scheduled_at', '>=', Carbon::now()->toDateTimeString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,13 +166,25 @@ class Incident extends Model implements HasPresenter
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeNotScheduled($query)
|
||||
public function scopeNotScheduled(Builder $query)
|
||||
{
|
||||
return $query->where(function ($query) {
|
||||
return $query->whereNull('scheduled_at')->orWhere('scheduled_at', '<=', Carbon::now());
|
||||
return $query->where('status', '>', 0)->orWhere(function ($query) {
|
||||
$query->where('status', 0)->where(function ($query) {
|
||||
$query->whereNull('scheduled_at')->orWhere('scheduled_at', '<=', Carbon::now()->toDateTimeString());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the updates relation.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function updates()
|
||||
{
|
||||
return $this->hasMany(IncidentUpdate::class)->orderBy('created_at', 'desc');
|
||||
}
|
||||
|
||||
/**
|
||||
* An incident belongs to a component.
|
||||
*
|
||||
@@ -137,6 +195,20 @@ class Incident extends Model implements HasPresenter
|
||||
return $this->belongsTo(Component::class, 'component_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the incident resolved?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getIsResolvedAttribute()
|
||||
{
|
||||
if ($updates = $this->updates->first()) {
|
||||
return $updates->status === self::FIXED;
|
||||
}
|
||||
|
||||
return $this->status === self::FIXED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the "incident" is scheduled or not.
|
||||
*
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
namespace CachetHQ\Cachet\Models;
|
||||
|
||||
use AltThree\Validator\ValidatingTrait;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@@ -66,7 +67,7 @@ class IncidentTemplate extends Model
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder
|
||||
*/
|
||||
public function scopeForSlug($query, $slug)
|
||||
public function scopeForSlug(Builder $query, $slug)
|
||||
{
|
||||
return $query->where('slug', $slug);
|
||||
}
|
||||
|
||||
90
app/Models/IncidentUpdate.php
Normal file
90
app/Models/IncidentUpdate.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Models;
|
||||
|
||||
use AltThree\Validator\ValidatingTrait;
|
||||
use CachetHQ\Cachet\Models\Traits\SortableTrait;
|
||||
use CachetHQ\Cachet\Presenters\IncidentUpdatePresenter;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use McCool\LaravelAutoPresenter\HasPresenter;
|
||||
|
||||
class IncidentUpdate extends Model implements HasPresenter
|
||||
{
|
||||
use SortableTrait, ValidatingTrait;
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $casts = [
|
||||
'incident_id' => 'int',
|
||||
'status' => 'int',
|
||||
'message' => 'string',
|
||||
'user_id' => 'int',
|
||||
];
|
||||
|
||||
/**
|
||||
* The fillable properties.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $fillable = [
|
||||
'incident_id',
|
||||
'status',
|
||||
'message',
|
||||
'user_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $rules = [
|
||||
'incident_id' => 'int',
|
||||
'status' => 'required|int',
|
||||
'message' => 'required|string',
|
||||
'user_id' => 'required|int',
|
||||
];
|
||||
|
||||
/**
|
||||
* The sortable fields.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $sortable = [
|
||||
'id',
|
||||
'status',
|
||||
'user_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the incident relation.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function incident()
|
||||
{
|
||||
return $this->belongsTo(Incident::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the presenter class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPresenterClass()
|
||||
{
|
||||
return IncidentUpdatePresenter::class;
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ namespace CachetHQ\Cachet\Models;
|
||||
use AltThree\Validator\ValidatingTrait;
|
||||
use CachetHQ\Cachet\Models\Traits\SortableTrait;
|
||||
use CachetHQ\Cachet\Presenters\MetricPresenter;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use McCool\LaravelAutoPresenter\HasPresenter;
|
||||
|
||||
@@ -48,6 +49,7 @@ class Metric extends Model implements HasPresenter
|
||||
'places' => 2,
|
||||
'default_view' => 1,
|
||||
'threshold' => 5,
|
||||
'order' => 0,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -63,6 +65,7 @@ class Metric extends Model implements HasPresenter
|
||||
'places' => 'int',
|
||||
'default_view' => 'int',
|
||||
'threshold' => 'int',
|
||||
'order' => 'int',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -80,6 +83,7 @@ class Metric extends Model implements HasPresenter
|
||||
'places',
|
||||
'default_view',
|
||||
'threshold',
|
||||
'order',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -95,6 +99,7 @@ class Metric extends Model implements HasPresenter
|
||||
'places' => 'numeric|between:0,4',
|
||||
'default_view' => 'numeric|between:0,3',
|
||||
'threshold' => 'numeric|between:0,10',
|
||||
'threshold' => 'int',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -108,6 +113,7 @@ class Metric extends Model implements HasPresenter
|
||||
'display_chart',
|
||||
'default_value',
|
||||
'calc_type',
|
||||
'order',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -120,6 +126,18 @@ class Metric extends Model implements HasPresenter
|
||||
return $this->hasMany(MetricPoint::class, 'metric_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope metrics to those of which are displayable.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeDisplayable(Builder $query)
|
||||
{
|
||||
return $query->where('display_chart', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a chart should be shown.
|
||||
*
|
||||
|
||||
@@ -11,11 +11,15 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Models;
|
||||
|
||||
use CachetHQ\Cachet\Models\Traits\SearchableTrait;
|
||||
use CachetHQ\Cachet\Models\Traits\SortableTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Tag extends Model
|
||||
{
|
||||
use SearchableTrait, SortableTrait;
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
@@ -32,6 +36,28 @@ class Tag extends Model
|
||||
*/
|
||||
protected $fillable = ['name'];
|
||||
|
||||
/**
|
||||
* The searchable fields.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $searchable = [
|
||||
'id',
|
||||
'name',
|
||||
'slug',
|
||||
];
|
||||
|
||||
/**
|
||||
* The sortable fields.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $sortable = [
|
||||
'id',
|
||||
'name',
|
||||
'slug',
|
||||
];
|
||||
|
||||
/**
|
||||
* Overrides the models boot method.
|
||||
*/
|
||||
|
||||
@@ -97,4 +97,27 @@ class ComponentGroupPresenter extends BasePresenter implements Arrayable
|
||||
'lowest_human_status' => $this->lowest_human_status(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if any of the contained components have active subscriptions.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has_subscriber($subscriptions)
|
||||
{
|
||||
$enabled_components = $this->wrappedObject->enabled_components()->orderBy('order')->pluck('id')->toArray();
|
||||
$intersected = array_intersect($enabled_components, $subscriptions);
|
||||
|
||||
return count($intersected) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the class for collapsed/uncollapsed groups on the subscription form.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function collapse_class_with_subscriptions($subscriptions)
|
||||
{
|
||||
return $this->has_subscriber($subscriptions) ? 'ion-ios-minus-outline' : 'ion-ios-plus-outline';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,19 @@ class IncidentPresenter extends BasePresenter implements Arrayable
|
||||
{
|
||||
use TimestampsTrait;
|
||||
|
||||
/**
|
||||
* Inciden icon lookup.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $icons = [
|
||||
0 => 'icon ion-android-calendar', // Scheduled
|
||||
1 => 'icon ion-flag oranges', // Investigating
|
||||
2 => 'icon ion-alert yellows', // Identified
|
||||
3 => 'icon ion-eye blues', // Watching
|
||||
4 => 'icon ion-checkmark greens', // Fixed
|
||||
];
|
||||
|
||||
/**
|
||||
* Renders the message from Markdown into HTML.
|
||||
*
|
||||
@@ -32,6 +45,16 @@ class IncidentPresenter extends BasePresenter implements Arrayable
|
||||
return Markdown::convertToHtml($this->wrappedObject->message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the raw text of the message, even without Markdown.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function raw_message()
|
||||
{
|
||||
return strip_tags($this->formattedMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Present diff for humans date time.
|
||||
*
|
||||
@@ -157,19 +180,8 @@ class IncidentPresenter extends BasePresenter implements Arrayable
|
||||
*/
|
||||
public function icon()
|
||||
{
|
||||
switch ($this->wrappedObject->status) {
|
||||
case 0: // Scheduled
|
||||
return 'icon ion-android-calendar';
|
||||
case 1: // Investigating
|
||||
return 'icon ion-flag oranges';
|
||||
case 2: // Identified
|
||||
return 'icon ion-alert yellows';
|
||||
case 3: // Watching
|
||||
return 'icon ion-eye blues';
|
||||
case 4: // Fixed
|
||||
return 'icon ion-checkmark greens';
|
||||
default: // Something actually broke, this shouldn't happen.
|
||||
return '';
|
||||
if (isset($this->icons[$this->wrappedObject->status])) {
|
||||
return $this->icons[$this->wrappedObject->status];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +195,72 @@ class IncidentPresenter extends BasePresenter implements Arrayable
|
||||
return trans('cachet.incidents.status.'.$this->wrappedObject->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest update.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function latest_status()
|
||||
{
|
||||
if ($update = $this->latest()) {
|
||||
return $update->status;
|
||||
}
|
||||
|
||||
return $this->wrappedObject->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest update.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function latest_human_status()
|
||||
{
|
||||
if ($update = $this->latest()) {
|
||||
return trans('cachet.incidents.status.'.$update->status);
|
||||
}
|
||||
|
||||
return $this->human_status();
|
||||
}
|
||||
|
||||
/**
|
||||
* Present the latest icon.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function latest_icon()
|
||||
{
|
||||
if ($update = $this->latest()) {
|
||||
if (isset($this->icons[$update->status])) {
|
||||
return $this->icons[$update->status];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->icon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the latest incident update.
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\IncidentUpdate|null
|
||||
*/
|
||||
public function latest()
|
||||
{
|
||||
if ($update = $this->wrappedObject->updates()->orderBy('created_at', 'desc')->first()) {
|
||||
return $update;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the incident permalink.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function permalink()
|
||||
{
|
||||
return route('incident', $this->wrappedObject->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the presenter instance to an array.
|
||||
*
|
||||
@@ -191,10 +269,15 @@ class IncidentPresenter extends BasePresenter implements Arrayable
|
||||
public function toArray()
|
||||
{
|
||||
return array_merge($this->wrappedObject->toArray(), [
|
||||
'human_status' => $this->human_status(),
|
||||
'scheduled_at' => $this->scheduled_at(),
|
||||
'created_at' => $this->created_at(),
|
||||
'updated_at' => $this->updated_at(),
|
||||
'human_status' => $this->human_status(),
|
||||
'latest_update_id' => $this->latest() ? $this->latest()->id : null,
|
||||
'latest_status' => $this->latest_status(),
|
||||
'latest_human_status' => $this->latest_human_status(),
|
||||
'latest_icon' => $this->latest_icon(),
|
||||
'permalink' => $this->permalink(),
|
||||
'scheduled_at' => $this->scheduled_at(),
|
||||
'created_at' => $this->created_at(),
|
||||
'updated_at' => $this->updated_at(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
162
app/Presenters/IncidentUpdatePresenter.php
Normal file
162
app/Presenters/IncidentUpdatePresenter.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Presenters;
|
||||
|
||||
use CachetHQ\Cachet\Dates\DateFactory;
|
||||
use CachetHQ\Cachet\Presenters\Traits\TimestampsTrait;
|
||||
use GrahamCampbell\Markdown\Facades\Markdown;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use McCool\LaravelAutoPresenter\BasePresenter;
|
||||
|
||||
/**
|
||||
* This is the incident update presenter.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class IncidentUpdatePresenter extends BasePresenter implements Arrayable
|
||||
{
|
||||
use TimestampsTrait;
|
||||
|
||||
/**
|
||||
* Renders the message from Markdown into HTML.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formattedMessage()
|
||||
{
|
||||
return Markdown::convertToHtml($this->wrappedObject->message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the raw text of the message, even without Markdown.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function raw_message()
|
||||
{
|
||||
return strip_tags($this->formattedMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Present diff for humans date time.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function created_at_diff()
|
||||
{
|
||||
return app(DateFactory::class)->make($this->wrappedObject->created_at)->diffForHumans();
|
||||
}
|
||||
|
||||
/**
|
||||
* Present formatted date time.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function created_at_formatted()
|
||||
{
|
||||
return ucfirst(app(DateFactory::class)->make($this->wrappedObject->created_at)->format(Config::get('setting.incident_date_format', 'l jS F Y H:i:s')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the created_at time ready to be used by bootstrap-datetimepicker.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function created_at_datetimepicker()
|
||||
{
|
||||
return app(DateFactory::class)->make($this->wrappedObject->created_at)->format('d/m/Y H:i');
|
||||
}
|
||||
|
||||
/**
|
||||
* Present formatted date time.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function created_at_iso()
|
||||
{
|
||||
return app(DateFactory::class)->make($this->wrappedObject->created_at)->toISO8601String();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a formatted timestamp for use within the timeline.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function timestamp_formatted()
|
||||
{
|
||||
if ($this->wrappedObject->is_scheduled) {
|
||||
return $this->scheduled_at_formatted;
|
||||
}
|
||||
|
||||
return $this->created_at_formatted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the iso timestamp for use within the timeline.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function timestamp_iso()
|
||||
{
|
||||
if ($this->wrappedObject->is_scheduled) {
|
||||
return $this->scheduled_at_iso;
|
||||
}
|
||||
|
||||
return $this->created_at_iso;
|
||||
}
|
||||
|
||||
/**
|
||||
* Present the status with an icon.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function icon()
|
||||
{
|
||||
switch ($this->wrappedObject->status) {
|
||||
case 1: // Investigating
|
||||
return 'icon ion-flag oranges';
|
||||
case 2: // Identified
|
||||
return 'icon ion-alert yellows';
|
||||
case 3: // Watching
|
||||
return 'icon ion-eye blues';
|
||||
case 4: // Fixed
|
||||
return 'icon ion-checkmark greens';
|
||||
default: // Something actually broke, this shouldn't happen.
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a human readable version of the status.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function human_status()
|
||||
{
|
||||
return trans('cachet.incidents.status.'.$this->wrappedObject->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the presenter instance to an array.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return array_merge($this->wrappedObject->toArray(), [
|
||||
'human_status' => $this->human_status(),
|
||||
'created_at' => $this->created_at(),
|
||||
'updated_at' => $this->updated_at(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
63
app/Repositories/Metric/AbstractMetricRepository.php
Normal file
63
app/Repositories/Metric/AbstractMetricRepository.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Repositories\Metric;
|
||||
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
|
||||
/**
|
||||
* This is the abstract metric repository class.
|
||||
*
|
||||
* @author Jams Brooks <james@alt-three.com>
|
||||
*/
|
||||
abstract class AbstractMetricRepository
|
||||
{
|
||||
/**
|
||||
* The illuminate config repository.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* The name of the metrics table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $tableName;
|
||||
|
||||
/**
|
||||
* Create a new abstract metric repository instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Config\Repository $config
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Repository $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the metrics table name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getTableName()
|
||||
{
|
||||
$driver = $this->config->get('database.default');
|
||||
$connection = $this->config->get('database.connections.'.$driver);
|
||||
$prefix = $connection['prefix'];
|
||||
|
||||
return $prefix.'metrics';
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,12 @@ use DateInterval;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
class MySqlRepository implements MetricInterface
|
||||
/**
|
||||
* This is the mysql repository class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class MySqlRepository extends AbstractMetricRepository implements MetricInterface
|
||||
{
|
||||
/**
|
||||
* Returns metrics for the last hour.
|
||||
@@ -40,7 +45,7 @@ class MySqlRepository implements MetricInterface
|
||||
|
||||
$value = 0;
|
||||
|
||||
$points = DB::select("SELECT {$queryType} FROM metrics m INNER JOIN metric_points mp ON m.id = mp.metric_id WHERE m.id = :metricId AND DATE_FORMAT(mp.`created_at`, '%Y%m%d%H%i') = :timeInterval GROUP BY HOUR(mp.`created_at`), MINUTE(mp.`created_at`)", [
|
||||
$points = DB::select("SELECT {$queryType} FROM {$this->getTableName()} m INNER JOIN metric_points mp ON m.id = mp.metric_id WHERE m.id = :metricId AND DATE_FORMAT(mp.`created_at`, '%Y%m%d%H%i') = :timeInterval GROUP BY HOUR(mp.`created_at`), MINUTE(mp.`created_at`)", [
|
||||
'metricId' => $metric->id,
|
||||
'timeInterval' => $timeInterval,
|
||||
]);
|
||||
@@ -77,7 +82,7 @@ class MySqlRepository implements MetricInterface
|
||||
|
||||
$value = 0;
|
||||
|
||||
$points = DB::select("SELECT {$queryType} FROM metrics m INNER JOIN metric_points mp ON m.id = mp.metric_id WHERE m.id = :metricId AND DATE_FORMAT(mp.`created_at`, '%Y%m%d%H') = :hourInterval GROUP BY HOUR(mp.`created_at`)", [
|
||||
$points = DB::select("SELECT {$queryType} FROM {$this->getTableName()} m INNER JOIN metric_points mp ON m.id = mp.metric_id WHERE m.id = :metricId AND DATE_FORMAT(mp.`created_at`, '%Y%m%d%H') = :hourInterval GROUP BY HOUR(mp.`created_at`)", [
|
||||
'metricId' => $metric->id,
|
||||
'hourInterval' => $hourInterval,
|
||||
]);
|
||||
@@ -112,7 +117,7 @@ class MySqlRepository implements MetricInterface
|
||||
|
||||
$value = 0;
|
||||
|
||||
$points = DB::select("SELECT {$queryType} FROM metrics m INNER JOIN metric_points mp ON m.id = mp.metric_id WHERE m.id = :metricId AND mp.`created_at` BETWEEN DATE_SUB(mp.`created_at`, INTERVAL 1 WEEK) AND DATE_ADD(NOW(), INTERVAL 1 DAY) AND DATE_FORMAT(mp.`created_at`, '%Y%m%d') = :timeInterval GROUP BY DATE_FORMAT(mp.`created_at`, '%Y%m%d')", [
|
||||
$points = DB::select("SELECT {$queryType} FROM {$this->getTableName()} m INNER JOIN metric_points mp ON m.id = mp.metric_id WHERE m.id = :metricId AND mp.`created_at` BETWEEN DATE_SUB(mp.`created_at`, INTERVAL 1 WEEK) AND DATE_ADD(NOW(), INTERVAL 1 DAY) AND DATE_FORMAT(mp.`created_at`, '%Y%m%d') = :timeInterval GROUP BY DATE_FORMAT(mp.`created_at`, '%Y%m%d')", [
|
||||
'metricId' => $metric->id,
|
||||
'timeInterval' => $dateTime->format('Ymd'),
|
||||
]);
|
||||
|
||||
@@ -16,7 +16,12 @@ use DateInterval;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
class PgSqlRepository implements MetricInterface
|
||||
/**
|
||||
* This is the pgsql repository class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class PgSqlRepository extends AbstractMetricRepository implements MetricInterface
|
||||
{
|
||||
/**
|
||||
* Returns metrics for the last hour.
|
||||
@@ -41,7 +46,7 @@ class PgSqlRepository implements MetricInterface
|
||||
}
|
||||
|
||||
$value = 0;
|
||||
$query = DB::select("select {$queryType} as value FROM metrics JOIN metric_points ON metric_points.metric_id = metrics.id WHERE metrics.id = :metricId AND to_char(metric_points.created_at, 'YYYYMMDDHH24MI') = :timeInterval GROUP BY to_char(metric_points.created_at, 'HHMI')", [
|
||||
$query = DB::select("select {$queryType} as value FROM {$this->getTableName()} m JOIN metric_points ON metric_points.metric_id = m.id WHERE m.id = :metricId AND to_char(metric_points.created_at, 'YYYYMMDDHH24MI') = :timeInterval GROUP BY to_char(metric_points.created_at, 'HHMI')", [
|
||||
'metricId' => $metric->id,
|
||||
'timeInterval' => $dateTime->format('YmdHi'),
|
||||
]);
|
||||
@@ -79,7 +84,7 @@ class PgSqlRepository implements MetricInterface
|
||||
}
|
||||
|
||||
$value = 0;
|
||||
$query = DB::select("select {$queryType} as value FROM metrics JOIN metric_points ON metric_points.metric_id = metrics.id WHERE metric_points.metric_id = :metricId AND to_char(metric_points.created_at, 'YYYYMMDDHH24') = :timeInterval GROUP BY to_char(metric_points.created_at, 'H')", [
|
||||
$query = DB::select("select {$queryType} as value FROM {$this->getTableName()} m JOIN metric_points ON metric_points.metric_id = m.id WHERE metric_points.metric_id = :metricId AND to_char(metric_points.created_at, 'YYYYMMDDHH24') = :timeInterval GROUP BY to_char(metric_points.created_at, 'H')", [
|
||||
'metricId' => $metric->id,
|
||||
'timeInterval' => $dateTime->format('YmdH'),
|
||||
]);
|
||||
@@ -113,7 +118,7 @@ class PgSqlRepository implements MetricInterface
|
||||
}
|
||||
|
||||
$value = 0;
|
||||
$points = DB::select("SELECT {$queryType} FROM metrics m INNER JOIN metric_points mp ON m.id = mp.metric_id WHERE m.id = :metricId AND mp.created_at BETWEEN (mp.created_at - interval '1 week') AND (now() + interval '1 day') AND to_char(mp.created_at, 'YYYYMMDD') = :timeInterval GROUP BY to_char(mp.created_at, 'YYYYMMDD')", [
|
||||
$points = DB::select("SELECT {$queryType} FROM {$this->getTableName()} m INNER JOIN metric_points mp ON m.id = mp.metric_id WHERE m.id = :metricId AND mp.created_at BETWEEN (mp.created_at - interval '1 week') AND (now() + interval '1 day') AND to_char(mp.created_at, 'YYYYMMDD') = :timeInterval GROUP BY to_char(mp.created_at, 'YYYYMMDD')", [
|
||||
'metricId' => $metric->id,
|
||||
'timeInterval' => $dateTime->format('Ymd'),
|
||||
]);
|
||||
|
||||
@@ -16,7 +16,7 @@ use DateInterval;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
class SqliteRepository implements MetricInterface
|
||||
class SqliteRepository extends AbstractMetricRepository implements MetricInterface
|
||||
{
|
||||
/**
|
||||
* Returns metrics for the last hour.
|
||||
@@ -41,7 +41,7 @@ class SqliteRepository implements MetricInterface
|
||||
}
|
||||
|
||||
$value = 0;
|
||||
$query = DB::select("select {$queryType} as value FROM metrics JOIN metric_points ON metric_points.metric_id = metrics.id WHERE metrics.id = :metricId AND strftime('%Y%m%d%H%M', metric_points.created_at) = :timeInterval GROUP BY strftime('%H%M', metric_points.created_at)", [
|
||||
$query = DB::select("select {$queryType} as value FROM {$this->getTableName()} m JOIN metric_points ON metric_points.metric_id = m.id WHERE m.id = :metricId AND strftime('%Y%m%d%H%M', metric_points.created_at) = :timeInterval GROUP BY strftime('%H%M', metric_points.created_at)", [
|
||||
'metricId' => $metric->id,
|
||||
'timeInterval' => $dateTime->format('YmdHi'),
|
||||
]);
|
||||
@@ -79,7 +79,7 @@ class SqliteRepository implements MetricInterface
|
||||
}
|
||||
|
||||
$value = 0;
|
||||
$query = DB::select("select {$queryType} as value FROM metrics JOIN metric_points ON metric_points.metric_id = metrics.id WHERE metrics.id = :metricId AND strftime('%Y%m%d%H', metric_points.created_at) = :timeInterval GROUP BY strftime('%H', metric_points.created_at)", [
|
||||
$query = DB::select("select {$queryType} as value FROM {$this->getTableName()} m JOIN metric_points ON metric_points.metric_id = m.id WHERE m.id = :metricId AND strftime('%Y%m%d%H', metric_points.created_at) = :timeInterval GROUP BY strftime('%H', metric_points.created_at)", [
|
||||
'metricId' => $metric->id,
|
||||
'timeInterval' => $dateTime->format('YmdH'),
|
||||
]);
|
||||
@@ -116,7 +116,7 @@ class SqliteRepository implements MetricInterface
|
||||
}
|
||||
|
||||
$value = 0;
|
||||
$query = DB::select("select {$queryType} as value FROM metrics JOIN metric_points ON metric_points.metric_id = metrics.id WHERE metrics.id = :metricId AND metric_points.created_at > date('now', '-7 day') AND strftime('%Y%m%d', metric_points.created_at) = :timeInterval GROUP BY strftime('%Y%m%d', metric_points.created_at)", [
|
||||
$query = DB::select("select {$queryType} as value FROM {$this->getTableName()} m JOIN metric_points ON metric_points.metric_id = m.id WHERE m.id = :metricId AND metric_points.created_at > date('now', '-7 day') AND strftime('%Y%m%d', metric_points.created_at) = :timeInterval GROUP BY strftime('%Y%m%d', metric_points.created_at)", [
|
||||
'metricId' => $metric->id,
|
||||
'timeInterval' => $dateTime->format('Ymd'),
|
||||
]);
|
||||
|
||||
@@ -26,7 +26,7 @@ $app->singleton('Illuminate\Contracts\Http\Kernel', 'CachetHQ\Cachet\Http\Kernel
|
||||
|
||||
$app->singleton('Illuminate\Contracts\Console\Kernel', 'CachetHQ\Cachet\Console\Kernel');
|
||||
|
||||
$app->singleton('Illuminate\Contracts\Debug\ExceptionHandler', 'GrahamCampbell\Exceptions\ExceptionHandler');
|
||||
$app->singleton('Illuminate\Contracts\Debug\ExceptionHandler', 'GrahamCampbell\Exceptions\NewExceptionHandler');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user