mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Toggle visibilty of Dashboard Editor (#11321)
* Toggle visibilty of Dashboard Editor
* code climate
* reposition Menu point
* add Dashboard Menu
* unclickability ob Dashboard menu
* Global Settings - Alert Default Settings
* Revert "Global Settings - Alert Default Settings"
This reverts commit a1af62b146.
* update to Frontend rewrite
* globalize hide_dashboard_editor variable
* .
* .
* remove legacy code
* update link path to laravel routing
* Travis ...
* Travis ...
This commit is contained in:
@@ -98,12 +98,13 @@ class OverviewController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
$bare = $request->bare;
|
||||
$data = serialize(json_encode($data));
|
||||
$dash_config = unserialize(stripslashes($data));
|
||||
$widgets = Widget::select('widget_id', 'widget_title')->orderBy('widget_title')->get();
|
||||
$bare = $request->bare;
|
||||
$data = serialize(json_encode($data));
|
||||
$dash_config = unserialize(stripslashes($data));
|
||||
$hide_dashboard_editor = UserPref::getPref($user, 'hide_dashboard_editor');
|
||||
$widgets = Widget::select('widget_id', 'widget_title')->orderBy('widget_title')->get();
|
||||
|
||||
return view('overview.default', compact('bare', 'dash_config', 'dashboard', 'user_dashboards', 'shared_dashboards', 'widgets'));
|
||||
return view('overview.default', compact('bare', 'dash_config', 'dashboard', 'hide_dashboard_editor', 'user_dashboards', 'shared_dashboards', 'widgets'));
|
||||
}
|
||||
|
||||
public function simple(Request $request)
|
||||
|
||||
@@ -73,7 +73,7 @@ class UserPreferencesController extends Controller
|
||||
'site_style' => UserPref::getPref($user, 'site_style'),
|
||||
'site_style_default' => $styles[$default_style] ?? $default_style,
|
||||
'site_styles' => $styles,
|
||||
|
||||
'hide_dashboard_editor' => UserPref::getPref($user, 'hide_dashboard_editor') ?? 0,
|
||||
];
|
||||
|
||||
if (Config::get('twofactor')) {
|
||||
@@ -110,6 +110,7 @@ class UserPreferencesController extends Controller
|
||||
'required',
|
||||
Rule::in(array_merge(['default'], array_keys($this->getValidStyles()))),
|
||||
],
|
||||
'hide_dashboard_editor' => 'required|integer',
|
||||
];
|
||||
|
||||
$this->validate($request, [
|
||||
@@ -122,6 +123,13 @@ class UserPreferencesController extends Controller
|
||||
return response()->json(['status' => 'success']);
|
||||
}
|
||||
|
||||
public function toggleDashboardEditor(Request $request)
|
||||
{
|
||||
$hide_dashboard_editor = UserPref::getPref(Auth::user(), 'hide_dashboard_editor') ? 0 : 1;
|
||||
UserPref::setPref(Auth::user(), 'hide_dashboard_editor', $hide_dashboard_editor);
|
||||
return redirect('overview');
|
||||
}
|
||||
|
||||
private function getValidLocales()
|
||||
{
|
||||
return array_reduce(glob(resource_path('lang') . '/*', GLOB_ONLYDIR), function ($locales, $locale) {
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace App\Http\ViewComposers;
|
||||
|
||||
use App\Models\AlertRule;
|
||||
use App\Models\BgpPeer;
|
||||
use App\Models\Dashboard;
|
||||
use App\Models\Device;
|
||||
use App\Models\DeviceGroup;
|
||||
use App\Models\Location;
|
||||
@@ -56,12 +57,19 @@ class MenuComposer
|
||||
$user = Auth::user();
|
||||
$site_style = Config::get('applied_site_style');
|
||||
|
||||
//global Settings
|
||||
$vars['hide_dashboard_editor'] = UserPref::getPref($user, 'hide_dashboard_editor');
|
||||
// end global Settings
|
||||
|
||||
//TODO: should be handled via CSS Themes
|
||||
$vars['navbar'] = in_array($site_style, ['mono', 'dark']) ? 'navbar-inverse' : '';
|
||||
|
||||
$vars['project_name'] = Config::get('project_name', 'LibreNMS');
|
||||
$vars['title_image'] = Config::get('title_image', "images/librenms_logo_$site_style.svg");
|
||||
|
||||
//Dashboards
|
||||
$vars['dashboards'] = Dashboard::select('dashboard_id', 'dashboard_name')->allAvailable($user)->orderBy('dashboard_name')->get();
|
||||
|
||||
// Device menu
|
||||
$vars['device_groups'] = DeviceGroup::hasAccess($user)->orderBy('name')->get(['device_groups.id', 'name', 'desc']);
|
||||
$vars['package_count'] = Package::hasAccess($user)->count();
|
||||
|
||||
@@ -25,8 +25,23 @@
|
||||
aria-hidden="true"></i> <span
|
||||
class="hidden-sm">@lang('Overview')</span></a>
|
||||
<ul class="dropdown-menu multi-level" role="menu">
|
||||
<li><a href="{{ url('overview') }}"><i class="fa fa-tv fa-fw fa-lg"
|
||||
aria-hidden="true"></i> @lang('Dashboard')</a></li>
|
||||
<li class="dropdown-submenu">
|
||||
<a><i class="fa fa-tv fa-fw fa-lg" aria-hidden="true"></i> @lang('Dashboard')</a>
|
||||
<ul class="dropdown-menu">
|
||||
@foreach($dashboards as $dashboard)
|
||||
<li><a href="{{ route('overview', ['dashboard' => $dashboard->dashboard_id]) }}"><i class="fa fa-tv fa-fw fa-lg" aria-hidden="true"></i> {{ $dashboard->dashboard_name }}</a></li>
|
||||
@endforeach
|
||||
<li role="presentation" class="divider"></li>
|
||||
<li>
|
||||
<a href="{{ url('toggle_dashboard_editor') }}">
|
||||
<i class="fa fa-bar-chart fa-fw fa-lg" aria-hidden="true"></i>
|
||||
@if ($hide_dashboard_editor) @lang('Show Dashboard Editor')
|
||||
@else @lang('Hide Dashboard Editor')
|
||||
@endif</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li role="presentation" class="divider"></li>
|
||||
<li class="dropdown-submenu">
|
||||
<a><i class="fa fa-map fa-fw fa-lg"
|
||||
aria-hidden="true"></i> @lang('Maps')</a>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
@include('alerts.modals.ack')
|
||||
@include('alerts.modals.notes')
|
||||
@if (!$bare)
|
||||
@if (!$hide_dashboard_editor)
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="btn-group btn-lg">
|
||||
@@ -127,6 +128,7 @@
|
||||
<!-- End Widget-Select -->
|
||||
<hr>
|
||||
</div>
|
||||
@endif
|
||||
<div class="dash-collapse" id="del_dash" style="display: none;">
|
||||
<div class="row" style="margin-top:5px;">
|
||||
<div class="col-md-6">
|
||||
|
||||
@@ -32,9 +32,12 @@ Route::group(['middleware' => ['auth', '2fa'], 'guard' => 'auth'], function () {
|
||||
Route::resource('users', 'UserController');
|
||||
Route::get('about', 'AboutController@index');
|
||||
Route::get('authlog', 'UserController@authlog');
|
||||
Route::get('overview', 'OverviewController@index');
|
||||
Route::get('overview', 'OverviewController@index')->name('overview');
|
||||
Route::get('/', 'OverviewController@index');
|
||||
|
||||
// Dashboard toggle
|
||||
Route::get('toggle_dashboard_editor', 'UserPreferencesController@toggleDashboardEditor');
|
||||
|
||||
// Maps
|
||||
Route::group(['prefix' => 'maps', 'namespace' => 'Maps'], function () {
|
||||
Route::get('devicedependency', 'DeviceDependencyController@dependencyMap');
|
||||
|
||||
Reference in New Issue
Block a user