Refactor validator stuff and fix variable names in views

This commit is contained in:
Graham Campbell
2015-08-03 22:32:36 +01:00
parent 5d958bac81
commit fcbbfdd84e
56 changed files with 514 additions and 766 deletions

View File

@@ -14,7 +14,7 @@ namespace CachetHQ\Cachet\Composers;
use Illuminate\Contracts\View\View; use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
class LoggedUserComposer class CurrentUserComposer
{ {
/** /**
* Bind data to the view. * Bind data to the view.
@@ -23,6 +23,6 @@ class LoggedUserComposer
*/ */
public function compose(View $view) public function compose(View $view)
{ {
$view->with('loggedUser', Auth::user()); $view->withCurrentUser(Auth::user());
} }
} }

View File

@@ -24,7 +24,7 @@ class DashboardComposer
*/ */
public function compose(View $view) public function compose(View $view)
{ {
$view->with('incidentCount', Incident::notScheduled()->count()); $view->withIncidentCount(Incident::notScheduled()->count());
$view->with('componentCount', Component::all()->count()); $view->withComponentCount(Component::all()->count());
} }
} }

View File

@@ -23,8 +23,8 @@ class ThemeComposer
*/ */
public function compose(View $view) public function compose(View $view)
{ {
$view->with('themeBackgroundColor', Setting::get('style_background_color')); $view->withThemeBackgroundColor(Setting::get('style_background_color'));
$view->with('themeTextColor', Setting::get('style_text_color')); $view->withThemeTextColor(Setting::get('style_text_color'));
$viewData = $view->getData(); $viewData = $view->getData();
$themeView = array_only($viewData, preg_grep('/^theme/', array_keys($viewData))); $themeView = array_only($viewData, preg_grep('/^theme/', array_keys($viewData)));
@@ -32,6 +32,6 @@ class ThemeComposer
return $data != null; return $data != null;
}); });
$view->with('themeSetup', !empty($hasThemeSettings)); $view->withThemeSetup(!empty($hasThemeSettings));
} }
} }

View File

@@ -65,9 +65,7 @@ class TimezoneLocaleComposer
} }
} }
$view->with([ $view->withTimezones($timezones);
'timezones' => $timezones, $view->withLangs($langs);
'langs' => $langs,
]);
} }
} }

View File

@@ -66,9 +66,7 @@ class ApiController extends AbstractController
$groupData = Binput::get('ids'); $groupData = Binput::get('ids');
foreach ($groupData as $order => $groupId) { foreach ($groupData as $order => $groupId) {
ComponentGroup::find($groupId)->update([ ComponentGroup::find($groupId)->update(['order' => $order + 1]);
'order' => $order + 1,
]);
} }
return $groupData; return $groupData;
@@ -85,12 +83,10 @@ class ApiController extends AbstractController
{ {
$templateSlug = Binput::get('slug'); $templateSlug = Binput::get('slug');
$template = IncidentTemplate::where('slug', $templateSlug)->first(); if ($template = IncidentTemplate::where('slug', $templateSlug)->first()) {
if ($template) {
return $template; return $template;
} }
throw new ModelNotFoundException('Incident template for '.$templateSlug.' could not be found.'); throw new ModelNotFoundException("Incident template for $templateSlug could not be found.");
} }
} }

View File

@@ -11,6 +11,7 @@
namespace CachetHQ\Cachet\Http\Controllers\Admin; namespace CachetHQ\Cachet\Http\Controllers\Admin;
use AltThree\Validator\ValidationException;
use CachetHQ\Cachet\Http\Controllers\AbstractController; use CachetHQ\Cachet\Http\Controllers\AbstractController;
use CachetHQ\Cachet\Models\Component; use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\ComponentGroup; use CachetHQ\Cachet\Models\ComponentGroup;
@@ -57,11 +58,10 @@ class ComponentController extends AbstractController
$this->subMenu['components']['active'] = true; $this->subMenu['components']['active'] = true;
return View::make('dashboard.components.index')->with([ return View::make('dashboard.components.index')
'page_title' => trans_choice('dashboard.components.components', 2).' - '.trans('dashboard.dashboard'), ->withPageTitle(trans_choice('dashboard.components.components', 2).' - '.trans('dashboard.dashboard'))
'components' => $components, ->withComponents($components)
'sub_menu' => $this->subMenu, ->withSubMenu($this->subMenu);
]);
} }
/** /**
@@ -73,11 +73,10 @@ class ComponentController extends AbstractController
{ {
$this->subMenu['groups']['active'] = true; $this->subMenu['groups']['active'] = true;
return View::make('dashboard.components.groups.index')->with([ return View::make('dashboard.components.groups.index')
'page_title' => trans_choice('dashboard.components.groups.groups', 2).' - '.trans('dashboard.dashboard'), ->withPageTitle(trans_choice('dashboard.components.groups.groups', 2).' - '.trans('dashboard.dashboard'))
'groups' => ComponentGroup::orderBy('order')->get(), ->withGroups(ComponentGroup::orderBy('order')->get())
'sub_menu' => $this->subMenu, ->withSubMenu($this->subMenu);
]);
} }
/** /**
@@ -91,18 +90,12 @@ class ComponentController extends AbstractController
{ {
$groups = ComponentGroup::all(); $groups = ComponentGroup::all();
$pageTitle = sprintf( $pageTitle = sprintf('"%s" - %s - %s', $component->name, trans('dashboard.components.edit.title'), trans('dashboard.dashboard'));
'"%s" - %s - %s',
$component->name,
trans('dashboard.components.edit.title'),
trans('dashboard.dashboard')
);
return View::make('dashboard.components.edit')->with([ return View::make('dashboard.components.edit')
'page_title' => $pageTitle, ->withPageTitle($pageTitle)
'component' => $component, ->withComponent($component)
'groups' => $groups, ->withGroups($groups);
]);
} }
/** /**
@@ -117,16 +110,13 @@ class ComponentController extends AbstractController
$_component = Binput::get('component'); $_component = Binput::get('component');
$tags = array_pull($_component, 'tags'); $tags = array_pull($_component, 'tags');
try {
$component->update($_component); $component->update($_component);
} catch (ValidationException $e) {
if (!$component->isValid()) { return Redirect::back()
return Redirect::back()->withInput(Binput::all()) ->withInput(Binput::all())
->with('title', sprintf( ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.edit.failure')))
'%s %s', ->withErrors($e->getMessageBag());
trans('dashboard.notifications.whoops'),
trans('dashboard.components.edit.failure')
))
->with('errors', $component->getErrors());
} }
// The component was added successfully, so now let's deal with the tags. // The component was added successfully, so now let's deal with the tags.
@@ -134,20 +124,13 @@ class ComponentController extends AbstractController
// For every tag, do we need to create it? // For every tag, do we need to create it?
$componentTags = array_map(function ($taggable) use ($component) { $componentTags = array_map(function ($taggable) use ($component) {
return Tag::firstOrCreate([ return Tag::firstOrCreate(['name' => $taggable])->id;
'name' => $taggable,
])->id;
}, $tags); }, $tags);
$component->tags()->sync($componentTags); $component->tags()->sync($componentTags);
$successMsg = sprintf( return Redirect::back()
'%s %s', ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.edit.success')));
trans('dashboard.notifications.awesome'),
trans('dashboard.components.edit.success')
);
return Redirect::back()->with('success', $successMsg);
} }
/** /**
@@ -157,12 +140,9 @@ class ComponentController extends AbstractController
*/ */
public function showAddComponent() public function showAddComponent()
{ {
$groups = ComponentGroup::all(); return View::make('dashboard.components.add')
->withPageTitle(trans('dashboard.components.add.title').' - '.trans('dashboard.dashboard'))
return View::make('dashboard.components.add')->with([ ->withGroups(ComponentGroup::all());
'page_title' => trans('dashboard.components.add.title').' - '.trans('dashboard.dashboard'),
'groups' => $groups,
]);
} }
/** /**
@@ -176,16 +156,13 @@ class ComponentController extends AbstractController
// We deal with tags separately. // We deal with tags separately.
$tags = array_pull($_component, 'tags'); $tags = array_pull($_component, 'tags');
try {
$component = Component::create($_component); $component = Component::create($_component);
} catch (ValidationException $e) {
if (!$component->isValid()) { return Redirect::back()
return Redirect::back()->withInput(Binput::all()) ->withInput(Binput::all())
->with('title', sprintf( ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.add.failure')))
'%s %s', ->withErrors($e->getMessageBag());
trans('dashboard.notifications.whoops'),
trans('dashboard.components.add.failure')
))
->with('errors', $component->getErrors());
} }
// The component was added successfully, so now let's deal with the tags. // The component was added successfully, so now let's deal with the tags.
@@ -193,20 +170,13 @@ class ComponentController extends AbstractController
// For every tag, do we need to create it? // For every tag, do we need to create it?
$componentTags = array_map(function ($taggable) use ($component) { $componentTags = array_map(function ($taggable) use ($component) {
return Tag::firstOrCreate([ return Tag::firstOrCreate(['name' => $taggable])->id;
'name' => $taggable,
])->id;
}, $tags); }, $tags);
$component->tags()->sync($componentTags); $component->tags()->sync($componentTags);
$successMsg = sprintf( return Redirect::back()
'%s %s', ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.add.success')));
trans('dashboard.notifications.awesome'),
trans('dashboard.components.add.success')
);
return Redirect::back()->with('success', $successMsg);
} }
/** /**
@@ -233,9 +203,7 @@ class ComponentController extends AbstractController
public function deleteComponentGroupAction(ComponentGroup $group) public function deleteComponentGroupAction(ComponentGroup $group)
{ {
$group->components->map(function ($component) { $group->components->map(function ($component) {
$component->update([ $component->update(['group_id' => 0]);
'group_id' => 0,
]);
}); });
$group->delete(); $group->delete();
@@ -250,9 +218,8 @@ class ComponentController extends AbstractController
*/ */
public function showAddComponentGroup() public function showAddComponentGroup()
{ {
return View::make('dashboard.components.groups.add')->with([ return View::make('dashboard.components.groups.add')
'page_title' => trans('dashboard.components.groups.add.title').' - '.trans('dashboard.dashboard'), ->withPageTitle(trans('dashboard.components.groups.add.title').' - '.trans('dashboard.dashboard'));
]);
} }
/** /**
@@ -264,10 +231,9 @@ class ComponentController extends AbstractController
*/ */
public function showEditComponentGroup(ComponentGroup $group) public function showEditComponentGroup(ComponentGroup $group)
{ {
return View::make('dashboard.components.groups.edit')->with([ return View::make('dashboard.components.groups.edit')
'page_title' => trans('dashboard.components.groups.edit.title').' - '.trans('dashboard.dashboard'), ->withPageTitle(trans('dashboard.components.groups.edit.title').' - '.trans('dashboard.dashboard'))
'group' => $group, ->withGroup($group);
]);
} }
/** /**
@@ -277,25 +243,17 @@ class ComponentController extends AbstractController
*/ */
public function postAddComponentGroup() public function postAddComponentGroup()
{ {
try {
$group = ComponentGroup::create(Binput::get('group')); $group = ComponentGroup::create(Binput::get('group'));
} catch (ValidationException $e) {
if (!$group->isValid()) { return Redirect::back()
return Redirect::back()->withInput(Binput::all()) ->withInput(Binput::all())
->with('title', sprintf( ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.groups.add.failure')))
'%s %s', ->withErrors($e->getMessageBag());
trans('dashboard.notifications.whoops'),
trans('dashboard.components.groups.add.failure')
))
->with('errors', $group->getErrors());
} }
$successMsg = sprintf( return Redirect::back()
'%s %s', ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.groups.add.success')));
trans('dashboard.notifications.awesome'),
trans('dashboard.components.groups.add.success')
);
return Redirect::back()->with('success', $successMsg);
} }
/** /**
@@ -308,24 +266,17 @@ class ComponentController extends AbstractController
public function updateComponentGroupAction(ComponentGroup $group) public function updateComponentGroupAction(ComponentGroup $group)
{ {
$groupData = Binput::get('group'); $groupData = Binput::get('group');
$group->update($groupData);
if (!$group->isValid()) { try {
return Redirect::back()->withInput(Binput::all()) $group->update($groupData);
->with('title', sprintf( } catch (ValidationException $e) {
'%s %s', return Redirect::back()
trans('dashboard.notifications.whoops'), ->withInput(Binput::all())
trans('dashboard.components.groups.edit.failure') ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.groups.edit.failure')))
)) ->withErrors($e->getMessageBag());
->with('errors', $group->getErrors());
} }
$successMsg = sprintf( return Redirect::back()
'%s %s', ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.groups.edit.success')));
trans('dashboard.notifications.awesome'),
trans('dashboard.components.groups.edit.success')
);
return Redirect::back()->with('success', $successMsg);
} }
} }

View File

@@ -26,9 +26,8 @@ class DashboardController extends AbstractController
{ {
$components = Component::orderBy('order')->get(); $components = Component::orderBy('order')->get();
return View::make('dashboard.index')->with([ return View::make('dashboard.index')
'components' => $components, ->withComponents($components);
]);
} }
/** /**
@@ -38,8 +37,7 @@ class DashboardController extends AbstractController
*/ */
public function showNotifications() public function showNotifications()
{ {
return View::make('dashboard.notifications.index')->with([ return View::make('dashboard.notifications.index')
'page_title' => trans('dashboard.notifications.notifications').' '.trans('dashboard.dashboard'), ->withPageTitle(trans('dashboard.notifications.notifications').' '.trans('dashboard.dashboard'));
]);
} }
} }

View File

@@ -11,6 +11,7 @@
namespace CachetHQ\Cachet\Http\Controllers\Admin; namespace CachetHQ\Cachet\Http\Controllers\Admin;
use AltThree\Validator\ValidationException;
use CachetHQ\Cachet\Events\IncidentHasReportedEvent; use CachetHQ\Cachet\Events\IncidentHasReportedEvent;
use CachetHQ\Cachet\Facades\Setting; use CachetHQ\Cachet\Facades\Setting;
use CachetHQ\Cachet\Http\Controllers\AbstractController; use CachetHQ\Cachet\Http\Controllers\AbstractController;
@@ -68,10 +69,9 @@ class IncidentController extends AbstractController
{ {
$incidents = Incident::notScheduled()->orderBy('created_at', 'desc')->get(); $incidents = Incident::notScheduled()->orderBy('created_at', 'desc')->get();
return View::make('dashboard.incidents.index')->with([ return View::make('dashboard.incidents.index')
'page_title' => trans('dashboard.incidents.incidents').' - '.trans('dashboard.dashboard'), ->withPageTitle(trans('dashboard.incidents.incidents').' - '.trans('dashboard.dashboard'))
'incidents' => $incidents, ->withIncidents($incidents);
]);
} }
/** /**
@@ -81,15 +81,11 @@ class IncidentController extends AbstractController
*/ */
public function showAddIncident() public function showAddIncident()
{ {
$componentsInGroups = ComponentGroup::with('components')->get(); return View::make('dashboard.incidents.add')
$componentsOutGroups = Component::where('group_id', 0)->get(); ->withPageTitle(trans('dashboard.incidents.add.title').' - '.trans('dashboard.dashboard'))
->withComponentsInGroups(ComponentGroup::with('components')->get())
return View::make('dashboard.incidents.add')->with([ ->withComponentsOutGroups(Component::where('group_id', 0)->get())
'page_title' => trans('dashboard.incidents.add.title').' - '.trans('dashboard.dashboard'), ->withIncidentTemplates(IncidentTemplate::all());
'componentsInGroups' => $componentsInGroups,
'componentsOutGroups' => $componentsOutGroups,
'incidentTemplates' => IncidentTemplate::all(),
]);
} }
/** /**
@@ -99,10 +95,9 @@ class IncidentController extends AbstractController
*/ */
public function showTemplates() public function showTemplates()
{ {
return View::make('dashboard.incidents.templates.index')->with([ return View::make('dashboard.incidents.templates.index')
'page_title' => trans('dashboard.incidents.templates.title').' - '.trans('dashboard.dashboard'), ->withPageTitle(trans('dashboard.incidents.templates.title').' - '.trans('dashboard.dashboard'))
'incidentTemplates' => IncidentTemplate::all(), ->withIncidentTemplates(IncidentTemplate::all());
]);
} }
/** /**
@@ -123,41 +118,26 @@ class IncidentController extends AbstractController
unset($incidentData['created_at']); unset($incidentData['created_at']);
} }
try {
$incident = Incident::create($incidentData); $incident = Incident::create($incidentData);
} catch (ValidationException $e) {
if (!$incident->isValid()) { return Redirect::back()
return Redirect::back()->withInput(Binput::all()) ->withInput(Binput::all())
->with('title', sprintf( ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.add.failure')))
'%s %s', ->withErrors($e->getMessageBag());
trans('dashboard.notifications.whoops'),
trans('dashboard.incidents.add.failure')
))
->with('errors', $incident->getErrors());
} }
// Update the component. // Update the component.
if (isset($incidentData['component_id']) && (int) $incidentData['component_id'] > 0) { if (isset($incidentData['component_id']) && (int) $incidentData['component_id'] > 0) {
Component::find($incidentData['component_id'])->update([ Component::find($incidentData['component_id'])->update(['status' => $componentStatus]);
'status' => $componentStatus,
]);
} }
$successMsg = sprintf( if (array_get($incidentData, 'notify') && subscribers_enabled()) {
'%s %s',
trans('dashboard.notifications.awesome'),
trans('dashboard.incidents.add.success')
);
$isEnabled = (bool) Setting::get('enable_subscribers', false);
$mailAddress = env('MAIL_ADDRESS', false);
$mailFrom = env('MAIL_NAME', false);
$subscribersEnabled = $isEnabled && $mailAddress && $mailFrom;
if (array_get($incidentData, 'notify') && $subscribersEnabled) {
event(new IncidentHasReportedEvent($incident)); event(new IncidentHasReportedEvent($incident));
} }
return Redirect::back()->with('success', $successMsg); return Redirect::back()
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.add.success')));
} }
/** /**
@@ -167,9 +147,8 @@ class IncidentController extends AbstractController
*/ */
public function showAddIncidentTemplate() public function showAddIncidentTemplate()
{ {
return View::make('dashboard.incidents.templates.add')->with([ return View::make('dashboard.incidents.templates.add')
'page_title' => trans('dashboard.incidents.templates.add.title').' - '.trans('dashboard.dashboard'), ->withPageTitle(trans('dashboard.incidents.templates.add.title').' - '.trans('dashboard.dashboard'));
]);
} }
/** /**
@@ -181,10 +160,9 @@ class IncidentController extends AbstractController
*/ */
public function showEditTemplateAction(IncidentTemplate $template) public function showEditTemplateAction(IncidentTemplate $template)
{ {
return View::make('dashboard.incidents.templates.edit')->with([ return View::make('dashboard.incidents.templates.edit')
'page_title' => trans('dashboard.incidents.templates.edit.title').' - '.trans('dashboard.dashboard'), ->withPageTitle(trans('dashboard.incidents.templates.edit.title').' - '.trans('dashboard.dashboard'))
'template' => $template, ->withTemplate($template);
]);
} }
/** /**
@@ -208,26 +186,17 @@ class IncidentController extends AbstractController
*/ */
public function createIncidentTemplateAction() public function createIncidentTemplateAction()
{ {
$_template = Binput::get('template'); try {
$template = IncidentTemplate::create($_template); IncidentTemplate::create(Binput::get('template'));
} catch (ValidationException $e) {
if (!$template->isValid()) { return Redirect::back()
return Redirect::back()->withInput(Binput::all()) ->withInput(Binput::all())
->with('title', sprintf( ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.add.failure')))
'%s %s', ->withErrors($e->getMessageBag());
trans('dashboard.notifications.whoops'),
trans('dashboard.incidents.templates.add.failure')
))
->with('errors', $template->getErrors());
} }
$successMsg = sprintf( return Redirect::back()
'%s %s', ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.templates.add.success')));
trans('dashboard.notifications.awesome'),
trans('dashboard.incidents.templates.add.success')
);
return Redirect::back()->with('success', $successMsg);
} }
/** /**
@@ -253,15 +222,11 @@ class IncidentController extends AbstractController
*/ */
public function showEditIncidentAction(Incident $incident) public function showEditIncidentAction(Incident $incident)
{ {
$componentsInGroups = ComponentGroup::with('components')->get(); return View::make('dashboard.incidents.edit')
$componentsOutGroups = Component::where('group_id', 0)->get(); ->withPageTitle(trans('dashboard.incidents.edit.title').' - '.trans('dashboard.dashboard'))
->withIncident($incident)
return View::make('dashboard.incidents.edit')->with([ ->withComponentsInGroups(ComponentGroup::with('components')->get())
'page_title' => trans('dashboard.incidents.edit.title').' - '.trans('dashboard.dashboard'), ->withComponentsOutGroups(Component::where('group_id', 0)->get());
'incident' => $incident,
'componentsInGroups' => $componentsInGroups,
'componentsOutGroups' => $componentsOutGroups,
]);
} }
/** /**
@@ -283,32 +248,23 @@ class IncidentController extends AbstractController
unset($incidentData['created_at']); unset($incidentData['created_at']);
} }
try {
$incident->update($incidentData); $incident->update($incidentData);
} catch (ValidationException $e) {
if (!$incident->isValid()) { return Redirect::back()
return Redirect::back()->withInput(Binput::all()) ->withInput(Binput::all())
->with('title', sprintf( ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure')))
'%s %s', ->withErrors($e->getMessageBag());
trans('dashboard.notifications.whoops'),
trans('dashboard.incidents.templates.edit.failure')
))
->with('errors', $incident->getErrors());
} }
$componentStatus = array_pull($incidentData, 'component_status'); $componentStatus = array_pull($incidentData, 'component_status');
if ($incident->component) { if ($incident->component) {
$incident->component->update([ $incident->component->update(['status' => $componentStatus]);
'status' => $componentStatus,
]);
} }
$successMsg = sprintf( return Redirect::to('dashboard/incidents')
'%s %s', ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.edit.success')));
trans('dashboard.notifications.awesome'),
trans('dashboard.incidents.edit.success')
);
return Redirect::to('dashboard/incidents')->with('success', $successMsg);
} }
/** /**
@@ -320,8 +276,15 @@ class IncidentController extends AbstractController
*/ */
public function editTemplateAction(IncidentTemplate $template) public function editTemplateAction(IncidentTemplate $template)
{ {
try {
$template->update(Binput::get('template')); $template->update(Binput::get('template'));
} catch (ValidationException $e) {
return Redirect::back()
->withUpdatedTemplate($template)
->withTemplateErrors($e->getMessageBag()->getErrors());
}
return Redirect::back()->with('updatedTemplate', $template); return Redirect::back()
->withUpdatedTemplate($template);
} }
} }

View File

@@ -11,6 +11,7 @@
namespace CachetHQ\Cachet\Http\Controllers\Admin; namespace CachetHQ\Cachet\Http\Controllers\Admin;
use AltThree\Validator\ValidationException;
use CachetHQ\Cachet\Http\Controllers\AbstractController; use CachetHQ\Cachet\Http\Controllers\AbstractController;
use CachetHQ\Cachet\Models\Metric; use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Cachet\Models\MetricPoint; use CachetHQ\Cachet\Models\MetricPoint;
@@ -29,10 +30,9 @@ class MetricController extends AbstractController
{ {
$metrics = Metric::orderBy('created_at', 'desc')->get(); $metrics = Metric::orderBy('created_at', 'desc')->get();
return View::make('dashboard.metrics.index')->with([ return View::make('dashboard.metrics.index')
'page_title' => trans('dashboard.metrics.metrics').' - '.trans('dashboard.dashboard'), ->withPageTitle(trans('dashboard.metrics.metrics').' - '.trans('dashboard.dashboard'))
'metrics' => $metrics, ->withMetrics($metrics);
]);
} }
/** /**
@@ -42,10 +42,8 @@ class MetricController extends AbstractController
*/ */
public function showAddMetric() public function showAddMetric()
{ {
return View::make('dashboard.metrics.add')->with([ return View::make('dashboard.metrics.add')
'page_title' => trans('dashboard.metrics.add.title').' - '.trans('dashboard.dashboard'), ->withPageTitle(trans('dashboard.metrics.add.title').' - '.trans('dashboard.dashboard'));
'metricMetricPoints' => MetricPoint::all(),
]);
} }
/** /**
@@ -55,10 +53,9 @@ class MetricController extends AbstractController
*/ */
public function showMetricPoints() public function showMetricPoints()
{ {
return View::make('dashboard.metrics.points.index')->with([ return View::make('dashboard.metrics.points.index')
'page_title' => trans('dashboard.metrics.points.title').' - '.trans('dashboard.dashboard'), ->withPageTitle(trans('dashboard.metrics.points.title').' - '.trans('dashboard.dashboard'))
'metricMetricPoints' => MetricPoint::all(), ->withMetrics(MetricPoint::all());
]);
} }
/** /**
@@ -68,26 +65,17 @@ class MetricController extends AbstractController
*/ */
public function createMetricAction() public function createMetricAction()
{ {
$metricData = Binput::get('metric'); try {
$metric = Metric::create($metricData); Metric::create(Binput::get('metric'));
} catch (ValidationException $e) {
if (!$metric->isValid()) { return Redirect::back()
return Redirect::back()->withInput(Binput::all()) ->withInput(Binput::all())
->with('title', sprintf( ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.metrics.add.failure')))
'%s %s', ->withErrors($e->getMessageBag());
trans('dashboard.notifications.whoops'),
trans('dashboard.metrics.add.failure')
))
->with('errors', $metric->getErrors());
} }
$successMsg = sprintf( return Redirect::back()
'%s %s', ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.add.success')));
trans('dashboard.notifications.awesome'),
trans('dashboard.metrics.add.success')
);
return Redirect::back()->with('success', $successMsg);
} }
/** /**
@@ -97,9 +85,8 @@ class MetricController extends AbstractController
*/ */
public function showAddMetricPoint() public function showAddMetricPoint()
{ {
return View::make('dashboard.metrics.points.add')->with([ return View::make('dashboard.metrics.points.add')
'page_title' => trans('dashboard.metrics.points.add.title').' - '.trans('dashboard.dashboard'), ->withPageTitle(trans('dashboard.metrics.points.add.title').' - '.trans('dashboard.dashboard'));
]);
} }
/** /**
@@ -109,26 +96,17 @@ class MetricController extends AbstractController
*/ */
public function createMetricPointAction() public function createMetricPointAction()
{ {
$_point = Binput::get('point', null, false); try {
$point = MetricPoint::create($_point); MetricPoint::create(Binput::get('point', null, false));
} catch (ValidationException $e) {
if (!$point->isValid()) { return Redirect::back()
return Redirect::back()->withInput(Binput::all()) ->withInput(Binput::all())
->with('title', sprintf( ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.metrics.points.add.failure')))
'%s %s', ->withErrors($e->getMessageBag());
trans('dashboard.notifications.whoops'),
trans('dashboard.metrics.points.add.failure')
))
->with('errors', $point->getErrors());
} }
$successMsg = sprintf( return Redirect::back()
'%s %s', ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.points.add.success')));
trans('dashboard.notifications.awesome'),
trans('dashboard.metrics.points.add.success')
);
return Redirect::back()->with('success', $successMsg);
} }
/** /**
@@ -154,10 +132,9 @@ class MetricController extends AbstractController
*/ */
public function showEditMetricAction(Metric $metric) public function showEditMetricAction(Metric $metric)
{ {
return View::make('dashboard.metrics.edit')->with([ return View::make('dashboard.metrics.edit')
'page_title' => trans('dashboard.metrics.edit.title').' - '.trans('dashboard.dashboard'), ->withPageTitle(trans('dashboard.metrics.edit.title').' - '.trans('dashboard.dashboard'))
'metric' => $metric, ->withMetric($metric);
]);
} }
/** /**
@@ -169,24 +146,16 @@ class MetricController extends AbstractController
*/ */
public function editMetricAction(Metric $metric) public function editMetricAction(Metric $metric)
{ {
$metricData = Binput::get('metric', null, false); try {
$metric->update($metricData); $metric->update(Binput::get('metric', null, false));
} catch (ValidationException $e) {
if (!$metric->isValid()) { return Redirect::back()
return Redirect::back()->withInput(Binput::all()) ->withInput(Binput::all())
->with('title', sprintf( ->withTitle(sprintf('<strong>%s</strong>', trans('dashboard.notifications.whoops')))
'<strong>%s</strong>', ->withErrors($e->getMessageBag());
trans('dashboard.notifications.whoops')
))
->with('errors', $metric->getErrors());
} }
$successMsg = sprintf( return Redirect::to('dashboard/metrics')
'%s %s', ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.edit.success')));
trans('dashboard.notifications.awesome'),
trans('dashboard.metrics.edit.success')
);
return Redirect::to('dashboard/metrics')->with('success', $successMsg);
} }
} }

View File

@@ -11,6 +11,7 @@
namespace CachetHQ\Cachet\Http\Controllers\Admin; namespace CachetHQ\Cachet\Http\Controllers\Admin;
use AltThree\Validator\ValidationException;
use CachetHQ\Cachet\Events\MaintenanceHasScheduledEvent; use CachetHQ\Cachet\Events\MaintenanceHasScheduledEvent;
use CachetHQ\Cachet\Facades\Setting; use CachetHQ\Cachet\Facades\Setting;
use CachetHQ\Cachet\Http\Controllers\AbstractController; use CachetHQ\Cachet\Http\Controllers\AbstractController;
@@ -80,9 +81,8 @@ class ScheduleController extends AbstractController
{ {
$incidentTemplates = IncidentTemplate::all(); $incidentTemplates = IncidentTemplate::all();
return View::make('dashboard.schedule.add')->with([ return View::make('dashboard.schedule.add')
'incidentTemplates' => $incidentTemplates, ->withIncidentTemplates($incidentTemplates);
]);
} }
/** /**
@@ -99,9 +99,7 @@ class ScheduleController extends AbstractController
if ($scheduledAt->isPast()) { if ($scheduledAt->isPast()) {
$messageBag = new MessageBag(); $messageBag = new MessageBag();
$messageBag->add('scheduled_at', trans('validation.date', [ $messageBag->add('scheduled_at', trans('validation.date', ['attribute' => 'scheduled time you supplied']));
'attribute' => 'scheduled time you supplied',
]));
return Redirect::back()->withErrors($messageBag); return Redirect::back()->withErrors($messageBag);
} }
@@ -110,34 +108,21 @@ class ScheduleController extends AbstractController
// Bypass the incident.status field. // Bypass the incident.status field.
$scheduleData['status'] = 0; $scheduleData['status'] = 0;
$incident = Incident::create($scheduleData); try {
Incident::create($scheduleData);
if (!$incident->isValid()) { } catch (ValidationException $e) {
return Redirect::back()->withInput(Binput::all()) return Redirect::back()
->with('success', sprintf( ->withInput(Binput::all())
'%s %s', ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.add.failure')))
trans('dashboard.notifications.whoops'), ->withErrors($e->getMessageBag());
trans('dashboard.schedule.add.failure')
))
->with('errors', $incident->getErrors());
} }
$successMsg = sprintf( if (array_get($scheduleData, 'notify') && subscribers_enabled()) {
'%s %s',
trans('dashboard.notifications.awesome'),
trans('dashboard.schedule.add.success')
);
$isEnabled = (bool) Setting::get('enable_subscribers', false);
$mailAddress = env('MAIL_ADDRESS', false);
$mailFrom = env('MAIL_NAME', false);
$subscribersEnabled = $isEnabled && $mailAddress && $mailFrom;
if (array_get($scheduleData, 'notify') && $subscribersEnabled) {
event(new MaintenanceHasScheduledEvent($incident)); event(new MaintenanceHasScheduledEvent($incident));
} }
return Redirect::back()->with('success', $successMsg); return Redirect::back()
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.add.success')));
} }
/** /**
@@ -151,10 +136,9 @@ class ScheduleController extends AbstractController
{ {
$incidentTemplates = IncidentTemplate::all(); $incidentTemplates = IncidentTemplate::all();
return View::make('dashboard.schedule.edit')->with([ return View::make('dashboard.schedule.edit')
'incidentTemplates' => $incidentTemplates, ->withIncidentTemplates($incidentTemplates)
'schedule' => $schedule, ->withSchedule($schedule);
]);
} }
/** /**
@@ -173,9 +157,7 @@ class ScheduleController extends AbstractController
if ($scheduledAt->isPast()) { if ($scheduledAt->isPast()) {
$messageBag = new MessageBag(); $messageBag = new MessageBag();
$messageBag->add('scheduled_at', trans('validation.date', [ $messageBag->add('scheduled_at', trans('validation.date', ['attribute' => 'scheduled time you supplied']));
'attribute' => 'scheduled time you supplied',
]));
return Redirect::back()->withErrors($messageBag); return Redirect::back()->withErrors($messageBag);
} }
@@ -184,25 +166,17 @@ class ScheduleController extends AbstractController
// Bypass the incident.status field. // Bypass the incident.status field.
$scheduleData['status'] = 0; $scheduleData['status'] = 0;
try {
$schedule->update($scheduleData); $schedule->update($scheduleData);
} catch (ValidationException $e) {
if (!$schedule->isValid()) { return Redirect::back()
return Redirect::back()->withInput(Binput::all()) ->withInput(Binput::all())
->with('title', sprintf( ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.edit.failure')))
'%s %s', ->withErrors($e->getMessageBag());
trans('dashboard.notifications.whoops'),
trans('dashboard.schedule.edit.failure')
))
->with('errors', $schedule->getErrors());
} }
$successMsg = sprintf( return Redirect::to('dashboard/schedule')
'%s %s', ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.edit.success')));
trans('dashboard.notifications.awesome'),
trans('dashboard.schedule.edit.success')
);
return Redirect::to('dashboard/schedule')->with('success', $successMsg);
} }
/** /**
@@ -216,10 +190,7 @@ class ScheduleController extends AbstractController
{ {
$schedule->delete(); $schedule->delete();
return Redirect::back()->with('warning', sprintf( return Redirect::back()
'%s %s', ->withWarning(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.delete.failure')));
trans('dashboard.notifications.whoops'),
trans('dashboard.schedule.delete.failure')
));
} }
} }

View File

@@ -68,10 +68,9 @@ class SettingsController extends AbstractController
{ {
$this->subMenu['setup']['active'] = true; $this->subMenu['setup']['active'] = true;
return View::make('dashboard.settings.app-setup')->with([ return View::make('dashboard.settings.app-setup')
'page_title' => 'Application Setup - Dashboard', ->withPageTitle('Application Setup - Dashboard')
'sub_menu' => $this->subMenu, ->withSubMenu($this->subMenu);
]);
} }
/** /**
@@ -83,10 +82,9 @@ class SettingsController extends AbstractController
{ {
$this->subMenu['theme']['active'] = true; $this->subMenu['theme']['active'] = true;
return View::make('dashboard.settings.theme')->with([ return View::make('dashboard.settings.theme')
'page_title' => 'Theme - Dashboard', ->withPageTitle('Theme - Dashboard')
'sub_menu' => $this->subMenu, ->withSubMenu($this->subMenu);
]);
} }
/** /**
@@ -100,11 +98,10 @@ class SettingsController extends AbstractController
$unsecureUsers = User::whereNull('google_2fa_secret')->orWhere('google_2fa_secret', '')->get(); $unsecureUsers = User::whereNull('google_2fa_secret')->orWhere('google_2fa_secret', '')->get();
return View::make('dashboard.settings.security')->with([ return View::make('dashboard.settings.security')
'page_title' => 'Security - Dashboard', ->withPageTitle('Security - Dashboard')
'sub_menu' => $this->subMenu, ->withSubMenu($this->subMenu)
'unsecureUsers' => $unsecureUsers, ->withUnsecureUsers($unsecureUsers);
]);
} }
/** /**
@@ -116,10 +113,9 @@ class SettingsController extends AbstractController
{ {
$this->subMenu['stylesheet']['active'] = true; $this->subMenu['stylesheet']['active'] = true;
return View::make('dashboard.settings.stylesheet')->with([ return View::make('dashboard.settings.stylesheet')
'page_title' => 'Stylesheet - Dashboard', ->withPageTitle('Stylesheet - Dashboard')
'sub_menu' => $this->subMenu, ->withSubMenu($this->subMenu);
]);
} }
/** /**
@@ -142,9 +138,7 @@ class SettingsController extends AbstractController
$maxSize = $file->getMaxFilesize(); $maxSize = $file->getMaxFilesize();
if ($file->getSize() > $maxSize) { if ($file->getSize() > $maxSize) {
return Redirect::back()->withErrors(trans('dashboard.settings.app-setup.too-big', [ return Redirect::back()->withErrors(trans('dashboard.settings.app-setup.too-big', ['size' => $maxSize]));
'size' => $maxSize,
]));
} }
if (!$file->isValid() || $file->getError()) { if (!$file->isValid() || $file->getError()) {
@@ -156,18 +150,10 @@ class SettingsController extends AbstractController
} }
// Store the banner. // Store the banner.
Setting::firstOrCreate([ Setting::firstOrCreate(['name' => 'app_banner'])->update(['value' => base64_encode(file_get_contents($file->getRealPath()))]);
'name' => 'app_banner',
])->update([
'value' => base64_encode(file_get_contents($file->getRealPath())),
]);
// Store the banner type // Store the banner type
Setting::firstOrCreate([ Setting::firstOrCreate(['name' => 'app_banner_type'])->update(['value' => $file->getMimeType()]);
'name' => 'app_banner_type',
])->update([
'value' => $file->getMimeType(),
]);
} }
try { try {
@@ -176,18 +162,15 @@ class SettingsController extends AbstractController
$settingValue = rtrim($settingValue, '/'); $settingValue = rtrim($settingValue, '/');
} }
Setting::firstOrCreate([ Setting::firstOrCreate(['name' => $settingName])->update(['value' => $settingValue]);
'name' => $settingName,
])->update([
'value' => $settingValue,
]);
} }
} catch (Exception $e) { } catch (Exception $e) {
return Redirect::back()->with('errors', trans('dashboard.settings.edit.failure')); return Redirect::back()->withErrors(trans('dashboard.settings.edit.failure'));
} }
Lang::setLocale(Binput::get('app_locale')); Lang::setLocale(Binput::get('app_locale'));
return Redirect::back()->with('success', trans('dashboard.settings.edit.success')); return Redirect::back()
->withSuccess(trans('dashboard.settings.edit.success'));
} }
} }

View File

@@ -11,6 +11,7 @@
namespace CachetHQ\Cachet\Http\Controllers\Admin; namespace CachetHQ\Cachet\Http\Controllers\Admin;
use AltThree\Validator\ValidationException;
use CachetHQ\Cachet\Events\CustomerHasSubscribedEvent; use CachetHQ\Cachet\Events\CustomerHasSubscribedEvent;
use CachetHQ\Cachet\Http\Controllers\AbstractController; use CachetHQ\Cachet\Http\Controllers\AbstractController;
use CachetHQ\Cachet\Models\Subscriber; use CachetHQ\Cachet\Models\Subscriber;
@@ -30,10 +31,8 @@ class SubscriberController extends AbstractController
$subscribers = Subscriber::all(); $subscribers = Subscriber::all();
return View::make('dashboard.subscribers.index') return View::make('dashboard.subscribers.index')
->with([ ->withPageTitle(trans('dashboard.subscribers.subscribers').' - '.trans('dashboard.dashboard'))
'page_title' => trans('dashboard.subscribers.subscribers').' - '.trans('dashboard.dashboard'), ->withSubscribers(Subscriber::all());
'subscribers' => $subscribers,
]);
} }
/** /**
@@ -44,10 +43,7 @@ class SubscriberController extends AbstractController
public function showAddSubscriber() public function showAddSubscriber()
{ {
return View::make('dashboard.subscribers.add') return View::make('dashboard.subscribers.add')
->with([ ->withPageTitle(trans('dashboard.subscribers.add.title').' - '.trans('dashboard.dashboard'));
'page_title' => trans('dashboard.subscribers.add.title').' - '.trans('dashboard.dashboard'),
'incidentTemplates' => Subscriber::all(),
]);
} }
/** /**
@@ -59,31 +55,19 @@ class SubscriberController extends AbstractController
{ {
$email = Binput::get('email'); $email = Binput::get('email');
$subscriber = Subscriber::create([ try {
'email' => $email, $subscriber = Subscriber::create(['email' => $email]);
]); } catch (ValidationException $e) {
if (!$subscriber->isValid()) {
return Redirect::back() return Redirect::back()
->withInput(Binput::all()) ->withInput(Binput::all())
->with('title', sprintf( ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.subscribers.add.failure')))
'%s %s', ->withErrors($e->getMessageBag());
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)); event(new CustomerHasSubscribedEvent($subscriber));
return Redirect::back() return Redirect::back()
->with('success', $successMsg); ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.subscribers.add.success')));
} }
/** /**

View File

@@ -11,6 +11,7 @@
namespace CachetHQ\Cachet\Http\Controllers\Admin; namespace CachetHQ\Cachet\Http\Controllers\Admin;
use AltThree\Validator\ValidationException;
use CachetHQ\Cachet\Http\Controllers\AbstractController; use CachetHQ\Cachet\Http\Controllers\AbstractController;
use CachetHQ\Cachet\Models\User; use CachetHQ\Cachet\Models\User;
use GrahamCampbell\Binput\Facades\Binput; use GrahamCampbell\Binput\Facades\Binput;
@@ -28,10 +29,9 @@ class TeamController extends AbstractController
{ {
$team = User::all(); $team = User::all();
return View::make('dashboard.team.index')->with([ return View::make('dashboard.team.index')
'page_title' => trans('dashboard.team.team').' - '.trans('dashboard.dashboard'), ->withPageTitle(trans('dashboard.team.team').' - '.trans('dashboard.dashboard'))
'teamMembers' => $team, ->withTeamMembers($team);
]);
} }
/** /**
@@ -41,10 +41,9 @@ class TeamController extends AbstractController
*/ */
public function showTeamMemberView(User $user) public function showTeamMemberView(User $user)
{ {
return View::make('dashboard.team.edit')->with([ return View::make('dashboard.team.edit')
'page_title' => trans('dashboard.team.edit.title').' - '.trans('dashboard.dashboard'), ->withPageTitle(trans('dashboard.team.edit.title').' - '.trans('dashboard.dashboard'))
'user' => $user, ->withUser($user);
]);
} }
/** /**
@@ -54,9 +53,8 @@ class TeamController extends AbstractController
*/ */
public function showAddTeamMemberView() public function showAddTeamMemberView()
{ {
return View::make('dashboard.team.add')->with([ return View::make('dashboard.team.add')
'page_title' => trans('dashboard.team.add.title').' - '.trans('dashboard.dashboard'), ->withPageTitle(trans('dashboard.team.add.title').' - '.trans('dashboard.dashboard'));
]);
} }
/** /**
@@ -66,25 +64,17 @@ class TeamController extends AbstractController
*/ */
public function postAddUser() public function postAddUser()
{ {
$user = User::create(Binput::all()); try {
User::create(Binput::all());
if (!$user->isValid()) { } catch (ValidationException $e) {
return Redirect::back()->withInput(Binput::except('password')) return Redirect::back()
->with('title', sprintf( ->withInput(Binput::except('password'))
'%s %s', ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.add.failure')))
trans('dashboard.notifications.whoops'), ->withErrors($e->getMessageBag());
trans('dashboard.team.add.failure')
))
->with('errors', $user->getErrors());
} }
$successMsg = sprintf( return Redirect::back()
'%s %s', ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.add.success')));
trans('dashboard.notifications.awesome'),
trans('dashboard.team.add.success')
);
return Redirect::back()->with('success', $successMsg);
} }
/** /**
@@ -104,24 +94,16 @@ class TeamController extends AbstractController
unset($items['password']); unset($items['password']);
} }
try {
$user->update($items); $user->update($items);
} catch (ValidationException $e) {
if (!$user->isValid()) { return Redirect::back()
return Redirect::back()->withInput(Binput::except('password')) ->withInput(Binput::except('password'))
->with('title', sprintf( ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure')))
'%s %s', ->withErrors($e->getMessageBag());
trans('dashboard.notifications.whoops'),
trans('dashboard.team.edit.failure')
))
->with('errors', $user->getErrors());
} }
$successMsg = sprintf( return Redirect::back()
'%s %s', ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.edit.success')));
trans('dashboard.notifications.awesome'),
trans('dashboard.team.edit.success')
);
return Redirect::back()->with('success', $successMsg);
} }
} }

View File

@@ -11,6 +11,7 @@
namespace CachetHQ\Cachet\Http\Controllers\Admin; namespace CachetHQ\Cachet\Http\Controllers\Admin;
use AltThree\Validator\ValidationException;
use CachetHQ\Cachet\Http\Controllers\AbstractController; use CachetHQ\Cachet\Http\Controllers\AbstractController;
use CachetHQ\Cachet\Models\User; use CachetHQ\Cachet\Models\User;
use GrahamCampbell\Binput\Facades\Binput; use GrahamCampbell\Binput\Facades\Binput;
@@ -28,9 +29,8 @@ class UserController extends AbstractController
*/ */
public function showUser() public function showUser()
{ {
return View::make('dashboard.user.index')->with([ return View::make('dashboard.user.index')
'page_title' => trans('dashboard.team.profile').' - '.trans('dashboard.dashboard'), ->withPageTitle(trans('dashboard.team.profile').' - '.trans('dashboard.dashboard'));
]);
} }
/** /**
@@ -56,26 +56,17 @@ class UserController extends AbstractController
unset($items['password']); unset($items['password']);
} }
$user = Auth::user(); try {
$user->update($items); Auth::user()->update($items);
} catch (ValidationException $e) {
if (!$user->isValid()) { return Redirect::back()
return Redirect::back()->withInput(Binput::except('password')) ->withInput(Binput::except('password'))
->with('title', sprintf( ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure')))
'%s %s', ->withErrors($e->getMessageBag());
trans('dashboard.notifications.whoops'),
trans('dashboard.team.edit.failure')
))
->with('errors', $user->getErrors());
} }
$successMsg = sprintf( return Redirect::back()
'%s %s', ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.edit.success')));
trans('dashboard.notifications.awesome'),
trans('dashboard.team.edit.success')
);
return Redirect::back()->with('success', $successMsg);
} }
/** /**

View File

@@ -64,10 +64,6 @@ class ComponentController extends AbstractApiController
throw new BadRequestHttpException(); throw new BadRequestHttpException();
} }
if (!$component->isValid()) {
throw new BadRequestHttpException();
}
if (Binput::has('tags')) { if (Binput::has('tags')) {
// The component was added successfully, so now let's deal with the tags. // The component was added successfully, so now let's deal with the tags.
$tags = preg_split('/ ?, ?/', Binput::get('tags')); $tags = preg_split('/ ?, ?/', Binput::get('tags'));
@@ -94,9 +90,9 @@ class ComponentController extends AbstractApiController
*/ */
public function putComponent(Component $component) public function putComponent(Component $component)
{ {
try {
$component->update(Binput::except('tags')); $component->update(Binput::except('tags'));
} catch (Exception $e) {
if (!$component->isValid('updating')) {
throw new BadRequestHttpException(); throw new BadRequestHttpException();
} }
@@ -105,9 +101,7 @@ class ComponentController extends AbstractApiController
// For every tag, do we need to create it? // For every tag, do we need to create it?
$componentTags = array_map(function ($taggable) use ($component) { $componentTags = array_map(function ($taggable) use ($component) {
return Tag::firstOrCreate([ return Tag::firstOrCreate(['name' => $taggable])->id;
'name' => $taggable,
])->id;
}, $tags); }, $tags);
$component->tags()->sync($componentTags); $component->tags()->sync($componentTags);

View File

@@ -12,7 +12,6 @@
namespace CachetHQ\Cachet\Http\Controllers\Api; namespace CachetHQ\Cachet\Http\Controllers\Api;
use CachetHQ\Cachet\Events\IncidentHasReportedEvent; use CachetHQ\Cachet\Events\IncidentHasReportedEvent;
use CachetHQ\Cachet\Facades\Setting;
use CachetHQ\Cachet\Models\Incident; use CachetHQ\Cachet\Models\Incident;
use Exception; use Exception;
use GrahamCampbell\Binput\Facades\Binput; use GrahamCampbell\Binput\Facades\Binput;
@@ -34,8 +33,7 @@ class IncidentController extends AbstractApiController
{ {
$incidentVisiblity = $auth->check() ? 0 : 1; $incidentVisiblity = $auth->check() ? 0 : 1;
$incidents = Incident::where('visible', '>=', $incidentVisiblity) $incidents = Incident::where('visible', '>=', $incidentVisiblity)->paginate(Binput::get('per_page', 20));
->paginate(Binput::get('per_page', 20));
return $this->paginator($incidents, $request); return $this->paginator($incidents, $request);
} }
@@ -73,22 +71,13 @@ class IncidentController extends AbstractApiController
throw new BadRequestHttpException(); throw new BadRequestHttpException();
} }
$isEnabled = (bool) Setting::get('enable_subscribers', false); if (array_get($incidentData, 'notify') && subscribers_enabled()) {
$mailAddress = env('MAIL_ADDRESS', false);
$mailFrom = env('MAIL_NAME', false);
$subscribersEnabled = $isEnabled && $mailAddress && $mailFrom;
if (array_get($incidentData, 'notify') && $subscribersEnabled) {
event(new IncidentHasReportedEvent($incident)); event(new IncidentHasReportedEvent($incident));
} }
if ($incident->isValid()) {
return $this->item($incident); return $this->item($incident);
} }
throw new BadRequestHttpException();
}
/** /**
* Update an existing incident. * Update an existing incident.
* *
@@ -98,13 +87,13 @@ class IncidentController extends AbstractApiController
*/ */
public function putIncident(Incident $incident) public function putIncident(Incident $incident)
{ {
try {
$incident->update(Binput::all()); $incident->update(Binput::all());
} catch (Exception $e) {
if ($incident->isValid('updating')) { throw new BadRequestHttpException();
return $this->item($incident);
} }
throw new BadRequestHttpException(); return $this->item($incident);
} }
/** /**

View File

@@ -70,13 +70,9 @@ class MetricController extends AbstractApiController
throw new BadRequestHttpException(); throw new BadRequestHttpException();
} }
if ($metric->isValid()) {
return $this->item($metric); return $this->item($metric);
} }
throw new BadRequestHttpException();
}
/** /**
* Update an existing metric. * Update an existing metric.
* *
@@ -86,13 +82,13 @@ class MetricController extends AbstractApiController
*/ */
public function putMetric(Metric $metric) public function putMetric(Metric $metric)
{ {
try {
$metric->update(Binput::all()); $metric->update(Binput::all());
} catch (Exception $e) {
if ($metric->isValid('updating')) { throw new BadRequestHttpException();
return $this->item($metric);
} }
throw new BadRequestHttpException(); return $this->item($metric);
} }
/** /**

View File

@@ -49,7 +49,6 @@ class SubscriberController extends AbstractApiController
throw new BadRequestHttpException(); throw new BadRequestHttpException();
} }
if ($subscriber->isValid()) {
// If we're auto-verifying the subscriber, don't bother with this event. // If we're auto-verifying the subscriber, don't bother with this event.
if (!(Binput::get('verify'))) { if (!(Binput::get('verify'))) {
event(new CustomerHasSubscribedEvent($subscriber)); event(new CustomerHasSubscribedEvent($subscriber));
@@ -58,9 +57,6 @@ class SubscriberController extends AbstractApiController
return $this->item($subscriber); return $this->item($subscriber);
} }
throw new BadRequestHttpException();
}
/** /**
* Delete a subscriber. * Delete a subscriber.
* *

View File

@@ -56,6 +56,8 @@ class AtomController extends AbstractController
* *
* @param \Roumen\Feed\Facades\Feed $feed * @param \Roumen\Feed\Facades\Feed $feed
* @param \CachetHQ\Cachet\Models\Incident $incident * @param \CachetHQ\Cachet\Models\Incident $incident
*
* @return void
*/ */
private function feedAddItem(&$feed, $incident) private function feedAddItem(&$feed, $incident)
{ {

View File

@@ -19,9 +19,6 @@ use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\View; use Illuminate\Support\Facades\View;
use PragmaRX\Google2FA\Vendor\Laravel\Facade as Google2FA; use PragmaRX\Google2FA\Vendor\Laravel\Facade as Google2FA;
/**
* Logs users into their account.
*/
class AuthController extends AbstractController class AuthController extends AbstractController
{ {
/** /**
@@ -31,9 +28,8 @@ class AuthController extends AbstractController
*/ */
public function showLogin() public function showLogin()
{ {
return View::make('auth.login')->with([ return View::make('auth.login')
'page_title' => trans('dashboard.login.login'), ->withPageTitle(trans('dashboard.login.login'));
]);
} }
/** /**
@@ -64,7 +60,7 @@ class AuthController extends AbstractController
return Redirect::back() return Redirect::back()
->withInput(Binput::except('password')) ->withInput(Binput::except('password'))
->with('error', trans('forms.login.invalid')); ->withError(trans('forms.login.invalid'));
} }
/** /**
@@ -101,11 +97,11 @@ class AuthController extends AbstractController
// Failed login, log back out. // Failed login, log back out.
Auth::logout(); Auth::logout();
return Redirect::route('login')->with('error', trans('forms.login.invalid-token')); return Redirect::route('login')->withError(trans('forms.login.invalid-token'));
} }
} }
return Redirect::route('login')->with('error', trans('forms.login.invalid-token')); return Redirect::route('login')->withError(trans('forms.login.invalid-token'));
} }
/** /**

View File

@@ -92,21 +92,18 @@ class HomeController extends AbstractController
$componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get(); $componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get();
$ungroupedComponents = Component::where('group_id', 0)->orderBy('order')->orderBy('created_at')->get(); $ungroupedComponents = Component::where('group_id', 0)->orderBy('order')->orderBy('created_at')->get();
$canPageBackward = Incident::notScheduled()->where('created_at', '<', $startDate->format('Y-m-d'))->count() != 0; return View::make('index')
->withComponentGroups($componentGroups)
return View::make('index', [ ->withUngroupedComponents($ungroupedComponents)
'componentGroups' => $componentGroups, ->withDisplayMetrics($displayMetrics)
'ungroupedComponents' => $ungroupedComponents, ->withMetrics($metrics)
'displayMetrics' => $displayMetrics, ->withAllIncidents($allIncidents)
'metrics' => $metrics, ->withScheduledMaintenance($scheduledMaintenance)
'allIncidents' => $allIncidents, ->withAboutApp(Markdown::convertToHtml(Setting::get('app_about')))
'scheduledMaintenance' => $scheduledMaintenance, ->withCanPageForward((bool) $today->gt($startDate))
'aboutApp' => Markdown::convertToHtml(Setting::get('app_about')), ->withCanPageBackward(Incident::notScheduled()->where('created_at', '<', $startDate->format('Y-m-d'))->count() > 0)
'canPageForward' => (bool) $today->gt($startDate), ->withPreviousDate($startDate->copy()->subDays($daysToShow)->toDateString())
'canPageBackward' => $canPageBackward, ->withNextDate($startDate->copy()->addDays($daysToShow)->toDateString())
'previousDate' => $startDate->copy()->subDays($daysToShow)->toDateString(), ->withPageTitle(Setting::get('app_name'));
'nextDate' => $startDate->copy()->addDays($daysToShow)->toDateString(),
'page_title' => Setting::get('app_name'),
]);
} }
} }

View File

@@ -41,6 +41,8 @@ class SetupController extends AbstractController
/** /**
* Create a new setup controller instance. * Create a new setup controller instance.
*
* @return void
*/ */
public function __construct() public function __construct()
{ {
@@ -59,11 +61,10 @@ class SetupController extends AbstractController
$this->keyGenerate(); $this->keyGenerate();
} }
return View::make('setup')->with([ return View::make('setup')
'page_title' => trans('setup.setup'), ->withPageTitle(trans('setup.setup'))
'cacheDrivers' => $this->cacheDrivers, ->withCacheDrivers($this->cacheDrivers)
'appUrl' => Request::root(), ->withAppUrl(Request::root());
]);
} }
/** /**
@@ -82,9 +83,9 @@ class SetupController extends AbstractController
if ($v->passes()) { if ($v->passes()) {
return Response::json(['status' => 1]); return Response::json(['status' => 1]);
} else {
return Response::json(['errors' => $v->messages()], 400);
} }
return Response::json(['errors' => $v->getMessageBag()], 400);
} }
/** /**
@@ -108,9 +109,9 @@ class SetupController extends AbstractController
if ($v->passes()) { if ($v->passes()) {
return Response::json(['status' => 1]); return Response::json(['status' => 1]);
} else {
return Response::json(['errors' => $v->messages()], 400);
} }
return Response::json(['errors' => $v->getMessageBag()], 400);
} }
/** /**
@@ -171,13 +172,13 @@ class SetupController extends AbstractController
} }
return Redirect::to('dashboard'); return Redirect::to('dashboard');
} else {
if (Request::ajax()) {
return Response::json(['errors' => $v->messages()], 400);
} }
return Redirect::back()->withInput()->with('errors', $v->messages()); if (Request::ajax()) {
return Response::json(['errors' => $v->getMessageBag()], 400);
} }
return Redirect::back()->withInput()->withErrors($v->getMessageBag());
} }
/** /**
@@ -185,6 +186,8 @@ class SetupController extends AbstractController
* *
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
*
* @return void
*/ */
protected function writeEnv($key, $value) protected function writeEnv($key, $value)
{ {
@@ -200,6 +203,8 @@ class SetupController extends AbstractController
/** /**
* Generate the app.key value. * Generate the app.key value.
*
* @return void
*/ */
protected function keyGenerate() protected function keyGenerate()
{ {

View File

@@ -11,6 +11,7 @@
namespace CachetHQ\Cachet\Http\Controllers; namespace CachetHQ\Cachet\Http\Controllers;
use AltThree\Validator\ValidationException;
use CachetHQ\Cachet\Events\CustomerHasSubscribedEvent; use CachetHQ\Cachet\Events\CustomerHasSubscribedEvent;
use CachetHQ\Cachet\Facades\Setting; use CachetHQ\Cachet\Facades\Setting;
use CachetHQ\Cachet\Models\Subscriber; use CachetHQ\Cachet\Models\Subscriber;
@@ -30,10 +31,9 @@ class SubscribeController extends AbstractController
*/ */
public function showSubscribe() public function showSubscribe()
{ {
return View::make('subscribe', [ return View::make('subscribe')
'page_title' => Setting::get('app_name'), ->withPageTitle(Setting::get('app_name'))
'aboutApp' => Markdown::convertToHtml(Setting::get('app_about')), ->withAboutApp(Markdown::convertToHtml(Setting::get('app_about')));
]);
} }
/** /**
@@ -43,33 +43,25 @@ class SubscribeController extends AbstractController
*/ */
public function postSubscribe() public function postSubscribe()
{ {
try {
$subscriber = Subscriber::create(['email' => Binput::get('email')]); $subscriber = Subscriber::create(['email' => Binput::get('email')]);
} catch (ValidationException $e) {
if (!$subscriber->isValid()) { return Redirect::back()
return Redirect::back()->withInput(Binput::all()) ->withInput(Binput::all())
->with('title', sprintf( ->withTitle(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))
'<strong>%s</strong> %s', ->withErrors($e->getMessageBag());
trans('dashboard.notifications.whoops'),
trans('cachet.subscriber.email.failure')
))
->with('errors', $subscriber->getErrors());
} }
$successMsg = sprintf(
'<strong>%s</strong> %s',
trans('dashboard.notifications.awesome'),
trans('cachet.subscriber.email.subscribed')
);
event(new CustomerHasSubscribedEvent($subscriber)); event(new CustomerHasSubscribedEvent($subscriber));
return Redirect::route('status-page')->with('success', $successMsg); return Redirect::route('status-page')
->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed')));
} }
/** /**
* Handle the verify subscriber email. * Handle the verify subscriber email.
* *
* @param string $code * @param string|null $code
* *
* @return \Illuminate\View\View * @return \Illuminate\View\View
*/ */
@@ -88,19 +80,14 @@ class SubscribeController extends AbstractController
$subscriber->verified_at = Carbon::now(); $subscriber->verified_at = Carbon::now();
$subscriber->save(); $subscriber->save();
$successMsg = sprintf( return Redirect::route('status-page')
'<strong>%s</strong> %s', ->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.verified')));
trans('dashboard.notifications.awesome'),
trans('cachet.subscriber.email.verified')
);
return Redirect::route('status-page')->with('success', $successMsg);
} }
/** /**
* Handle the unsubscribe. * Handle the unsubscribe.
* *
* @param string $code * @param string|null $code
* *
* @return \Illuminate\View\View * @return \Illuminate\View\View
*/ */
@@ -118,12 +105,7 @@ class SubscribeController extends AbstractController
$subscriber->delete(); $subscriber->delete();
$successMsg = sprintf( return Redirect::route('status-page')
'<strong>%s</strong> %s', ->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.unsuscribed')));
trans('dashboard.notifications.awesome'),
trans('cachet.subscriber.email.unsuscribed')
);
return Redirect::route('status-page')->with('success', $successMsg);
} }
} }

View File

@@ -11,12 +11,12 @@
namespace CachetHQ\Cachet\Models; namespace CachetHQ\Cachet\Models;
use AltThree\Validator\ValidatingTrait;
use CachetHQ\Cachet\Presenters\ComponentPresenter; use CachetHQ\Cachet\Presenters\ComponentPresenter;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use McCool\LaravelAutoPresenter\HasPresenter; use McCool\LaravelAutoPresenter\HasPresenter;
use Watson\Validating\ValidatingTrait;
class Component extends Model implements HasPresenter class Component extends Model implements HasPresenter
{ {
@@ -27,7 +27,7 @@ class Component extends Model implements HasPresenter
* *
* @var string[] * @var string[]
*/ */
protected $rules = [ public $rules = [
'name' => 'required|string', 'name' => 'required|string',
'status' => 'integer|required', 'status' => 'integer|required',
'link' => 'url', 'link' => 'url',

View File

@@ -11,8 +11,8 @@
namespace CachetHQ\Cachet\Models; namespace CachetHQ\Cachet\Models;
use AltThree\Validator\ValidatingTrait;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Watson\Validating\ValidatingTrait;
class ComponentGroup extends Model class ComponentGroup extends Model
{ {
@@ -23,8 +23,8 @@ class ComponentGroup extends Model
* *
* @var string[] * @var string[]
*/ */
protected $rules = [ public $rules = [
'name' => 'required|unique:component_groups', 'name' => 'required',
]; ];
/** /**

View File

@@ -11,12 +11,12 @@
namespace CachetHQ\Cachet\Models; namespace CachetHQ\Cachet\Models;
use AltThree\Validator\ValidatingTrait;
use CachetHQ\Cachet\Presenters\IncidentPresenter; use CachetHQ\Cachet\Presenters\IncidentPresenter;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use McCool\LaravelAutoPresenter\HasPresenter; use McCool\LaravelAutoPresenter\HasPresenter;
use Watson\Validating\ValidatingTrait;
class Incident extends Model implements HasPresenter class Incident extends Model implements HasPresenter
{ {
@@ -27,7 +27,7 @@ class Incident extends Model implements HasPresenter
* *
* @var string[] * @var string[]
*/ */
protected $rules = [ public $rules = [
'component_id' => 'integer', 'component_id' => 'integer',
'name' => 'required', 'name' => 'required',
'status' => 'required|integer', 'status' => 'required|integer',

View File

@@ -11,9 +11,9 @@
namespace CachetHQ\Cachet\Models; namespace CachetHQ\Cachet\Models;
use AltThree\Validator\ValidatingTrait;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Watson\Validating\ValidatingTrait;
class IncidentTemplate extends Model class IncidentTemplate extends Model
{ {
@@ -24,7 +24,7 @@ class IncidentTemplate extends Model
* *
* @var string[] * @var string[]
*/ */
protected $rules = [ public $rules = [
'name' => 'required', 'name' => 'required',
'template' => 'required', 'template' => 'required',
]; ];

View File

@@ -11,6 +11,7 @@
namespace CachetHQ\Cachet\Models; namespace CachetHQ\Cachet\Models;
use AltThree\Validator\ValidatingTrait;
use CachetHQ\Cachet\Facades\Setting as SettingFacade; use CachetHQ\Cachet\Facades\Setting as SettingFacade;
use CachetHQ\Cachet\Presenters\MetricPresenter; use CachetHQ\Cachet\Presenters\MetricPresenter;
use DateInterval; use DateInterval;
@@ -19,7 +20,6 @@ use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Jenssegers\Date\Date; use Jenssegers\Date\Date;
use McCool\LaravelAutoPresenter\HasPresenter; use McCool\LaravelAutoPresenter\HasPresenter;
use Watson\Validating\ValidatingTrait;
class Metric extends Model implements HasPresenter class Metric extends Model implements HasPresenter
{ {
@@ -45,7 +45,7 @@ class Metric extends Model implements HasPresenter
* *
* @var string[] * @var string[]
*/ */
protected $rules = [ public $rules = [
'name' => 'required', 'name' => 'required',
'suffix' => 'required', 'suffix' => 'required',
'display_chart' => 'boolean', 'display_chart' => 'boolean',

View File

@@ -11,10 +11,10 @@
namespace CachetHQ\Cachet\Models; namespace CachetHQ\Cachet\Models;
use AltThree\Validator\ValidatingTrait;
use CachetHQ\Cachet\Presenters\MetricPointPresenter; use CachetHQ\Cachet\Presenters\MetricPointPresenter;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use McCool\LaravelAutoPresenter\HasPresenter; use McCool\LaravelAutoPresenter\HasPresenter;
use Watson\Validating\ValidatingTrait;
class MetricPoint extends Model implements HasPresenter class MetricPoint extends Model implements HasPresenter
{ {
@@ -32,7 +32,7 @@ class MetricPoint extends Model implements HasPresenter
* *
* @var string[] * @var string[]
*/ */
protected $rules = [ public $rules = [
'value' => 'numeric|required', 'value' => 'numeric|required',
]; ];

View File

@@ -11,10 +11,10 @@
namespace CachetHQ\Cachet\Models; namespace CachetHQ\Cachet\Models;
use AltThree\Validator\ValidatingTrait;
use CachetHQ\Cachet\Presenters\SubscriberPresenter; use CachetHQ\Cachet\Presenters\SubscriberPresenter;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use McCool\LaravelAutoPresenter\HasPresenter; use McCool\LaravelAutoPresenter\HasPresenter;
use Watson\Validating\ValidatingTrait;
class Subscriber extends Model implements HasPresenter class Subscriber extends Model implements HasPresenter
{ {
@@ -25,8 +25,8 @@ class Subscriber extends Model implements HasPresenter
* *
* @var string[] * @var string[]
*/ */
protected $rules = [ public $rules = [
'email' => 'required|email|unique:subscribers', 'email' => 'required|email',
]; ];
/** /**

View File

@@ -11,6 +11,7 @@
namespace CachetHQ\Cachet\Models; namespace CachetHQ\Cachet\Models;
use AltThree\Validator\ValidatingTrait;
use Illuminate\Auth\Authenticatable; use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword; use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
@@ -18,7 +19,6 @@ use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Watson\Validating\ValidatingTrait;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{ {
@@ -29,9 +29,9 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
* *
* @var string[] * @var string[]
*/ */
protected $rules = [ public $rules = [
'username' => ['required', 'regex:/\A(?!.*[:;]-\))[ -~]+\z/', 'unique:users'], 'username' => ['required', 'regex:/\A(?!.*[:;]-\))[ -~]+\z/'],
'email' => 'required|email|unique:users', 'email' => 'required|email',
'password' => 'required', 'password' => 'required',
]; ];

View File

@@ -12,9 +12,9 @@
namespace CachetHQ\Cachet\Providers; namespace CachetHQ\Cachet\Providers;
use CachetHQ\Cachet\Composers\AppComposer; use CachetHQ\Cachet\Composers\AppComposer;
use CachetHQ\Cachet\Composers\CurrentUserComposer;
use CachetHQ\Cachet\Composers\DashboardComposer; use CachetHQ\Cachet\Composers\DashboardComposer;
use CachetHQ\Cachet\Composers\IndexComposer; use CachetHQ\Cachet\Composers\IndexComposer;
use CachetHQ\Cachet\Composers\LoggedUserComposer;
use CachetHQ\Cachet\Composers\ThemeComposer; use CachetHQ\Cachet\Composers\ThemeComposer;
use CachetHQ\Cachet\Composers\TimezoneLocaleComposer; use CachetHQ\Cachet\Composers\TimezoneLocaleComposer;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
@@ -30,7 +30,7 @@ class ComposerServiceProvider extends ServiceProvider
public function boot(Factory $factory) public function boot(Factory $factory)
{ {
$factory->composer('*', AppComposer::class); $factory->composer('*', AppComposer::class);
$factory->composer('*', LoggedUserComposer::class); $factory->composer('*', CurrentUserComposer::class);
$factory->composer(['index', 'subscribe'], IndexComposer::class); $factory->composer(['index', 'subscribe'], IndexComposer::class);
$factory->composer(['index', 'subscribe'], ThemeComposer::class); $factory->composer(['index', 'subscribe'], ThemeComposer::class);
$factory->composer('dashboard.*', DashboardComposer::class); $factory->composer('dashboard.*', DashboardComposer::class);

View File

@@ -22,6 +22,7 @@
"php": "^5.5.9", "php": "^5.5.9",
"laravel/framework": "~5.1.6", "laravel/framework": "~5.1.6",
"alt-three/emoji": "^1.0", "alt-three/emoji": "^1.0",
"alt-three/validator": "^1.2",
"barryvdh/laravel-cors": "^0.5", "barryvdh/laravel-cors": "^0.5",
"doctrine/dbal": "^2.5", "doctrine/dbal": "^2.5",
"fideloper/proxy": "^3.0", "fideloper/proxy": "^3.0",
@@ -33,8 +34,7 @@
"jenssegers/date": "^3.0", "jenssegers/date": "^3.0",
"mccool/laravel-auto-presenter": "^3.1", "mccool/laravel-auto-presenter": "^3.1",
"pragmarx/google2fa": "^0.5", "pragmarx/google2fa": "^0.5",
"roumen/feed": "^2.9", "roumen/feed": "^2.9"
"watson/validating": "^1.0"
}, },
"require-dev": { "require-dev": {
"fzaninotto/faker": "^1.5", "fzaninotto/faker": "^1.5",

117
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "f7d40ec10be871e505c18b6e4331322d", "hash": "b875f1d2eed19b89b2c784345ca2d200",
"packages": [ "packages": [
{ {
"name": "alt-three/emoji", "name": "alt-three/emoji",
@@ -67,6 +67,66 @@
], ],
"time": "2015-07-25 14:20:46" "time": "2015-07-25 14:20:46"
}, },
{
"name": "alt-three/validator",
"version": "v1.2.0",
"source": {
"type": "git",
"url": "https://github.com/AltThree/Validator.git",
"reference": "01fc9ab865df38254d03c749f6a266529a2df392"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/AltThree/Validator/zipball/01fc9ab865df38254d03c749f6a266529a2df392",
"reference": "01fc9ab865df38254d03c749f6a266529a2df392",
"shasum": ""
},
"require": {
"illuminate/contracts": "5.1.*",
"illuminate/support": "5.1.*",
"php": ">=5.5.9",
"psr/log": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.7.6"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2-dev"
}
},
"autoload": {
"psr-4": {
"AltThree\\Validator\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "James Brooks",
"email": "james@alt-three.com"
},
{
"name": "Graham Campbell",
"email": "graham@alt-three.com"
},
{
"name": "Joseph Cohen",
"email": "joe@alt-three.com"
}
],
"description": "A Validation Wrapper For Laravel 5",
"keywords": [
"Alt Three",
"logging",
"validator"
],
"time": "2015-07-28 23:55:40"
},
{ {
"name": "asm89/stack-cors", "name": "asm89/stack-cors",
"version": "0.2.1", "version": "0.2.1",
@@ -3165,61 +3225,6 @@
"environment" "environment"
], ],
"time": "2015-05-30 15:59:26" "time": "2015-05-30 15:59:26"
},
{
"name": "watson/validating",
"version": "1.0.3",
"source": {
"type": "git",
"url": "https://github.com/dwightwatson/validating.git",
"reference": "c32912f760b456c043657951683ed6c468ab83e7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dwightwatson/validating/zipball/c32912f760b456c043657951683ed6c468ab83e7",
"reference": "c32912f760b456c043657951683ed6c468ab83e7",
"shasum": ""
},
"require": {
"illuminate/contracts": "5.0.*|5.1.*",
"illuminate/database": "5.0.*|5.1.*",
"illuminate/events": "5.0.*|5.1.*",
"illuminate/support": "5.0.*|5.1.*",
"illuminate/validation": "5.0.*|5.1.*",
"php": ">=5.4.0"
},
"require-dev": {
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"Watson\\Validating\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Dwight Watson",
"email": "dwight@studiousapp.com"
}
],
"description": "Eloquent model validating trait.",
"keywords": [
"eloquent",
"laravel",
"validation"
],
"time": "2015-06-03 02:25:38"
} }
], ],
"packages-dev": [ "packages-dev": [

View File

@@ -58,7 +58,7 @@
</div> </div>
</fieldset> </fieldset>
<input type="hidden" name="component[user_id]" value="{{ $component->agent_id || $loggedUser->id }}"> <input type="hidden" name="component[user_id]" value="{{ $component->agent_id || $current_user->id }}">
<input type="hidden" name="component[order]" value="{{ $component->order or 0 }}"> <input type="hidden" name="component[order]" value="{{ $component->order or 0 }}">
<div class="btn-group"> <div class="btn-group">

View File

@@ -17,12 +17,12 @@
<form class="form-vertical" name="IncidentForm" role="form" method="POST" autocomplete="off"> <form class="form-vertical" name="IncidentForm" role="form" method="POST" autocomplete="off">
<input type="hidden" name="_token" value="{{ csrf_token() }}"> <input type="hidden" name="_token" value="{{ csrf_token() }}">
<fieldset> <fieldset>
@if($incidentTemplates->count() > 0) @if($incident_templates->count() > 0)
<div class="form-group"> <div class="form-group">
<label for="incident-template">{{ trans('forms.incidents.templates.template') }}</label> <label for="incident-template">{{ trans('forms.incidents.templates.template') }}</label>
<select class="form-control" name="template"> <select class="form-control" name="template">
<option selected></option> <option selected></option>
@foreach($incidentTemplates as $tpl) @foreach($incident_templates as $tpl)
<option value="{{ $tpl->slug }}">{{ $tpl->name }}</option> <option value="{{ $tpl->slug }}">{{ $tpl->name }}</option>
@endforeach @endforeach
</select> </select>
@@ -62,19 +62,19 @@
<option value='0'>{{ trans('forms.incidents.logged_in_only') }}</option> <option value='0'>{{ trans('forms.incidents.logged_in_only') }}</option>
</select> </select>
</div> </div>
@if(!$componentsInGroups->isEmpty() || !$componentsOutGroups->isEmpty()) @if(!$components_in_groups->isEmpty() || !$components_out_groups->isEmpty())
<div class="form-group"> <div class="form-group">
<label>{{ trans('forms.incidents.component') }}</label> <label>{{ trans('forms.incidents.component') }}</label>
<select name='incident[component_id]' class='form-control'> <select name='incident[component_id]' class='form-control'>
<option value='0' selected></option> <option value='0' selected></option>
@foreach($componentsInGroups as $group) @foreach($components_in_groups as $group)
<optgroup label="{{ $group->name }}"> <optgroup label="{{ $group->name }}">
@foreach($group->components as $component) @foreach($group->components as $component)
<option value='{{ $component->id }}'>{{ $component->name }}</option> <option value='{{ $component->id }}'>{{ $component->name }}</option>
@endforeach @endforeach
</optgroup> </optgroup>
@endforeach @endforeach
@foreach($componentsOutGroups as $component) @foreach($components_out_groups as $component)
<option value='{{ $component->id }}'>{{ $component->name }}</option> <option value='{{ $component->id }}'>{{ $component->name }}</option>
@endforeach @endforeach
</select> </select>

View File

@@ -13,12 +13,12 @@
<div class="content-wrapper"> <div class="content-wrapper">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
@if($updatedTemplate = Session::get('updatedTemplate')) @if($updated_template = Session::get('updated_template'))
<div class="alert alert-{{ $updatedTemplate->isValid() ? 'success' : 'danger' }}"> <div class="alert alert-{{ ($template_errors = Session::get('template_errors')) ? 'danger' : 'success' }}">
@if($updatedTemplate->isValid()) @if($template_errors)
{{ sprintf("%s - %s", trans('dashboard.notifications.awesome'), trans('dashboard.incidents.templates.edit.success')) }} {{ sprintf("%s - %s", trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure').' '.$template_errors) }}
@else @else
{{ sprintf("%s - %s", trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure').' '.$updatedTemplate->getErrors()) }} {{ sprintf("%s - %s", trans('dashboard.notifications.awesome'), trans('dashboard.incidents.templates.edit.success')) }}
@endif @endif
</div> </div>
@endif @endif

View File

@@ -16,7 +16,7 @@
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-12">
<div class="striped-list"> <div class="striped-list">
@foreach($incidentTemplates as $template) @foreach($incident_templates as $template)
<div class="row striped-list-item"> <div class="row striped-list-item">
<div class="col-xs-6"> <div class="col-xs-6">
<strong>{{ $template->name }}</strong> <strong>{{ $template->name }}</strong>

View File

@@ -18,12 +18,12 @@
<input type="hidden" name="_token" value="{{ csrf_token() }}"> <input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="hidden" name="incident[visible]" value="1"> <input type="hidden" name="incident[visible]" value="1">
<fieldset> <fieldset>
@if($incidentTemplates->count() > 0) @if($incident_templates->count() > 0)
<div class="form-group"> <div class="form-group">
<label for="incident-template">{{ trans('forms.incidents.templates.template') }}</label> <label for="incident-template">{{ trans('forms.incidents.templates.template') }}</label>
<select class="form-control" name="template"> <select class="form-control" name="template">
<option selected></option> <option selected></option>
@foreach($incidentTemplates as $tpl) @foreach($incident_templates as $tpl)
<option value="{{ $tpl->slug }}">{{ $tpl->name }}</option> <option value="{{ $tpl->slug }}">{{ $tpl->name }}</option>
@endforeach @endforeach
</select> </select>

View File

@@ -18,12 +18,12 @@
<input type="hidden" name="_token" value="{{ csrf_token() }}"> <input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="hidden" name="incident[visible]" value="1"> <input type="hidden" name="incident[visible]" value="1">
<fieldset> <fieldset>
@if($incidentTemplates->count() > 0) @if($incident_templates->count() > 0)
<div class="form-group"> <div class="form-group">
<label for="incident-template">{{ trans('forms.incidents.templates.template') }}</label> <label for="incident-template">{{ trans('forms.incidents.templates.template') }}</label>
<select class="form-control" name="template"> <select class="form-control" name="template">
<option selected></option> <option selected></option>
@foreach($incidentTemplates as $tpl) @foreach($incident_templates as $tpl)
<option value="{{ $tpl->slug }}">{{ $tpl->name }}</option> <option value="{{ $tpl->slug }}">{{ $tpl->name }}</option>
@endforeach @endforeach
</select> </select>

View File

@@ -38,13 +38,13 @@
</div> </div>
</div> </div>
@if(! $unsecureUsers->isEmpty()) @if(!$unsecure_users->isEmpty())
<hr> <hr>
<div class="panel panel-danger"> <div class="panel panel-danger">
<div class="panel-heading">{{ trans('dashboard.settings.security.two-factor') }}</div> <div class="panel-heading">{{ trans('dashboard.settings.security.two-factor') }}</div>
<div class="list-group"> <div class="list-group">
@foreach($unsecureUsers as $user) @foreach($unsecure_users as $user)
<div class="list-group-item"> <div class="list-group-item">
<strong>{{ $user->username }}</strong> <strong>{{ $user->username }}</strong>
<span class="label label-danger pull-right"><i class="ion-ios-unlocked"></i></span> <span class="label label-danger pull-right"><i class="ion-ios-unlocked"></i></span>

View File

@@ -8,7 +8,7 @@
<span class="uppercase"> <span class="uppercase">
<i class="icon icon ion-android-alert"></i> {{ trans('dashboard.subscribers.subscribers') }} <i class="icon icon ion-android-alert"></i> {{ trans('dashboard.subscribers.subscribers') }}
</span> </span>
@if($loggedUser->isAdmin) @if($current_user->isAdmin)
<a class="btn btn-sm btn-success pull-right" href="{{ route('dashboard.subscribers.add') }}"> <a class="btn btn-sm btn-success pull-right" href="{{ route('dashboard.subscribers.add') }}">
{{ trans('dashboard.subscribers.add.title') }} {{ trans('dashboard.subscribers.add.title') }}
</a> </a>

View File

@@ -28,7 +28,7 @@
<label>{{ trans('forms.user.password') }}</label> <label>{{ trans('forms.user.password') }}</label>
<input type="password" class="form-control" name="password" value=""> <input type="password" class="form-control" name="password" value="">
</div> </div>
@if($loggedUser->isAdmin) @if($current_user->isAdmin)
<div class="form-group"> <div class="form-group">
<label>{{ trans('forms.user.user_level') }}</label> <label>{{ trans('forms.user.user_level') }}</label>
<select name="level" class="form-control"> <select name="level" class="form-control">

View File

@@ -26,13 +26,13 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label>{{ trans('forms.user.password') }}</label> <label>{{ trans('forms.user.password') }}</label>
<input type="password" class="form-control" name="password" value="" {{ !$loggedUser->isAdmin ? "disabled": "" }}> <input type="password" class="form-control" name="password" value="" {{ !$current_user->isAdmin ? "disabled": "" }}>
</div> </div>
</fieldset> </fieldset>
<div class="form-group"> <div class="form-group">
<button type="submit" class="btn btn-success">{{ trans('forms.update') }}</button> <button type="submit" class="btn btn-success">{{ trans('forms.update') }}</button>
@if($loggedUser->isAdmin) @if($current_user->isAdmin)
<a class="btn btn-danger" href="/dashboard/user/{{ $user->id }}/api/regen">{{ trans('cachet.api.revoke') }}</a> <a class="btn btn-danger" href="/dashboard/user/{{ $user->id }}/api/regen">{{ trans('cachet.api.revoke') }}</a>
@endif @endif
</div> </div>

View File

@@ -8,7 +8,7 @@
<span class="uppercase"> <span class="uppercase">
<i class="icon icon ion-android-alert"></i> {{ trans('dashboard.team.team') }} <i class="icon icon ion-android-alert"></i> {{ trans('dashboard.team.team') }}
</span> </span>
@if($loggedUser->isAdmin) @if($current_user->isAdmin)
<a class="btn btn-sm btn-success pull-right" href="{{ route('dashboard.team.add') }}"> <a class="btn btn-sm btn-success pull-right" href="{{ route('dashboard.team.add') }}">
{{ trans('dashboard.team.add.title') }} {{ trans('dashboard.team.add.title') }}
</a> </a>
@@ -21,9 +21,9 @@
<p class="lead">{{ trans('dashboard.team.description') }}</p> <p class="lead">{{ trans('dashboard.team.description') }}</p>
<div class="user-grid"> <div class="user-grid">
@foreach($teamMembers as $member) @foreach($team_members as $member)
<div class="user col-sm-3 col-xs-6"> <div class="user col-sm-3 col-xs-6">
<a href="@if($loggedUser->id == $member->id) {{ url('dashboard/user') }} @else /dashboard/team/{{ $member->id }} @endif"> <a href="@if($current_user->id == $member->id) {{ url('dashboard/user') }} @else /dashboard/team/{{ $member->id }} @endif">
<img src="{{ $member->gravatar }}"> <img src="{{ $member->gravatar }}">
</a> </a>
<div class="name">{{ $member->username }}</div> <div class="name">{{ $member->username }}</div>

View File

@@ -17,11 +17,11 @@
<fieldset> <fieldset>
<div class="form-group"> <div class="form-group">
<label>{{ trans('forms.user.username') }}</label> <label>{{ trans('forms.user.username') }}</label>
<input type="text" class="form-control" name="username" value="{{ $loggedUser->username }}" required> <input type="text" class="form-control" name="username" value="{{ $current_user->username }}" required>
</div> </div>
<div class="form-group"> <div class="form-group">
<label>{{ trans('forms.user.email') }}</label> <label>{{ trans('forms.user.email') }}</label>
<input type="email" class="form-control" name="email" value="{{ $loggedUser->email }}" required> <input type="email" class="form-control" name="email" value="{{ $current_user->email }}" required>
</div> </div>
<div class="form-group"> <div class="form-group">
<label>{{ trans('forms.user.password') }}</label> <label>{{ trans('forms.user.password') }}</label>
@@ -31,8 +31,8 @@
<div class="form-group"> <div class="form-group">
<label>{{ trans('forms.user.api-token') }}</label> <label>{{ trans('forms.user.api-token') }}</label>
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" name="api_key" disabled value="{{ $loggedUser->api_key }}"> <input type="text" class="form-control" name="api_key" disabled value="{{ $current_user->api_key }}">
<a href="/dashboard/user/{{ $loggedUser->id }}/api/regen" class="input-group-addon btn btn-danger">{{ trans('cachet.api.regenerate') }}</a> <a href="/dashboard/user/{{ $current_user->id }}/api/regen" class="input-group-addon btn btn-danger">{{ trans('cachet.api.regenerate') }}</a>
</div> </div>
<span class="help-block">{{ trans('forms.user.api-token-help') }}</span> <span class="help-block">{{ trans('forms.user.api-token-help') }}</span>
</div> </div>
@@ -40,17 +40,17 @@
<div class="form-group"> <div class="form-group">
<label class="checkbox-inline"> <label class="checkbox-inline">
<input type="hidden" name="google2fa" value="0"> <input type="hidden" name="google2fa" value="0">
<input type='checkbox' name="google2fa" value="1" {{ $loggedUser->hasTwoFactor ? "checked" : "" }}> <input type='checkbox' name="google2fa" value="1" {{ $current_user->hasTwoFactor ? "checked" : "" }}>
{{ trans('forms.setup.enable_google2fa') }} {{ trans('forms.setup.enable_google2fa') }}
</label> </label>
</div> </div>
@if($loggedUser->hasTwoFactor) @if($current_user->hasTwoFactor)
<div class="form-group"> <div class="form-group">
<?php <?php
$google2fa_url = PragmaRX\Google2FA\Vendor\Laravel\Facade::getQRCodeGoogleUrl( $google2fa_url = PragmaRX\Google2FA\Vendor\Laravel\Facade::getQRCodeGoogleUrl(
'CachetHQ', 'CachetHQ',
$loggedUser->email, $current_user->email,
$loggedUser->google_2fa_secret $current_user->google_2fa_secret
); );
?> ?>
<img src="{{ $google2fa_url }}" class="img-responsive"> <img src="{{ $google2fa_url }}" class="img-responsive">

View File

@@ -17,8 +17,8 @@
<div class="row app-banner"> <div class="row app-banner">
<div class="col-md-12 text-center"> <div class="col-md-12 text-center">
<?php $bannerType = Setting::get('app_banner_type') ?> <?php $bannerType = Setting::get('app_banner_type') ?>
@if($appUrl = Setting::get('app_domain')) @if($app_url = Setting::get('app_domain'))
<a href="{{ $appUrl }}"><img src="data:{{ $bannerType }};base64, {{ $bannerImage}}" class="banner-image img-responsive"></a> <a href="{{ $app_url }}"><img src="data:{{ $bannerType }};base64, {{ $bannerImage}}" class="banner-image img-responsive"></a>
@else @else
<img src="data:{{ $bannerType }};base64, {{ $bannerImage}}" class="banner-image img-responsive"> <img src="data:{{ $bannerType }};base64, {{ $bannerImage}}" class="banner-image img-responsive">
@endif @endif
@@ -30,26 +30,26 @@
<div class="alert alert-{{ $systemStatus }}">{{ $systemMessage }}</div> <div class="alert alert-{{ $systemStatus }}">{{ $systemMessage }}</div>
</div> </div>
@if($aboutApp) @if($about_app)
<div class="about-app"> <div class="about-app">
<h1>{{ trans('cachet.about_this_site') }}</h1> <h1>{{ trans('cachet.about_this_site') }}</h1>
<p>{!! $aboutApp !!}</p> <p>{!! $about_app !!}</p>
</div> </div>
@endif @endif
@if(!$componentGroups->isEmpty() || !$ungroupedComponents->isEmpty()) @if(!$component_groups->isEmpty() || !$ungrouped_components->isEmpty())
<div class="section-components"> <div class="section-components">
@include('partials.components') @include('partials.components')
</div> </div>
@endif @endif
@if($displayMetrics && Setting::get('display_graphs')) @if($display_metrics && Setting::get('display_graphs'))
<div class="section-metrics"> <div class="section-metrics">
@include('partials.metrics') @include('partials.metrics')
</div> </div>
@endif @endif
@if(!$scheduledMaintenance->isEmpty()) @if(!$scheduled_maintenance->isEmpty())
<div class="section-scheduled"> <div class="section-scheduled">
@include('partials.schedule') @include('partials.schedule')
</div> </div>
@@ -57,23 +57,23 @@
<div class="section-timeline"> <div class="section-timeline">
<h1>{{ trans('cachet.incidents.past') }}</h1> <h1>{{ trans('cachet.incidents.past') }}</h1>
@foreach($allIncidents as $date => $incidents) @foreach($all_incidents as $date => $incidents)
@include('partials.incidents', [compact($date), compact($incidents)]) @include('partials.incidents', [compact($date), compact($incidents)])
@endforeach @endforeach
</div> </div>
<nav> <nav>
<ul class="pager"> <ul class="pager">
@if($canPageBackward) @if($can_page_backward)
<li class="previous"> <li class="previous">
<a href="{{ route('status-page') }}?start_date={{ $previousDate }}"> <a href="{{ route('status-page') }}?start_date={{ $previous_date }}">
<span aria-hidden="true">&larr;</span> {{ trans('cachet.incidents.previous_week') }} <span aria-hidden="true">&larr;</span> {{ trans('cachet.incidents.previous_week') }}
</a> </a>
</li> </li>
@endif @endif
@if($canPageForward) @if($can_page_forward)
<li class="next"> <li class="next">
<a href="{{ route('status-page') }}?start_date={{ $nextDate }}"> <a href="{{ route('status-page') }}?start_date={{ $next_date }}">
{{ trans('cachet.incidents.next_week') }} <span aria-hidden="true">&rarr;</span> {{ trans('cachet.incidents.next_week') }} <span aria-hidden="true">&rarr;</span>
</a> </a>
</li> </li>

View File

@@ -19,7 +19,7 @@
<table width="100%" border="0" cellpadding="0" cellspacing="0"> <table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr> <tr>
<td class="header-logo"> <td class="header-logo">
<a href="{{ $appUrl }}"><img src="data:{{ Setting::get('app_banner_type') }};base64, {{ $bannerImage}}"></a> <a href="{{ $app_url }}"><img src="data:{{ Setting::get('app_banner_type') }};base64, {{ $bannerImage}}"></a>
</td> </td>
</tr> </tr>
</table> </table>

View File

@@ -1,6 +1,6 @@
<ul class="list-group components"> <ul class="list-group components">
@if($componentGroups->count() > 0) @if($component_groups->count() > 0)
@foreach($componentGroups as $componentGroup) @foreach($component_groups as $componentGroup)
@if($componentGroup->components->count() > 0) @if($componentGroup->components->count() > 0)
<li class="list-group-item group-name"> <li class="list-group-item group-name">
<i class="ion-ios-minus-outline group-toggle"></i> <i class="ion-ios-minus-outline group-toggle"></i>
@@ -14,13 +14,13 @@
</div> </div>
@endif @endif
@endforeach @endforeach
@if($ungroupedComponents->count() > 0) @if($ungrouped_components->count() > 0)
<li class="list-group-item break"></li> <li class="list-group-item break"></li>
@endif @endif
@endif @endif
@if($ungroupedComponents->count() > 0) @if($ungrouped_components->count() > 0)
@foreach($ungroupedComponents as $component) @foreach($ungrouped_components as $component)
@include('partials.component', compact($component)) @include('partials.component', compact($component))
@endforeach @endforeach
@endif @endif

View File

@@ -1,10 +1,10 @@
@if($loggedUser) @if($current_user)
<div class="sidebar"> <div class="sidebar">
<div class="sidebar-inner"> <div class="sidebar-inner">
<div class="profile"> <div class="profile">
<div class="dropdown"> <div class="dropdown">
<a class="dropdown-toggle" href="#" id="profile-dropdown" data-toggle="dropdown" aria-expanded="true"> <a class="dropdown-toggle" href="#" id="profile-dropdown" data-toggle="dropdown" aria-expanded="true">
<span class="avatar"><img src="{{ $loggedUser->gravatar }}"></span> <span class="username">{{ $loggedUser->username }}</span> <span class="avatar"><img src="{{ $current_user->gravatar }}"></span> <span class="username">{{ $current_user->username }}</span>
<span class="caret"></span> <span class="caret"></span>
</a> </a>
<ul class="dropdown-menu" role="menu" aria-labelledby="profile-dropdown"> <ul class="dropdown-menu" role="menu" aria-labelledby="profile-dropdown">
@@ -35,7 +35,7 @@
<a href="{{ route('dashboard.incidents') }}"> <a href="{{ route('dashboard.incidents') }}">
<i class="icon ion-android-alert"></i> <i class="icon ion-android-alert"></i>
<span>{{ trans('dashboard.incidents.incidents') }}</span> <span>{{ trans('dashboard.incidents.incidents') }}</span>
<span class="label label-info">{{ $incidentCount }}</span> <span class="label label-info">{{ $incident_count }}</span>
</a> </a>
</li> </li>
<li {!! set_active('dashboard/templates*') !!}> <li {!! set_active('dashboard/templates*') !!}>
@@ -48,7 +48,7 @@
<a href="{{ route('dashboard.components') }}"> <a href="{{ route('dashboard.components') }}">
<i class="icons ion-outlet"></i> <i class="icons ion-outlet"></i>
<span>{{ trans('dashboard.components.components') }}</span> <span>{{ trans('dashboard.components.components') }}</span>
<span class="label label-info">{{ $componentCount }}</span> <span class="label label-info">{{ $component_count }}</span>
</a> </a>
</li> </li>
<li {!! set_active('dashboard/team*') !!}> <li {!! set_active('dashboard/team*') !!}>

View File

@@ -8,10 +8,10 @@
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="icons"> <div class="icons">
@if($loggedUser || Setting::get('dashboard_login_link')) @if($current_user || Setting::get('dashboard_login_link'))
<a href="/dashboard" class="icon-link"><i class="ion-levels"></i> {{ trans('dashboard.dashboard') }}</a> <a href="/dashboard" class="icon-link"><i class="ion-levels"></i> {{ trans('dashboard.dashboard') }}</a>
@endif @endif
@if($loggedUser) @if($current_user)
<a href="/auth/logout" class="icon-link"><i class="ion-android-exit"></i> {{ trans('dashboard.logout') }}</a> <a href="/auth/logout" class="icon-link"><i class="ion-android-exit"></i> {{ trans('dashboard.logout') }}</a>
@endif @endif
<a href="/rss" class="icon-link rss"><i class="ion-social-rss"></i> {{ trans('cachet.rss-feed') }}</a> <a href="/rss" class="icon-link rss"><i class="ion-social-rss"></i> {{ trans('cachet.rss-feed') }}</a>

View File

@@ -12,7 +12,7 @@
<div class="col-xs-10 col-xs-offset-2 col-sm-11 col-sm-offset-0"> <div class="col-xs-10 col-xs-offset-2 col-sm-11 col-sm-offset-0">
<div class="panel panel-message"> <div class="panel panel-message">
<div class="panel-heading"> <div class="panel-heading">
@if($loggedUser) @if($current_user)
<div class="pull-right btn-group"> <div class="pull-right btn-group">
<a href="/dashboard/incidents/{{ $incident->id }}/edit" class="btn btn-default">{{ trans('forms.edit') }}</a> <a href="/dashboard/incidents/{{ $incident->id }}/edit" class="btn btn-default">{{ trans('forms.edit') }}</a>
<a href="/dashboard/incidents/{{ $incident->id }}/delete" class="btn btn-danger confirm-action" data-method='DELETE'>{{ trans('forms.delete') }}</a> <a href="/dashboard/incidents/{{ $incident->id }}/delete" class="btn btn-danger confirm-action" data-method='DELETE'>{{ trans('forms.delete') }}</a>

View File

@@ -5,7 +5,7 @@
<strong>{{ trans('cachet.incidents.scheduled') }}</strong> <strong>{{ trans('cachet.incidents.scheduled') }}</strong>
</div> </div>
<div class="list-group"> <div class="list-group">
@foreach($scheduledMaintenance as $schedule) @foreach($scheduled_maintenance as $schedule)
<div class="list-group-item"> <div class="list-group-item">
<strong>{{ $schedule->name }}</strong> <small class="date"><abbr class="timeago" data-toggle="tooltip" data-placement="right" title="{{ $schedule->scheduled_at_formatted }}" data-timeago="{{ $schedule->scheduled_at_iso }}"></abbr></small> <strong>{{ $schedule->name }}</strong> <small class="date"><abbr class="timeago" data-toggle="tooltip" data-placement="right" title="{{ $schedule->scheduled_at_formatted }}" data-timeago="{{ $schedule->scheduled_at_iso }}"></abbr></small>
{!! $schedule->formattedMessage !!} {!! $schedule->formattedMessage !!}

View File

@@ -1,11 +1,11 @@
@if($themeSetup) @if($theme_setup)
<style type="text/css"> <style type="text/css">
body.status-page { body.status-page {
@if($themeBackgroundColor) @if($theme_background_color)
background-color: {{ $themeBackgroundColor }}; background-color: {{ $theme_background_color }};
@endif @endif
@if($themeTextColor) @if($theme_text_color)
color: {{ $themeTextColor }}; color: {{ $theme_text_color }};
@endif @endif
} }
</style> </style>

View File

@@ -34,7 +34,7 @@
<label>{{ trans('forms.setup.cache_driver') }}</label> <label>{{ trans('forms.setup.cache_driver') }}</label>
<select name="env[cache_driver]" class="form-control" required> <select name="env[cache_driver]" class="form-control" required>
<option disabled>{{ trans('forms.setup.cache_driver') }}</option> <option disabled>{{ trans('forms.setup.cache_driver') }}</option>
@foreach($cacheDrivers as $driver => $driverName) @foreach($cache_drivers as $driver => $driverName)
<option value="{{ $driver }}" {{ Input::old('env.cache_driver') == $driver ? "selected" : null }}>{{ $driverName }}</option> <option value="{{ $driver }}" {{ Input::old('env.cache_driver') == $driver ? "selected" : null }}>{{ $driverName }}</option>
@endforeach @endforeach
</select> </select>
@@ -46,7 +46,7 @@
<label>{{ trans('forms.setup.session_driver') }}</label> <label>{{ trans('forms.setup.session_driver') }}</label>
<select name="env[session_driver]" class="form-control" required> <select name="env[session_driver]" class="form-control" required>
<option disabled>{{ trans('forms.setup.session_driver') }}</option> <option disabled>{{ trans('forms.setup.session_driver') }}</option>
@foreach($cacheDrivers as $driver => $driverName) @foreach($cache_drivers as $driver => $driverName)
<option value="{{ $driver }}" {{ Input::old('env.session_driver') == $driver ? "selected" : null }}>{{ $driverName }}</option> <option value="{{ $driver }}" {{ Input::old('env.session_driver') == $driver ? "selected" : null }}>{{ $driverName }}</option>
@endforeach @endforeach
</select> </select>

View File

@@ -11,8 +11,8 @@
<div class="row app-banner"> <div class="row app-banner">
<div class="col-md-12 text-center"> <div class="col-md-12 text-center">
<?php $bannerType = Setting::get('app_banner_type') ?> <?php $bannerType = Setting::get('app_banner_type') ?>
@if($appUrl = Setting::get('app_domain')) @if($app_url = Setting::get('app_domain'))
<a href="{{ $appUrl }}"><img src="data:{{ $bannerType }};base64, {{ $bannerImage}}" class="banner-image img-responsive"></a> <a href="{{ $app_url }}"><img src="data:{{ $bannerType }};base64, {{ $bannerImage}}" class="banner-image img-responsive"></a>
@else @else
<img src="data:{{ $bannerType }};base64, {{ $bannerImage}}" class="banner-image img-responsive"> <img src="data:{{ $bannerType }};base64, {{ $bannerImage}}" class="banner-image img-responsive">
@endif @endif
@@ -20,10 +20,10 @@
</div> </div>
@endif @endif
@if($aboutApp) @if($about_app)
<div class="about-app"> <div class="about-app">
<h1>{{ trans('cachet.about_this_site') }}</h1> <h1>{{ trans('cachet.about_this_site') }}</h1>
<p>{!! $aboutApp !!}</p> <p>{!! $about_app !!}</p>
</div> </div>
@endif @endif