0003-Bug-785-Fix-leases-prints-for-VNETs.patch

Hector Sanjuan, 08/31/2011 11:26 PM

Download (2.71 KB)

View differences:

src/sunstone/public/js/plugins/vnets-tab.js
302 302
//returns an array with the VNET information fetched from the JSON object
303 303
function vNetworkElementArray(vn_json){
304 304
    var network = vn_json.VNET;
305
    var total_leases = "0";
306

  
307
    if (network.TOTAL_LEASES){
308
        total_leases = network.TOTAL_LEASES;
309
    } else if (network.LEASES && network.LEASES.LEASE){
310
        total_leases = network.LEASES.LEASE.length ? network.LEASES.LEASE.length : "1";
311
    }
312 305

  
313 306
    return [
314 307
        '<input type="checkbox" id="vnetwork_'+network.ID+'" name="selected_items" value="'+network.ID+'"/>',
......
319 312
        parseInt(network.TYPE) ? "FIXED" : "RANGED",
320 313
        network.BRIDGE,
321 314
        parseInt(network.PUBLIC) ? "yes" : "no",
322
        total_leases ];
315
        network.TOTAL_LEASES ];
323 316
}
324 317

  
325 318

  
......
411 404
              <td class="key_td">Public</td>\
412 405
              <td class="value_td">'+(parseInt(vn_info.PUBLIC) ? "yes" : "no" )+'</td>\
413 406
            </tr>\
414
        </table>';
415

  
416
    //if it is a fixed VNET we can add leases information
417
    if (vn_info.TEMPLATE.TYPE == "FIXED"){
418
        info_tab_content +=
419
        '<table id="vn_leases_info_table" class="info_table">\
407
        </table>\
408
       <table id="vn_leases_info_table" class="info_table">\
420 409
            <thead>\
421 410
               <tr><th colspan="2">Leases information</th></tr>\
422 411
            </thead>'+
423
            prettyPrintJSON(vn_info.TEMPLATE.LEASES)+
424
        '</table>';
425
    }
412
              printLeases(vn_info.LEASES)+
413
        '</table>';;
414

  
426 415

  
427 416

  
428 417
    var info_tab = {
......
446 435

  
447 436
}
448 437

  
438
function printLeases(leases){
439
    if (!leases.LEASE) //empty
440
    {
441
        return "";
442
    };
443

  
444
    if (leases.LEASE.constructor == Array) //>1 lease
445
    {
446
        return prettyPrintJSON(leases.LEASE);
447
    }
448
    else {//1 lease
449
        return prettyPrintJSON([leases.LEASE]);
450
    };
451
}
452

  
449 453
//Prepares the vnet creation dialog
450 454
function setupCreateVNetDialog() {
451 455
    dialogs_context.append('<div title="Create Virtual Network" id="create_vn_dialog"></div>');
452
-