1 // Bweb - A Bacula web interface
2 // Bacula® - The Network Backup Solution
4 // Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
6 // The main author of Bweb is Eric Bollengier.
7 // The main author of Bacula is Kern Sibbald, with contributions from
8 // many others, a complete list can be found in the file AUTHORS.
10 // This program is Free Software; you can redistribute it and/or
11 // modify it under the terms of version two of the GNU General Public
12 // License as published by the Free Software Foundation plus additions
13 // that are listed in the file LICENSE.
15 // This program is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // General Public License for more details.
20 // You should have received a copy of the GNU General Public License
21 // along with this program; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 // Bacula® is a registered trademark of John Walker.
26 // The licensor of Bacula is the Free Software Foundation Europe
27 // (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zurich,
28 // Switzerland, email:ftf@fsfeurope.org.
30 var even_cell_color = "#FFFFFF";
31 var odd_cell_color = "#EEEEEE";
32 var header_color = "#E1E0DA";
33 var rows_per_page = 20;
34 var bweb_root = "/bweb/";
35 var up_icon = "/bweb/up.gif";
36 var down_icon = "/bweb/down.gif";
37 var prev_icon = "/bweb/left.gif";
38 var next_icon = "/bweb/right.gif";
39 var rew_icon = "/bweb/first.gif";
40 var fwd_icon = "/bweb/last.gif";
43 'C': 'created but not yet running',
46 'T': 'terminated normally',
47 'E': 'Job terminated in error',
48 'e': 'Non-fatal error',
50 'D': 'Verify differences',
51 'A': 'canceled by user',
52 'F': 'waiting on File daemon',
53 'S': 'waiting on the Storage daemon',
54 'm': 'waiting for new media',
55 'M': 'waiting for Mount',
56 's': 'Waiting for storage resource',
57 'j': 'Waiting for job resource',
58 'c': 'Waiting for Client resource',
59 'd': 'Waiting for maximum jobs',
60 't': 'Waiting for start time',
61 'p': 'Waiting for higher priority jobs to finish'
66 'I': 'Incr (since last backup)',
67 'D': 'Diff (since last full backup)',
68 'C': 'verify from catalog',
69 'V': 'verify save (init DB)',
70 'O': 'verify Volume to catalog entries',
71 'd': 'verify Disk attributes to catalog',
72 'A': 'verify data on volume',
83 var refresh_time = 60000;
85 function bweb_refresh() {
88 function bweb_add_refresh(){
89 window.setInterval("bweb_refresh()",refresh_time);
92 function human_size(val)
97 var unit = ['b', 'Kb', 'Mb', 'Gb', 'Tb'];
100 while (val /1024 > 1) {
105 var format = (i>0)?1:0;
106 return val.toFixed(format) + ' ' + unit[i];
109 function human_sec(val)
114 val /= 60; // sec -> min
116 if ((val / 60) <= 1) {
117 return val.toFixed(0) + ' mins';
120 val /= 60; // min -> hour
122 if ((val / 24) <= 1) {
123 return val.toFixed(0) + ' hours';
126 val /= 24; // hour -> day
128 if ((val / 365) < 2) {
129 return val.toFixed(0) + ' days';
134 return val.toFixed(0) + ' years';
139 // percent_display("row2", [ { nb: 1, name: "Full" },
140 // { nb: 2, name: "Error" },
141 // { nb: 5, name: "Append" },
142 // { nb: 2, name: "Purged" },
143 // {} # last element must be {}
146 function percent_get_img(type)
148 var img=document.createElement('img');
150 img.className="pSlice" + type ;
152 img.className="pSlice";
154 img.src="/bweb/pix.png";
159 var percent_display_nb_slice = 20;
160 var percent_usage_nb_slice = 5;
162 function percent_display(hash_values, parent)
164 var nb_elt=percent_display_nb_slice;
168 parent = document.createElement('DIV');
171 if (typeof parent != "object") {
172 parent = document.getElementById(parent);
176 alert("E : display_percent(): Can't find parent " + parent);
180 hash_values.pop(); // drop last element {}
182 var nb_displayed = 0;
185 for(var i=0;i<hash_values.length;i++) {
186 nb_max += hash_values[i]['nb'];
189 for(var i=0;i<hash_values.length;i++) {
190 var elt = hash_values[i];
191 var cur_nb = (elt['nb'] * nb_elt)/nb_max;
192 var cur_name = elt['name'];
193 cur_name.replace(/-/,"_");
195 tips = tips + " " + elt['nb'] + " " + cur_name;
197 while ((nb_displayed < nb_elt) && (cur_nb >=1)) {
201 var img= percent_get_img(cur_name);
202 parent.appendChild(img);
206 while (nb_displayed < nb_elt) {
208 var img= percent_get_img();
209 parent.appendChild(img);
217 function percent_usage(value, parent)
219 var nb_elt=percent_usage_nb_slice;
223 parent = document.createElement('DIV');
226 if (typeof parent != "object") {
227 parent = document.getElementById(parent);
231 alert("E : display_percent(): Can't find parent " + parent);
235 if (value <= 0.001) {
238 } else if (value <= 40) {
240 } else if (value <= 75) {
242 } else if (value <= 85) {
248 var nb = parseInt(value*nb_elt/100, 10);
249 parent.title = parseInt(value*100,10)/100 + "% used (approximate)";
251 for(var i=0; i<nb; i++) {
252 var img= percent_get_img(type);
253 parent.appendChild(img);
256 for(nb;nb < nb_elt;nb++) {
257 var img= percent_get_img("Empty");
258 parent.appendChild(img);
264 function bweb_get_job_img(status, errors)
277 ret = status + ".png";
280 return bweb_root + ret;
283 function search_media()
285 var what = document.getElementById('searchbox').value;
287 document.search.action.value='media';
288 document.search.re_media.value=what;
289 document.search.submit();
293 function search_client()
295 var what = document.getElementById('searchbox').value;
297 document.search.action.value='client';
298 document.search.re_client.value=what;
299 document.search.submit();
303 sfHover = function() {
304 var sfEls = document.getElementById("menu").getElementsByTagName("LI");
305 for (var i=0; i<sfEls.length; i++) {
306 sfEls[i].onmouseover=function() {
307 this.className+=" sfhover";
309 sfEls[i].onmouseout=function() {
310 this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
315 if (window.attachEvent) window.attachEvent("onload", sfHover);