Jobs on Compass often timeout
[releng.git] / utils / test / vnfcatalogue / VNF_Catalogue / public / javascripts / mode_edit.js
1 /*******************************************************************************\r
2  * Copyright (c) 2017 Kumar Rishabh and others.\r
3  *\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Apache License, Version 2.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.apache.org/licenses/LICENSE-2.0\r
8  *******************************************************************************/\r
9 \r
10 $(document).ready( function() {\r
11 \r
12     //getVnfs : get 5 main VNFs using typeahead\r
13     var getVnfs = new Bloodhound({\r
14         datumTokenizer: Bloodhound.tokenizers.obj.whitespace('vnf_name'),\r
15         queryTokenizer: Bloodhound.tokenizers.obj.whitespace('vnf_name'),\r
16         remote: {\r
17             url: '/search_vnf?key=%QUERY',\r
18             wildcard: '%QUERY'\r
19         },\r
20         limit: 5\r
21     });\r
22 \r
23     getVnfs.initialize();\r
24     $('#scrollable-dropdown-menu #vnf_name.typeahead').typeahead(\r
25     {\r
26         hint: true,\r
27         highlight: true,\r
28         minLength: 1\r
29     },\r
30     {\r
31         name: 'vnf_name',\r
32         display: 'vnf_name',\r
33         limit: 5,\r
34         source: getVnfs.ttAdapter()\r
35     });\r
36 \r
37     //getTags : get 5 main tags using typeahead\r
38     var getTags = new Bloodhound({\r
39         datumTokenizer: Bloodhound.tokenizers.obj.whitespace('tag_name'),\r
40         queryTokenizer: Bloodhound.tokenizers.obj.whitespace('tag_name'),\r
41         remote: {\r
42             url: '/search_tag?key=%QUERY',\r
43             wildcard: '%QUERY'\r
44         },\r
45         limit: 5\r
46     });\r
47 \r
48     getTags.initialize();\r
49     $('#scrollable-dropdown-menu #tag_name.typeahead').typeahead(\r
50     {\r
51         hint: true,\r
52         highlight: true,\r
53         minLength: 1\r
54     },\r
55     {\r
56         name: 'tag_name',\r
57         display: 'tag_name',\r
58         limit: 5,\r
59         source: getTags.ttAdapter()\r
60     });\r
61 \r
62     $("#add_vnf_tag_association_button").on('click',function(){\r
63         event.preventDefault();\r
64         var vnf_name = $("#vnf_name").val() ;\r
65 \r
66         $.ajax({\r
67             url: '/vnf_tag_association',\r
68             type: 'post',\r
69             dataType: 'json',\r
70             data: $('form#add_vnf_tag_association_form').serialize(),\r
71             success: function(data) {\r
72                     $('#modal3').modal('close');\r
73                     $('form#add_vnf_tag_association_form').trigger('reset');\r
74                     Materialize.toast('Successfully added the TAG to the VNF!', 3000, 'rounded');\r
75             },\r
76             error: function (error) {\r
77                 Materialize.toast(error['responseJSON']['error'], 3000, 'rounded');\r
78             }\r
79         });\r
80     });\r
81 \r
82 });\r