[CCSDK-28] populated the seed code for dgbuilder
[ccsdk/distribution.git] / dgbuilder / nodes / dge / dgemain / serviceLogic.html
1 <!--
2   Copyright 2013 IBM Corp.
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 "AS IS" 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
17 <script type="text/x-red" data-template-name="service-logic">
18     <div class="form-row">
19         <!--<label for="node-input-name"><i class="fa"></i> Name</label>-->
20         <input type="hidden" id="node-input-name" placeholder="Name">
21     </div>
22     <div class="form-row">
23         <input type="hidden" id="node-input-xml">
24         <label for="node-input-module"><i class="fa"></i>Module</label>
25         <input type="text" id="node-input-module" autofocus="autofocus">
26         <label for="node-input-version"><i class="fa"></i>Version</label>
27         <input type="text" id="node-input-version">
28         <input type="hidden" id="node-input-comments">
29         <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a>
30     </div>
31     <!--<div class="form-tips">See the Info tab for help using this node.</div>-->
32 </script>
33
34 <script type="text/x-red" data-help-name="service-logic">
35         <p>A service-logic node.</p>
36         <p>Double click the node to configure the module name and the version</p>
37
38 </script>
39
40 <script type="text/javascript">
41     RED.nodes.registerType('service-logic',{
42         color:"#fdd0a2",
43         category: 'DGEmain',
44         defaults: {
45             name: {value:"service-logic"},
46             module: {value:""},
47             version: {value:""},
48             comments:{value:""},        
49             xml: {value:"<service-logic xmlns='http://www.onap.org/sdnc/svclogic' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='' version=''>\n"},
50             outputs: {value:1}
51         },
52         inputs:1,
53         outputs:1,
54         icon: "arrow-in.png",
55         label: function() {
56             return this.name;
57         },
58         oneditprepare: function() {
59             $( "#node-input-outputs" ).spinner({
60                 min:1
61             });
62
63              var comments = $( "#node-input-comments").val();
64              if(comments != null){
65                 comments = comments.trim();
66                 if(comments != ''){
67                         $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>");
68                 }
69              }
70
71             function functionDialogResize(ev,ui) {
72                 //$("#node-input-xml-editor").css("height",(ui.size.height-275)+"px");
73             };
74
75             $( "#dialog" ).on("dialogresize", functionDialogResize);
76             $( "#dialog" ).one("dialogopen", function(ev) {
77                 var size = $( "#dialog" ).dialog('option','sizeCache-function');
78                 if (size) {
79                     functionDialogResize(null,{size:size});
80                 }
81             });
82
83             /* close dialog when ESC is pressed and released */ 
84             $( "#dialog" ).keyup(function(event){
85                 if(event.which == 27 ) {
86                         $("#node-dialog-cancel").click();
87                 }
88             }); 
89
90             $( "#dialog" ).one("dialogclose", function(ev,ui) {
91                 var height = $( "#dialog" ).dialog('option','height');
92                 $( "#dialog" ).off("dialogresize",functionDialogResize);
93             });
94
95             $("#node-input-module").focus(); 
96
97             //for click of add comments button
98             $("#node-input-btnComments").click(function(e){
99                         showCommentsBox();
100             }); 
101         },
102         oneditsave: function() {
103                 var module = $("#node-input-module").val();
104                 if(module == null){
105                         module='';
106                 }
107                 var version = $("#node-input-version").val();
108                 if(version == null){
109                         version='';
110                 }
111                 console.log("module:" + module);
112                 console.log("version:" + version);
113                 //xmlStr= xmlStr.replace("$MODULE",module);
114                 //xmlStr= xmlStr.replace("$VERSION",version);
115                 var xmlVal = "<service-logic xmlns='http://www.onap.org/sdnc/svclogic' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='" + module + "' version='" + version +  "'>"
116                 $("#node-input-xml").val(xmlVal);
117                 if(module == "" || version == ""){
118                         this.status = {fill:"red",shape:"dot",text:"Not configured"};
119                 }else{
120                         this.status = {fill:"green",shape:"dot",text:"configured"};
121                         $("#node-input-name").val(module + " " + version);
122                 }
123         }
124     });
125 </script>