Update code to match master

This commit is contained in:
Joseph Cohen
2015-03-26 15:07:16 -06:00
parent eb22ac6d8a
commit 37e20bf2bf
15 changed files with 192 additions and 105 deletions

View File

@@ -4,6 +4,7 @@ namespace CachetHQ\Cachet\Http\Controllers\Admin;
use CachetHQ\Cachet\Http\Controllers\AbstractController;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\IncidentTemplate;
use GrahamCampbell\Binput\Facades\Binput;
@@ -68,10 +69,14 @@ class IncidentController extends AbstractController
*/
public function showAddIncident()
{
$componentsInGroups = ComponentGroup::with('components')->get();
$componentsOutGroups = Component::where('group_id', 0)->get();
return View::make('dashboard.incidents.add')->with([
'pageTitle' => trans('dashboard.incidents.add.title').' - '.trans('dashboard.dashboard'),
'components' => Component::all(),
'incidentTemplates' => IncidentTemplate::all(),
'pageTitle' => trans('dashboard.incidents.add.title').' - '.trans('dashboard.dashboard'),
'componentsInGroups' => $componentsInGroups,
'componentsOutGroups' => $componentsOutGroups,
'incidentTemplates' => IncidentTemplate::all(),
]);
}
@@ -248,10 +253,14 @@ class IncidentController extends AbstractController
*/
public function showEditIncidentAction(Incident $incident)
{
$componentsInGroups = ComponentGroup::with('components')->get();
$componentsOutGroups = Component::where('group_id', 0)->get();
return View::make('dashboard.incidents.edit')->with([
'pageTitle' => trans('dashboard.incidents.edit.title').' - '.trans('dashboard.dashboard'),
'incident' => $incident,
'components' => Component::all(),
'pageTitle' => trans('dashboard.incidents.edit.title').' - '.trans('dashboard.dashboard'),
'incident' => $incident,
'componentsInGroups' => $componentsInGroups,
'componentsOutGroups' => $componentsOutGroups,
]);
}

View File

@@ -12,9 +12,11 @@ class AtomController extends AbstractController
/**
* Generates an Atom feed of all incidents.
*
* @param \CachetHQ\Cachet\Models\ComponentGroup|null $group
*
* @return \Illuminate\Http\Response
*/
public function feedAction()
public function feedAction(ComponentGroup $group = null)
{
$feed = Feed::make();
$feed->title = Setting::get('app_name');
@@ -23,23 +25,37 @@ class AtomController extends AbstractController
$feed->setDateFormat('datetime');
Incident::all()->map(function ($incident) use ($feed) {
if ($incident->component) {
$componentName = $incident->component->name;
} else {
$componentName = null;
}
$feed->add(
$incident->name,
Setting::get('app_name'),
Setting::get('app_domain'),
$incident->created_at,
($componentName === null ? $incident->humanStatus : $componentName.' '.$incident->humanStatus),
$incident->message
);
});
if ($group) {
$group->components->map(function ($component) use ($feed) {
$component->incidents->orderBy('created_at', 'desc')->map(function ($incident) use ($feed) {
$this->feedAddItem($feed, $incident);
});
});
} else {
Incident::orderBy('created_at', 'desc')->get()->map(function ($incident) use ($feed) {
$this->feedAddItem($feed, $incident);
});
}
return $feed->render('atom');
}
/**
* Adds an item to the feed.
*
* @param \Thujohn\Rss\Rss $feed
* @param \CachetHQ\Cachet\Models\Incident $incident
*
* @return void
*/
private function feedAddItem(& $feed, $incident)
{
$feed->add(
$incident->name,
Setting::get('app_name'),
Setting::get('app_domain'),
$incident->created_at->toAtomString(),
$incident->message
);
}
}

View File

@@ -10,11 +10,13 @@ use Roumen\Feed\Facades\Feed;
class RssController extends AbstractController
{
/**
* Generates an RSS feed of all incidents.
* Generates an Atom feed of all incidents.
*
* @param \CachetHQ\Cachet\Models\ComponentGroup|null $group
*
* @return \Illuminate\Http\Response
*/
public function feedAction()
public function feedAction(ComponentGroup $group = null)
{
$feed = Feed::make();
$feed->title = Setting::get('app_name');
@@ -23,23 +25,37 @@ class RssController extends AbstractController
$feed->setDateFormat('datetime');
Incident::all()->map(function ($incident) use ($feed) {
if ($incident->component) {
$componentName = $incident->component->name;
} else {
$componentName = null;
}
$feed->add(
$incident->name,
Setting::get('app_name'),
Setting::get('app_domain'),
$incident->created_at,
($componentName === null ? $incident->humanStatus : $componentName.' '.$incident->humanStatus),
$incident->message
);
});
if ($group) {
$group->components->map(function ($component) use ($feed) {
$component->incidents->orderBy('created_at', 'desc')->map(function ($incident) use ($feed) {
$this->feedAddItem($feed, $incident);
});
});
} else {
Incident::orderBy('created_at', 'desc')->get()->map(function ($incident) use ($feed) {
$this->feedAddItem($feed, $incident);
});
}
return $feed->render('rss');
}
/**
* Adds an item to the feed.
*
* @param \Thujohn\Rss\Rss $feed
* @param \CachetHQ\Cachet\Models\Incident $incident
*
* @return void
*/
private function feedAddItem(& $feed, $incident)
{
$feed->add(
$incident->name,
Setting::get('app_name'),
Setting::get('app_domain'),
$incident->created_at->toAtomString(),
$incident->message
);
}
}