blob: 4273f90e9fa5c2b8390834d3e9722468efb4a3a0 [file] [log] [blame]
lombardofdd73c0c2018-05-09 10:46:49 +02001/*
2 Copyright 2018 CNIT - Consorzio Nazionale Interuniversitario per le Telecomunicazioni
3
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
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
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.
15*/
16
lombardofrb58d5d82019-01-04 15:25:45 +010017function openModalCreatePDU(args) {
18 var select2_groups = $('#pdu_vim_accounts').select2({
19 placeholder: 'Select Vims',
20 width: '100%',
21 ajax: {
22 url: args.vim_list_url,
23 dataType: 'json',
24 processResults: function (data) {
25 vims = [];
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'] })
30 }
31 }
32 return {
33 results: vims
34 };
35 }
36 }
37 });
38
39 $('#modal_new_pdu').modal('show');
40}
41
lombardofdd73c0c2018-05-09 10:46:49 +020042function openModalCreateNS(args) {
lombardofdd73c0c2018-05-09 10:46:49 +020043 // load vim account list
44 select2_groups = $('#vimAccountId').select2({
45 placeholder: 'Select VIM',
lombardof74ed51a2018-05-11 01:07:01 +020046 width: '100%',
lombardofdd73c0c2018-05-09 10:46:49 +020047 ajax: {
48 url: args.vim_list_url,
49 dataType: 'json',
50 processResults: function (data) {
51 vims = [];
52 if (data['datacenters']) {
53 for (d in data['datacenters']) {
54 var datacenter = data['datacenters'][d];
lombardofrb58d5d82019-01-04 15:25:45 +010055 vims.push({ id: datacenter['_id'], text: datacenter['name'] })
lombardofdd73c0c2018-05-09 10:46:49 +020056 }
57 }
58
59 return {
60 results: vims
61 };
62 }
63 }
64 });
lombardof07db64f2018-05-11 13:47:10 +020065
lombardofdd73c0c2018-05-09 10:46:49 +020066 // load nsd list
67 select2_groups = $('#nsdId').select2({
68 placeholder: 'Select NSD',
lombardof07db64f2018-05-11 13:47:10 +020069 width: '100%',
lombardofdd73c0c2018-05-09 10:46:49 +020070 ajax: {
71 url: args.nsd_list_url,
72 dataType: 'json',
73 processResults: function (data) {
74 nsd_list = [];
lombardof07db64f2018-05-11 13:47:10 +020075
76 if (data['descriptors']) {
77 for (d in data['descriptors']) {
78 var nsd = data['descriptors'][d];
lombardofrb58d5d82019-01-04 15:25:45 +010079 nsd_list.push({ id: nsd['_id'], text: nsd['name'] })
lombardofdd73c0c2018-05-09 10:46:49 +020080 }
81 }
82
83 return {
84 results: nsd_list
85 };
86 }
87 }
88 });
lombardof07db64f2018-05-11 13:47:10 +020089
lombardofr1e320062018-10-30 22:16:25 +010090 if (args.descriptor_id) {
lombardof07db64f2018-05-11 13:47:10 +020091 // 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');
94 } else {
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');
99 }
100 }
101
lombardofdd73c0c2018-05-09 10:46:49 +0200102 $('#modal_new_instance').modal('show');
103}