2 Copyright 2013 IBM Corp.
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 "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.
16 <script type="text/x-red" data-template-name="block">
17 <div class="form-row">
18 <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
19 <input type="text" id="node-input-name" placeholder="Name">
21 <div class="form-row">
23 <table border='0' width='100%' style='cellspacing:5px;'>
26 <input type="checkbox" id="node-input-atomic-chkBox" onclick=updateXml()>
27 <input type="hidden" id="node-input-atomic" value="">
30 <span style="font-size:.8em;">Atomic</span>
35 <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label>
36 <input type="hidden" id="node-input-xml" autofocus="autofocus">
37 <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div>
39 <div class="form-row">
40 <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a>
41 <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show Values</b></a>
42 <input type="hidden" id="node-input-comments">
43 <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a>
44 <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div>
46 <div class="form-tips">See the Info tab for help using this node.</div>
49 <script type="text/x-red" data-help-name="block">
51 <p>Name can be anything.</p>
52 <p>Do not include closing tag - it will be automatically generated.</p>
55 <h3><a name="Flow_Control"></a>Flow Control</h3>
57 <h4><a name="Block_node"></a>Block node</h4>
59 <h5><a name="Description"></a>Description</h5>
60 <p>A <b>block</b> node is used to executes a set of nodes. </p></div>
62 <h5><a name="Attributes"></a>Attributes</h5>
63 <table border="1" class="table table-striped">
65 <td align="center"><b>atomic</b></td>
66 <td align="left">if <i>true</i>, then if a node returns failure, subsequent nodes will not be executed and nodes already executed will be backed out.</td></tr></table></div>
68 <h5><a name="Parameters"></a>Parameters</h5>
71 <h5><a name="Outcomes"></a>Outcomes</h5>
74 <h5><a name="Example"></a>Example</h5>
77 <record plugin="org.onap.ccsdk.sli.core.sli.recording.FileRecorder">
78 <parameter name="file" value="/tmp/sample_r1.log" />
79 <parameter name="field1" value="__TIMESTAMP__"/>
80 <parameter name="field2" value="RESERVED"/>
81 <parameter name="field3" value="$asePort.uni_circuit_id"/>
83 <return status="success">
84 <parameter name="uni-circuit-id" value="$asePort.uni_circuit_id" />
86 </block></pre></div></div></div>
91 <script type="text/javascript">
93 RED.nodes.registerType('block',{
97 name: {value:"block"},
98 xml: {value:"<block>\n"},
99 atomic: {value:"false"},
105 icon: "arrow-in.png",
109 oneditprepare: function() {
110 $( "#node-input-outputs" ).spinner({
114 var comments = $( "#node-input-comments").val();
115 if(comments != null){
116 comments = comments.trim();
118 $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>");
122 var atomic = $( "#node-input-atomic").val();
123 if(atomic == "true"){
124 $('#node-input-atomic-chkBox').prop('checked', true);
126 $('#node-input-atomic-chkBox').prop('checked', false);
130 function functionDialogResize(ev,ui) {
131 $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px");
134 $( "#dialog" ).dialog( "option", "width", 1200 );
135 $( "#dialog" ).dialog( "option", "height", 750 );
136 $( "#dialog" ).on("dialogresize", functionDialogResize);
137 $( "#dialog" ).one("dialogopen", function(ev) {
138 var size = $( "#dialog" ).dialog('option','sizeCache-function');
140 functionDialogResize(null,{size:size});
144 /* close dialog when ESC is pressed and released */
145 $( "#dialog" ).keyup(function(event){
146 if(event.which == 27 ) {
147 $("#node-dialog-cancel").click();
151 $( "#dialog" ).one("dialogclose", function(ev,ui) {
152 var height = $( "#dialog" ).dialog('option','height');
153 $( "#dialog" ).off("dialogresize",functionDialogResize);
156 require(["orion/editor/edit"], function(edit) {
158 parent:document.getElementById('node-input-xml-editor'),
160 contents: $("#node-input-xml").val()
162 blockXmlEditor=that.editor;
164 url:"functions", // where to get the data from
165 type:"function", // the type of object the library is for
166 editor:that.editor, // the field name the main text body goes to
167 fields:['name','outputs']
169 $("#node-input-name").focus();
170 $("#node-input-validate").click(function(){
171 //console.log("validate clicked.");
172 //console.dir(that.editor);
173 //console.log("getText:" + that.editor.getText());
174 var val = that.editor.getText();
177 $("#node-input-show-sli-values").click(function(){
178 //console.log("SLIValues clicked.");
179 showValuesBox(that.editor,sliValuesObj);
183 //for click of add comments button
184 $("#node-input-btnComments").click(function(e){
188 oneditsave: function() {
190 $("#node-input-xml").val(this.editor.getText());
191 var resp=validateXML(this.editor.getText());
193 this.status = {fill:"green",shape:"dot",text:"OK"};
195 this.status = {fill:"red",shape:"dot",text:"ERROR"};
198 delete blockXmlEditor;
201 function updateXml(){
202 if($("#node-input-atomic-chkBox").is(':checked')){
203 $("#node-input-name").val("block : atomic");
204 $("#node-input-atomic").val("true");
205 //alert($("#node-input-xml-editor div.textview div.textviewContent").text());
206 var xmlStr = blockXmlEditor.getText();
207 var re = new RegExp("<block[^<]+");
208 xmlStr=xmlStr.replace(re,"<block atomic='true'>");
209 //$("#node-input-xml-editor div.textview div.textviewContent").text(xmlStr);
210 blockXmlEditor.setText(xmlStr);
211 //console.log("block xmlStr:" + xmlStr);
213 $("#node-input-name").val("block");
214 $("#node-input-atomic").val("false");
215 var xmlStr = blockXmlEditor.getText();
216 var re = new RegExp("<block[^<]+");
217 xmlStr=xmlStr.replace(re,"<block>");
218 blockXmlEditor.setText(xmlStr);
219 //$("#node-input-xml-editor div.textview div.textviewContent").text(xmlStr);
220 //console.log("block xmlStr:" + xmlStr);