Title: [opsview] [11228] Added is_handled method, host and service context menu links use it to determine whether to show the ?\226?\128?\156Acknowledged?\226?\128?\157 link.
Revision
11228
Author
pknight
Date
2013-01-25 09:36:40 +0000 (Fri, 25 Jan 2013)

Log Message

Added is_handled method, host and service context menu links use it to determine whether to show the ?\226?\128?\156Acknowledged?\226?\128?\157 link.

Modified Paths

Modified: trunk/opsview-core/lib/Runtime/Host.pm
===================================================================
--- trunk/opsview-core/lib/Runtime/Host.pm	2013-01-24 17:23:35 UTC (rev 11227)
+++ trunk/opsview-core/lib/Runtime/Host.pm	2013-01-25 09:36:40 UTC (rev 11228)
@@ -55,8 +55,8 @@
 
 =item $self->downtime( { start => $start, end => $end, comment => $comment } )
 
-Will set up (if hash passed) or cancel (if no hash) scheduled downtime for 
-the hostgroup.  Both $start end $end are times in epoch format and should 
+Will set up (if hash passed) or cancel (if no hash) scheduled downtime for
+the hostgroup.  Both $start end $end are times in epoch format and should
 have been previously validated.
 
 Will affect all leaf hostgroups contained within this (possibly hierarchical) hostgroup.
@@ -149,7 +149,7 @@
 		LEFT JOIN nagios_scheduleddowntime nsd ON (nsd.object_id = ohs.service_object_id OR nsd.object_id = ohs.host_object_id)
 		WHERE
 			ohs.host_object_id = ?
-		AND 
+		AND
 			nsd.scheduleddowntime_id IS NOT NULL
 		GROUP BY nsd.comment_data,nsd.entry_time
 		ORDER BY nsd.comment_data,nsd.scheduled_start_time
@@ -173,7 +173,7 @@
 
     # Need the lft+1=rgt to get a leaf hostgroup
     my $sql = qq{
-SELECT opsview_hostgroups.id 
+SELECT opsview_hostgroups.id
 FROM opsview_hostgroups,opsview_hostgroup_hosts
 WHERE
  opsview_hostgroups.id = opsview_hostgroup_hosts.hostgroup_id
@@ -186,7 +186,7 @@
     return Runtime::Hostgroup->sth_to_objects( $sth, [ $self->id ] )->first;
 }
 
-=item $obj->can_be_viewed_by($contact_obj) 
+=item $obj->can_be_viewed_by($contact_obj)
 
 Check whether or not the given contact has permission to view the object
 
@@ -220,7 +220,7 @@
     return undef;
 }
 
-=item $obj->can_be_changed_by($contact_obj) 
+=item $obj->can_be_changed_by($contact_obj)
 
 Check whether or not the given contact has permisions on the object
 
@@ -252,7 +252,7 @@
     return;
 }
 
-=item $obj->can_set_downtime_by($contact_obj) 
+=item $obj->can_set_downtime_by($contact_obj)
 
 Check whether or not the given contact has permisions to set downtime
 
@@ -308,6 +308,13 @@
     return "host";
 }
 
+sub is_handled {
+    my $self = shift;
+    return (  $self->current_state != 0
+          and $self->problem_has_been_acknowledged == 0
+          and $self->scheduled_downtime_depth == 0 ) ? 0 : 1;
+}
+
 =back
 
 =head1 AUTHOR

Modified: trunk/opsview-core/lib/Runtime/Service.pm
===================================================================
--- trunk/opsview-core/lib/Runtime/Service.pm	2013-01-24 17:23:35 UTC (rev 11227)
+++ trunk/opsview-core/lib/Runtime/Service.pm	2013-01-25 09:36:40 UTC (rev 11228)
@@ -230,6 +230,13 @@
     return "service";
 }
 
+sub is_handled {
+    my $self = shift;
+    return (  $self->current_state != 0
+          and $self->problem_has_been_acknowledged == 0
+          and $self->host->object_id->current_state == 0 ) ? 0 : 1;
+}
+
 =back
 
 =head1 AUTHOR

Modified: trunk/opsview-web/root/state/host/menu
===================================================================
--- trunk/opsview-web/root/state/host/menu	2013-01-24 17:23:35 UTC (rev 11227)
+++ trunk/opsview-web/root/state/host/menu	2013-01-25 09:36:40 UTC (rev 11228)
@@ -31,7 +31,7 @@
 <a href="" c.uri_for(object.id, "detail").path_query | html %]" >[% c.loc("ui.menu.label.viewDowntimes" ) | html %]</a><br />
 
 [%- IF object.can_be_changed_by(c.user); -%]
-[%-  IF object.current_state != 0 && object.scheduled_downtime_depth == 0 && object.problem_has_been_acknowledged == 0 -%]
+[% UNLESS object.is_handled %]
 <a href="" c.uri_for("/status/service/acknowledge", { host => object.name, state => [1, 2, 3] }).path_query | html %]" >[% c.loc("ui.menu.label.acknowledge") | html %]</a><br />
 [%-  END -%]
 [%- END -%]

Modified: trunk/opsview-web/root/state/service/menu
===================================================================
--- trunk/opsview-web/root/state/service/menu	2013-01-24 17:23:35 UTC (rev 11227)
+++ trunk/opsview-web/root/state/service/menu	2013-01-25 09:36:40 UTC (rev 11228)
@@ -24,7 +24,7 @@
 <a href="" c.uri_for(object.id, "downtime").path_query | html %]" >[% c.loc("ui.menu.label.scheduleDowntime") | html %]</a><br />
 [% END %]
 [% IF object.can_be_changed_by(c.user) %]
-[% IF object.current_state != 0 && object.problem_has_been_acknowledged == 0 && object.host_object_id.current_state == 0 %]
+[% UNLESS object.is_handled %]
 <a href="" c.uri_for("/status/service/acknowledge", { host => object.hostname, servicecheck => object.name }).path_query | html %]" >[% c.loc("ui.menu.label.acknowledge") | html %]</a><br />
 [% END %]
 <a href="" c.uri_for("/state/service", object.id,"change").path_query | html %]" alt="[% c.loc("ui.menu.service.help.submitResult") | html %]">[% c.loc("ui.menu.service.label.submitResult") | html %]</a><br />

_______________________________________________
Opsview-checkins mailing list
[email protected]
http://lists.opsview.org/lists/listinfo/opsview-checkins

Reply via email to