Merge pull request #185 from cachethq/view-refactor

View refactor
This commit is contained in:
James Brooks
2015-01-01 10:45:03 +00:00
20 changed files with 43 additions and 25 deletions

View File

@@ -11,7 +11,7 @@ class DashComponentController extends Controller
{
$components = Component::all();
return View::make('dashboard.components')->with([
return View::make('dashboard.components.index')->with([
'pageTitle' => 'Components - Dashboard',
'components' => $components,
]);
@@ -26,7 +26,7 @@ class DashComponentController extends Controller
*/
public function showEditComponent(Component $component)
{
return View::make('dashboard.component-edit')->with([
return View::make('dashboard.components.edit')->with([
'pageTitle' => 'Editing "'.$component->name.'" Component - Dashboard',
'component' => $component,
]);
@@ -54,7 +54,7 @@ class DashComponentController extends Controller
*/
public function showAddComponent()
{
return View::make('dashboard.component-add')->with([
return View::make('dashboard.components.add')->with([
'pageTitle' => 'Add Component - Dashboard',
]);
}

View File

@@ -11,7 +11,7 @@ class DashIncidentController extends Controller
{
$incidents = Incident::orderBy('created_at', 'desc')->get();
return View::make('dashboard.incidents')->with([
return View::make('dashboard.incidents.index')->with([
'pageTitle' => 'Incidents - Dashboard',
'incidents' => $incidents,
]);
@@ -24,7 +24,7 @@ class DashIncidentController extends Controller
*/
public function showAddIncident()
{
return View::make('dashboard.incident-add')->with([
return View::make('dashboard.incidents.add')->with([
'pageTitle' => 'Add Incident - Dashboard',
]);
}
@@ -36,7 +36,7 @@ class DashIncidentController extends Controller
*/
public function showAddIncidentTemplate()
{
return View::make('dashboard.incident-template')->with([
return View::make('dashboard.incidents.incident-template')->with([
'pageTitle' => 'Add Incident Template - Dashboard',
]);
}

View File

@@ -47,7 +47,7 @@ class DashSettingsController extends Controller
{
$this->subMenu['setup']['active'] = true;
return View::make('dashboard.settings-app-setup')->with([
return View::make('dashboard.settings.app-setup')->with([
'pageTitle' => 'Application Setup - Dashboard',
'subMenu' => $this->subMenu,
]);
@@ -62,7 +62,7 @@ class DashSettingsController extends Controller
{
$this->subMenu['theme']['active'] = true;
return View::make('dashboard.settings-theme')->with([
return View::make('dashboard.settings.theme')->with([
'pageTitle' => 'Theme - Dashboard',
'subMenu' => $this->subMenu,
]);
@@ -77,7 +77,7 @@ class DashSettingsController extends Controller
{
$this->subMenu['security']['active'] = true;
return View::make('dashboard.settings-security')->with([
return View::make('dashboard.settings.security')->with([
'pageTitle' => 'Security - Dashboard',
'subMenu' => $this->subMenu,
]);
@@ -92,7 +92,7 @@ class DashSettingsController extends Controller
{
$this->subMenu['stylesheet']['active'] = true;
return View::make('dashboard.settings-stylesheet')->with([
return View::make('dashboard.settings.stylesheet')->with([
'pageTitle' => 'Stylesheet - Dashboard',
'subMenu' => $this->subMenu,
]);

View File

@@ -9,7 +9,7 @@ class DashUserController extends Controller
*/
public function showUser()
{
return View::make('dashboard.user')->with([
return View::make('dashboard.user.index')->with([
'pageTitle' => 'User - Dashboard',
]);
}

View File

@@ -24,7 +24,7 @@ class DashboardController extends Controller
*/
public function showMetrics()
{
return View::make('dashboard.metrics')->with([
return View::make('dashboard.metrics.index')->with([
'pageTitle' => 'Metrics - Dashboard',
]);
}
@@ -36,7 +36,7 @@ class DashboardController extends Controller
*/
public function showNotifications()
{
return View::make('dashboard.notifications')->with([
return View::make('dashboard.notifications.index')->with([
'pageTitle' => 'Notifications - Dashboard',
]);
}

View File

@@ -23,3 +23,26 @@ if (! function_exists('elixir')) {
throw new InvalidArgumentException("File {$file} not defined in asset manifest.");
}
}
if (! function_exists('set_active')) {
/**
* Set active class if request is in path.
*
* @param $path
* @param array $classes
* @param string $active
*
* @return string
*/
function set_active($path, $classes = [], $active = 'active')
{
if (Request::is($path)) {
$classes[] = $active;
}
$class = implode(' ', $classes);
return empty($classes) ? '' : "class=\"{$class}\"";
}
}

View File

@@ -24,42 +24,37 @@
</a>
</div>
<ul>
<li class="{{ Request::is('dashboard') ? 'active' : '' }}">
<li {{ set_active('dashboard') }}>
<a href="{{ URL::route('dashboard') }}">
<i class="icon ion-speedometer"></i> {{ Lang::get('cachet.dashboard.dashboard') }}
</a>
</li>
<li class="{{ Request::is('dashboard/incidents') ? 'active' : '' }}">
<li {{ set_active('dashboard/incidents*') }}>
<a href="{{ URL::route('dashboard.incidents') }}">
<i class="icon ion-android-alert"></i> {{ Lang::get('cachet.dashboard.incidents') }}
</a>
</li>
{{-- <li class="{{ Request::is('dashboard/incidents/template') ? 'active' : '' }} sub-nav-item">
{{-- <li {{ set_active('dashboard/incidents/templates') }}>
<a href="{{ URL::route('dashboard.incidents.template') }}">
<i class="fa fa-plus"></i> {{ Lang::get('cachet.dashboard.incident-create-template') }}
</a>
</li> --}}
<li class="{{ Request::is('dashboard/components') ? 'active' : '' }}">
<li {{ set_active('dashboard/components*') }}>
<a href="{{ URL::route('dashboard.components') }}">
<i class="icons ion-ios-keypad"></i> {{ Lang::get('cachet.dashboard.components') }}
</a>
</li>
{{-- <li class="{{ Request::is('dashboard/metrics') ? 'active' : '' }}">
{{-- <li {{ set_active('dashboard/metrics') }}>
<a href="{{ URL::route('dashboard.metrics') }}">
<i class="ion ion-stats-bats"></i> {{ Lang::get('cachet.dashboard.metrics') }}
</a>
</li>
<li class="sub-nav-item">
<a href="#">
<i class="fa fa-plus"></i> {{ Lang::get('cachet.dashboard.metrics-add') }}
</a>
</li>
<li class="{{ Request::is('dashboard/notifications') ? 'active' : '' }}">
<li {{ set_active('dashboard/notifications') }}>
<a href="{{ URL::route('dashboard.notifications') }}">
<i class="ion ion-email"></i> {{ Lang::get('cachet.dashboard.notifications') }}
</a>
</li> --}}
<li class="{{ preg_match('/dashboard\/settings\/.*/i', Request::path()) ? 'active' : '' }}">
<li {{ set_active('dashboard/settings*') }}>
<a href="{{ URL::route('dashboard.settings.setup') }}">
<i class="icon ion-gear-a"></i> {{ Lang::get('cachet.dashboard.settings') }}
</a>