aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/resources/META-INF/resources/designer/partials/portfolios/tca_properties.html
blob: c0bbe3b4bc1f86051da407303da32644eaf6e6c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
<!--
  ============LICENSE_START=======================================================
  ONAP CLAMP
  ================================================================================
  Copyright (C) 2017 AT&T Intellectual Property. All rights
                              reserved.
  ================================================================================
  Licensed under the Apache License, Version 2.0 (the "License"); 
  you may not use this file except in compliance with the License. 
  You may obtain a copy of the License at
  
  http://www.apache.org/licenses/LICENSE-2.0
  
  Unless required by applicable law or agreed to in writing, software 
  distributed under the License is distributed on an "AS IS" BASIS, 
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
  See the License for the specific language governing permissions and 
  limitations under the License.
  ============LICENSE_END============================================
  ===================================================================
  ECOMP is a trademark and service mark of AT&T Intellectual Property.
  -->

<style>
.fileUpload {
	position: relative;
	overflow: hidden;
	margin: 10px;
}

.fileUpload input.upload {
	position: absolute;
	top: 0;
	right: 0;
	margin: 0;
	padding: 0;
	font-size: 20px;
	cursor: pointer;
	opacity: 0;
	filter: alpha(opacity = 0);
	float: left;
}

.fileDisplay {
	display: inline-block;
	overflow: hidden;
	float: right;
	margin-left: 0px;
	z-index: initial;
	text-align: center;
	margin-top: 17px;
}

.form-group {
	margin-bottom:20px;
}

</style>

<script type="text/javascript">
	function disablefile() {

		document.getElementById("fileUpload").disabled = true;

	}

	function disableSVN() {
		var selectLength =  document.querySelectorAll(".disabled-block-container .tab-close-popup");
		if(selectLength && selectLength.length>0){
			for(var i = 0; i< selectLength.length ; i++){
				selectLength[i].disabled = true;
			}	
		}
	
		document.getElementById("schemaLocation").disabled = true;
		document.getElementById("userID").disabled = true;
		document.getElementById("password").disabled = true;

	}
</script>


<div id="configure-widgets" class="disabled-block-container">
	<div class="modal-header">
		<button type="button" class="close" ng-click="close(false)"
			aria-hidden="true" style="margin-top: -3px">&times;</button>
		<h4>TCA Micro Services</h4>
	</div>
	<div class="modal-body">
		<div style="height: 10px"></div>
		<div class="panel panel-default">
			<form id="topicPublish" class="form-horizontal">
				<div>

					<div class="form-group">
						<label for="userID" class="col-sm-4 control-label"> Topic Publishes</label>

						<div class="col-sm-8">
							<select class="form-control" id="topicPublishes"
								name="topicPublishes">
							</select>
						</div>
					</div>
				</div>
			</form>
			<div class="panel-heading">
				<ul id="nav_Tabs" class="nav nav-tabs">
					<li class><a id="add_one_more" href="#desc_tab"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></a></li>
				</ul>
			</div>
			<div class="panel-body">
				<div class="tab-content">
					<div id="properties_tab" class="tab-pane fade in active"></div>

				</div>

			</div>
		</div>
		<span id="formSpan" style="display: none">
			<form class="saveProps" class="form-horizontal">
				<div>

					<div class="form-group">
						<label class="col-sm-4 control-label">Field Path / Counter</label>
						<div class="col-sm-8">
							<select class="form-control" id="fieldPath" name="fieldPath"></select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-4 control-label">Threshold</label>
						<div class="col-sm-8">
							<input type="number" min="0" class="form-control" 
								name="threshold" id="threshold">
							</input>
						</div>
					</div>
					
					
					<div class="form-group">
						<label class="col-sm-4 control-label">Operator</label>
						<div class="col-sm-8">
							<select class="form-control" id="operator" name="operator"></select>
						</div>
					</div>
					
					

					<div class="form-group">
						<label class="col-sm-4 control-label">Ops Policy</label>

						<div class="col-sm-8">
							<select  class="form-control" id="opsPolicy" name="opsPolicy" 
							enableFilter="false" ></select>
						</div>
					</div>
				</div>

			</form>
		</span>
	</div>

	<div class="modal-footer">
		<!--<button ng-click="reset()" class="btn btn-primary" style="float:left">Reset</button>-->
		<button id="savePropsBtn" class="btn btn-primary">Close</button>
		<button ng-click="close(true)" id="close_button"
			class="btn btn-primary">Cancel</button>

	</div>
	<script>
		//Basically this method will add a new form. All forms share the same class. When you want one form to show(active form) the other forms get the 
		// css attribute display:none
		$("#add_one_more").click(function(event) {		
			event.preventDefault();
			add_one_more();	
			setMultiSelect();
		})
		loadPropertyWindow("tca")
		setASDCFields();
		var arr = elementMap[lastElementSelected];
		var vfc_temp=""
		var alarm_conditions_temp=""
		var event_severity_temp=""
		var event_type_source_temp=""
		if (arr !== undefined) {
			//arr[0]
			var el=arr[1]['serviceConfigurations']
			for (var i = 0; i < el.length; i++) {
				var num=add_one_more();
				for(var j=0;j<el[i].length;j++){
					if(el[i][j].name==="vfc"){
						vfc_temp=el[i][j].value
					}else if(el[i][j].name==="alarmCondition"){
						alarm_conditions_temp=el[i][j].value
					}else if(el[i][j].name==="eventSeverity"){
						event_severity_temp=el[i][j].value;
					}else if(el[i][j].name==="eventSourceType"){
						event_type_source_temp=el[i][j].value;
					}
					else
						$("#formId"+num+" #" + el[i][j].name).val(el[i][j].value);
					
					
				}
				
				set_vfc_alarm_event(num)
				vfc_temp=""
				alarm_conditions_temp=""
				event_severity_temp=""
				event_type_source_temp=""
				
			}
			
			$("#"+ arr[0][0].name).val(arr[0][0].value);
			
			
		}

		function set_vfc_alarm_event (count){
			if(vfc_temp!=="" && vfc_temp!==undefined){
				$("#formId"+count+" #vfc").val(vfc_temp)
				
				if(alarm_conditions_temp!=="" && alarm_conditions_temp!==undefined){
					setAlarmConditions(vfc_temp,count)
					$("#formId"+count+" #alarmCondition").val(alarm_conditions_temp)

					if(event_severity_temp!=="" && event_severity_temp!==undefined){
						setEventSourceType(alarm_conditions_temp,count)
						$("#formId"+count+" #eventSeverity").val(event_severity_temp)
						if(event_type_source_temp!=="" && event_type_source_temp!==undefined){
							$("#formId"+count+" #eventSourceType").val(event_type_source_temp)
						}
					}
					if(event_type_source_temp!=="" && event_type_source_temp!==undefined){
						setEventSourceType(alarm_conditions_temp,count)
						$("#formId"+count+" #eventSourceType").val(event_type_source_temp)
						if(event_severity_temp!=="" && event_severity_temp!==undefined){
							$("#formId"+count+" #eventSeverity").val(event_severity_temp)
						}
					}
				}
			}
			
			
		}

		
		function noRepeats(form){
			var select={};
			for(var i=0;i<form.length;i++){
				if(select[form[i].name]===undefined)
					select[form[i].name]=[]
				select[form[i].name].push(form[i].value);
			}
			var arr=[]
			for(s in select){
				var f={}
				f.name=s
				f.value=select[s]
				arr.push(f)
			}
			return arr
		}
	
		$("#savePropsBtn").click(function(event) {
			var form=[]
			var properties=$(".saveProps").not("#formSpan .saveProps")
			var topicP=$("#topicPublish").serializeArray()
			form.push(topicP)
			var d={}
			d["serviceConfigurations"]=[];
			
			for(var i=0;i<properties.length;i++){
				var ser=$(properties[i]).serializeArray();
				var s=noRepeats(ser)
				

				d["serviceConfigurations"].push(s)
			}
			form.push(d)
			saveProperties(form)

			$("#close_button").click();
			
		})
		
		
		function add_one_more(){
			$("#nav_Tabs li").removeClass("active");
			var form=$($("#formSpan").children()[0]).clone()
			var count=0;
			if($(".formId").length>0){
				var greatest=0;
				var s=$(".formId");
				for(var i=0;i<s.length; i++){
					if(parseInt($(s[i]).attr("id").substring(6))>greatest){
						greatest=parseInt($(s[i]).attr("id").substring(6))
					}
				}
				count=greatest+1;
				$("#properties_tab").append(('<span class="formId" id="formId'+count+'"></span>'));
			}else{
				count++;
				$("#properties_tab").append('<span class="formId" id="formId1"></span>');
			}
			$("#add_one_more").parent().before(' <li class="active"><a id="go_properties_tab'+count+'">Condition</a><button id="tab_close'+count+'" type="button" class="close tab-close-popup" aria-hidden="true" style="margin-top: -30px;margin-right: 5px">&times;</button></li>');
			$("#formId"+count).append(form);
			$(".formId").not($("#formId"+count)).css("display","none")
			addCustListen(count)
			add_vfc_alarm_event_listener(count)
			return count;
		}

		function addCustListen(count) {
			$('#go_properties_tab' + count).click(function(event) {
				$("#nav_Tabs li").removeClass("active");
				$(this).parent().addClass("active");
				$("#formId"+count).css("display","")
				$(".formId").not($("#formId"+count)).css("display","none")

			})
			$('#tab_close'+count).click(function(event){
				if(document.getElementById("topicPublishes").disabled){
					return false;
				}
				$(this).parent().remove();
				$("#formId"+count).remove();
			})
		}

function setAlarmConditions(vfcID, count){
        var alarmCondition={}

        /*if($("#formId"+count+" #vfc").val()!=="")
                alarmCondition=vf_Services['shared']['byVfc'][vfcID]['alarmCondition']*/

        if($("#formId"+count+" #vfc").val()!==""){
        	if(vf_Services && vf_Services['shared'] && vf_Services['shared']['byVfc'] && vf_Services['shared']['byVfc'][vfcID]){
        		alarmCondition=vf_Services['shared']['byVfc'][vfcID]['alarmCondition'];	
        	}
        }

        $("#formId"+count+" #alarmCondition").empty();
        $("#formId"+count+" #alarmCondition").append("<option value=\"\"></opton>")
        if(alarmCondition && _.keys(alarmCondition).length>0){
		        for(key in alarmCondition){
		                var safestring = $('<div>').text(key).html();
		                $("#formId"+count+" #alarmCondition").append("<option value='"+safestring+"'>"+alarmCondition[key]+"</opton>")

		    }	
        }
        
}

function setEventSourceType(alarm, count){
        var eventSourceTypSeverity={}
        if($("#formId"+count+" #alarmCondition").val()!=="") {
        	if(vf_Services && vf_Services['shared'] && vf_Services['shared']['byAlarmCondition'] && vf_Services['shared']['byAlarmCondition'][alarm]){

                eventSourceTypSeverity=vf_Services['shared']['byAlarmCondition'][alarm]
        	}
        }

        $("#formId"+count+" #eventSourceType").val(eventSourceTypSeverity.eventSourceType);
        $("#formId"+count+" #eventSeverity").val(eventSourceTypSeverity.eventSeverity);

}

		function add_vfc_alarm_event_listener(count) {
					
			 $("#formId"+count+" #vfc").on('focus', function () {
			        // Store the current value on focus and on change
			        previous = this.value;
			    }).change(function(){
					
					setAlarmConditions($("#formId"+count+" #vfc").val(), count);
					$("#formId"+count+" #eventSourceType").val("");
					$("#formId"+count+" #eventSeverity").val("")

				});
			 
			 $("#formId"+count+" #alarmCondition").on('focus', function () {
			        // Store the current value on focus and on change
			        previous = this.value;
			    }).change(function(){
					
					
			    	setEventSourceType($("#formId"+count+" #alarmCondition").val().toString(),count);
				});
				};
	</script>
</div>