[Enhancement] UI Storage info report

Discussions related to the 1.36.x series of ZoneMinder
Post Reply
emptyspiral
Posts: 2
Joined: Sun Dec 13, 2020 9:38 pm

[Enhancement] UI Storage info report

Post by emptyspiral »

Hello,

This is my first post here, I'm a happy user of Zoneminder, so a big thank you to the developers for creating it! :)

I'm using the ZM repo debian packages, 1.36.x line.

I think it would be really useful if in the homepage of ZM the Storage data is not a dropdown only values.
I mean I can see at a simple glance the load, DB and shm usage, but I need to click on the Storage dropdown to see my single storage data usage.

It would be so much simpler (for me at least with a single storage defined) if instead of:
Storage v
the first storage usage would be shown, like:
Storage: Default: 43% v

I guess it would be a minor change, but a time saver and at-a-glance status review usability improvement.

Thank you.
justanotherguy
Posts: 18
Joined: Wed Aug 03, 2022 12:48 am

Re: [Enhancement] UI Storage info report

Post by justanotherguy »

Modify the following file
/usr/share/zoneminder/www/skins/classic/includes/functions.php

and the function getStorageHTML() as follows:

Code: Select all

// Returns an html dropdown showing capacity of all storage areas
function getStorageHTML() {
  $result = '';
  if ( !canView('System') ) return $result;

  $func = function($S) {
    $class = '';
    if ( $S->disk_usage_percent() > 98 ) {
      $class = 'text-danger';
    } else if ( $S->disk_usage_percent() > 90 ) {
      $class = 'text-warning';
    }
    $title = human_filesize($S->disk_used_space()) . ' of ' . human_filesize($S->disk_total_space()).
      ( ( $S->disk_used_space() != $S->event_disk_space() ) ? ' ' .human_filesize($S->event_disk_space()) . ' used by events' : '' );
//    return '<a class="dropdown-item '.$class.'" title="'.$title.'" href="?view=options&amp;tab=storage">'.validHtmlStr($S->Name()) . ': ' . $S->disk_usage_percent().'%' . '</a>';
      $res1 = '';
//       $res1 .= '<li id="getStorageHTML" class="nav-item dropdown mx-2' .$class. '">'.PHP_EOL;
         $res1 .= '<i class="material-icons md-18 mr-1">storage</i>'.PHP_EOL;
           $res1 .= translate('Storage'). ': ' .$S->disk_usage_percent().'%'.PHP_EOL;
//           $res1 .= '</li>'.PHP_EOL;

    return $res1;
  };

  $storage_areas = ZM\Storage::find(array('Enabled'=>true));
  $num_storage_areas = count($storage_areas);

  $full_warning = 0;
  $full_error = 0;
  foreach ( $storage_areas as $area ) {
    if ( $area->disk_usage_percent() > 98 ) { $full_error++; continue; }
    if ( $area->disk_usage_percent() > 90 ) $full_warning++;
  }

  $class = '';
  if ( $full_error ) {
    $class = 'text-danger';
  } else if ( $full_warning ) {
    $class = 'text-warning';
  }

  $result .= '<li id="getStorageHTML" class="nav-item dropdown mx-2">'.PHP_EOL;
//  $result .= '<a class="dropdown-toggle mr-2 '.$class.'" href="#" id="dropdown_storage" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="material-icons md-18 mr-1">folder_shared</i>Storage</a>'.PHP_EOL;
//  $result .= '<div class="dropdown-menu" aria-labelledby="dropdown_storage">'.PHP_EOL;

  foreach ( $storage_areas as $area ) {
    $result .= $func($area).PHP_EOL;
  }
//  $result .= '</div>'.PHP_EOL;
  $result .= '</li>'.PHP_EOL;

  return $result;
}
That should give you what you are asking.

PS: Please backup the file before modifying, in case you need to restore it.
User avatar
iconnor
Posts: 3126
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: [Enhancement] UI Storage info report

Post by iconnor »

I have merged something like this queued for 1.36.25. Will be available in proposed ppa and master ppa as soon as packages finish building.
emptyspiral
Posts: 2
Joined: Sun Dec 13, 2020 9:38 pm

Re: [Enhancement] UI Storage info report

Post by emptyspiral »

Hello,

I confirm the changes in 1.36.25 are exactly what I was hoping for.
Now with one storage only there is no more dropdown, just at a glance:
Default: 44%

Thank you!

Also thank you to @justanotherguy , did not get to make the change (deb package installed via repo, would need to remember to patch the file on every update and my neurons are kind of tired), but thank you for the option.
justanotherguy wrote: Sat Aug 27, 2022 1:25 pm
PS. Note to self: Now.. where was that donate button? :)
Post Reply