More fixes
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers;
|
||||
|
||||
use CachetHQ\Cachet\Dates\DateFactory;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use Exception;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
@@ -54,27 +55,19 @@ class StatusPageController extends Controller
|
||||
} else {
|
||||
$incidentDays = range(0, $daysToShow);
|
||||
}
|
||||
$dateTimeZone = Config::get('cachet.timezone');
|
||||
|
||||
$incidentVisibility = Auth::check() ? 0 : 1;
|
||||
|
||||
$allIncidents = Incident::notScheduled()->where('visible', '>=', $incidentVisibility)->whereBetween('created_at', [
|
||||
$startDate->copy()->subDays($daysToShow)->format('Y-m-d').' 00:00:00',
|
||||
$startDate->format('Y-m-d').' 23:59:59',
|
||||
])->orderBy('scheduled_at', 'desc')->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) 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();
|
||||
])->orderBy('scheduled_at', 'desc')->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) {
|
||||
return app(DateFactory::class)->make($incident->is_scheduled ? $incident->scheduled_at : $incident->created_at)->toDateString();
|
||||
});
|
||||
|
||||
// Add in days that have no incidents
|
||||
foreach ($incidentDays as $i) {
|
||||
$date = (new Date($startDate))->setTimezone($dateTimeZone)->subDays($i);
|
||||
$date = app(DateFactory::class)->make($startDate)->subDays($i);
|
||||
|
||||
if (!isset($allIncidents[$date->toDateString()])) {
|
||||
$allIncidents[$date->toDateString()] = [];
|
||||
|
||||
@@ -28,6 +28,8 @@ class Admin
|
||||
* Create a new admin middleware instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Guard $auth
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
|
||||
@@ -12,9 +12,29 @@
|
||||
namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
|
||||
class Timezone
|
||||
{
|
||||
/**
|
||||
* Config repository.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Creates a new release instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Config\Repository $config
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Repository $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
@@ -26,7 +46,7 @@ class Timezone
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($tz = $request->header('Time-Zone')) {
|
||||
app('config')->set('cachet.timezone', $tz);
|
||||
$this->config->set('cachet.timezone', $tz);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
||||
Reference in New Issue
Block a user