mirror of
https://github.com/cachethq/cachet.git
synced 2026-03-05 15:27:01 +00:00
Compare commits
210 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2311d67624 | ||
|
|
715d65f464 | ||
|
|
1ac4b7a64a | ||
|
|
941809037a | ||
|
|
0b8ce37e84 | ||
|
|
0851427f2d | ||
|
|
860457bfae | ||
|
|
9112e2a58f | ||
|
|
b1600bdbee | ||
|
|
2ef8b8411f | ||
|
|
a55bcb8c48 | ||
|
|
5c8369344d | ||
|
|
8589089a04 | ||
|
|
324f8703ce | ||
|
|
9df14837b9 | ||
|
|
e3a3f97957 | ||
|
|
fbfa62d087 | ||
|
|
1c7fb1a434 | ||
|
|
02f069cdc1 | ||
|
|
1779ac40c9 | ||
|
|
e8d3c013a1 | ||
|
|
85efb7d114 | ||
|
|
11d77328dc | ||
|
|
c05e9d9867 | ||
|
|
f9f2e5c18a | ||
|
|
2ac9d3b23e | ||
|
|
848fb3b607 | ||
|
|
7d21a7682c | ||
|
|
e3c38c7461 | ||
|
|
8dd762184e | ||
|
|
578d4befef | ||
|
|
549c4e1594 | ||
|
|
60536d5334 | ||
|
|
ef3c32c5e9 | ||
|
|
11cf7ef2c8 | ||
|
|
ca367ff151 | ||
|
|
06ecb4b9fb | ||
|
|
122138402b | ||
|
|
14ec134ac1 | ||
|
|
ea0a8dfcff | ||
|
|
6cd10581e4 | ||
|
|
90baf18724 | ||
|
|
5bdbc87bf2 | ||
|
|
60c7235d94 | ||
|
|
2c8cd19137 | ||
|
|
c1d53a7b42 | ||
|
|
22b0e105ee | ||
|
|
c7b55401d4 | ||
|
|
167b90265f | ||
|
|
bb71d0175f | ||
|
|
f964c03072 | ||
|
|
46c43a8b82 | ||
|
|
ee7a0ec5f2 | ||
|
|
427c8d24a5 | ||
|
|
60e6d99b95 | ||
|
|
18db70b9cd | ||
|
|
3a73a9be5c | ||
|
|
fb933720fc | ||
|
|
a4ce37f29a | ||
|
|
4f3664b3e0 | ||
|
|
c46c255722 | ||
|
|
971a422258 | ||
|
|
b6de8bf258 | ||
|
|
573a301957 | ||
|
|
d8323f126c | ||
|
|
e6db90a798 | ||
|
|
9d9bec812d | ||
|
|
c9b3760a4d | ||
|
|
fb127fb861 | ||
|
|
2425682381 | ||
|
|
da1c999ca6 | ||
|
|
79aa78cff5 | ||
|
|
4438142348 | ||
|
|
e917e338cd | ||
|
|
da22fa208a | ||
|
|
2cb1d9e07d | ||
|
|
68c458227f | ||
|
|
043690764d | ||
|
|
845d9e1e14 | ||
|
|
68572db6d2 | ||
|
|
5d7b05d857 | ||
|
|
9eb65eba3b | ||
|
|
17492b0dcf | ||
|
|
0f8773a547 | ||
|
|
45f376e564 | ||
|
|
3a44e4a809 | ||
|
|
fea555f2b0 | ||
|
|
9094f37156 | ||
|
|
0e502ed53b | ||
|
|
7f0c2a772d | ||
|
|
e06688aee5 | ||
|
|
bfe2b6ca48 | ||
|
|
7e663d7a76 | ||
|
|
65fe410a93 | ||
|
|
c747f11f3c | ||
|
|
9065b7dccc | ||
|
|
7727dbf33b | ||
|
|
2868f9e052 | ||
|
|
aab2b1fe6e | ||
|
|
1e4a8c8143 | ||
|
|
e002d596b1 | ||
|
|
1e3e1df616 | ||
|
|
6e3d1af85a | ||
|
|
e91cf591ea | ||
|
|
14bbe69509 | ||
|
|
c328575417 | ||
|
|
ecb3a4e1d9 | ||
|
|
71f5de8726 | ||
|
|
38257c6ae6 | ||
|
|
6802609ce6 | ||
|
|
476adef1b0 | ||
|
|
3a83110f50 | ||
|
|
8c4832343d | ||
|
|
a0d354c3e9 | ||
|
|
02cb04d36f | ||
|
|
07861dd245 | ||
|
|
14ac707d76 | ||
|
|
0fba574f5b | ||
|
|
71c30fb0bd | ||
|
|
bf77fbdd33 | ||
|
|
6336bd8905 | ||
|
|
dbbf4a093e | ||
|
|
5190578da9 | ||
|
|
c5f3655d49 | ||
|
|
721df30642 | ||
|
|
b79c8902fc | ||
|
|
bcc72d224f | ||
|
|
679005fe3f | ||
|
|
4990868d9a | ||
|
|
a7a4fe03e4 | ||
|
|
c2678ea89c | ||
|
|
f1bbf0200c | ||
|
|
1a5155dbc5 | ||
|
|
7e14d6d25f | ||
|
|
b003a7aa1c | ||
|
|
2c5549120b | ||
|
|
6a29b306e2 | ||
|
|
f01849f758 | ||
|
|
f592aa08c9 | ||
|
|
691e6fffe7 | ||
|
|
dbda00cef8 | ||
|
|
408141dd8b | ||
|
|
9b43b42e27 | ||
|
|
83955fcff5 | ||
|
|
bf05197c4f | ||
|
|
a72543daa2 | ||
|
|
cbf888d7b7 | ||
|
|
0a321bffd8 | ||
|
|
f74f44048d | ||
|
|
78567f865a | ||
|
|
de9240d295 | ||
|
|
a3235f78d0 | ||
|
|
3da8f3065c | ||
|
|
39091b51b5 | ||
|
|
e250d5e3fe | ||
|
|
8ed0f17761 | ||
|
|
92caf08d1d | ||
|
|
1e6db61066 | ||
|
|
13e5ee548d | ||
|
|
3d328663d5 | ||
|
|
fafcc8880b | ||
|
|
7a283dceb7 | ||
|
|
c1a0fc10ae | ||
|
|
13180cf77d | ||
|
|
903da245ef | ||
|
|
939766bf7d | ||
|
|
977cac091c | ||
|
|
04161678b6 | ||
|
|
793564e0c0 | ||
|
|
ea89254bf6 | ||
|
|
54011d7635 | ||
|
|
62a71554c6 | ||
|
|
e92dd0151a | ||
|
|
0a2f7659aa | ||
|
|
c0f19093e4 | ||
|
|
e858a288a6 | ||
|
|
d20f2cbbc8 | ||
|
|
902d7bd01b | ||
|
|
19d780325e | ||
|
|
b6a6acec4d | ||
|
|
e28a08f6bb | ||
|
|
0d8a3b4efc | ||
|
|
7db305edcc | ||
|
|
74ceb9885b | ||
|
|
d6617b6971 | ||
|
|
c28ba2dfb8 | ||
|
|
e794aedb3a | ||
|
|
2fa2ff9070 | ||
|
|
0f187b323b | ||
|
|
00a480b98b | ||
|
|
69f213a4dc | ||
|
|
cef5c9b1e2 | ||
|
|
0ca1668518 | ||
|
|
814a6cf30b | ||
|
|
b0d1eaafc2 | ||
|
|
e68467a308 | ||
|
|
0c940adc56 | ||
|
|
96dfd5d057 | ||
|
|
91dfa822bc | ||
|
|
3c5a5b49f1 | ||
|
|
c12d901147 | ||
|
|
60dac4664b | ||
|
|
b7dc6ab503 | ||
|
|
d207a2eeeb | ||
|
|
986fb4c588 | ||
|
|
5b1c7a69dd | ||
|
|
f7b53c06f6 | ||
|
|
f9d831bf8a | ||
|
|
dc85aa79c8 | ||
|
|
261b38b308 |
@@ -1 +0,0 @@
|
||||
.git
|
||||
12
.env.example
12
.env.example
@@ -1,12 +1,12 @@
|
||||
APP_ENV=local
|
||||
APP_DEBUG=true
|
||||
APP_ENV=production
|
||||
APP_DEBUG=false
|
||||
APP_URL=http://localhost
|
||||
APP_KEY=SomeRandomString
|
||||
|
||||
DB_DRIVER=sqlite
|
||||
DB_DRIVER=mysql
|
||||
DB_HOST=localhost
|
||||
DB_DATABASE=cachet
|
||||
DB_USERNAME=user
|
||||
DB_USERNAME=homestead
|
||||
DB_PASSWORD=secret
|
||||
|
||||
CACHE_DRIVER=file
|
||||
@@ -20,3 +20,7 @@ MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ADDRESS=null
|
||||
MAIL_NAME=null
|
||||
|
||||
REDIS_HOST=null
|
||||
REDIS_DATABASE=null
|
||||
REDIS_PORT=null
|
||||
|
||||
@@ -2,16 +2,15 @@
|
||||
|
||||
## Creating issues
|
||||
|
||||
Issues should be made by using the [issue tracker](https://github.com/cachethq/Cachet/issues).
|
||||
Feature requests and bug reports should be made by using the [issue tracker](https://github.com/cachethq/Cachet/issues). Support questions should be directed to our support email; [support@alt-three.com](mailto:support@alt-three.com?subject=Cachet Support).
|
||||
|
||||
Things to remember:
|
||||
|
||||
- Be descriptive
|
||||
- Be respectful of others
|
||||
**Always be respectful.** Organization members reserve the right to lock topics if they feel necessary.
|
||||
|
||||
## Languages
|
||||
|
||||
When needing to add labels, placeholders or general text, you **must not** write directly into the source file, rather make use of the `./app/lang/` directory. Always provide the English translation and copy your English string to all other languages - making sure that the indentation and alignment of the arrays are updated.
|
||||
When needing to add labels, placeholders or general text, you **must not** write directly into the source file, rather make use of the `./resources/lang/` directory.
|
||||
|
||||
Always provide the English translation and copy your English string to all other languages - making sure that the indentation and alignment of the arrays are updated.
|
||||
|
||||
## Coding Standards
|
||||
|
||||
@@ -20,9 +19,9 @@ Please follow existing coding standards:
|
||||
```php
|
||||
<?php
|
||||
|
||||
namespace Foo\Bar\Controller;
|
||||
namespace CachetHQ\Cachet\Controller;
|
||||
|
||||
use Foo\Bar\Bar;
|
||||
use CachetHQ\Cachet\Bar;
|
||||
|
||||
class Foo extends Bar
|
||||
{
|
||||
@@ -50,14 +49,13 @@ class Foo extends Bar
|
||||
}
|
||||
```
|
||||
- Braces on a new line following: `namespace`, `use`, `function` and `class`.
|
||||
- Line lengths have a soft 80 limit and hard 120 length.
|
||||
- PHP constants should be in lowercase; `true`, `false` and `null`.
|
||||
- Defined constants should always be in uppercase.
|
||||
- Never leave trailing spaces at the end of a line.
|
||||
- Files should end with one blank line.
|
||||
- Do not use `# Bash` style comments.
|
||||
- Always add or update Docblocs to functions.
|
||||
- If your pull request consists of more than two commits, you **must** squash them into one.
|
||||
- We use [StyleCI](https://styleci.io) to automatically check code standards in Pull Requests. If your PR fails the CI check, then apply the supplied patch and re-push.
|
||||
|
||||
If you're still unsure, then take a look at existing code.
|
||||
|
||||
@@ -75,8 +73,6 @@ If you're not particularly fond of the command line, you can get one of GitHub's
|
||||
|
||||
If you're feeling adventurous, you can become a Git & GitHub master with the [Git Path on Code School](https://www.codeschool.com/paths/git).
|
||||
|
||||
There is always the Cachet Gitter chat to ask any questions you may have:
|
||||
|
||||
[](https://gitter.im/cachethq/Cachet?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||
## .editorconfig
|
||||
|
||||
You should also make use of the [.editorconfig](/.editorconfig) file found within the root of the repository. It'll make sure that your editor is setup with the same file settings.
|
||||
|
||||
42
Dockerfile
42
Dockerfile
@@ -1,42 +0,0 @@
|
||||
FROM debian:jessie
|
||||
|
||||
ENV DB_DRIVER=mysql \
|
||||
ENV=production \
|
||||
DB_DATABASE=cachet \
|
||||
DB_HOST= \
|
||||
DB_USERNAME= \
|
||||
DB_PASSWORD= \
|
||||
DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
COPY . /var/www/html/
|
||||
WORKDIR /var/www/html/
|
||||
|
||||
# Using nodesource and debian jessie packages instead of compiling from scratch
|
||||
RUN echo "APT::Install-Recommends \"0\";" >> /etc/apt/apt.conf.d/02recommends && \
|
||||
echo "APT::Install-Suggests \"0\";" >> /etc/apt/apt.conf.d/02recommends && \
|
||||
apt-get -qq update && \
|
||||
apt-get -qq install \
|
||||
ca-certificates nginx php5-fpm=5.* php5-curl php5-readline php5-mcrypt php5-mysql php5-apcu php5-cli \
|
||||
git sqlite libsqlite3-dev curl supervisor php5-pgsql && \
|
||||
apt-get clean && apt-get autoremove -qq && \
|
||||
rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man /tmp/* && \
|
||||
chown -R www-data /var/www/html
|
||||
|
||||
# Hardcode the Illuminate key in config/app.php. If you want security, feel free
|
||||
# to override the key in your own container with a 'php artisan key:generate' :)
|
||||
RUN sed -i "s/'key' => '\w.*/'key' => 'f20d3e5ae02125a94bd60203a4edfbde',/" config/app.php && \
|
||||
grep key config/app.php
|
||||
|
||||
# copy the various nginx and supervisor conf (to handle both fpm and nginx)
|
||||
RUN sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php5/fpm/php-fpm.conf ;\
|
||||
echo "daemon off;" >> /etc/nginx/nginx.conf ;\
|
||||
mv /var/www/html/docker/php-fpm-pool.conf /etc/php5/fpm/pool.d/www.conf ;\
|
||||
rm -f /etc/nginx/sites-enabled/* && rm -f /etc/nginx/conf.d/* && mv /var/www/html/docker/nginx-site.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
RUN curl -sS https://getcomposer.org/installer | php && php composer.phar install --no-dev -o
|
||||
|
||||
COPY docker/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
CMD ["/usr/bin/supervisord"]
|
||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2014-2015 Cachet HQ.
|
||||
Copyright (c) 2015 Alt Three Services Limited.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
72
README.md
72
README.md
@@ -4,7 +4,7 @@
|
||||
[](https://travis-ci.org/cachethq/Cachet)
|
||||
[](https://scrutinizer-ci.com/g/cachethq/Cachet)
|
||||
[](LICENSE)
|
||||
[](https://gitter.im/cachethq/Cachet?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||
[](http://translate.cachethq.io/project/cachet)
|
||||
|
||||

|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
### Development Requirements
|
||||
|
||||
The following extra dependencies are required to develop Cachet:
|
||||
Theses extra dependencies are required to develop Cachet:
|
||||
|
||||
- Node.js
|
||||
- Bower
|
||||
@@ -38,6 +38,10 @@ The following extra dependencies are required to develop Cachet:
|
||||
|
||||
You can now find our documentation at [https://docs.cachethq.io](https://docs.cachethq.io).
|
||||
|
||||
- [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
|
||||
|
||||
To test out the demo, you may login to the [Dashboard](https://demo.cachethq.io/dashboard) with the following:
|
||||
@@ -47,70 +51,6 @@ To test out the demo, you may login to the [Dashboard](https://demo.cachethq.io/
|
||||
|
||||
The demo is reset every half hour.
|
||||
|
||||
## What Cachet is not
|
||||
|
||||
Here is a list of things that Cachet is not or does not do:
|
||||
|
||||
1. It does not monitor your services. It works only as a way to display the status of your services. *However, Cachet is able to receive updates from third-party services via its API.*
|
||||
2. It does not work on a plugin system. There are no monitoring services to extend.
|
||||
3. It's not a Twitter clone.
|
||||
|
||||
## Quickstart with Docker
|
||||
|
||||
Run a DB container (you can either pass in environment variables for the DB, or mount a config with `-v /my/database.php:/var/www/html/app/config/database.php`):
|
||||
|
||||
```bash
|
||||
$ export DB_USERNAME=cachet
|
||||
$ export DB_PASSWORD=cachet
|
||||
$ export DB_ROOT_PASSWORD=cachet
|
||||
$ export DB_DATABASE=cachet
|
||||
$ docker run --name mysql -e MYSQL_USER=$DB_USERNAME -e MYSQL_PASSWORD=$DB_PASSWORD -e MYSQL_ROOT_PASSWORD=$DB_ROOT_PASSWORD -e MYSQL_DATABASE=$DB_DATABASE -d mysql
|
||||
```
|
||||
|
||||
Initialize the DB if you haven't yet:
|
||||
|
||||
```bash
|
||||
$ docker run --rm --link mysql:mysql -e DB_HOST=mysql -e DB_DATABASE=$DB_DATABASE -e DB_USERNAME=$DB_USERNAME -e DB_PASSWORD=$DB_PASSWORD cachethq/cachet:latest php artisan migrate --force
|
||||
```
|
||||
|
||||
Run Cachet:
|
||||
|
||||
```bash
|
||||
$ docker run -d --name cachet --link mysql:mysql -p 80:8000 -e DB_HOST=mysql -e DB_DATABASE=$DB_DATABASE -e DB_USERNAME=$DB_USERNAME -e DB_PASSWORD=$DB_PASSWORD cachethq/cachet:latest
|
||||
```
|
||||
|
||||
Now go to `http://<ipdockerisboundto>/setup` and have fun!
|
||||
|
||||
Note: When running in production you should ensure that you enable SSL.
|
||||
This is commonly achieved by running Nginx with your certificates on your Docker host, service or load balancers in-front of the running container, or by adding your custom SSL certificates and configuration to the supplied Nginx configuration.
|
||||
|
||||
### docker-compose
|
||||
|
||||
Quickly launch Cachet and MySQL docker images with [docker-compose](https://docs.docker.com/compose/)
|
||||
|
||||
```bash
|
||||
git clone https://github.com/cachethq/Cachet.git
|
||||
cd Cachet
|
||||
docker-compose build
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
To initialize the database, utilize [docker exec](https://docs.docker.com/reference/commandline/cli/#exec):
|
||||
```bash
|
||||
docker exec -it cachet_cachet_1 php artisan migrate --force
|
||||
```
|
||||
|
||||
Continue to `http://<ipdockerisboundto>/setup` to configure Cachet.
|
||||
|
||||
## Addons
|
||||
|
||||
- [cachet-monitor](https://github.com/castawaylabs/cachet-monitor) - For URL monitoring. Automatic incident updates.
|
||||
- [sensu-cachet](https://github.com/bimlendu/sensu-cachethq) - Sensu handler for updating CachetHQ.
|
||||
|
||||
## Read more about Cachet
|
||||
|
||||
For more information on why I started developing Cachet, check out my [Cachet articles on my blog](https://james-brooks.uk/tag/cachet/?utm_source=github&utm_medium=readme&utm_campaign=github-cachet).
|
||||
|
||||
## Translations
|
||||
|
||||
A special thank you to our [translators](https://crowdin.com/project/cachet/activity_stream), who have allowed us to share Cachet with the world. If you'd like to contribute translations, please check out our [CrowdIn project](https://crowdin.com/project/cachet).
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -28,6 +28,7 @@ class IndexComposer
|
||||
$withData = [
|
||||
'systemStatus' => 'danger',
|
||||
'systemMessage' => trans('cachet.service.bad'),
|
||||
'favicon' => 'favicon-high-alert',
|
||||
];
|
||||
|
||||
if (Component::notStatus(1)->count() === 0) {
|
||||
@@ -39,8 +40,13 @@ class IndexComposer
|
||||
$withData = [
|
||||
'systemStatus' => 'success',
|
||||
'systemMessage' => trans('cachet.service.good'),
|
||||
'favicon' => 'favicon',
|
||||
];
|
||||
}
|
||||
} else {
|
||||
if (Component::whereIn('status', [2, 3])->count() > 0) {
|
||||
$withData['favicon'] = 'favicon-medium-alert';
|
||||
}
|
||||
}
|
||||
|
||||
$view->with($withData);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -39,12 +39,13 @@ class RedirectDisplayer implements DisplayerInterface
|
||||
* Get the error response associated with the given exception.
|
||||
*
|
||||
* @param \Exception $exception
|
||||
* @param string $id
|
||||
* @param int $code
|
||||
* @param string[] $headers
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function display(Exception $exception, $code, array $headers)
|
||||
public function display(Exception $exception, $id, $code, array $headers)
|
||||
{
|
||||
return redirect()->guest('auth/login');
|
||||
}
|
||||
@@ -62,13 +63,14 @@ class RedirectDisplayer implements DisplayerInterface
|
||||
/**
|
||||
* Can we display the exception?
|
||||
*
|
||||
* @param \Exception $exception
|
||||
* @param \Exception $original
|
||||
* @param \Exception $transformed
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canDisplay(Exception $exception)
|
||||
public function canDisplay(Exception $original, Exception $transformed)
|
||||
{
|
||||
$redirect = $exception instanceof HttpExceptionInterface && $exception->getStatusCode() === 401;
|
||||
$redirect = $transformed instanceof HttpExceptionInterface && $transformed->getStatusCode() === 401;
|
||||
|
||||
return $redirect && !$this->request->is('api*');
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -37,11 +37,12 @@ class ApiFilter
|
||||
* Filter and return the displayers.
|
||||
*
|
||||
* @param \GrahamCampbell\Exceptions\Displayers\DisplayerInterface[] $displayers
|
||||
* @param \Exception $exception
|
||||
* @param \Exception $original
|
||||
* @param \Exception $transformed
|
||||
*
|
||||
* @return \GrahamCampbell\Exceptions\Displayers\DisplayerInterface[]
|
||||
*/
|
||||
public function filter(array $displayers, Exception $exception)
|
||||
public function filter(array $displayers, Exception $original, Exception $transformed)
|
||||
{
|
||||
if ($this->request->is('api*')) {
|
||||
foreach ($displayers as $index => $displayer) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -11,11 +11,8 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use GrahamCampbell\Exceptions\ExceptionHandler;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpNotFoundException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
@@ -25,23 +22,6 @@ class Handler extends ExceptionHandler
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dontReport = [
|
||||
HttpNotFoundException::class,
|
||||
NotFoundHttpException::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $e
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $e)
|
||||
{
|
||||
if ($e instanceof ModelNotFoundException) {
|
||||
$e = new HttpNotFoundException('Resource not found');
|
||||
}
|
||||
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
}
|
||||
|
||||
41
app/Exceptions/Transformers/ModelNotFoundTransformer.php
Normal file
41
app/Exceptions/Transformers/ModelNotFoundTransformer.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\Exceptions\Transformers;
|
||||
|
||||
use Exception;
|
||||
use GrahamCampbell\Exceptions\Transformers\TransformerInterface;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* This is the model not found transformer class.
|
||||
*
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class ModelNotFoundTransformer implements TransformerInterface
|
||||
{
|
||||
/**
|
||||
* Transform the provided exception.
|
||||
*
|
||||
* @param \Exception $exception
|
||||
*
|
||||
* @return \Exception
|
||||
*/
|
||||
public function transform(Exception $exception)
|
||||
{
|
||||
if ($exception instanceof ModelNotFoundException) {
|
||||
$exception = new NotFoundHttpException('Resource not found');
|
||||
}
|
||||
|
||||
return $exception;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -73,7 +73,7 @@ class SendIncidentEmailNotificationHandler
|
||||
'htmlContent' => $data->formattedMessage,
|
||||
'textContent' => $data->message,
|
||||
'token' => $subscriber->token,
|
||||
'unsubscribeLink' => route('unsubscribe', ['code' => $subscriber->token]),
|
||||
'unsubscribeLink' => route('unsubscribe', ['code' => $subscriber->verify_code]),
|
||||
'appUrl' => env('APP_URL'),
|
||||
];
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -71,7 +71,7 @@ class SendMaintenanceEmailNotificationHandler
|
||||
'htmlContent' => $data->formattedMessage,
|
||||
'textContent' => $data->message,
|
||||
'token' => $subscriber->token,
|
||||
'unsubscribeLink' => route('unsubscribe', ['code' => $subscriber->token]),
|
||||
'unsubscribeLink' => route('unsubscribe', ['code' => $subscriber->verify_code]),
|
||||
'appUrl' => env('APP_URL'),
|
||||
];
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -41,8 +41,8 @@ class ComponentController extends AbstractController
|
||||
];
|
||||
|
||||
View::share([
|
||||
'subMenu' => $this->subMenu,
|
||||
'subTitle' => trans_choice('dashboard.components.components', 2),
|
||||
'sub_menu' => $this->subMenu,
|
||||
'sub_title' => trans_choice('dashboard.components.components', 2),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -58,9 +58,9 @@ class ComponentController extends AbstractController
|
||||
$this->subMenu['components']['active'] = true;
|
||||
|
||||
return View::make('dashboard.components.index')->with([
|
||||
'pageTitle' => trans_choice('dashboard.components.components', 2).' - '.trans('dashboard.dashboard'),
|
||||
'page_title' => trans_choice('dashboard.components.components', 2).' - '.trans('dashboard.dashboard'),
|
||||
'components' => $components,
|
||||
'subMenu' => $this->subMenu,
|
||||
'sub_menu' => $this->subMenu,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -74,9 +74,9 @@ class ComponentController extends AbstractController
|
||||
$this->subMenu['groups']['active'] = true;
|
||||
|
||||
return View::make('dashboard.components.groups.index')->with([
|
||||
'pageTitle' => trans_choice('dashboard.components.groups.groups', 2).' - '.trans('dashboard.dashboard'),
|
||||
'groups' => ComponentGroup::orderBy('order')->get(),
|
||||
'subMenu' => $this->subMenu,
|
||||
'page_title' => trans_choice('dashboard.components.groups.groups', 2).' - '.trans('dashboard.dashboard'),
|
||||
'groups' => ComponentGroup::orderBy('order')->get(),
|
||||
'sub_menu' => $this->subMenu,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -99,9 +99,9 @@ class ComponentController extends AbstractController
|
||||
);
|
||||
|
||||
return View::make('dashboard.components.edit')->with([
|
||||
'pageTitle' => $pageTitle,
|
||||
'component' => $component,
|
||||
'groups' => $groups,
|
||||
'page_title' => $pageTitle,
|
||||
'component' => $component,
|
||||
'groups' => $groups,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -120,11 +120,6 @@ class ComponentController extends AbstractController
|
||||
$component->update($_component);
|
||||
|
||||
if (!$component->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edit Component',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
@@ -134,11 +129,6 @@ class ComponentController extends AbstractController
|
||||
->with('errors', $component->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edit Component',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
// The component was added successfully, so now let's deal with the tags.
|
||||
$tags = preg_split('/ ?, ?/', $tags);
|
||||
|
||||
@@ -170,8 +160,8 @@ class ComponentController extends AbstractController
|
||||
$groups = ComponentGroup::all();
|
||||
|
||||
return View::make('dashboard.components.add')->with([
|
||||
'pageTitle' => trans('dashboard.components.add.title').' - '.trans('dashboard.dashboard'),
|
||||
'groups' => $groups,
|
||||
'page_title' => trans('dashboard.components.add.title').' - '.trans('dashboard.dashboard'),
|
||||
'groups' => $groups,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -189,11 +179,6 @@ class ComponentController extends AbstractController
|
||||
$component = Component::create($_component);
|
||||
|
||||
if (!$component->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Component',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
@@ -203,11 +188,6 @@ class ComponentController extends AbstractController
|
||||
->with('errors', $component->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Component',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
// The component was added successfully, so now let's deal with the tags.
|
||||
$tags = preg_split('/ ?, ?/', $tags);
|
||||
|
||||
@@ -238,10 +218,6 @@ class ComponentController extends AbstractController
|
||||
*/
|
||||
public function deleteComponentAction(Component $component)
|
||||
{
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Deleted Component',
|
||||
]);
|
||||
|
||||
$component->delete();
|
||||
|
||||
return Redirect::back();
|
||||
@@ -256,10 +232,6 @@ class ComponentController extends AbstractController
|
||||
*/
|
||||
public function deleteComponentGroupAction(ComponentGroup $group)
|
||||
{
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Deleted Component Group',
|
||||
]);
|
||||
|
||||
$group->components->map(function ($component) {
|
||||
$component->update([
|
||||
'group_id' => 0,
|
||||
@@ -279,7 +251,7 @@ class ComponentController extends AbstractController
|
||||
public function showAddComponentGroup()
|
||||
{
|
||||
return View::make('dashboard.components.groups.add')->with([
|
||||
'pageTitle' => trans('dashboard.components.groups.add.title').' - '.trans('dashboard.dashboard'),
|
||||
'page_title' => trans('dashboard.components.groups.add.title').' - '.trans('dashboard.dashboard'),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -293,8 +265,8 @@ class ComponentController extends AbstractController
|
||||
public function showEditComponentGroup(ComponentGroup $group)
|
||||
{
|
||||
return View::make('dashboard.components.groups.edit')->with([
|
||||
'pageTitle' => trans('dashboard.components.groups.edit.title').' - '.trans('dashboard.dashboard'),
|
||||
'group' => $group,
|
||||
'page_title' => trans('dashboard.components.groups.edit.title').' - '.trans('dashboard.dashboard'),
|
||||
'group' => $group,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -308,11 +280,6 @@ class ComponentController extends AbstractController
|
||||
$group = ComponentGroup::create(Binput::get('group'));
|
||||
|
||||
if (!$group->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Component Group',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
@@ -322,11 +289,6 @@ class ComponentController extends AbstractController
|
||||
->with('errors', $group->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Component Group',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@@ -349,11 +311,6 @@ class ComponentController extends AbstractController
|
||||
$group->update($groupData);
|
||||
|
||||
if (!$group->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edit Component Group',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
@@ -363,11 +320,6 @@ class ComponentController extends AbstractController
|
||||
->with('errors', $group->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edit Component Group',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -26,8 +26,6 @@ class DashboardController extends AbstractController
|
||||
{
|
||||
$components = Component::orderBy('order')->get();
|
||||
|
||||
segment_page('Dashboard');
|
||||
|
||||
return View::make('dashboard.index')->with([
|
||||
'components' => $components,
|
||||
]);
|
||||
@@ -41,7 +39,7 @@ class DashboardController extends AbstractController
|
||||
public function showNotifications()
|
||||
{
|
||||
return View::make('dashboard.notifications.index')->with([
|
||||
'pageTitle' => trans('dashboard.notifications.notifications').' '.trans('dashboard.dashboard'),
|
||||
'page_title' => trans('dashboard.notifications.notifications').' '.trans('dashboard.dashboard'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -55,8 +55,8 @@ class IncidentController extends AbstractController
|
||||
],
|
||||
];
|
||||
|
||||
View::share('subMenu', $this->subMenu);
|
||||
View::share('subTitle', trans('dashboard.incidents.title'));
|
||||
View::share('sub_menu', $this->subMenu);
|
||||
View::share('sub_title', trans('dashboard.incidents.title'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,8 +69,8 @@ class IncidentController extends AbstractController
|
||||
$incidents = Incident::notScheduled()->orderBy('created_at', 'desc')->get();
|
||||
|
||||
return View::make('dashboard.incidents.index')->with([
|
||||
'pageTitle' => trans('dashboard.incidents.incidents').' - '.trans('dashboard.dashboard'),
|
||||
'incidents' => $incidents,
|
||||
'page_title' => trans('dashboard.incidents.incidents').' - '.trans('dashboard.dashboard'),
|
||||
'incidents' => $incidents,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ class IncidentController extends AbstractController
|
||||
$componentsOutGroups = Component::where('group_id', 0)->get();
|
||||
|
||||
return View::make('dashboard.incidents.add')->with([
|
||||
'pageTitle' => trans('dashboard.incidents.add.title').' - '.trans('dashboard.dashboard'),
|
||||
'page_title' => trans('dashboard.incidents.add.title').' - '.trans('dashboard.dashboard'),
|
||||
'componentsInGroups' => $componentsInGroups,
|
||||
'componentsOutGroups' => $componentsOutGroups,
|
||||
'incidentTemplates' => IncidentTemplate::all(),
|
||||
@@ -100,7 +100,7 @@ class IncidentController extends AbstractController
|
||||
public function showTemplates()
|
||||
{
|
||||
return View::make('dashboard.incidents.templates.index')->with([
|
||||
'pageTitle' => trans('dashboard.incidents.templates.title').' - '.trans('dashboard.dashboard'),
|
||||
'page_title' => trans('dashboard.incidents.templates.title').' - '.trans('dashboard.dashboard'),
|
||||
'incidentTemplates' => IncidentTemplate::all(),
|
||||
]);
|
||||
}
|
||||
@@ -126,11 +126,6 @@ class IncidentController extends AbstractController
|
||||
$incident = Incident::create($incidentData);
|
||||
|
||||
if (!$incident->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Incident',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
@@ -147,11 +142,6 @@ class IncidentController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Incident',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@@ -178,7 +168,7 @@ class IncidentController extends AbstractController
|
||||
public function showAddIncidentTemplate()
|
||||
{
|
||||
return View::make('dashboard.incidents.templates.add')->with([
|
||||
'pageTitle' => trans('dashboard.incidents.templates.add.title').' - '.trans('dashboard.dashboard'),
|
||||
'page_title' => trans('dashboard.incidents.templates.add.title').' - '.trans('dashboard.dashboard'),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -192,8 +182,8 @@ class IncidentController extends AbstractController
|
||||
public function showEditTemplateAction(IncidentTemplate $template)
|
||||
{
|
||||
return View::make('dashboard.incidents.templates.edit')->with([
|
||||
'pageTitle' => trans('dashboard.incidents.templates.edit.title').' - '.trans('dashboard.dashboard'),
|
||||
'template' => $template,
|
||||
'page_title' => trans('dashboard.incidents.templates.edit.title').' - '.trans('dashboard.dashboard'),
|
||||
'template' => $template,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -206,10 +196,6 @@ class IncidentController extends AbstractController
|
||||
*/
|
||||
public function deleteTemplateAction(IncidentTemplate $template)
|
||||
{
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Deleted Incident Template',
|
||||
]);
|
||||
|
||||
$template->delete();
|
||||
|
||||
return Redirect::back();
|
||||
@@ -226,25 +212,15 @@ class IncidentController extends AbstractController
|
||||
$template = IncidentTemplate::create($_template);
|
||||
|
||||
if (!$template->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Incident Template',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.incidents.templates.add.failure')
|
||||
))
|
||||
->with('errors', $template->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Incident Template',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@@ -263,10 +239,6 @@ class IncidentController extends AbstractController
|
||||
*/
|
||||
public function deleteIncidentAction(Incident $incident)
|
||||
{
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Deleted Incident',
|
||||
]);
|
||||
|
||||
$incident->delete();
|
||||
|
||||
return Redirect::back();
|
||||
@@ -285,7 +257,7 @@ class IncidentController extends AbstractController
|
||||
$componentsOutGroups = Component::where('group_id', 0)->get();
|
||||
|
||||
return View::make('dashboard.incidents.edit')->with([
|
||||
'pageTitle' => trans('dashboard.incidents.edit.title').' - '.trans('dashboard.dashboard'),
|
||||
'page_title' => trans('dashboard.incidents.edit.title').' - '.trans('dashboard.dashboard'),
|
||||
'incident' => $incident,
|
||||
'componentsInGroups' => $componentsInGroups,
|
||||
'componentsOutGroups' => $componentsOutGroups,
|
||||
@@ -314,15 +286,10 @@ class IncidentController extends AbstractController
|
||||
$incident->update($incidentData);
|
||||
|
||||
if (!$incident->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edited Incident',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.incidents.templates.edit.failure')
|
||||
))
|
||||
->with('errors', $incident->getErrors());
|
||||
@@ -335,11 +302,6 @@ class IncidentController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edited Incident',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@@ -358,10 +320,6 @@ class IncidentController extends AbstractController
|
||||
*/
|
||||
public function editTemplateAction(IncidentTemplate $template)
|
||||
{
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edited Incident Template',
|
||||
]);
|
||||
|
||||
$template->update(Binput::get('template'));
|
||||
|
||||
return Redirect::back()->with('updatedTemplate', $template);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -30,8 +30,8 @@ class MetricController extends AbstractController
|
||||
$metrics = Metric::orderBy('created_at', 'desc')->get();
|
||||
|
||||
return View::make('dashboard.metrics.index')->with([
|
||||
'pageTitle' => trans('dashboard.metrics.metrics').' - '.trans('dashboard.dashboard'),
|
||||
'metrics' => $metrics,
|
||||
'page_title' => trans('dashboard.metrics.metrics').' - '.trans('dashboard.dashboard'),
|
||||
'metrics' => $metrics,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class MetricController extends AbstractController
|
||||
public function showAddMetric()
|
||||
{
|
||||
return View::make('dashboard.metrics.add')->with([
|
||||
'pageTitle' => trans('dashboard.metrics.add.title').' - '.trans('dashboard.dashboard'),
|
||||
'page_title' => trans('dashboard.metrics.add.title').' - '.trans('dashboard.dashboard'),
|
||||
'metricMetricPoints' => MetricPoint::all(),
|
||||
]);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class MetricController extends AbstractController
|
||||
public function showMetricPoints()
|
||||
{
|
||||
return View::make('dashboard.metrics.points.index')->with([
|
||||
'pageTitle' => trans('dashboard.metrics.points.title').' - '.trans('dashboard.dashboard'),
|
||||
'page_title' => trans('dashboard.metrics.points.title').' - '.trans('dashboard.dashboard'),
|
||||
'metricMetricPoints' => MetricPoint::all(),
|
||||
]);
|
||||
}
|
||||
@@ -72,11 +72,6 @@ class MetricController extends AbstractController
|
||||
$metric = Metric::create($metricData);
|
||||
|
||||
if (!$metric->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Metric',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
@@ -86,11 +81,6 @@ class MetricController extends AbstractController
|
||||
->with('errors', $metric->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Metric',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@@ -108,7 +98,7 @@ class MetricController extends AbstractController
|
||||
public function showAddMetricPoint()
|
||||
{
|
||||
return View::make('dashboard.metrics.points.add')->with([
|
||||
'pageTitle' => trans('dashboard.metrics.points.add.title').' - '.trans('dashboard.dashboard'),
|
||||
'page_title' => trans('dashboard.metrics.points.add.title').' - '.trans('dashboard.dashboard'),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -126,7 +116,7 @@ class MetricController extends AbstractController
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.metrics.points.add.failure')
|
||||
))
|
||||
->with('errors', $point->getErrors());
|
||||
@@ -165,8 +155,8 @@ class MetricController extends AbstractController
|
||||
public function showEditMetricAction(Metric $metric)
|
||||
{
|
||||
return View::make('dashboard.metrics.edit')->with([
|
||||
'pageTitle' => trans('dashboard.metrics.edit.title').' - '.trans('dashboard.dashboard'),
|
||||
'metric' => $metric,
|
||||
'page_title' => trans('dashboard.metrics.edit.title').' - '.trans('dashboard.dashboard'),
|
||||
'metric' => $metric,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -183,24 +173,14 @@ class MetricController extends AbstractController
|
||||
$metric->update($metricData);
|
||||
|
||||
if (!$metric->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edited Metric',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'<strong>%s</strong>',
|
||||
trans('dashboard.notifications.awesome')
|
||||
trans('dashboard.notifications.whoops')
|
||||
))
|
||||
->with('errors', $metric->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edited Metric',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -55,8 +55,8 @@ class ScheduleController extends AbstractController
|
||||
],
|
||||
];
|
||||
|
||||
View::share('subMenu', $this->subMenu);
|
||||
View::share('subTitle', trans('dashboard.incidents.title'));
|
||||
View::share('sub_menu', $this->subMenu);
|
||||
View::share('sub_title', trans('dashboard.incidents.title'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,11 +113,6 @@ class ScheduleController extends AbstractController
|
||||
$incident = Incident::create($scheduleData);
|
||||
|
||||
if (!$incident->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Scheduled Maintenance',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('success', sprintf(
|
||||
'%s %s',
|
||||
@@ -127,11 +122,6 @@ class ScheduleController extends AbstractController
|
||||
->with('errors', $incident->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Scheduled Maintenance',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@@ -197,11 +187,6 @@ class ScheduleController extends AbstractController
|
||||
$schedule->update($scheduleData);
|
||||
|
||||
if (!$schedule->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edited Schedule',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
@@ -211,11 +196,6 @@ class ScheduleController extends AbstractController
|
||||
->with('errors', $schedule->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edited Schedule',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@@ -234,10 +214,6 @@ class ScheduleController extends AbstractController
|
||||
*/
|
||||
public function deleteScheduleAction(Incident $schedule)
|
||||
{
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Deleted Schedule',
|
||||
]);
|
||||
|
||||
$schedule->delete();
|
||||
|
||||
return Redirect::back()->with('warning', sprintf(
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -54,9 +54,9 @@ class SettingsController extends AbstractController
|
||||
],
|
||||
];
|
||||
|
||||
View::share('subTitle', $this->subTitle);
|
||||
View::share('sub_title', $this->subTitle);
|
||||
|
||||
View::share('subMenu', $this->subMenu);
|
||||
View::share('sub_menu', $this->subMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,8 +69,8 @@ class SettingsController extends AbstractController
|
||||
$this->subMenu['setup']['active'] = true;
|
||||
|
||||
return View::make('dashboard.settings.app-setup')->with([
|
||||
'pageTitle' => 'Application Setup - Dashboard',
|
||||
'subMenu' => $this->subMenu,
|
||||
'page_title' => 'Application Setup - Dashboard',
|
||||
'sub_menu' => $this->subMenu,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -84,8 +84,8 @@ class SettingsController extends AbstractController
|
||||
$this->subMenu['theme']['active'] = true;
|
||||
|
||||
return View::make('dashboard.settings.theme')->with([
|
||||
'pageTitle' => 'Theme - Dashboard',
|
||||
'subMenu' => $this->subMenu,
|
||||
'page_title' => 'Theme - Dashboard',
|
||||
'sub_menu' => $this->subMenu,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -101,8 +101,8 @@ class SettingsController extends AbstractController
|
||||
$unsecureUsers = User::whereNull('google_2fa_secret')->orWhere('google_2fa_secret', '')->get();
|
||||
|
||||
return View::make('dashboard.settings.security')->with([
|
||||
'pageTitle' => 'Security - Dashboard',
|
||||
'subMenu' => $this->subMenu,
|
||||
'page_title' => 'Security - Dashboard',
|
||||
'sub_menu' => $this->subMenu,
|
||||
'unsecureUsers' => $unsecureUsers,
|
||||
]);
|
||||
}
|
||||
@@ -117,8 +117,8 @@ class SettingsController extends AbstractController
|
||||
$this->subMenu['stylesheet']['active'] = true;
|
||||
|
||||
return View::make('dashboard.settings.stylesheet')->with([
|
||||
'pageTitle' => 'Stylesheet - Dashboard',
|
||||
'subMenu' => $this->subMenu,
|
||||
'page_title' => 'Stylesheet - Dashboard',
|
||||
'sub_menu' => $this->subMenu,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -172,6 +172,10 @@ class SettingsController extends AbstractController
|
||||
|
||||
try {
|
||||
foreach (Binput::except(['app_banner', 'remove_banner']) as $settingName => $settingValue) {
|
||||
if ($settingName === 'app_analytics_pi_url') {
|
||||
$settingValue = rtrim($settingValue, '/');
|
||||
}
|
||||
|
||||
Setting::firstOrCreate([
|
||||
'name' => $settingName,
|
||||
])->update([
|
||||
|
||||
104
app/Http/Controllers/Admin/SubscriberController.php
Normal file
104
app/Http/Controllers/Admin/SubscriberController.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?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\Admin;
|
||||
|
||||
use CachetHQ\Cachet\Events\CustomerHasSubscribedEvent;
|
||||
use CachetHQ\Cachet\Http\Controllers\AbstractController;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class SubscriberController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* Shows the subscribers view.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function showSubscribers()
|
||||
{
|
||||
$subscribers = Subscriber::all();
|
||||
|
||||
return View::make('dashboard.subscribers.index')
|
||||
->with([
|
||||
'page_title' => trans('dashboard.subscribers.subscribers').' - '.trans('dashboard.dashboard'),
|
||||
'subscribers' => $subscribers,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the add subscriber view.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function showAddSubscriber()
|
||||
{
|
||||
return View::make('dashboard.subscribers.add')
|
||||
->with([
|
||||
'page_title' => trans('dashboard.subscribers.add.title').' - '.trans('dashboard.dashboard'),
|
||||
'incidentTemplates' => Subscriber::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new subscriber.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function createSubscriberAction()
|
||||
{
|
||||
$email = Binput::get('email');
|
||||
|
||||
$subscriber = Subscriber::create([
|
||||
'email' => $email,
|
||||
]);
|
||||
|
||||
if (!$subscriber->isValid()) {
|
||||
return Redirect::back()
|
||||
->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.subscribers.add.failure')
|
||||
))
|
||||
->with('errors', $subscriber->getErrors());
|
||||
}
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.subscribers.add.success')
|
||||
);
|
||||
|
||||
event(new CustomerHasSubscribedEvent($subscriber));
|
||||
|
||||
return Redirect::back()
|
||||
->with('success', $successMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a subscriber.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Subscriber $subscriber
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function deleteSubscriberAction(Subscriber $subscriber)
|
||||
{
|
||||
$subscriber->delete();
|
||||
|
||||
return Redirect::back();
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -29,7 +29,7 @@ class TeamController extends AbstractController
|
||||
$team = User::all();
|
||||
|
||||
return View::make('dashboard.team.index')->with([
|
||||
'pageTitle' => trans('dashboard.team.team').' - '.trans('dashboard.dashboard'),
|
||||
'page_title' => trans('dashboard.team.team').' - '.trans('dashboard.dashboard'),
|
||||
'teamMembers' => $team,
|
||||
]);
|
||||
}
|
||||
@@ -42,8 +42,8 @@ class TeamController extends AbstractController
|
||||
public function showTeamMemberView(User $user)
|
||||
{
|
||||
return View::make('dashboard.team.edit')->with([
|
||||
'pageTitle' => trans('dashboard.team.edit.title').' - '.trans('dashboard.dashboard'),
|
||||
'user' => $user,
|
||||
'page_title' => trans('dashboard.team.edit.title').' - '.trans('dashboard.dashboard'),
|
||||
'user' => $user,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class TeamController extends AbstractController
|
||||
public function showAddTeamMemberView()
|
||||
{
|
||||
return View::make('dashboard.team.add')->with([
|
||||
'pageTitle' => trans('dashboard.team.add.title').' - '.trans('dashboard.dashboard'),
|
||||
'page_title' => trans('dashboard.team.add.title').' - '.trans('dashboard.dashboard'),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -69,11 +69,6 @@ class TeamController extends AbstractController
|
||||
$user = User::create(Binput::all());
|
||||
|
||||
if (!$user->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Added User',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::except('password'))
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
@@ -83,11 +78,6 @@ class TeamController extends AbstractController
|
||||
->with('errors', $user->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Added User',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@@ -117,11 +107,6 @@ class TeamController extends AbstractController
|
||||
$user->update($items);
|
||||
|
||||
if (!$user->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Updated User',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::except('password'))
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
@@ -131,11 +116,6 @@ class TeamController extends AbstractController
|
||||
->with('errors', $user->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Updated User',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -29,7 +29,7 @@ class UserController extends AbstractController
|
||||
public function showUser()
|
||||
{
|
||||
return View::make('dashboard.user.index')->with([
|
||||
'pageTitle' => trans('dashboard.team.profile').' - '.trans('dashboard.dashboard'),
|
||||
'page_title' => trans('dashboard.team.profile').' - '.trans('dashboard.dashboard'),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -48,18 +48,8 @@ class UserController extends AbstractController
|
||||
// Let's enable/disable auth
|
||||
if ($enable2FA && !Auth::user()->hasTwoFactor) {
|
||||
$items['google_2fa_secret'] = Google2FA::generateSecretKey();
|
||||
|
||||
segment_track('User Management', [
|
||||
'event' => 'enabled_two_factor',
|
||||
'value' => true,
|
||||
]);
|
||||
} elseif (!$enable2FA) {
|
||||
$items['google_2fa_secret'] = '';
|
||||
|
||||
segment_track('User Management', [
|
||||
'event' => 'enabled_two_factor',
|
||||
'value' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
if (trim($passwordChange) === '') {
|
||||
@@ -95,10 +85,6 @@ class UserController extends AbstractController
|
||||
*/
|
||||
public function regenerateApiKey(User $user)
|
||||
{
|
||||
segment_track('User Management', [
|
||||
'event' => 'regenrated_api_token',
|
||||
]);
|
||||
|
||||
$user->api_key = User::generateApiKey();
|
||||
$user->save();
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -159,7 +159,15 @@ abstract class AbstractApiController extends BaseController
|
||||
],
|
||||
];
|
||||
|
||||
return $this->setMetaData($pagination)->setData(AutoPresenter::decorate($paginator->getCollection()))->respond();
|
||||
$items = $paginator->getCollection();
|
||||
|
||||
if ($sortBy = $request->get('sort')) {
|
||||
$direction = $request->has('order') && $request->get('order') == 'desc';
|
||||
|
||||
$items = $items->sortBy($sortBy, SORT_REGULAR, $direction);
|
||||
}
|
||||
|
||||
return $this->setMetaData($pagination)->setData(AutoPresenter::decorate($items->values()->all()))->respond();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -63,6 +63,10 @@ class IncidentController extends AbstractApiController
|
||||
{
|
||||
$incidentData = Binput::all();
|
||||
|
||||
if (!array_has($incidentData, 'visible')) {
|
||||
$incidentData['visible'] = 1;
|
||||
}
|
||||
|
||||
try {
|
||||
$incident = Incident::create($incidentData);
|
||||
} catch (Exception $e) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
77
app/Http/Controllers/Api/SubscriberController.php
Normal file
77
app/Http/Controllers/Api/SubscriberController.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?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\Events\CustomerHasSubscribedEvent;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use Exception;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
class SubscriberController extends AbstractApiController
|
||||
{
|
||||
/**
|
||||
* Get all subscribers.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public function getSubscribers(Request $request)
|
||||
{
|
||||
$subscribers = Subscriber::paginate(Binput::get('per_page', 20));
|
||||
|
||||
return $this->paginator($subscribers, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new subscriber.
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\Subscriber
|
||||
*/
|
||||
public function postSubscribers()
|
||||
{
|
||||
$subscriberData = Binput::except('verify');
|
||||
|
||||
try {
|
||||
$subscriber = Subscriber::create($subscriberData);
|
||||
} catch (Exception $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
if ($subscriber->isValid()) {
|
||||
// If we're auto-verifying the subscriber, don't bother with this event.
|
||||
if (!(Binput::get('verify'))) {
|
||||
event(new CustomerHasSubscribedEvent($subscriber));
|
||||
}
|
||||
|
||||
return $this->item($subscriber);
|
||||
}
|
||||
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a subscriber.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Subscriber $subscriber
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function deleteSubscriber(Subscriber $subscriber)
|
||||
{
|
||||
$subscriber->delete();
|
||||
|
||||
return $this->noContent();
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -12,7 +12,6 @@
|
||||
namespace CachetHQ\Cachet\Http\Controllers;
|
||||
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use GrahamCampbell\Throttle\Facades\Throttle;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
@@ -33,7 +32,7 @@ class AuthController extends AbstractController
|
||||
public function showLogin()
|
||||
{
|
||||
return View::make('auth.login')->with([
|
||||
'pageTitle' => trans('dashboard.login.login'),
|
||||
'page_title' => trans('dashboard.login.login'),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -57,16 +56,12 @@ class AuthController extends AbstractController
|
||||
return Redirect::route('two-factor');
|
||||
}
|
||||
|
||||
// We probably wan't to add support for "Remember me" here.
|
||||
// We probably want to add support for "Remember me" here.
|
||||
Auth::attempt(Binput::only(['email', 'password']));
|
||||
|
||||
segment_track('Logged In');
|
||||
|
||||
return Redirect::intended('dashboard');
|
||||
}
|
||||
|
||||
Throttle::hit(Request::instance(), 10, 10);
|
||||
|
||||
return Redirect::back()
|
||||
->withInput(Binput::except('password'))
|
||||
->with('error', trans('forms.login.invalid'));
|
||||
@@ -122,8 +117,6 @@ class AuthController extends AbstractController
|
||||
{
|
||||
Auth::logout();
|
||||
|
||||
segment_track('Logged Out');
|
||||
|
||||
return Redirect::to('/');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -35,18 +35,12 @@ class HomeController extends AbstractController
|
||||
$today = Date::now();
|
||||
$startDate = Date::now();
|
||||
|
||||
segment_page('Status Page');
|
||||
|
||||
// Check if we have another starting date
|
||||
if (Binput::has('start_date')) {
|
||||
try {
|
||||
// If date provided is valid
|
||||
$oldDate = Date::createFromFormat('Y-m-d', Binput::get('start_date'));
|
||||
|
||||
segment_track('Status Page', [
|
||||
'start_date' => $oldDate->format('Y-m-d'),
|
||||
]);
|
||||
|
||||
// If trying to get a future date fallback to today
|
||||
if ($today->gt($oldDate)) {
|
||||
$startDate = $oldDate;
|
||||
@@ -71,7 +65,13 @@ class HomeController extends AbstractController
|
||||
$allIncidents = Incident::notScheduled()->where('visible', '>=', $incidentVisiblity)->whereBetween('created_at', [
|
||||
$startDate->copy()->subDays($daysToShow)->format('Y-m-d').' 00:00:00',
|
||||
$startDate->format('Y-m-d').' 23:59:59',
|
||||
])->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) use ($dateTimeZone) {
|
||||
])->orderBy('scheduled_at', 'desc')->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) use ($dateTimeZone) {
|
||||
// If it's scheduled, get the scheduled at date.
|
||||
if ($incident->is_scheduled) {
|
||||
return (new Date($incident->scheduled_at))
|
||||
->setTimezone($dateTimeZone)->toDateString();
|
||||
}
|
||||
|
||||
return (new Date($incident->created_at))
|
||||
->setTimezone($dateTimeZone)->toDateString();
|
||||
});
|
||||
@@ -112,7 +112,7 @@ class HomeController extends AbstractController
|
||||
'canPageBackward' => $canPageBackward,
|
||||
'previousDate' => $startDate->copy()->subDays($daysToShow)->toDateString(),
|
||||
'nextDate' => $startDate->copy()->addDays($daysToShow)->toDateString(),
|
||||
'pageTitle' => Setting::get('app_name').' Status',
|
||||
'page_title' => Setting::get('app_name'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -31,9 +31,12 @@ class SetupController extends AbstractController
|
||||
* @var string[]
|
||||
*/
|
||||
protected $cacheDrivers = [
|
||||
'apc' => 'APC(u)',
|
||||
'file' => 'File',
|
||||
'database' => 'Database',
|
||||
'apc' => 'APC(u)',
|
||||
'array' => 'Array',
|
||||
'file' => 'File',
|
||||
'database' => 'Database',
|
||||
'memcached' => 'Memcached',
|
||||
'redis' => 'Redis',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -51,15 +54,13 @@ class SetupController extends AbstractController
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
segment_page('Setup');
|
||||
|
||||
// If we've copied the .env.example file, then we should try and reset it ready for Segment to kick in.
|
||||
// If we've copied the .env.example file, then we should try and reset it.
|
||||
if (getenv('APP_KEY') === 'SomeRandomString') {
|
||||
$this->keyGenerate();
|
||||
}
|
||||
|
||||
return View::make('setup')->with([
|
||||
'pageTitle' => trans('setup.setup'),
|
||||
'page_title' => trans('setup.setup'),
|
||||
'cacheDrivers' => $this->cacheDrivers,
|
||||
'appUrl' => Request::root(),
|
||||
]);
|
||||
@@ -80,19 +81,8 @@ class SetupController extends AbstractController
|
||||
]);
|
||||
|
||||
if ($v->passes()) {
|
||||
segment_track('Setup', [
|
||||
'event' => 'Step 1',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
return Response::json(['status' => 1]);
|
||||
} else {
|
||||
// No good, let's try that again.
|
||||
segment_track('Setup', [
|
||||
'event' => 'Step 1',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Response::json(['errors' => $v->messages()], 400);
|
||||
}
|
||||
}
|
||||
@@ -117,19 +107,8 @@ class SetupController extends AbstractController
|
||||
]);
|
||||
|
||||
if ($v->passes()) {
|
||||
segment_track('Setup', [
|
||||
'event' => 'Step 2',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
return Response::json(['status' => 1]);
|
||||
} else {
|
||||
// No good, let's try that again.
|
||||
segment_track('Setup', [
|
||||
'event' => 'Step 2',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Response::json(['errors' => $v->messages()], 400);
|
||||
}
|
||||
}
|
||||
@@ -187,25 +166,12 @@ class SetupController extends AbstractController
|
||||
|
||||
Session::flash('setup.done', true);
|
||||
|
||||
segment_track('Setup', [
|
||||
'event' => 'Step 3',
|
||||
'success' => true,
|
||||
'cache_driver' => $envData['cache_driver'],
|
||||
'session_driver' => $envData['session_driver'],
|
||||
]);
|
||||
|
||||
if (Request::ajax()) {
|
||||
return Response::json(['status' => 1]);
|
||||
}
|
||||
|
||||
return Redirect::to('dashboard');
|
||||
} else {
|
||||
segment_track('Setup', [
|
||||
'event' => 'Step 3',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
// No good, let's try that again.
|
||||
if (Request::ajax()) {
|
||||
return Response::json(['errors' => $v->messages()], 400);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -31,8 +31,8 @@ class SubscribeController extends AbstractController
|
||||
public function showSubscribe()
|
||||
{
|
||||
return View::make('subscribe', [
|
||||
'pageTitle' => Setting::get('app_name'),
|
||||
'aboutApp' => Markdown::convertToHtml(Setting::get('app_about')),
|
||||
'page_title' => Setting::get('app_name'),
|
||||
'aboutApp' => Markdown::convertToHtml(Setting::get('app_about')),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -46,11 +46,6 @@ class SubscribeController extends AbstractController
|
||||
$subscriber = Subscriber::create(['email' => Binput::get('email')]);
|
||||
|
||||
if (!$subscriber->isValid()) {
|
||||
segment_track('Subscribers', [
|
||||
'event' => 'Customer Subscribed',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'<strong>%s</strong> %s',
|
||||
@@ -60,11 +55,6 @@ class SubscribeController extends AbstractController
|
||||
->with('errors', $subscriber->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Subscribers', [
|
||||
'event' => 'Customer Subscribed',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'<strong>%s</strong> %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@@ -98,11 +88,6 @@ class SubscribeController extends AbstractController
|
||||
$subscriber->verified_at = Carbon::now();
|
||||
$subscriber->save();
|
||||
|
||||
segment_track('Subscribers', [
|
||||
'event' => 'Customer Email Verified',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'<strong>%s</strong> %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@@ -133,11 +118,6 @@ class SubscribeController extends AbstractController
|
||||
|
||||
$subscriber->delete();
|
||||
|
||||
segment_track('Subscribers', [
|
||||
'event' => 'Customer Unsubscribed',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'<strong>%s</strong> %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -35,16 +35,16 @@ class Kernel extends HttpKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => 'CachetHQ\Cachet\Http\Middleware\Authenticate',
|
||||
'auth.api' => 'CachetHQ\Cachet\Http\Middleware\ApiAuthenticate',
|
||||
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
|
||||
'guest' => 'CachetHQ\Cachet\Http\Middleware\RedirectIfAuthenticated',
|
||||
'csrf' => 'Illuminate\Foundation\Http\Middleware\VerifyCsrfToken',
|
||||
'admin' => 'CachetHQ\Cachet\Http\Middleware\Admin',
|
||||
'login.throttling' => 'CachetHQ\Cachet\Http\Middleware\LoginThrottling',
|
||||
'app.isSetup' => 'CachetHQ\Cachet\Http\Middleware\AppIsSetup',
|
||||
'app.hasSetting' => 'CachetHQ\Cachet\Http\Middleware\HasSetting',
|
||||
'app.subscribers' => 'CachetHQ\Cachet\Http\Middleware\SubscribersConfigured',
|
||||
'accept' => 'CachetHQ\Cachet\Http\Middleware\Acceptable',
|
||||
'auth' => 'CachetHQ\Cachet\Http\Middleware\Authenticate',
|
||||
'auth.api' => 'CachetHQ\Cachet\Http\Middleware\ApiAuthenticate',
|
||||
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
|
||||
'guest' => 'CachetHQ\Cachet\Http\Middleware\RedirectIfAuthenticated',
|
||||
'csrf' => 'Illuminate\Foundation\Http\Middleware\VerifyCsrfToken',
|
||||
'admin' => 'CachetHQ\Cachet\Http\Middleware\Admin',
|
||||
'throttling' => 'GrahamCampbell\Throttle\Http\Middleware\ThrottleMiddleware',
|
||||
'app.isSetup' => 'CachetHQ\Cachet\Http\Middleware\AppIsSetup',
|
||||
'app.hasSetting' => 'CachetHQ\Cachet\Http\Middleware\HasSetting',
|
||||
'app.subscribers' => 'CachetHQ\Cachet\Http\Middleware\SubscribersConfigured',
|
||||
'accept' => 'CachetHQ\Cachet\Http\Middleware\Acceptable',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use GrahamCampbell\Throttle\Facades\Throttle;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
|
||||
class LoginThrottling
|
||||
{
|
||||
/**
|
||||
* Run the login throttling middleware.
|
||||
*
|
||||
* We're verifying that the user is not attempting to brute force Cachet's
|
||||
* login system. If the user has reached the rate limit, then we're sending
|
||||
* them away, otherwise, we do nothing, and allow them to continue.
|
||||
*
|
||||
* Note that this filter is not responsible for incrementing the hit count.
|
||||
* Another part of Cachet will increment the hit count for the given route
|
||||
* only if validation passes, and the user did not successfully login.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (!Throttle::check($request, 10, 10)) {
|
||||
return Redirect::back()->with('error', 'You have made too many login requests.');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
|
||||
@@ -27,11 +26,7 @@ class SubscribersConfigured
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$isEnabled = Setting::get('enable_subscribers', false);
|
||||
$mailAddress = env('MAIL_ADDRESS', false);
|
||||
$mailFrom = env('MAIL_NAME', false);
|
||||
|
||||
if (!($isEnabled && $mailAddress && $mailFrom)) {
|
||||
if (!subscribers_enabled()) {
|
||||
return Redirect::route('status-page');
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -121,6 +121,22 @@ class AdminRoutes
|
||||
$router->delete('{incident_template}/delete', 'IncidentController@deleteTemplateAction');
|
||||
});
|
||||
|
||||
// Subscribers
|
||||
$router->group(['prefix' => 'subscribers'], function ($router) {
|
||||
$router->get('/', [
|
||||
'as' => 'dashboard.subscribers',
|
||||
'uses' => 'SubscriberController@showSubscribers',
|
||||
]);
|
||||
|
||||
$router->get('add', [
|
||||
'as' => 'dashboard.subscribers.add',
|
||||
'uses' => 'SubscriberController@showAddSubscriber',
|
||||
]);
|
||||
$router->post('add', 'SubscriberController@createSubscriberAction');
|
||||
|
||||
$router->delete('{subscriber}/delete', 'SubscriberController@deleteSubscriberAction');
|
||||
});
|
||||
|
||||
// Metrics
|
||||
$router->group(['prefix' => 'metrics'], function ($router) {
|
||||
$router->get('/', [
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -45,10 +45,13 @@ class ApiRoutes
|
||||
|
||||
// Api protected
|
||||
$router->group(['middleware' => 'auth.api'], function ($router) {
|
||||
$router->get('subscribers', 'SubscriberController@getSubscribers');
|
||||
|
||||
$router->post('components', 'ComponentController@postComponents');
|
||||
$router->post('incidents', 'IncidentController@postIncidents');
|
||||
$router->post('metrics', 'MetricController@postMetrics');
|
||||
$router->post('metrics/{metric}/points', 'MetricPointController@postMetricPoints');
|
||||
$router->post('subscribers', 'SubscriberController@postSubscribers');
|
||||
|
||||
$router->put('components/{component}', 'ComponentController@putComponent');
|
||||
$router->put('incidents/{incident}', 'IncidentController@putIncident');
|
||||
@@ -59,6 +62,7 @@ class ApiRoutes
|
||||
$router->delete('incidents/{incident}', 'IncidentController@deleteIncident');
|
||||
$router->delete('metrics/{metric}', 'MetricController@deleteMetric');
|
||||
$router->delete('metrics/{metric}/points/{metric_point}', 'MetricPointController@deleteMetricPoint');
|
||||
$router->delete('subscribers/{subscriber}', 'SubscriberController@deleteSubscriber');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -32,8 +32,8 @@ class AuthRoutes
|
||||
]);
|
||||
|
||||
$router->post('login', [
|
||||
'middleware' => ['guest', 'csrf', 'login.throttling'],
|
||||
'as' => 'logout',
|
||||
'middleware' => ['guest', 'csrf', 'throttling:10,10'],
|
||||
'as' => 'login',
|
||||
'uses' => 'AuthController@postLogin',
|
||||
]);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -31,25 +31,6 @@ class StatusPageRoutes
|
||||
|
||||
$router->get('/atom/{component_group?}', 'AtomController@feedAction');
|
||||
$router->get('/rss/{component_group?}', 'RssController@feedAction');
|
||||
|
||||
$router->group(['middleware' => 'app.subscribers'], function ($router) {
|
||||
$router->get('subscribe', [
|
||||
'as' => 'subscribe-page',
|
||||
'uses' => 'SubscribeController@showSubscribe',
|
||||
]);
|
||||
$router->post('subscribe', [
|
||||
'as' => 'subscribe',
|
||||
'uses' => 'SubscribeController@postSubscribe',
|
||||
]);
|
||||
$router->get('subscribe/verify/{code}', [
|
||||
'as' => 'subscribe-verify',
|
||||
'uses' => 'SubscribeController@getVerify',
|
||||
]);
|
||||
$router->get('unsubscribe/{code}', [
|
||||
'as' => 'unsubscribe',
|
||||
'uses' => 'SubscribeController@getUnsubscribe',
|
||||
]);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
49
app/Http/Routes/SubscribeRoutes.php
Normal file
49
app/Http/Routes/SubscribeRoutes.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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\Routes;
|
||||
|
||||
use Illuminate\Contracts\Routing\Registrar;
|
||||
|
||||
class SubscribeRoutes
|
||||
{
|
||||
/**
|
||||
* Define the subscribe routes.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Routing\Registrar $router
|
||||
*/
|
||||
public function map(Registrar $router)
|
||||
{
|
||||
$router->group(['middleware' => 'app.hasSetting', 'setting' => 'app_name'], function ($router) {
|
||||
$router->group(['middleware' => 'app.subscribers'], function ($router) {
|
||||
$router->get('subscribe', [
|
||||
'as' => 'subscribe-page',
|
||||
'uses' => 'SubscribeController@showSubscribe',
|
||||
]);
|
||||
|
||||
$router->post('subscribe', [
|
||||
'as' => 'subscribe',
|
||||
'uses' => 'SubscribeController@postSubscribe',
|
||||
]);
|
||||
|
||||
$router->get('subscribe/verify/{code}', [
|
||||
'as' => 'subscribe-verify',
|
||||
'uses' => 'SubscribeController@getVerify',
|
||||
]);
|
||||
|
||||
$router->get('unsubscribe/{code}', [
|
||||
'as' => 'unsubscribe',
|
||||
'uses' => 'SubscribeController@getUnsubscribe',
|
||||
]);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -3,15 +3,13 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use CachetHQ\Segment\Facades\Segment;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
@@ -32,113 +30,12 @@ if (!function_exists('set_active')) {
|
||||
$classes[] = $active;
|
||||
}
|
||||
|
||||
$class = implode(' ', $classes);
|
||||
$class = e(implode(' ', $classes));
|
||||
|
||||
return empty($classes) ? '' : "class=\"{$class}\"";
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('segment_identify')) {
|
||||
/**
|
||||
* Identifies the user for Segment.com.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function segment_identify()
|
||||
{
|
||||
if (Config::get('segment.write_key')) {
|
||||
try {
|
||||
if (Setting::get('app_track')) {
|
||||
return Segment::identify([
|
||||
'anonymousId' => Config::get('app.key'),
|
||||
'context' => [
|
||||
'locale' => Config::get('app.locale'),
|
||||
'timezone' => Setting::get('app_timezone'),
|
||||
'DB_DRIVER' => getenv('DB_DRIVER'),
|
||||
'CACHE_DRIVER' => getenv('CACHE_DRIVER'),
|
||||
'SESSION_DRIVER' => getenv('SESSION_DRIVER'),
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (QueryException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('segment_track')) {
|
||||
/**
|
||||
* Tracks events in Segment.com.
|
||||
*
|
||||
* @param string $event
|
||||
* @param array $properties
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function segment_track($event, array $properties = [])
|
||||
{
|
||||
if (Config::get('segment.write_key')) {
|
||||
try {
|
||||
if (Setting::get('app_track')) {
|
||||
return Segment::track([
|
||||
'anonymousId' => Config::get('app.key'),
|
||||
'event' => $event,
|
||||
'properties' => $properties,
|
||||
'context' => [
|
||||
'locale' => Config::get('app.locale'),
|
||||
'timezone' => Setting::get('app_timezone'),
|
||||
'DB_DRIVER' => getenv('DB_DRIVER'),
|
||||
'CACHE_DRIVER' => getenv('CACHE_DRIVER'),
|
||||
'SESSION_DRIVER' => getenv('SESSION_DRIVER'),
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (QueryException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('segment_page')) {
|
||||
/**
|
||||
* Tracks pages in Segment.com.
|
||||
*
|
||||
* @param string $page
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function segment_page($page)
|
||||
{
|
||||
if (Config::get('segment.write_key')) {
|
||||
try {
|
||||
if (Setting::get('app_track')) {
|
||||
return Segment::page([
|
||||
'anonymousId' => Config::get('app.key'),
|
||||
'name' => $page,
|
||||
'context' => [
|
||||
'locale' => Config::get('app.locale'),
|
||||
'timezone' => Setting::get('app_timezone'),
|
||||
'DB_DRIVER' => getenv('DB_DRIVER'),
|
||||
'CACHE_DRIVER' => getenv('CACHE_DRIVER'),
|
||||
'SESSION_DRIVER' => getenv('SESSION_DRIVER'),
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (QueryException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('formatted_date')) {
|
||||
/**
|
||||
* Formats a date with the user timezone and the selected format.
|
||||
@@ -154,3 +51,19 @@ if (!function_exists('formatted_date')) {
|
||||
return (new Date($date))->format($dateFormat);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('subscribers_enabled')) {
|
||||
/**
|
||||
* Is the subscriber functionality enabled and configured.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function subscribers_enabled()
|
||||
{
|
||||
$isEnabled = Setting::get('enable_subscribers', false);
|
||||
$mailAddress = env('MAIL_ADDRESS', false);
|
||||
$mailFrom = env('MAIL_NAME', false);
|
||||
|
||||
return $isEnabled && $mailAddress && $mailFrom;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -141,7 +141,7 @@ class Incident extends Model implements HasPresenter
|
||||
*/
|
||||
public function getIsScheduledAttribute()
|
||||
{
|
||||
return $this->getOriginal('scheduled_at');
|
||||
return $this->getOriginal('scheduled_at') !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -59,6 +59,13 @@ class Metric extends Model implements HasPresenter
|
||||
*/
|
||||
protected $fillable = ['name', 'suffix', 'description', 'display_chart', 'default_value', 'calc_type'];
|
||||
|
||||
/**
|
||||
* The relations to eager load on every query.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $with = ['points'];
|
||||
|
||||
/**
|
||||
* Metrics contain many metric points.
|
||||
*
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -11,13 +11,14 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Models;
|
||||
|
||||
use CachetHQ\Cachet\Presenters\SubscriberPresenter;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use McCool\LaravelAutoPresenter\HasPresenter;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
class Subscriber extends Model
|
||||
class Subscriber extends Model implements HasPresenter
|
||||
{
|
||||
use SoftDeletes, ValidatingTrait;
|
||||
use ValidatingTrait;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
@@ -40,7 +41,17 @@ class Subscriber extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = ['deleted_at', 'verified_at'];
|
||||
protected $dates = ['verified_at'];
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $casts = [
|
||||
'email' => 'string',
|
||||
'verify_code' => 'string',
|
||||
];
|
||||
|
||||
/**
|
||||
* Overrides the models boot method.
|
||||
@@ -75,4 +86,14 @@ class Subscriber extends Model
|
||||
{
|
||||
return str_random(42);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the presenter class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPresenterClass()
|
||||
{
|
||||
return SubscriberPresenter::class;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -25,8 +25,9 @@ class ComponentPresenter extends AbstractPresenter
|
||||
public function toArray()
|
||||
{
|
||||
return array_merge($this->wrappedObject->toArray(), [
|
||||
'created_at' => $this->created_at(),
|
||||
'updated_at' => $this->updated_at(),
|
||||
'created_at' => $this->created_at(),
|
||||
'updated_at' => $this->updated_at(),
|
||||
'status_name' => $this->wrappedObject->humanStatus,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -129,6 +129,34 @@ class IncidentPresenter extends AbstractPresenter
|
||||
return $this->wrappedObject->scheduled_at->setTimezone($this->setting->get('app_timezone'))->format('d/m/Y H:i');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
} else {
|
||||
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;
|
||||
} else {
|
||||
return $this->created_at_iso;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Present the status with an icon.
|
||||
*
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
33
app/Presenters/SubscriberPresenter.php
Normal file
33
app/Presenters/SubscriberPresenter.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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\Presenters\Traits\TimestampsTrait;
|
||||
|
||||
class SubscriberPresenter extends AbstractPresenter
|
||||
{
|
||||
use TimestampsTrait;
|
||||
|
||||
/**
|
||||
* Convert the presenter instance to an array.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return array_merge($this->wrappedObject->toArray(), [
|
||||
'created_at' => $this->created_at(),
|
||||
'updated_at' => $this->updated_at(),
|
||||
'verified_at' => $this->verified_at(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -47,4 +47,15 @@ trait TimestampsTrait
|
||||
return (new Date($this->wrappedObject->deleted_at))
|
||||
->setTimezone($this->setting->get('app_timezone'))->toDateTimeString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Present formatted date time.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function verified_at()
|
||||
{
|
||||
return (new Date($this->wrappedObject->verified_at))
|
||||
->setTimezone($this->setting->get('app_timezone'))->toDateTimeString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -31,12 +31,6 @@ class ConfigServiceProvider extends ServiceProvider
|
||||
$appDomain = Setting::get('app_domain');
|
||||
$appLocale = Setting::get('app_locale');
|
||||
|
||||
// Set the Segment.com settings.
|
||||
if (Setting::get('app_track')) {
|
||||
$segmentRepository = $this->app->make('CachetHQ\Cachet\Segment\RepositoryInterface');
|
||||
$this->app->config->set('segment.write_key', $segmentRepository->fetch());
|
||||
}
|
||||
|
||||
// Setup Cors.
|
||||
$allowedOrigins = $this->app->config->get('cors.defaults.allowedOrigins');
|
||||
$allowedOrigins[] = Setting::get('app_domain');
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -49,6 +49,7 @@ class RouteServiceProvider extends ServiceProvider
|
||||
$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('user', 'CachetHQ\Cachet\Models\User');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Providers;
|
||||
|
||||
use CachetHQ\Cachet\Segment\CacheRepository;
|
||||
use CachetHQ\Cachet\Segment\HttpRepository;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class SegmentServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register the service provider.
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->singleton('CachetHQ\Cachet\Segment\RepositoryInterface', function () {
|
||||
$url = 'https://gist.githubusercontent.com/jbrooksuk/5de24bc1cf90fb1a3d57/raw/cachet.json';
|
||||
$guzzleClient = new Client();
|
||||
$client = new HttpRepository($guzzleClient, $url);
|
||||
|
||||
return new CacheRepository($client);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Segment;
|
||||
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use CachetHQ\Cachet\Models\Setting as SettingModel;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
class CacheRepository implements RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* The underlying segment repository instance.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Segment\RepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* Create a new segment cache repository instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Segment\RepositoryInterface $repository
|
||||
*/
|
||||
public function __construct(RepositoryInterface $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the segment write key.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetch()
|
||||
{
|
||||
$writeKey = null;
|
||||
|
||||
try {
|
||||
// Firstly, does the setting exist?
|
||||
if (null === ($writeKey = Setting::get('segment_write_key'))) {
|
||||
// No, let's go fetch it.
|
||||
$writeKey = $this->repository->fetch();
|
||||
Setting::set('segment_write_key', $writeKey);
|
||||
} else {
|
||||
// It does, but how old is it?
|
||||
$setting = SettingModel::where('name', 'segment_write_key')->first();
|
||||
|
||||
// It's older than an hour, let's refresh
|
||||
if ($setting->updated_at->lt(Carbon::now()->subHour())) {
|
||||
$writeKey = $this->repository->fetch();
|
||||
|
||||
// Update the setting. This is done manual to make sure updated_at is overwritten.
|
||||
$setting->value = $writeKey;
|
||||
$setting->updated_at = Carbon::now();
|
||||
$setting->save();
|
||||
}
|
||||
}
|
||||
} catch (QueryException $e) {
|
||||
// Just return it until we're setup.
|
||||
$writeKey = $this->repository->fetch();
|
||||
}
|
||||
|
||||
return $writeKey;
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Segment;
|
||||
|
||||
use GuzzleHttp\ClientInterface;
|
||||
|
||||
class HttpRepository implements RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* The guzzle client instance.
|
||||
*
|
||||
* @var \GuzzleHttp\ClientInterface
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* The url to use.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* Create a new segment http repository instance.
|
||||
*
|
||||
* @param \GuzzleHttp\ClientInterface $client
|
||||
* @param string $url
|
||||
*/
|
||||
public function __construct(ClientInterface $client, $url)
|
||||
{
|
||||
$this->client = $client;
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the segment write key.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetch()
|
||||
{
|
||||
$response = $this->client->get($this->url);
|
||||
|
||||
$body = json_decode($response->getBody());
|
||||
|
||||
return $body->segment_write_key;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Segment;
|
||||
|
||||
interface RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Returns the segment write key.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetch();
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
0
bootstrap/cache/.gitignore
vendored
Normal file → Executable file
0
bootstrap/cache/.gitignore
vendored
Normal file → Executable file
@@ -7,38 +7,39 @@
|
||||
"authors": [
|
||||
{
|
||||
"name": "James Brooks",
|
||||
"email": "james@cachethq.io"
|
||||
"email": "james@alt-three.com"
|
||||
},
|
||||
{
|
||||
"name": "Graham Campbell",
|
||||
"email": "graham@cachethq.io"
|
||||
"email": "graham@alt-three.com"
|
||||
},
|
||||
{
|
||||
"name": "Joseph Cohen",
|
||||
"email": "joe@cachethq.io"
|
||||
"email": "joe@alt-three.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^5.5.9",
|
||||
"laravel/framework": "~5.1.3",
|
||||
"cachethq/segment": "^2.1",
|
||||
"laravel/framework": "~5.1.16",
|
||||
"alt-three/emoji": "^1.2",
|
||||
"barryvdh/laravel-cors": "^0.5",
|
||||
"doctrine/dbal": "^2.5",
|
||||
"fideloper/proxy": "^3.0",
|
||||
"graham-campbell/binput": "^3.1",
|
||||
"graham-campbell/markdown": "^3.1",
|
||||
"graham-campbell/throttle": "^4.0",
|
||||
"graham-campbell/exceptions": "^3.0",
|
||||
"guzzlehttp/guzzle": "^6.0",
|
||||
"graham-campbell/binput": "^3.2",
|
||||
"graham-campbell/markdown": "^4.0",
|
||||
"graham-campbell/throttle": "^4.1",
|
||||
"graham-campbell/exceptions": "^4.0",
|
||||
"guzzlehttp/guzzle": "^6.0.2",
|
||||
"jenssegers/date": "^3.0",
|
||||
"mccool/laravel-auto-presenter": "^3.0",
|
||||
"mccool/laravel-auto-presenter": "^3.1",
|
||||
"pragmarx/google2fa": "^0.5",
|
||||
"roumen/feed": "^2.9",
|
||||
"watson/validating": "^1.0",
|
||||
"barryvdh/laravel-cors": "^0.5"
|
||||
"watson/validating": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.6",
|
||||
"fzaninotto/faker": "^1.5"
|
||||
"fzaninotto/faker": "^1.5",
|
||||
"mockery/mockery": "^0.9.4",
|
||||
"phpunit/phpunit": "^4.7.6"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
@@ -57,16 +58,22 @@
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"pre-install-cmd": [
|
||||
"rm -f compiled.php config.php routes.php services.json"
|
||||
],
|
||||
"post-install-cmd": [
|
||||
"php artisan clear-compiled",
|
||||
"php artisan optimize",
|
||||
"php artisan optimize --force",
|
||||
"php artisan config:cache",
|
||||
"php artisan route:cache",
|
||||
"chmod -R 755 storage"
|
||||
],
|
||||
"pre-update-cmd": [
|
||||
"php artisan clear-compiled"
|
||||
"rm -f compiled.php config.php routes.php services.json"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"php artisan optimize",
|
||||
"php artisan optimize --force",
|
||||
"php artisan config:cache",
|
||||
"php artisan route:cache",
|
||||
"chmod -R 755 storage"
|
||||
],
|
||||
"post-create-project-cmd": [
|
||||
@@ -79,7 +86,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
"dev-master": "1.2-dev"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
|
||||
961
composer.lock
generated
961
composer.lock
generated
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user