]> git.sur5r.net Git - bacula/bacula/blob - 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
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 var max_pos=0;
45
46 <TMPL_LOOP items>
47 infos = new Array();
48  <TMPL_LOOP events>
49  dates['<TMPL_VAR date>']='<TMPL_VAR num>';
50  infos['<TMPL_VAR date>'] = new Array('<TMPL_VAR num>', '<TMPL_VAR status>', 
51                                       '<TMPL_VAR joberrors>', '<TMPL_VAR title>');
52  </TMPL_LOOP>
53 all.push({ name: "<TMPL_VAR name>", values: infos});
54 </TMPL_LOOP>
55
56 //infos = new Array();
57 //infos['2007-10-01'] = new Array(1, 'T', 8, '2007-10-01');
58 //infos['2007-10-02'] = new Array(2, 'T', 8, '2007-10-02');
59 //infos['2007-10-05'] = new Array(3, 'R', 8, '2007-10-05');
60 //
61 //all.push({ name: "zog", values: infos});
62
63 function init_tab() // initialize the table
64 {
65     var i=0;
66     var step = new Array();
67     // common steps in milliseconds
68     step['day'] = 86400000;
69     step['week'] = 604800000;
70     step['month'] = 2678400000;
71     var last_date;
72     var current_date;
73
74     // javascript can't do foreach $j (sort keys %dates)
75     var keys = new Array();
76     for (var j in dates) {
77         keys.push(j);
78     }
79     keys.sort();
80
81     for (var j in keys) {
82        j = keys[j];                     // get real key
83        if (!last_date) {                // do it once
84           last_date = new Date(j.substr(0, 10));
85        }
86        // current date
87        var current_date = new Date(j.substr(0, 10));
88
89        // Try to find days where we have nothing reported
90        if (step['<TMPL_VAR type>']) {
91           last_date.setTime( last_date.getTime() + step['<TMPL_VAR type>'] * 1.25);
92           while ( last_date < current_date ) {
93              // Insert gap between current_date and last_date
94              last_date.setTime( last_date.getTime() + step['<TMPL_VAR type>']);
95              var t=document.createElement("TD");
96              t.setAttribute("id", "day" + i++); // should not be used
97              t.appendChild(document.createTextNode('?'));
98              document.getElementById("days").appendChild(t);
99           }
100        }
101        last_date = current_date;
102        var t=document.createElement("TD");
103        t.setAttribute("id", "day" + i);
104        nodate[j]=1;
105        dates_pos[j]=i++;        // position in the tab
106        document.getElementById("days").appendChild(t);
107     }
108     max_pos=i;
109 }
110
111 function add_client(name, infos)
112 {
113     tr=document.createElement("TR"); // client row
114     table.appendChild(tr);
115
116     td=document.createElement("TD"); // client name
117     tr.appendChild(td);
118     a=document.createElement("A");
119     a.setAttribute("href", "?action=<TMPL_VAR action>" + name);
120     a.appendChild(document.createTextNode(name));
121     td.appendChild(a);
122     var cur_pos=0;
123
124     for (var j in infos) { // one img for each days
125         while (cur_pos <= dates_pos[j]) { // create empty blocks
126            td=document.createElement("TD"); 
127            tr.appendChild(td);
128            cur_pos++;
129         }
130         if (nodate[j] == 1) { // put the date in the first row if empty
131            var t = document.getElementById("day" + dates_pos[j]);
132            t.appendChild(document.createTextNode(infos[j][0]));
133            nodate[j]=0;
134         }
135 //      a=document.createElement("A"); // create a link to action=job
136 //      a.setAttribute('href', "?action=job;client_group=" + name);
137         img=document.createElement("IMG");
138         img.setAttribute("src", bweb_get_job_img(infos[j][1],infos[j][2], 'B'));
139         img.setAttribute("title", infos[j][3]);
140 //      a.appendChild(img);
141         td.appendChild(img);        
142     }
143
144     while (cur_pos++ < max_pos) {
145        td=document.createElement("TD"); 
146        tr.appendChild(td);
147     }
148 }
149
150 init_tab();
151
152 for(var i=0; i<all.length; i++) {
153    var elt = all[i];
154    add_client(elt['name'], elt['values']);
155 }
156
157 </script>