Revision 6405f879

View differences:

src/sunstone/public/js/opennebula.js
589 589
        },
590 590
        "fetch_template" : function(params){
591 591
            OpenNebula.Action.show(params,OpenNebula.Network.resource,"template");
592
        },
593
        "rename" : function(params){
594
            OpenNebula.Action.simple_action(params,
595
                                            OpenNebula.Network.resource,
596
                                            "rename",
597
                                            action_obj);
592 598
        }
593 599
    },
594 600

  
src/sunstone/public/js/plugins/vnets-tab.js
355 355
        notify: true
356 356
    },
357 357

  
358
    "Network.rename" : {
359
        type: "single",
360
        call: OpenNebula.Network.rename,
361
        callback: function(request) {
362
            notifyMessage("VirtualNetwork renamed correctly");
363
            Sunstone.runAction('Network.showinfo',request.request.data[0]);
364
        },
365
        error: onError,
366
        notify: true
367
    },
368

  
358 369
    "Network.fetch_permissions" : {
359 370
        type: "single",
360 371
        call: OpenNebula.Network.show,
......
610 621
    };
611 622

  
612 623
    $("#div_edit_link").die();
613
    $(".input_edit_value").die();
624
    $(".div_edit_rename_link").die();
614 625

  
615 626
    // Listener for key,value pair edit action
616
    $("#div_edit_link").live("click", function() {
617
        var value_str = $("#value_td_rename").text();
618
        $("#value_td_rename").html('<input class="input_edit_value_rename" id="input_edit_rename" type="text" value="'+value_str+'"/>');
619

  
627
    $("#div_edit_rename_link").live("click", function() {
628
        var value_str = $(".value_td_rename").text();
629
        $(".value_td_rename").html('<input class="input_edit_value_rename" id="input_edit_rename" type="text" value="'+value_str+'"/>');
620 630
    });
621 631

  
622
    $(".input_edit_value").live("change", function() {
623
        var value_str = $("#value_td_rename").text();
624

  
625
        // Let OpenNebula know
626
        Sunstone.runAction("Network.rename",vn_info.ID,$("#input_edit_rename").val());
632
    $(".input_edit_value_rename").live("change", function() {
633
        var value_str = $(".input_edit_value_rename").val();
634
        console.log(this);
635
        if(value_str!="")
636
        {
637
            // Let OpenNebula know
638
            Sunstone.runAction("Network.rename",vn_info.ID,value_str);
639
        }
627 640
    });
628 641

  
629 642

  
src/sunstone/public/js/sunstone-util.js
1272 1272
                      tr("Extended Template") +
1273 1273
                     '</th>\
1274 1274
                   </tr>\
1275
                  </thead>' + fromJSONtoHTMLTable(template_json,
1276
                                                  resource_type,
1277
                                                  resource_id) +
1278
                 '<tr>\
1275
                  </thead>\
1276
                  <tr>\
1279 1277
                    <td class="key_td"><input type="text" name="new_key" id="new_key" /></td>\
1280 1278
                    <td class="value_td"><input type="text" name="new_value" id="new_value" /></td>\
1281
                  </tr>\
1282
                </table>'
1279
                    <td class=""><button id="button_add_value">'+tr("Add")+'</button>\</td>\
1280
                  </tr>' + fromJSONtoHTMLTable(template_json,
1281
                                               resource_type,
1282
                                               resource_id) +
1283
                 '</table>'
1283 1284

  
1284 1285
    // Remove previous listeners
1285 1286
    $("#new_key").die();
......
1287 1288
    $("#div_minus").die();
1288 1289
    $("#div_edit").die();
1289 1290
    $(".input_edit_value").die();
1291
    $("button").die();
1290 1292

  
1291 1293
    // Add listener for add key and add value for Extended Template
1292
    $("#new_key").live("change", function() {
1293
      if ( $('#new_value').val() != "" )
1294
      {
1295
        template_json[$('#new_key').val()] = $('#new_value').val();
1294
    $('button').live("click", function() {
1295
        if ( $('#new_value').val() != "" && $('#new_key').val() != "" )
1296
        {
1297
            template_json[$('#new_key').val()] = $('#new_value').val();
1296 1298

  
1297
        var template_str = "";
1298
        for(var key in template_json)
1299
            template_str=template_str+key+"="+ template_json[key]+"\n";
1300

  
1301
        Sunstone.runAction(resource_type+".update_template",resource_id,template_str);
1302
      }
1303
    });
1304

  
1305
    $("#new_value").live("change", function() {
1306
      if ( $('#new_key').val() != "" )
1307
      {
1308
        template_json[$('#new_key').val()] = $('#new_value').val();
1299
            var template_str = "";
1300
            for(var key in template_json)
1301
                template_str=template_str+key+"="+ template_json[key]+"\n";
1309 1302

  
1310
        var template_str = "";
1311
        for(var key in template_json)
1312
            template_str=template_str+key+"="+ template_json[key]+"\n";
1313

  
1314
        Sunstone.runAction(resource_type+".update_template",resource_id,template_str);
1315
      }
1303
            Sunstone.runAction(resource_type+".update_template",resource_id,template_str);
1304
        }
1316 1305
    });
1317 1306

  
1318 1307
    // Listener for key,value pair remove action
......
1391 1380
    var str="";
1392 1381

  
1393 1382
    if (typeof value == 'object'){
1394
        //name of field row
1395
        str += '<tr>\
1396
                  <td class="key_td">'+tr(field)+'</td>\
1397
                  <td class="value_td"></td>\
1398
                  <td class="value_td"></td>\
1399
                </tr>';
1400
        //attributes rows
1401
        //empty row - prettyprint - empty row
1402
        str += '<tr>\
1403
                  <td class="key_td" style="border-bottom:0"></td>\
1404
                  <td class="value_td" style="border-bottom:0"></td>\
1405
                </tr>' + fromJSONtoHTMLTable(value) +
1406
                '<tr>\
1407
                  <td class="key_td"></td>\
1408
                  <td class="value_td"></td>\
1409
               </tr>';
1383

  
1384
        for(var key in value){
1385

  
1386
            str += '<tr>\
1387
                      <td class="key_td">'+tr(field)+'</td>\
1388
                      <td class="value_td" id="value_td_input_'+tr(field)+'">'+value[key]+'</td>\
1389
                      <td><div id="div_edit">\
1390
                             <a id="div_edit_'+tr(field)+'" class="edit_e" href="#">e</a>\
1391
                          </div>\
1392
                      </td>\
1393
                      <td><div id="div_minus">\
1394
                             <a id="div_minus_'+tr(field)+'" class="remove_x" href="#">x</a>\
1395
                          </div>\
1396
                      </td>\
1397
                    </tr>';
1398

  
1399
        };
1400

  
1410 1401
    } else {
1411 1402
        str += '<tr>\
1412 1403
                  <td class="key_td">'+tr(field)+'</td>\

Also available in: Unified diff