]> git.sur5r.net Git - bacula/bacula/blobdiff - gui/bweb/tpl/overview.tpl
bacula-web: Replaced Get_human_file_size() function by Utils::Get_Human_Size
[bacula/bacula] / gui / bweb / tpl / overview.tpl
index 9895cca38ebf0bf74ecfc488d02531e1ebabb407..b68054d9864c368e7dd0588d3f8a8b3faf03d317 100644 (file)
@@ -36,40 +36,76 @@ table.sample td {
 <script type="text/javascript" language="JavaScript">
 
 var table = document.getElementById('report');
-var nodate = new Array();
-var nb_col=1;
+var nodate = {};
 var tr; var td; var img; var infos;
 var all = new Array();
-var max_cel=0;
-var min_cel=200;
+var dates = {};
+var dates_pos = {};
+var max_pos=0;
 
 <TMPL_LOOP items>
 infos = new Array();
  <TMPL_LOOP events>
min_cel=(min_cel< <TMPL_VAR num>)?min_cel:<TMPL_VAR num>;
- infos[<TMPL_VAR num>] = new Array('<TMPL_VAR num>', '<TMPL_VAR status>', 
-                                   '<TMPL_VAR joberrors>', '<TMPL_VAR title>');
dates['<TMPL_VAR date>']='<TMPL_VAR num>';
+ infos['<TMPL_VAR date>'] = new Array('<TMPL_VAR num>', '<TMPL_VAR status>', 
+                                      '<TMPL_VAR joberrors>', '<TMPL_VAR title>');
  </TMPL_LOOP>
-max_cel=(max_cel>infos.length)?max_cel:infos.length;
 all.push({ name: "<TMPL_VAR name>", values: infos});
 </TMPL_LOOP>
 
 //infos = new Array();
-//infos[1] = new Array('2007-10-01', 'T', 8);
-//infos[2] = new Array('2007-10-02', 'T', 8);
-//infos[5] = new Array('2007-10-05', 'R', 8);
+//infos['2007-10-01'] = new Array(1, 'T', 8, '2007-10-01');
+//infos['2007-10-02'] = new Array(2, 'T', 8, '2007-10-02');
+//infos['2007-10-05'] = new Array(3, 'R', 8, '2007-10-05');
 //
-//max_cel=(max_cel>infos.length)?max_cel:infos.length;
 //all.push({ name: "zog", values: infos});
 
 function init_tab() // initialize the table
 {
-    for(var j=min_cel; j < max_cel ; j++) {
+    var i=0;
+    var step = new Array();
+    // common steps in milliseconds
+    step['day'] = 86400000;
+    step['week'] = 604800000;
+    step['month'] = 2678400000;
+    var last_date;
+    var current_date;
+
+    // javascript can't do foreach $j (sort keys %dates)
+    var keys = new Array();
+    for (var j in dates) {
+        keys.push(j);
+    }
+    keys.sort();
+
+    for (var j in keys) {
+       j = keys[j];                     // get real key
+       if (!last_date) {                // do it once
+          last_date = new Date(j.substr(0, 10));
+       }
+       // current date
+       var current_date = new Date(j.substr(0, 10));
+
+       // Try to find days where we have nothing reported
+       if (step['<TMPL_VAR type>']) {
+          last_date.setTime( last_date.getTime() + step['<TMPL_VAR type>'] * 1.25);
+          while ( last_date < current_date ) {
+             // Insert gap between current_date and last_date
+             last_date.setTime( last_date.getTime() + step['<TMPL_VAR type>']);
+             var t=document.createElement("TD");
+             t.setAttribute("id", "day" + i++); // should not be used
+             t.appendChild(document.createTextNode('?'));
+             document.getElementById("days").appendChild(t);
+          }
+       }
+       last_date = current_date;
        var t=document.createElement("TD");
-       t.setAttribute("id", "day" + j);
+       t.setAttribute("id", "day" + i);
        nodate[j]=1;
+       dates_pos[j]=i++;        // position in the tab
        document.getElementById("days").appendChild(t);
     }
+    max_pos=i;
 }
 
 function add_client(name, infos)
@@ -83,27 +119,31 @@ function add_client(name, infos)
     a.setAttribute("href", "?action=<TMPL_VAR action>" + name);
     a.appendChild(document.createTextNode(name));
     td.appendChild(a);
-    var len = infos.length;
-
-    for(var j=min_cel; j < max_cel ; j++) { // one img for each days
-        td=document.createElement("TD"); 
-        tr.appendChild(td);
-        if (len > j && infos[j]) {
-           if (nodate[j] == 1) { // put the date in the first row if empty
-              var t = document.getElementById("day" + j);
-              t.appendChild(document.createTextNode(infos[j][0]));
-              nodate[j]=0;
-           }
-//         a=document.createElement("A"); // create a link to action=job
-//         a.setAttribute('href', "?action=job;client_group=" + name);
-            img=document.createElement("IMG");
-            img.setAttribute("src", bweb_get_job_img(infos[j][1],infos[j][2], 'B'));
-            img.setAttribute("title", infos[j][3]);
-//         a.appendChild(img);
-            td.appendChild(img);
-        } else {
-//            td.appendChild(document.createTextNode('N/A'));
+    var cur_pos=0;
+
+    for (var j in infos) { // one img for each days
+        while (cur_pos <= dates_pos[j]) { // create empty blocks
+           td=document.createElement("TD"); 
+           tr.appendChild(td);
+           cur_pos++;
+        }
+        if (nodate[j] == 1) { // put the date in the first row if empty
+           var t = document.getElementById("day" + dates_pos[j]);
+          t.appendChild(document.createTextNode(infos[j][0]));
+          nodate[j]=0;
         }
+//     a=document.createElement("A"); // create a link to action=job
+//     a.setAttribute('href', "?action=job;client_group=" + name);
+        img=document.createElement("IMG");
+        img.setAttribute("src", bweb_get_job_img(infos[j][1],infos[j][2], 'B'));
+        img.setAttribute("title", infos[j][3]);
+//     a.appendChild(img);
+        td.appendChild(img);        
+    }
+
+    while (cur_pos++ < max_pos) {
+       td=document.createElement("TD"); 
+       tr.appendChild(td);
     }
 }