diff --git a/app/Bus/Handlers/Commands/Schedule/CreateScheduleCommandHandler.php b/app/Bus/Handlers/Commands/Schedule/CreateScheduleCommandHandler.php index 9069eadb9c0..45258b5129f 100644 --- a/app/Bus/Handlers/Commands/Schedule/CreateScheduleCommandHandler.php +++ b/app/Bus/Handlers/Commands/Schedule/CreateScheduleCommandHandler.php @@ -66,6 +66,7 @@ public function handle(CreateScheduleCommand $command) { try { $schedule = Schedule::create($this->filter($command)); + $schedule->attachComponents($command->components); event(new ScheduleWasCreatedEvent($this->auth->user(), $schedule, (bool) $command->notify)); } catch (InvalidArgumentException $e) { throw new ValidationException(new MessageBag([$e->getMessage()])); diff --git a/app/Bus/Handlers/Commands/Schedule/DeleteScheduleCommandHandler.php b/app/Bus/Handlers/Commands/Schedule/DeleteScheduleCommandHandler.php index cf5f62278a5..d0971f27c93 100644 --- a/app/Bus/Handlers/Commands/Schedule/DeleteScheduleCommandHandler.php +++ b/app/Bus/Handlers/Commands/Schedule/DeleteScheduleCommandHandler.php @@ -53,7 +53,6 @@ public function handle(DeleteScheduleCommand $command) $schedule = $command->schedule; event(new ScheduleWasRemovedEvent($this->auth->user(), $schedule)); - $schedule->delete(); } } diff --git a/app/Bus/Handlers/Commands/Schedule/UpdateScheduleCommandHandler.php b/app/Bus/Handlers/Commands/Schedule/UpdateScheduleCommandHandler.php index 72f74328010..00f17b2670f 100644 --- a/app/Bus/Handlers/Commands/Schedule/UpdateScheduleCommandHandler.php +++ b/app/Bus/Handlers/Commands/Schedule/UpdateScheduleCommandHandler.php @@ -16,6 +16,7 @@ use CachetHQ\Cachet\Models\Schedule; use CachetHQ\Cachet\Services\Dates\DateFactory; use Illuminate\Contracts\Auth\Guard; +use Illuminate\Support\Facades\DB; /** * This is the update schedule command handler. @@ -65,6 +66,8 @@ public function handle(UpdateScheduleCommand $command) $schedule->update($this->filter($command)); + $schedule->attachComponents($command->components); + event(new ScheduleWasUpdatedEvent($this->auth->user(), $schedule)); return $schedule; diff --git a/app/Http/Controllers/Dashboard/ScheduleController.php b/app/Http/Controllers/Dashboard/ScheduleController.php index c06216a916f..2e91583477d 100644 --- a/app/Http/Controllers/Dashboard/ScheduleController.php +++ b/app/Http/Controllers/Dashboard/ScheduleController.php @@ -16,6 +16,8 @@ use CachetHQ\Cachet\Bus\Commands\Schedule\DeleteScheduleCommand; use CachetHQ\Cachet\Bus\Commands\Schedule\UpdateScheduleCommand; use CachetHQ\Cachet\Integrations\Contracts\System; +use CachetHQ\Cachet\Models\Component; +use CachetHQ\Cachet\Models\ComponentGroup; use CachetHQ\Cachet\Models\IncidentTemplate; use CachetHQ\Cachet\Models\Schedule; use GrahamCampbell\Binput\Facades\Binput; @@ -79,6 +81,7 @@ public function showAddSchedule() return View::make('dashboard.maintenance.add') ->withPageTitle(trans('dashboard.schedule.add.title').' - '.trans('dashboard.dashboard')) + ->withComponents(Component::all()) ->withIncidentTemplates($incidentTemplates) ->withNotificationsEnabled($this->system->canNotifySubscribers()); } @@ -121,9 +124,9 @@ public function addScheduleAction() public function showEditSchedule(Schedule $schedule) { $incidentTemplates = IncidentTemplate::all(); - return View::make('dashboard.maintenance.edit') ->withPageTitle(trans('dashboard.schedule.edit.title').' - '.trans('dashboard.dashboard')) + ->withComponents(Component::all()) ->withIncidentTemplates($incidentTemplates) ->withSchedule($schedule); } diff --git a/app/Models/Schedule.php b/app/Models/Schedule.php index 6120842666b..e2c803491b1 100644 --- a/app/Models/Schedule.php +++ b/app/Models/Schedule.php @@ -20,6 +20,7 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Support\Facades\DB; use McCool\LaravelAutoPresenter\HasPresenter; class Schedule extends Model implements HasPresenter @@ -57,7 +58,7 @@ class Schedule extends Model implements HasPresenter * @var string[] */ protected $attributes = [ - 'status' => self::UPCOMING, + 'status' => self::UPCOMING, 'completed_at' => null, ]; @@ -67,9 +68,9 @@ class Schedule extends Model implements HasPresenter * @var string[] */ protected $casts = [ - 'name' => 'string', - 'message' => 'string', - 'status' => 'int', + 'name' => 'string', + 'message' => 'string', + 'status' => 'int', 'scheduled_at' => 'datetime', 'completed_at' => 'datetime', ]; @@ -95,9 +96,9 @@ class Schedule extends Model implements HasPresenter * @var string[] */ public $rules = [ - 'name' => 'required|string', - 'message' => 'nullable|string', - 'status' => 'required|int|between:0,2', + 'name' => 'required|string', + 'message' => 'nullable|string', + 'status' => 'required|int|between:0,2', ]; /** @@ -143,6 +144,26 @@ public function components() return $this->hasMany(ScheduleComponent::class); } + /** + * Added function to connect components trough the DB directly. Terrible solution. Works for me. + */ + public function attachComponents(array $components) + { + $this->detachAllComponents(); + foreach ($components as $componentId => $component){ + if(isset($component['affected']) && $component['affected']){ + $data = [ + 'schedule_id' => $this->id, + 'component_id' => (int) $componentId, + 'component_status' => (int) $component['status'], + 'created_at' => Carbon::now(), + 'updated_at' => Carbon::now() + ]; + DB::table('schedule_components')->insert($data); + } + } + } + /** * Scope schedules that are uncompleted. * @@ -216,4 +237,16 @@ public function getPresenterClass() { return SchedulePresenter::class; } + + private function detachAllComponents(): void + { + DB::table('schedule_components')->where('schedule_id', $this->id)->delete(); + } + + public function delete() + { + $this->detachAllComponents(); + // Do some stuff before delete + return parent::delete(); + } } diff --git a/config/bugsnag.php b/config/bugsnag.php new file mode 100644 index 00000000000..63f49cb6885 --- /dev/null +++ b/config/bugsnag.php @@ -0,0 +1,278 @@ + env('BUGSNAG_API_KEY', ''), + + /* + |-------------------------------------------------------------------------- + | App Type + |-------------------------------------------------------------------------- + | + | Set the type of application executing the current code. + | + */ + + 'app_type' => env('BUGSNAG_APP_TYPE'), + + /* + |-------------------------------------------------------------------------- + | App Version + |-------------------------------------------------------------------------- + | + | Set the version of application executing the current code. + | + */ + + 'app_version' => env('BUGSNAG_APP_VERSION'), + + /* + |-------------------------------------------------------------------------- + | Batch Sending + |-------------------------------------------------------------------------- + | + | Set to true to send the errors through to Bugsnag when the PHP process + | shuts down, in order to prevent your app waiting on HTTP requests. + | + | Setting this to false will send an HTTP request straight away for each + | error. + | + */ + + 'batch_sending' => env('BUGSNAG_BATCH_SENDING'), + + /* + |-------------------------------------------------------------------------- + | Endpoint + |-------------------------------------------------------------------------- + | + | Set what server the Bugsnag notifier should send errors to. By default + | this is set to 'https://notify.bugsnag.com', but for Bugsnag Enterprise + | this should be the URL to your Bugsnag instance. + | + */ + + 'endpoint' => env('BUGSNAG_ENDPOINT'), + + /* + |-------------------------------------------------------------------------- + | Filters + |-------------------------------------------------------------------------- + | + | Use this if you want to ensure you don't send sensitive data such as + | passwords, and credit card numbers to our servers. Any keys which + | contain these strings will be filtered. + | + */ + + 'filters' => empty(env('BUGSNAG_FILTERS')) ? ['password'] : explode(',', str_replace(' ', '', env('BUGSNAG_FILTERS'))), + + /* + |-------------------------------------------------------------------------- + | Hostname + |-------------------------------------------------------------------------- + | + | You can set the hostname of your server to something specific for you to + | identify it by if needed. + | + */ + + 'hostname' => env('BUGSNAG_HOSTNAME'), + + /* + |-------------------------------------------------------------------------- + | Proxy + |-------------------------------------------------------------------------- + | + | This is where you can set the proxy settings you'd like us to use when + | communicating with Bugsnag when reporting errors. + | + */ + + 'proxy' => array_filter([ + 'http' => env('HTTP_PROXY'), + 'https' => env('HTTPS_PROXY'), + 'no' => empty(env('NO_PROXY')) ? null : explode(',', str_replace(' ', '', env('NO_PROXY'))), + ]), + + /* + |-------------------------------------------------------------------------- + | Project Root + |-------------------------------------------------------------------------- + | + | Bugsnag marks stacktrace lines as in-project if they come from files + | inside your “project root”. You can set this here. + | + | If this is not set, we will automatically try to detect it. + | + */ + + 'project_root' => env('BUGSNAG_PROJECT_ROOT'), + + /* + |-------------------------------------------------------------------------- + | Strip Path + |-------------------------------------------------------------------------- + | + | You can set a strip path to have it also trimmed from the start of any + | filepath in your stacktraces. + | + | If this is not set, we will automatically try to detect it. + | + */ + + 'strip_path' => env('BUGSNAG_STRIP_PATH'), + + /* + |-------------------------------------------------------------------------- + | Query + |-------------------------------------------------------------------------- + | + | Enable this if you'd like us to automatically record all queries executed + | as breadcrumbs. + | + */ + + 'query' => env('BUGSNAG_QUERY', true), + + /* + |-------------------------------------------------------------------------- + | Bindings + |-------------------------------------------------------------------------- + | + | Enable this if you'd like us to include the query bindings in our query + | breadcrumbs. + | + */ + + 'bindings' => env('BUGSNAG_QUERY_BINDINGS', false), + + /* + |-------------------------------------------------------------------------- + | Release Stage + |-------------------------------------------------------------------------- + | + | Set the release stage to use when sending notifications to Bugsnag. + | + | Leaving this unset will default to using the application environment. + | + */ + + 'release_stage' => env('BUGSNAG_RELEASE_STAGE'), + + /* + |-------------------------------------------------------------------------- + | Notify Release Stages + |-------------------------------------------------------------------------- + | + | Set which release stages should send notifications to Bugsnag. + | + */ + + 'notify_release_stages' => empty(env('BUGSNAG_NOTIFY_RELEASE_STAGES')) ? null : explode(',', str_replace(' ', '', env('BUGSNAG_NOTIFY_RELEASE_STAGES'))), + + /* + |-------------------------------------------------------------------------- + | Send Code + |-------------------------------------------------------------------------- + | + | Bugsnag automatically sends a small snippet of the code that crashed to + | help you diagnose even faster from within your dashboard. If you don’t + | want to send this snippet, then set this to false. + | + */ + + 'send_code' => env('BUGSNAG_SEND_CODE', true), + + /* + |-------------------------------------------------------------------------- + | Callbacks + |-------------------------------------------------------------------------- + | + | Enable this if you'd like us to enable our default set of notification + | callbacks. These add things like the cookie information and session + | details to the error to be sent to Bugsnag. + | + | If you'd like to add your own callbacks, you can call the + | Bugsnag::registerCallback method from the boot method of your app + | service provider. + | + */ + + 'callbacks' => env('BUGSNAG_CALLBACKS', true), + + /* + |-------------------------------------------------------------------------- + | User + |-------------------------------------------------------------------------- + | + | Enable this if you'd like us to set the current user logged in via + | Laravel's authentication system. + | + | If you'd like to add your own user resolver, you can do this by using + | callbacks via Bugsnag::registerCallback. + | + */ + + 'user' => env('BUGSNAG_USER', true), + + /* + |-------------------------------------------------------------------------- + | Logger Notify Level + |-------------------------------------------------------------------------- + | + | This sets the level at which a logged message will trigger a notification + | to Bugsnag. By default this level will be 'notice'. + | + | Must be one of the Psr\Log\LogLevel levels from the Psr specification. + | + */ + + 'logger_notify_level' => env('BUGSNAG_LOGGER_LEVEL'), + + /* + |-------------------------------------------------------------------------- + | Auto Capture Sessions + |-------------------------------------------------------------------------- + | + | Enable this to start tracking sessions and deliver them to Bugsnag. + | + */ + + 'auto_capture_sessions' => env('BUGSNAG_CAPTURE_SESSIONS', false), + + /* + |-------------------------------------------------------------------------- + | Sessions Endpoint + |-------------------------------------------------------------------------- + | + | Sets a url to send tracked sessions to. + | + */ + + 'session_endpoint' => env('BUGSNAG_SESSION_ENDPOINT'), + + /* + |-------------------------------------------------------------------------- + | Builds Endpoint + |-------------------------------------------------------------------------- + | + | Sets a url to send build reports to. + | + */ + + 'build_endpoint' => env('BUGSNAG_BUILD_ENDPOINT'), + +]; diff --git a/database/backups/2020-02-26 13.29.45.gz b/database/backups/2020-02-26 13.29.45.gz new file mode 100644 index 00000000000..22d75ed6b84 Binary files /dev/null and b/database/backups/2020-02-26 13.29.45.gz differ diff --git a/database/backups/2020-02-26 13.31.51.gz b/database/backups/2020-02-26 13.31.51.gz new file mode 100644 index 00000000000..73b3c954ce7 Binary files /dev/null and b/database/backups/2020-02-26 13.31.51.gz differ diff --git a/database/backups/2020-02-26 13.41.04.gz b/database/backups/2020-02-26 13.41.04.gz new file mode 100644 index 00000000000..8ae2d01ab66 Binary files /dev/null and b/database/backups/2020-02-26 13.41.04.gz differ diff --git a/resources/views/dashboard/maintenance/_componentsSelection.blade.php b/resources/views/dashboard/maintenance/_componentsSelection.blade.php new file mode 100644 index 00000000000..7ebad97f106 --- /dev/null +++ b/resources/views/dashboard/maintenance/_componentsSelection.blade.php @@ -0,0 +1,33 @@ +
+ @if(!$components->isEmpty()) +
+
+ + @foreach($components as $component) +
+ @php + $currentComponentIsSelected = isset($schedule) ? $schedule->components()->where('component_id', $component->id)->first() : null; + if($currentComponentIsSelected){ + $currentStatus = $currentComponentIsSelected->component_status; + }else{ + $currentStatus = 1; + } + @endphp + + +
+ @foreach(trans('cachet.components.status') as $statusID => $status) +
+ +
+ @endforeach +
+
+ @endforeach +
+
+ @endif +
diff --git a/resources/views/dashboard/maintenance/add.blade.php b/resources/views/dashboard/maintenance/add.blade.php index 07c5d6fa7ea..17cb5211b5c 100644 --- a/resources/views/dashboard/maintenance/add.blade.php +++ b/resources/views/dashboard/maintenance/add.blade.php @@ -56,6 +56,7 @@ + @include('dashboard.maintenance._componentsSelection') @if($notificationsEnabled) diff --git a/resources/views/dashboard/maintenance/edit.blade.php b/resources/views/dashboard/maintenance/edit.blade.php index 456e0797ae8..0ffef9b7ade 100644 --- a/resources/views/dashboard/maintenance/edit.blade.php +++ b/resources/views/dashboard/maintenance/edit.blade.php @@ -56,6 +56,7 @@ + @include('dashboard.maintenance._componentsSelection')
diff --git a/resources/views/partials/schedule.blade.php b/resources/views/partials/schedule.blade.php index a077589bbe5..7dde8868d15 100644 --- a/resources/views/partials/schedule.blade.php +++ b/resources/views/partials/schedule.blade.php @@ -12,10 +12,10 @@ {!! $schedule->formatted_message !!}
@if($schedule->components->count() > 0) -
- @foreach($schedule->components as $affectedComponent) - {{ $affectedComponent->component->name }} - @endforeach +{{--
--}} +{{-- @foreach($schedule->components as $affectedComponent)--}} +{{-- {{ $affectedComponent->component->name }}--}} +{{-- @endforeach--}} @endif @endforeach diff --git a/resources/views/vendor/feed/atom.blade.php b/resources/views/vendor/feed/atom.blade.php new file mode 100644 index 00000000000..78bffe8f82c --- /dev/null +++ b/resources/views/vendor/feed/atom.blade.php @@ -0,0 +1,29 @@ +{!! '<'.'?'.'xml version="1.0" encoding="UTF-8" ?>' !!} +> + {!! $channel['title'] !!} + + + {{ $channel['link'] }} + + +@if (!empty($channel['logo'])) + {{ $channel['logo'] }} +@endif +@if (!empty($channel['icon'])) + {{ $channel['icon'] }} +@endif + {{ $channel['pubdate'] }} +@foreach($items as $item) + + + {{ $item['author'] }} + + <![CDATA[{!! $item['title'] !!}]]> + + {{ $item['link'] }} + + + {{ $item['pubdate'] }} + +@endforeach + diff --git a/resources/views/vendor/feed/rss.blade.php b/resources/views/vendor/feed/rss.blade.php new file mode 100644 index 00000000000..812e9cd5f5d --- /dev/null +++ b/resources/views/vendor/feed/rss.blade.php @@ -0,0 +1,89 @@ +{!! '<'.'?'.'xml version="1.0" encoding="UTF-8" ?>' !!} +> + + {!! $channel['title'] !!} + {{ Request::url() }} + + + @if (!empty($channel['copyright'])) + {{ $channel['copyright'] }} + @endif + @if (!empty($channel['color'])) + {{ $channel['color'] }} + @endif + @if (!empty($channel['cover'])) + + @endif + @if (!empty($channel['icon'])) + {{ $channel['icon'] }} + @endif + @if (!empty($channel['logo'])) + {{ $channel['logo'] }} + + {{ $channel['logo'] }} + {{ $channel['title'] }} + {{ Request::url() }} + + @endif + @if (!empty($channel['related'])) + + @endif + @if (!empty($channel['ga'])) + + @endif + {{ $channel['lang'] }} + {{ $channel['pubdate'] }} + @foreach($items as $item) + + <![CDATA[{!! $item['title'] !!}]]> + @if (!empty($item['category'])) + {{ $item['category'] }} + @endif + {{ $item['link'] }} + {{ $item['link'] }} + + @if (!empty($item['content'])) + + @endif + {{ $item['author'] }} + {{ $item['pubdate'] }} + @if (!empty($item['enclosure'])) + $v) + {!! $k.'="'.$v.'" ' !!} + @endforeach + /> + @endif + @if (!empty($item['media:content'])) + $v) + {!! $k.'="'.$v.'" ' !!} + @endforeach + /> + @endif + @if (!empty($item['media:thumbnail'])) + $v) + {!! $k.'="'.$v.'" ' !!} + @endforeach + /> + @endif + @if (!empty($item['media:title'])) + {{ $item['media:title'] }} + @endif + @if (!empty($item['media:description'])) + {{ $item['media:description'] }} + @endif + @if (!empty($item['media:keywords'])) + {{ $item['media:title'] }} + @endif + @if (!empty($item['media:rating'])) + {{ $item['media:rating'] }} + @endif + @if (!empty($item['creativeCommons:license'])) + {{ $item['creativeCommons:license'] }} + @endif + + @endforeach + +