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.
18 function openModalCreatePDU(args
) {
19 var select2_groups
= $('#pdu_vim_accounts').select2({
20 placeholder
: 'Select Vims',
23 url
: args
.vim_list_url
,
25 processResults: function (data
) {
27 if (data
['datacenters']) {
28 for (d
in data
['datacenters']) {
29 var datacenter
= data
['datacenters'][d
];
30 vims
.push({ id
: datacenter
['_id'], text
: datacenter
['name'] })
40 $('#modal_new_pdu').modal('show');
43 function openModalCreateNS(args
) {
44 // load vim account list
45 select2_groups
= $('#vimAccountId').select2({
46 placeholder
: 'Select VIM',
49 url
: args
.vim_list_url
,
51 processResults: function (data
) {
53 if (data
['datacenters']) {
54 for (d
in data
['datacenters']) {
55 var datacenter
= data
['datacenters'][d
];
56 vims
.push({ id
: datacenter
['_id'], text
: datacenter
['name'] })
68 select2_groups
= $('#nsdId').select2({
69 placeholder
: 'Select NSD',
72 url
: args
.nsd_list_url
,
74 processResults: function (data
) {
77 if (data
['descriptors']) {
78 for (d
in data
['descriptors']) {
79 var nsd
= data
['descriptors'][d
];
80 nsd_list
.push({ id
: nsd
['_id'], text
: nsd
['name'] })
91 if (args
.descriptor_id
) {
92 // Set the value, creating a new option if necessary
93 if ($('#nsdId').find("option[value='" + args
.descriptor_id
+ "']").length
) {
94 $('#nsdId').val(args
.descriptor_id
).trigger('change');
96 // Create a DOM Option and pre-select by default
97 var newOption
= new Option(args
.descriptor_name
, args
.descriptor_id
, true, true);
98 // Append it to the select
99 $('#nsdId').append(newOption
).trigger('change');
103 $('#modal_new_instance').modal('show');
105 function openModalCreateNSI(args
) {
106 // load vim account list
107 select2_groups
= $('#vimAccountIdNSI').select2({
108 placeholder
: 'Select VIM',
111 url
: args
.vim_list_url
,
113 processResults: function (data
) {
115 if (data
['datacenters']) {
116 for (d
in data
['datacenters']) {
117 var datacenter
= data
['datacenters'][d
];
118 vims
.push({ id
: datacenter
['_id'], text
: datacenter
['name'] })
130 select2_groups
= $('#nstId').select2({
131 placeholder
: 'Select NST',
134 url
: args
.nst_list_url
,
136 processResults: function (data
) {
139 if (data
['templates']) {
140 for (d
in data
['templates']) {
141 var nst
= data
['templates'][d
];
142 nst_list
.push({ id
: nst
['_id'], text
: nst
['name'] })
152 if (args
.template_id
) {
153 // Set the value, creating a new option if necessary
154 if ($('#nstId').find("option[value='" + args
.template_id
+ "']").length
) {
155 $('#nstId').val(args
.template_id
).trigger('change');
157 // Create a DOM Option and pre-select by default
158 var newOption
= new Option(args
.template_name
, args
.template_id
, true, true);
159 // Append it to the select
160 $('#nstId').append(newOption
).trigger('change');
164 $('#modal_new_nsi').modal('show');