mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Natural Sort Applications by Display Name (#11577)
* Natural Sort Applications by Display Name * some optimizations * .
This commit is contained in:
@@ -51,8 +51,8 @@ class ObjectCache
|
|||||||
return Application::hasAccess(auth()->user())
|
return Application::hasAccess(auth()->user())
|
||||||
->select('app_type', 'app_instance')
|
->select('app_type', 'app_instance')
|
||||||
->groupBy('app_type', 'app_instance')
|
->groupBy('app_type', 'app_instance')
|
||||||
->orderBy('app_type')
|
|
||||||
->get()
|
->get()
|
||||||
|
->sortBy('show_name', SORT_NATURAL|SORT_FLAG_CASE)
|
||||||
->groupBy('app_type');
|
->groupBy('app_type');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -49,4 +49,9 @@ class Application extends DeviceRelatedModel
|
|||||||
{
|
{
|
||||||
return StringHelpers::niceCase($this->app_type);
|
return StringHelpers::niceCase($this->app_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getShowNameAttribute()
|
||||||
|
{
|
||||||
|
return StringHelpers::niceCase($this->app_type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -329,7 +329,7 @@ $link_array = array(
|
|||||||
'device' => $device['device_id'],
|
'device' => $device['device_id'],
|
||||||
'tab' => 'apps',
|
'tab' => 'apps',
|
||||||
);
|
);
|
||||||
$apps = \LibreNMS\Util\ObjectCache::applications()->flatten()->sortBy('app_type');
|
$apps = \LibreNMS\Util\ObjectCache::applications()->flatten();
|
||||||
foreach ($apps as $app) {
|
foreach ($apps as $app) {
|
||||||
echo $sep;
|
echo $sep;
|
||||||
if ($vars['app'] == $app->app_type) {
|
if ($vars['app'] == $app->app_type) {
|
||||||
|
@@ -11,7 +11,7 @@ $graph_array_zoom['height'] = '150';
|
|||||||
$graph_array_zoom['width'] = '400';
|
$graph_array_zoom['width'] = '400';
|
||||||
$graph_array['legend'] = 'no';
|
$graph_array['legend'] = 'no';
|
||||||
|
|
||||||
foreach (Application::query()->hasAccess(Auth::user())->with('device')->orderBy('app_type')->get()->groupBy('app_type') as $type => $groupedApps) {
|
foreach (Application::query()->hasAccess(Auth::user())->with('device')->get()->sortBy('show_name', SORT_NATURAL|SORT_FLAG_CASE)->groupBy('app_type') as $type => $groupedApps) {
|
||||||
echo '<div style="clear: both;">';
|
echo '<div style="clear: both;">';
|
||||||
echo '<h2>'.generate_link($groupedApps->first()->displayName(), array('page' => 'apps', 'app' => $type)).'</h2>';
|
echo '<h2>'.generate_link($groupedApps->first()->displayName(), array('page' => 'apps', 'app' => $type)).'</h2>';
|
||||||
/** @var \Illuminate\Support\Collection $groupedApps */
|
/** @var \Illuminate\Support\Collection $groupedApps */
|
||||||
|
@@ -12,7 +12,16 @@ $link_array = array(
|
|||||||
'tab' => 'apps',
|
'tab' => 'apps',
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach (dbFetchRows('SELECT * FROM `applications` WHERE `device_id` = ? ORDER BY `app_type` ASC', array($device['device_id'])) as $app) {
|
$app_list = [];
|
||||||
|
foreach (dbFetchRows('SELECT * FROM `applications` WHERE `device_id` = ?', array($device['device_id'])) as $app) {
|
||||||
|
$app['app_display'] = nicecase($app['app_type']);
|
||||||
|
$app_list[] = $app;
|
||||||
|
}
|
||||||
|
|
||||||
|
$app_displays = array_column($app_list, 'app_display');
|
||||||
|
array_multisort($app_displays, SORT_NATURAL|SORT_FLAG_CASE, $app_list);
|
||||||
|
|
||||||
|
foreach ($app_list as $app) {
|
||||||
echo $sep;
|
echo $sep;
|
||||||
|
|
||||||
if (!$vars['app']) {
|
if (!$vars['app']) {
|
||||||
@@ -21,11 +30,10 @@ foreach (dbFetchRows('SELECT * FROM `applications` WHERE `device_id` = ? ORDER B
|
|||||||
|
|
||||||
if ($vars['app'] == $app['app_type']) {
|
if ($vars['app'] == $app['app_type']) {
|
||||||
echo "<span class='pagemenu-selected'>";
|
echo "<span class='pagemenu-selected'>";
|
||||||
} else {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$link_add = array('app' => $app['app_type']);
|
$link_add = array('app' => $app['app_type']);
|
||||||
$text = nicecase($app['app_type']);
|
$text = $app['app_display'];
|
||||||
if (!empty($app['app_instance'])) {
|
if (!empty($app['app_instance'])) {
|
||||||
$text .= '('.$app['app_instance'].')';
|
$text .= '('.$app['app_instance'].')';
|
||||||
$link_add['instance'] = $app['app_id'];
|
$link_add['instance'] = $app['app_id'];
|
||||||
|
Reference in New Issue
Block a user