Revision 9efd0075 snf-astakos-app/astakos/im/static/im/js/quotas.js
b/snf-astakos-app/astakos/im/static/im/js/quotas.js | ||
---|---|---|
43 | 43 |
function bytesToSize2(bytes) { |
44 | 44 |
var sizes = [ 'n/a', 'bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; |
45 | 45 |
var i = +Math.floor(Math.log(bytes) / Math.log(1024)); |
46 |
if (!isFinite(i)) { return 0 + 'KB'} |
|
46 | 47 |
return (bytes / Math.pow(1024, i)).toFixed( 0 ) + sizes[ isNaN( bytes ) ? 0 : i+1 ]; |
47 | 48 |
} |
48 | 49 |
|
... | ... | |
270 | 271 |
|
271 | 272 |
|
272 | 273 |
|
273 |
$('.group input[name$="_uplimit_proxy"]').each(function() { |
|
274 |
$('.group input[name$="_m_uplimit_proxy"], .group input[name$="_p_uplimit_proxy"]').each(function() {
|
|
274 | 275 |
if ($(this).val()){ |
275 |
|
|
276 | 276 |
// get value from input |
277 | 277 |
var value = $(this).val(); |
278 | 278 |
|
279 |
|
|
280 | 279 |
// get hidden input name |
281 | 280 |
hidden_name = $(this).attr('name'); |
282 |
hidden_field_name = hidden_name.replace("_proxy",""); |
|
281 |
hidden_field_name = hidden_name.replace("_proxy", "");
|
|
283 | 282 |
$("input[name='"+hidden_field_name+"']").val(value); |
284 | 283 |
var field = $(this); |
285 | 284 |
|
286 |
|
|
287 | 285 |
if ( (field.hasClass('dehumanize')) && !($(this).parents('.form-row').hasClass('with-errors'))) { |
288 | 286 |
// for dehumanize fields transform bytes to KB, MB, etc |
289 | 287 |
// unless there is an error |
290 |
field.val(bytesToSize2(value)) |
|
288 |
field.val(bytesToSize2(value) || 0)
|
|
291 | 289 |
} else { |
292 | 290 |
// else just return the value |
293 | 291 |
field.val(value); |
294 | 292 |
} |
295 |
|
|
296 | 293 |
var group_class = field.parents('div[class^="group"]').attr('class').replace('group ', ''); |
297 |
|
|
298 |
|
|
299 |
|
|
300 |
|
|
294 |
|
|
301 | 295 |
// select group icon |
302 | 296 |
$('.quotas-form ul li a').each(function() { |
303 | 297 |
|
... | ... | |
311 | 305 |
$("input[name='"+hidden_name+"']").val("1"); |
312 | 306 |
|
313 | 307 |
group_form_show_resources($(this)); |
314 |
|
|
315 | 308 |
} |
316 | 309 |
}); |
317 | 310 |
|
318 |
|
|
319 |
|
|
320 | 311 |
// if the field has class error, transfer error to the proxy fields |
321 | 312 |
if ( $(this).parents('.form-row').hasClass('with-errors') ) { |
322 | 313 |
field.parents('.form-row').addClass('with-errors'); |
323 | 314 |
} |
324 |
|
|
325 |
|
|
326 | 315 |
} |
327 | 316 |
}); |
328 | 317 |
|
... | ... | |
375 | 364 |
}); |
376 | 365 |
|
377 | 366 |
|
378 |
}); |
|
367 |
}); |
Also available in: Unified diff