]> git.sur5r.net Git - bacula/bacula/blob - gui/bweb/tpl/overview.tpl
bweb: tweak overview page
[bacula/bacula] / gui / bweb / tpl / overview.tpl
1 <style type="text/css">
2 table.sample {
3         border-width: 1px 1px 1px 1px;
4         border-spacing: 3px;
5         border-style: solid solid solid solid;
6         border-color: black black black black;
7         border-collapse: collapse;
8         background-color: white;
9 }
10 table.sample th {
11         border-width: 1px 1px 1px 1px;
12         padding: 4px 4px 4px 4px;
13         border-style: solid solid solid solid;
14         border-color: gray gray gray gray;
15         background-color: white;
16 }
17 table.sample td {
18         border-width: 1px 1px 1px 1px;
19         padding: 4px 4px 4px 4px;
20         border-style: solid solid solid solid;
21         border-color: gray gray gray gray;
22         background-color: white;
23 }
24 </style>
25  <div class='titlediv'>
26   <h1 class='newstitle'> __Jobs overview__ (<TMPL_VAR label>)</h1>
27  </div>
28  <div class='bodydiv'>
29   <table class='sample' id='report'>
30    <tr id='days'><td/>
31   </table>
32  </div>
33
34
35
36 <script type="text/javascript" language="JavaScript">
37
38 var table = document.getElementById('report');
39 var nodate = {};
40 var tr; var td; var img; var infos;
41 var all = new Array();
42 var dates = {};
43 var dates_pos = {};
44
45 <TMPL_LOOP items>
46 infos = new Array();
47  <TMPL_LOOP events>
48  dates['<TMPL_VAR date>']='<TMPL_VAR num>';
49  infos['<TMPL_VAR date>'] = new Array('<TMPL_VAR num>', '<TMPL_VAR status>', 
50                                       '<TMPL_VAR joberrors>', '<TMPL_VAR title>');
51  </TMPL_LOOP>
52 all.push({ name: "<TMPL_VAR name>", values: infos});
53 </TMPL_LOOP>
54
55 //infos = new Array();
56 //infos['2007-10-01'] = new Array(1, 'T', 8, '2007-10-01');
57 //infos['2007-10-02'] = new Array(2, 'T', 8, '2007-10-02');
58 //infos['2007-10-05'] = new Array(3, 'R', 8, '2007-10-05');
59 //
60 //all.push({ name: "zog", values: infos});
61
62 function init_tab() // initialize the table
63 {
64     var i=0;
65     var step = new Array();
66     // common steps in milliseconds
67     step['day'] = 86400000;
68     step['week'] = 604800000;
69     step['month'] = 2678400000;
70     var last_date;
71     var current_date;
72
73     // javascript can't do foreach $j (sort keys %dates)
74     var keys = new Array();
75     for (var j in dates) {
76         keys.push(j);
77     }
78     keys.sort();
79
80     for (var j in keys) {
81        j = keys[j];                     // get real key
82        if (!last_date) {                // do it once
83           last_date = new Date(j.substr(0, 10));
84        }
85        // current date
86        var current_date = new Date(j.substr(0, 10));
87
88        // Try to find days where we have nothing reported
89        if (step['<TMPL_VAR type>']) {
90           last_date.setTime( last_date.getTime() + step['<TMPL_VAR type>'] * 1.25);
91           while ( last_date < current_date ) {
92              // Insert gap between current_date and last_date
93              last_date.setTime( last_date.getTime() + step['<TMPL_VAR type>']);
94              var t=document.createElement("TD");
95              t.setAttribute("id", "day" + i++); // should not be used
96              t.appendChild(document.createTextNode('?'));
97              document.getElementById("days").appendChild(t);
98           }
99        }
100        last_date = current_date;
101        var t=document.createElement("TD");
102        t.setAttribute("id", "day" + i);
103        nodate[j]=1;
104        dates_pos[j]=i++;        // position in the tab
105        document.getElementById("days").appendChild(t);
106     }
107 }
108
109 function add_client(name, infos)
110 {
111     tr=document.createElement("TR"); // client row
112     table.appendChild(tr);
113
114     td=document.createElement("TD"); // client name
115     tr.appendChild(td);
116     a=document.createElement("A");
117     a.setAttribute("href", "?action=<TMPL_VAR action>" + name);
118     a.appendChild(document.createTextNode(name));
119     td.appendChild(a);
120     var cur_pos=0;
121
122     for (var j in infos) { // one img for each days
123         while (cur_pos <= dates_pos[j]) { // create empty blocks
124            td=document.createElement("TD"); 
125            tr.appendChild(td);
126            cur_pos++;
127         }
128         if (nodate[j] == 1) { // put the date in the first row if empty
129            var t = document.getElementById("day" + dates_pos[j]);
130            t.appendChild(document.createTextNode(infos[j][0]));
131            nodate[j]=0;
132         }
133 //      a=document.createElement("A"); // create a link to action=job
134 //      a.setAttribute('href', "?action=job;client_group=" + name);
135         img=document.createElement("IMG");
136         img.setAttribute("src", bweb_get_job_img(infos[j][1],infos[j][2], 'B'));
137         img.setAttribute("title", infos[j][3]);
138 //      a.appendChild(img);
139         td.appendChild(img);        
140     }
141 }
142
143 init_tab();
144
145 for(var i=0; i<all.length; i++) {
146    var elt = all[i];
147    add_client(elt['name'], elt['values']);
148 }
149
150 </script>