X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=static%2Fsrc%2Finstancehandler%2Finstance_create.js;h=4273f90e9fa5c2b8390834d3e9722468efb4a3a0;hb=b58d5d8e177049ab63587f4329f282bc206352ec;hp=55fb512373217d3404efd642eabbebaf1426a7cf;hpb=dd73c0c9bdfb085085fd6345e8ab9c5440e5e77a;p=osm%2FLW-UI.git diff --git a/static/src/instancehandler/instance_create.js b/static/src/instancehandler/instance_create.js index 55fb512..4273f90 100644 --- a/static/src/instancehandler/instance_create.js +++ b/static/src/instancehandler/instance_create.js @@ -14,12 +14,36 @@ limitations under the License. */ +function openModalCreatePDU(args) { + var select2_groups = $('#pdu_vim_accounts').select2({ + placeholder: 'Select Vims', + width: '100%', + ajax: { + url: args.vim_list_url, + dataType: 'json', + processResults: function (data) { + vims = []; + if (data['datacenters']) { + for (d in data['datacenters']) { + var datacenter = data['datacenters'][d]; + vims.push({ id: datacenter['_id'], text: datacenter['name'] }) + } + } + return { + results: vims + }; + } + } + }); -function openModalCreateNS(args) { + $('#modal_new_pdu').modal('show'); +} +function openModalCreateNS(args) { // load vim account list select2_groups = $('#vimAccountId').select2({ placeholder: 'Select VIM', + width: '100%', ajax: { url: args.vim_list_url, dataType: 'json', @@ -28,7 +52,7 @@ function openModalCreateNS(args) { if (data['datacenters']) { for (d in data['datacenters']) { var datacenter = data['datacenters'][d]; - vims.push({id: datacenter['_id'], text: datacenter['name']}) + vims.push({ id: datacenter['_id'], text: datacenter['name'] }) } } @@ -38,19 +62,21 @@ function openModalCreateNS(args) { } } }); - /* + // load nsd list select2_groups = $('#nsdId').select2({ placeholder: 'Select NSD', + width: '100%', ajax: { url: args.nsd_list_url, dataType: 'json', processResults: function (data) { nsd_list = []; - if (data['nsd_list']) { - for (d in data['nsd_list']) { - var nsd = data['nsd_list'][d]; - nsd_list.push({id: nsd['_id'], text: nsd['name']}) + + if (data['descriptors']) { + for (d in data['descriptors']) { + var nsd = data['descriptors'][d]; + nsd_list.push({ id: nsd['_id'], text: nsd['name'] }) } } @@ -60,7 +86,18 @@ function openModalCreateNS(args) { } } }); - */ - $('#nsdId').val(args.descriptor_id); + + if (args.descriptor_id) { + // Set the value, creating a new option if necessary + if ($('#nsdId').find("option[value='" + args.descriptor_id + "']").length) { + $('#nsdId').val(args.descriptor_id).trigger('change'); + } else { + // Create a DOM Option and pre-select by default + var newOption = new Option(args.descriptor_name, args.descriptor_id, true, true); + // Append it to the select + $('#nsdId').append(newOption).trigger('change'); + } + } + $('#modal_new_instance').modal('show'); } \ No newline at end of file