2 Copyright 2018 CNIT - Consorzio Nazionale Interuniversitario per le Telecomunicazioni
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
17 function openModalCreatePDU(args
) {
18 var select2_groups
= $('#pdu_vim_accounts').select2({
19 placeholder
: 'Select Vims',
22 url
: args
.vim_list_url
,
24 processResults: function (data
) {
26 if (data
['datacenters']) {
27 for (d
in data
['datacenters']) {
28 var datacenter
= data
['datacenters'][d
];
29 vims
.push({ id
: datacenter
['_id'], text
: datacenter
['name'] })
39 $('#modal_new_pdu').modal('show');
42 function openModalCreateNS(args
) {
43 // load vim account list
44 select2_groups
= $('#vimAccountId').select2({
45 placeholder
: 'Select VIM',
48 url
: args
.vim_list_url
,
50 processResults: function (data
) {
52 if (data
['datacenters']) {
53 for (d
in data
['datacenters']) {
54 var datacenter
= data
['datacenters'][d
];
55 vims
.push({ id
: datacenter
['_id'], text
: datacenter
['name'] })
67 select2_groups
= $('#nsdId').select2({
68 placeholder
: 'Select NSD',
71 url
: args
.nsd_list_url
,
73 processResults: function (data
) {
76 if (data
['descriptors']) {
77 for (d
in data
['descriptors']) {
78 var nsd
= data
['descriptors'][d
];
79 nsd_list
.push({ id
: nsd
['_id'], text
: nsd
['name'] })
90 if (args
.descriptor_id
) {
91 // Set the value, creating a new option if necessary
92 if ($('#nsdId').find("option[value='" + args
.descriptor_id
+ "']").length
) {
93 $('#nsdId').val(args
.descriptor_id
).trigger('change');
95 // Create a DOM Option and pre-select by default
96 var newOption
= new Option(args
.descriptor_name
, args
.descriptor_id
, true, true);
97 // Append it to the select
98 $('#nsdId').append(newOption
).trigger('change');
102 $('#modal_new_instance').modal('show');
104 function openModalCreateNSI(args
) {
105 // load vim account list
106 select2_groups
= $('#vimAccountIdNSI').select2({
107 placeholder
: 'Select VIM',
110 url
: args
.vim_list_url
,
112 processResults: function (data
) {
114 if (data
['datacenters']) {
115 for (d
in data
['datacenters']) {
116 var datacenter
= data
['datacenters'][d
];
117 vims
.push({ id
: datacenter
['_id'], text
: datacenter
['name'] })
129 select2_groups
= $('#nstId').select2({
130 placeholder
: 'Select NST',
133 url
: args
.nst_list_url
,
135 processResults: function (data
) {
138 if (data
['templates']) {
139 for (d
in data
['templates']) {
140 var nst
= data
['templates'][d
];
141 nst_list
.push({ id
: nst
['_id'], text
: nst
['name'] })
151 if (args
.template_id
) {
152 // Set the value, creating a new option if necessary
153 if ($('#nstId').find("option[value='" + args
.template_id
+ "']").length
) {
154 $('#nstId').val(args
.template_id
).trigger('change');
156 // Create a DOM Option and pre-select by default
157 var newOption
= new Option(args
.template_name
, args
.template_id
, true, true);
158 // Append it to the select
159 $('#nstId').append(newOption
).trigger('change');
163 $('#modal_new_nsi').modal('show');