Code

Updated image reload in gotomasses
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 19 May 2008 13:01:00 +0000 (13:01 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 19 May 2008 13:01:00 +0000 (13:01 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10953 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/html/getFAIstatus.php
gosa-plugins/goto/addons/goto/class_gotomasses.inc
gosa-plugins/goto/addons/goto/gotomasses.tpl

index ebac934462b25055264494abc4fac29c10f7cfc9..4f931a26f03fd3a6fca06045c4f9cb9a04d75f98 100644 (file)
@@ -41,21 +41,8 @@ if(!isset($_GET['mac'])){
 
 $config = session::get("config");
 $o =  new gosaSupportDaemon();
-$res = $o->get_entries_by_mac(array($_GET['mac']));
+$res = $o->get_entries_by_mac(split(",",$_GET['mac']));
 foreach($res as $entry){
-       if(strtolower($entry['MACADDRESS']) == strtolower($_GET['mac'])){
-               $img = "<img src='progress.php?x=80&y=13&p=".$entry['PROGRESS']."' 
-                       alt='".$entry['STATUS']."' title='".$entry['STATUS']."'>";
-       }
+       echo $entry['MACADDRESS']."|".$entry['PROGRESS']."\n";
 }
-
-
 ?>
-<html>
-<head>
-       <meta http-equiv="refresh" content="15">
-</head>
-<body style="margin:0px;padding:0px;">
-<?php echo $img; ?> 
-</body>
-</html>
index 5aa837e6c5c2ec8c6f2a17da1205895692102edb..b7f0e6ef7eac8d17ec59de9e0c214529dbc334e2 100644 (file)
@@ -500,9 +500,8 @@ class gotomasses extends plugin
         /* Real percent */
         } else {
          if (preg_match('/install/', $task['HEADERTAG'])){
-            $status = "<iframe style='border:0px;width:80px;height:13px; margin:0px; padding:0px;' 
-                          src='getFAIstatus.php?mac=".$task['MACADDRESS']."'>
-                        </iframe>";
+            $status = "<img src='progress.php?x=80&y=13&p=".$task['PROGRESS']."' alt=''
+                          id='progress_".preg_replace("/:/","_",$task['MACADDRESS'])."'>";
           } else {
             $status = preg_replace('/ /', '&nbsp;', _("in progress"));
           }
index 0f99633dfe46797b7b9a48760cc8f0820a16b76a..7ff94f653338b6f1fcb5241b83de76d8e7d3e918 100644 (file)
@@ -1 +1,115 @@
+
+
 {$div}
+
+
+{literal}
+<script type="text/javascript">
+
+if (typeof XMLHttpRequest != 'undefined')
+{
+    xmlHttpObject = new XMLHttpRequest();
+}
+if (!xmlHttpObject)
+{
+    try
+    {
+        xmlHttpObject = new ActiveXObject("Msxml2.XMLHTTP");
+    }
+    catch(e)
+    {
+        try
+        {
+            xmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP");
+        }
+        catch(e)
+        {
+            xmlHttpObject = null;
+        }
+    }
+}
+
+var fai_status = new Array();
+
+function loadContent()
+{
+       var c = 0;
+
+       /* Create array of available progress images once 
+        */
+       if(!fai_status.length){
+               for (var i = 0; i < document.images.length; i++) {
+                       var img = document.images[i];
+                       var id  = img.id;
+                       if(id.match(/^progress_/)){
+                               var mac = id.replace(/^progress_/,''); 
+                               mac = mac.replace(/_/g,':'); 
+                               fai_status[c] = new Object();
+                               fai_status[c]['MAC']  = mac;
+                               fai_status[c]['PROGRESS'] = -1;
+                               c ++;
+                       }
+               }
+       }
+
+       /* Create string of macs used as parameter for getFAIstatus.php
+               to retrieve all progress values.
+     */
+       var macs = "";
+       for (var i = 0; i < fai_status.length; i++) {
+               macs += fai_status[i]['MAC'] + ","
+       }
+
+       /* Send request 
+     */
+    xmlHttpObject.open('get','getFAIstatus.php?mac=' + macs);
+    xmlHttpObject.onreadystatechange = handleContent;
+    xmlHttpObject.send(null);
+    return false;
+}
+
+
+function handleContent()
+{
+    if (xmlHttpObject.readyState == 4)
+    {
+               /* Get text and split by newline 
+         */
+        var text = xmlHttpObject.responseText;
+               var data = text.split("\n");
+               
+               /* Walk through returned values and parse out 
+            mac and progress value */
+               for (var i = 0; i < data.length; i++) {
+                       var mac         = data[i].replace(/\|.*$/,"");
+                       var progress= data[i].replace(/^.*\|/,"");
+       
+                       /* Walk through progress images and check if the 
+                               progress status has changed 
+             */
+                       for (var e = 0; e < fai_status.length; e++) {
+
+                               /* */
+                               if(fai_status[e]["MAC"] == mac){
+
+                                       /* Check if progress has changed 
+                                        */     
+                                       if(fai_status[e]["PROGRESS"] != progress){
+                                               var id          = mac.replace(/:/g,"_"); 
+                                               id = "progress_" + id;
+                                               if(document.getElementById(id)){
+                                                       document.getElementById(id).src = "progress.php?x=80&y=13&p=" + progress; 
+                                                       fai_status[e]["PROGRESS"] = progress;
+                                               }
+                                       }
+                               }
+                       }
+               }
+               timer=setTimeout('loadContent()',5000);
+    }
+}
+
+timer=setTimeout('loadContent()',5000);
+</script>
+{/literal}
+