From: hickert Date: Mon, 5 May 2008 09:50:18 +0000 (+0000) Subject: Added logview for gotomasses. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=bea3cf5595bba69fda376a238de7a5bfd1fcee79;p=gosa.git Added logview for gotomasses. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10757 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/goto/addons/goto/class_goto_log_view.inc b/gosa-plugins/goto/addons/goto/class_goto_log_view.inc new file mode 100644 index 000000000..11fd58f2d --- /dev/null +++ b/gosa-plugins/goto/addons/goto/class_goto_log_view.inc @@ -0,0 +1,87 @@ +config = $config; + $this->event = $event; + $this->parent = $parent; + + /* Try to fetch logs for the given event (mac) + */ + $this->o_queue = new gosaSupportDaemon(); + + /* Fetch logs for this event (mac) + */ + if(isset($this->event['MACADDRESS'])){ + $this->mac = $this->event['MACADDRESS']; + } + $res = $this->o_queue->get_log_info_for_mac($this->mac); + if($this->o_queue->is_error()){ + msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG); + } + if(!isset($res[$this->mac]) || !is_array($res[$this->mac])){ + $this->logs = array(); + }else{ + $this->selected_date = key($res[$this->mac]); + $this->logs = $res; + } + } + + function execute() + { + $smarty = get_smarty(); + $smarty->assign("logs",$this->logs); + $smarty->assign("logs_available", isset($this->logs[$this->mac])); + $smarty->assign("mac",$this->mac); + $smarty->assign("selected_file",$this->selected_file); + $smarty->assign("selected_date",$this->selected_date); + $smarty->assign("log_file", $this->get_log($this->mac,$this->selected_date,$this->selected_file)); + return($smarty->fetch(get_template_path('log_view.tpl', TRUE))); + } + + + function get_log($mac,$date,$file) + { + $this->mac = "00:01:6c:9d:b9:fa"; + $res = $this->o_queue->get_log_file($mac,$date,$file); + if($this->o_queue->is_error()){ + msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG); + } + $res = nl2br(htmlentities($res)); + return($res); + } + + + function save_object() + { + plugin::save_object(); + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = get_post($attr); + } + } + } + +} + + + + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/goto/addons/goto/class_gotomasses.inc b/gosa-plugins/goto/addons/goto/class_gotomasses.inc index cd1c02223..dc3a9ce12 100644 --- a/gosa-plugins/goto/addons/goto/class_gotomasses.inc +++ b/gosa-plugins/goto/addons/goto/class_gotomasses.inc @@ -94,6 +94,7 @@ class gotomasses extends plugin "/^prio_down_/" => "prio_down", "/^edit_task_/" => "edit", + "/^log_view_/" => "logview", "/^remove_task_/" => "remove", "/^new_task_/" => "new_task");; @@ -186,6 +187,21 @@ class gotomasses extends plugin } } + + /************ + * LOG VIEW + ************/ + + if($s_action == "logview"){ + $id = $s_entry; + $type = FALSE; + if(isset($this->entries[$id])){ + $event = $this->entries[$s_entry]; + $this->dialog = new goto_log_view($this->config,$event,&$this); + } + } + + /************ * REMOVE ************/ @@ -353,7 +369,7 @@ class gotomasses extends plugin $divlist->AddHeader(array("string"=>""._("Status").$sort_img_4."", "attach"=>"style='width:80px;'")); $divlist->AddHeader(array("string"=>_("Action"), - "attach"=>"style='border-right:0px;width:120px;'")); + "attach"=>"style='border-right:0px;width:140px;'")); /* Reload the list of entries */ @@ -364,6 +380,7 @@ class gotomasses extends plugin $prio_actions=""; $action = ""; + /* If WAITING add priority action */ if(in_array($task['STATUS'],array("waiting"))){ @@ -387,13 +404,6 @@ class gotomasses extends plugin title='"._("Resume job")."' name='resume_".$key."'> "; } - /* If PROCESSING add abort action - */ - if(in_array($task['STATUS'],array("processing")) && preg_match("/install/",$task['HEADERTAG'])){ - $prio_actions.= ""; - } - /* If PAUSED or WAITING add execution action */ if(in_array($task['STATUS'],array("paused","waiting"))){ @@ -401,6 +411,13 @@ class gotomasses extends plugin title='"._("Force execution now!")."' name='execute_process_".$key."'> "; } + /* Add logview button, currently ever. + */ + if(TRUE){ + $action .= " "; + } + /* If PAUSED or WAITING add edit action */ if(in_array($task['STATUS'],array("waiting"))){ @@ -408,6 +425,14 @@ class gotomasses extends plugin class='center' alt='"._("Edit")."'>"; } + /* If PROCESSING add abort action + */ + if(in_array($task['STATUS'],array("processing")) && preg_match("/install/",$task['HEADERTAG'])){ + $action.= ""; + $action.= ""; + } + /* If WAITING or ERROR add remove action */ if( $this->acl_is_removeable() && in_array($task['STATUS'],array("waiting","error","processed"))){ @@ -491,7 +516,7 @@ class gotomasses extends plugin "attach" => "style='".$color.";width:120px;'"); $field2 = array("string" => date("d.m.Y H:i:s",strtotime($task['TIMESTAMP'])),"attach" => "style='".$color.";width:140px;'"); $field3 = array("string" => $status,"attach" => "style='".$color.";width:80px;'"); - $field4 = array("string" => $prio_actions.$action,"attach" => "style='".$color.";text-align:right;width:120px;border-right:0px;'"); + $field4 = array("string" => $prio_actions.$action,"attach" => "style='".$color.";text-align:right;width:140px;border-right:0px;'"); $divlist->AddElement(array($field0,$field1,$field1a,$field2,$field3,$field4)); } diff --git a/gosa-plugins/goto/addons/goto/log_view.tpl b/gosa-plugins/goto/addons/goto/log_view.tpl new file mode 100644 index 000000000..9ee5bbcea --- /dev/null +++ b/gosa-plugins/goto/addons/goto/log_view.tpl @@ -0,0 +1,47 @@ + +

{t}Log view{/t}

+ +{if $logs_available} + + + + + + + + + +
{t}Creation time{/t}:  + +
{t}Log file{/t}:  + +
+ +

{t}Log file{/t}

+
+ {$log_file} +
+{else} +

No logs for this host

+{/if} + +

+
+ +