Welcome to docs.opsview.com

Tabs

Edit/New pages can have tabs to simplify the look.

However, these are not dynamic tabs - rather they use hidden divs to switch between them. This means that there may still be a delay in producing the overall page.

Tab technology is based on Fabtabulous (http://www.tetlaw.id.au/view/blog/fabtabulous-simple-tabs-using-prototype/), though we have made some changes to how that works - see opsview-base for patches.

To enable tabs in the controller, set these:

__PACKAGE__->config(
  ...
  extra_javascript => [qw(fabtabulous)],
);

sub auto :Private {
  ...
  my $tabs = [qw(Host Monitors SNMP)];
  foreach my $plugin (Opsview->plugins) {
    next unless $plugin->can("display_host_tab");
    push @$tabs, $plugin->display_host_tab;
  }
  $c->stash( tabs => $tabs );
  $c->stash( edit_form_fields_template => "tab-wrapper" );
}

sub edit ... {
  ...
  if (my $p = $c->req->param("tab") ) {
    if ($p =~ /^[1-9]$/) {
      $p = lc($c->stash->{tabs}[$p-1]);
    }
    $c->stash( "initial_tab" => "tab-$p" );
  }
}

sub create_new ... {
  ...
  $c->stash( tabs_first_only => 1 );
  $c->stash( submit_name => "next" );
}

The template will now use tab-wrapper to setup the tabs. Create tab-{name} in the folder for the action to get this tab read. See root/admin/host/tab-host for an example structure.

Reordering

Reordering is available simply if:

  • There is a priority field for the class
  • Lists are by default searched according to priority

Then in the controller:

  • Inheritance of Opsview::Web::ControllerBase::Reorder
  • PACKAGE→config( reorder ⇒ 1 )

Then a “reorder” button should be available on list page, which will take you to a reorder screen where you can drag and drop the order of the items.