Skip to content

Commit

Permalink
status table rework fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Oct 9, 2024
1 parent 627076c commit 34f407e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 32 deletions.
20 changes: 10 additions & 10 deletions lib/Thruk/Controller/status.pm
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ sub _process_details_page {

# which host to display?
my($hostfilter, $servicefilter) = Thruk::Utils::Status::do_filter($c);
return 1 if $c->stash->{'has_error'};

# do the sort
my $sorttype = $c->req->parameters->{'sorttype'} || 1;
Expand All @@ -473,7 +472,7 @@ sub _process_details_page {
};
my $sortnum = 10;
for my $col (@{$c->stash->{'default_columns'}->{'dfl_'}}) {
next if defined $col->{'sort'};
next if defined $col->{'sortby'};

my $field = $col->{'field'};
if($field =~ m/^cust_(.*)$/mx) {
Expand All @@ -482,10 +481,11 @@ sub _process_details_page {
} else {
$sortoptions->{$sortnum} = [[$field], lc($col->{"title"}) ];
}
$col->{'sort'} = $sortnum;
$col->{'sortby'} = $sortnum;
$sortnum++;
}
$sortoption = 1 if !defined $sortoptions->{$sortoption};
return 1 if $c->stash->{'has_error'};

# reverse order for duration
my $backend_order = $order;
Expand Down Expand Up @@ -604,7 +604,6 @@ sub _process_hostdetails_page {

# which host to display?
my($hostfilter) = Thruk::Utils::Status::do_filter($c);
return 1 if $c->stash->{'has_error'};

# do the sort
my $sorttype = $c->req->parameters->{'sorttype'} || 1;
Expand All @@ -621,7 +620,7 @@ sub _process_hostdetails_page {
};
my $sortnum = 10;
for my $col (@{$c->stash->{'default_columns'}->{'dfl_'}}) {
next if defined $col->{'sort'};
next if defined $col->{'sortby'};

my $field = $col->{'field'};
if($field =~ m/^cust_(.*)$/mx) {
Expand All @@ -630,10 +629,11 @@ sub _process_hostdetails_page {
} else {
$sortoptions->{$sortnum} = [[$field], lc($col->{"title"}) ];
}
$col->{'sort'} = $sortnum;
$col->{'sortby'} = $sortnum;
$sortnum++;
}
$sortoption = 1 if !defined $sortoptions->{$sortoption};
return 1 if $c->stash->{'has_error'};

# reverse order for duration
my $backend_order = $order;
Expand Down Expand Up @@ -1121,7 +1121,7 @@ sub _process_combined_page {
};
my $sortnum = 10;
for my $col (@{$c->stash->{'default_columns'}->{'svc_'}}) {
next if defined $col->{'sort'};
next if defined $col->{'sortby'};

my $field = $col->{'field'};
if($field =~ m/^cust_(.*)$/mx) {
Expand All @@ -1130,7 +1130,7 @@ sub _process_combined_page {
} else {
$sortoptions->{$sortnum} = [[$field], lc($col->{"title"}) ];
}
$col->{'sort'} = $sortnum;
$col->{'sortby'} = $sortnum;
$sortnum++;
}
$sortoption = 1 if !defined $sortoptions->{$sortoption};
Expand Down Expand Up @@ -1171,7 +1171,7 @@ sub _process_combined_page {
};
$sortnum = 10;
for my $col (@{$c->stash->{'default_columns'}->{'hst_'}}) {
next if defined $col->{'sort'};
next if defined $col->{'sortby'};

my $field = $col->{'field'};
if($field =~ m/^cust_(.*)$/mx) {
Expand All @@ -1180,7 +1180,7 @@ sub _process_combined_page {
} else {
$sortoptions->{$sortnum} = [[$field], lc($col->{"title"}) ];
}
$col->{'sort'} = $sortnum;
$col->{'sortby'} = $sortnum;
$sortnum++;
}
$sortoption = 1 if !defined $sortoptions->{$sortoption};
Expand Down
38 changes: 19 additions & 19 deletions lib/Thruk/Utils/Status.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2372,28 +2372,28 @@ sub get_host_columns {
my $columns = [];
if($c->stash->{'show_backends_in_table'} == 2) {
push @{$columns},
{ title => "Site", "field" => "peer_name", "checked" => 1, sort => 7 };
{ title => "Site", "field" => "peer_name", "checked" => 1, sortby => 7 };
}
push @{$columns}, (
{ title => "Host", "field" => "name", "checked" => 1, sort => 1 },
{ title => "Status", "field" => "state", "checked" => 1, sort => 8 },
{ title => "Last Check", "field" => "last_check", "checked" => 1, sort => 4 },
{ title => "Duration", "field" => "duration", "checked" => 1, sort => 6 },
{ title => "Host", "field" => "name", "checked" => 1, sortby => 1 },
{ title => "Status", "field" => "state", "checked" => 1, sortby => 8 },
{ title => "Last Check", "field" => "last_check", "checked" => 1, sortby => 4 },
{ title => "Duration", "field" => "duration", "checked" => 1, sortby => 6 },
);
if($c->stash->{'show_host_attempts'}) {
push @{$columns},
{ title => "Attempt", "field" => "current_attempt", "checked" => 1, sort => 5 };
{ title => "Attempt", "field" => "current_attempt", "checked" => 1, sortby => 5 };
}
if($c->stash->{'show_backends_in_table'} == 1) {
push @{$columns},
{ title => "Site", "field" => "peer_name", "checked" => 1, sort => 7 };
{ title => "Site", "field" => "peer_name", "checked" => 1, sortby => 7 };
}
push @{$columns}, (
{ title => "Status Information", "field" => "plugin_output", "checked" => 1, sort => 9 },
{ title => "Status Information", "field" => "plugin_output", "checked" => 1, sortby => 9 },
);
if(!$c->stash->{'show_backends_in_table'}) {
push @{$columns},
{ title => "Site", "field" => "peer_name", "checked" => 0, sort => 7 };
{ title => "Site", "field" => "peer_name", "checked" => 0, sortby => 7 };
}
if(!$c->stash->{'show_host_attempts'}) {
push @{$columns},
Expand Down Expand Up @@ -2452,29 +2452,29 @@ sub get_service_columns {
my($c) = @_;

my $columns = [
{ title => "Host", "field" => "host_name", "checked" => 1, sort => 1 },
{ title => "Host", "field" => "host_name", "checked" => 1, sortby => 1 },
];
if($c->stash->{'show_backends_in_table'} == 2) {
push @{$columns},
{ title => "Site", "field" => "peer_name", "checked" => 1, sort => 7 };
{ title => "Site", "field" => "peer_name", "checked" => 1, sortby => 7 };
}
push @{$columns}, (
{ title => "Service", "field" => "description", "checked" => 1, sort => 2 },
{ title => "Status", "field" => "state", "checked" => 1, sort => 3 },
{ title => "Last Check", "field" => "last_check", "checked" => 1, sort => 4 },
{ title => "Duration", "field" => "duration", "checked" => 1, sort => 6 },
{ title => "Attempt", "field" => "current_attempt", "checked" => 1, sort => 5 },
{ title => "Service", "field" => "description", "checked" => 1, sortby => 2 },
{ title => "Status", "field" => "state", "checked" => 1, sortby => 3 },
{ title => "Last Check", "field" => "last_check", "checked" => 1, sortby => 4 },
{ title => "Duration", "field" => "duration", "checked" => 1, sortby => 6 },
{ title => "Attempt", "field" => "current_attempt", "checked" => 1, sortby => 5 },
);
if($c->stash->{'show_backends_in_table'} == 1) {
push @{$columns},
{ title => "Site", "field" => "peer_name", "checked" => 1, sort => 7 };
{ title => "Site", "field" => "peer_name", "checked" => 1, sortby => 7 };
}
push @{$columns}, (
{ title => "Status Information", "field" => "plugin_output", "checked" => 1, sort => 9 },
{ title => "Status Information", "field" => "plugin_output", "checked" => 1, sortby => 9 },
);
if(!$c->stash->{'show_backends_in_table'}) {
push @{$columns},
{ title => "Site", "field" => "peer_name", "checked" => 0, sort => 7 };
{ title => "Site", "field" => "peer_name", "checked" => 0, sortby => 7 };
}
push @{$columns}, (
{ title => "Host Address", "field" => "host_address", "checked" => 0 },
Expand Down
3 changes: 1 addition & 2 deletions templates/_status_detail_table.tt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
[% center = " text-center" %]
[% END %]
<th class="status col_[% col.field | html %][% center %]"[% IF ! col.checked %] style="display: none;"[% END %]>
<a class="status col_[% col.field | html %] sort-by" href='#' data-sort-type[% sortprefix %]="1" data-sort-option[% sortprefix %]="[% col.sort %]">[% col.title | html %]</a>
<a class="status col_[% col.field | html %] sort-by" href='#' data-sort-type[% sortprefix %]="1" data-sort-option[% sortprefix %]="[% col.sortby %]">[% col.title | html %]</a>
</th>
[% END %]
</tr>
Expand Down Expand Up @@ -250,7 +250,6 @@
[% ELSE %]
<td></td>
[% END %]
</td>
[% END %]
</tr>
[% SET lasthost = s.host_name %]
Expand Down
2 changes: 1 addition & 1 deletion templates/_status_hostdetail_table.tt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
[% center = " text-center" %]
[% END %]
<th class="status col_[% col.field | html %][% center %]"[% IF ! col.checked %] style="display: none;"[% END %]>
<a class="status col_[% col.field | html %] sort-by" href='#' data-sort-type[% sortprefix %]="1" data-sort-option[% sortprefix %]="[% col.sort %]">[% col.title | html %]</a>
<a class="status col_[% col.field | html %] sort-by" href='#' data-sort-type[% sortprefix %]="1" data-sort-option[% sortprefix %]="[% col.sortby %]">[% col.title | html %]</a>
</th>
[% END %]
</tr>
Expand Down

0 comments on commit 34f407e

Please sign in to comment.