2 * Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
18 $('#msbTable tbody').on('click', 'td.details-control', function () {
\r
19 var tr = $(this).closest('tr');
\r
20 var row = table.row( tr );
\r
21 if ( row.child.isShown() ) {
\r
22 // This row is already open - close it
\r
24 tr.removeClass('shown');
\r
28 var nodes=row.data()[1].match(/\d+.\d+.\d+.\d+:\d+:(-)?\d+/g)
\r
30 row.child( routeUtil.formatDetail(nodes) ).show();
\r
31 tr.addClass('shown');
\r
35 $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
\r
36 //Get the name of the TAB has been activated
\r
37 var activeTab = $(e.target).text();
\r
38 if(this.id=="customTab" || this.id=="msbTab"){
\r
39 $("#serviceContent").hide();
\r
40 $("#upArrawDiv").hide();
\r
43 $("#serviceContent").show();
\r
44 $("#upArrawDiv").show();
\r
45 $('#msbSubPage').attr("src","");
\r
46 $(".stats_box .routeDiv").removeClass("active");
\r
47 vm.selectedRouteType="";
\r
48 vm.routeTargetTitle=$.i18n.prop("org_openo_msb_route_content_title");
\r
54 $("[data-toggle='tooltip']").tooltip();
\r
56 $('#metricsFullurl').on('show.bs.collapse', function () {
\r
57 $('#metricsUrlCollapse').removeClass('fa-plus').addClass('fa-minus');
\r
61 $('#metricsFullurl').on('hide.bs.collapse', function () {
\r
62 $('#metricsUrlCollapse').removeClass('fa-minus').addClass('fa-plus');
\r
65 $('#apiJsonFullurl').on('show.bs.collapse', function () {
\r
66 $('#apiJsonCollapse').removeClass('fa-plus').addClass('fa-minus');
\r
70 $('#apiJsonFullurl').on('hide.bs.collapse', function () {
\r
71 $('#apiJsonCollapse').removeClass('fa-minus').addClass('fa-plus');
\r
76 $(".form-tip").blur(function(){
\r
77 if($.trim($(this).val())==""){
\r
78 $(this).removeClass("form-input-focus");
\r
79 $(this).prev().removeClass("item-tip-focus");
\r
82 $(".form-tip").focus(function(){
\r
83 if(!$(this).hasClass("form-input-focus")){
\r
84 $(this).addClass("form-input-focus");
\r
85 $(this).prev().addClass("item-tip-focus");
\r
88 $(".item-tip").click(function(){
\r
89 $(this).next().focus();
\r
94 $("input[name='version']").blur(function(){
\r
95 $(this).val($(this).val().toLowerCase());
\r
96 routeUtil.changeTargetServiceUrl();
\r
100 $("input[name='url']").blur(function(){
\r
102 routeUtil.changeTargetServiceUrl();
\r
105 $("input[name='serviceName']").blur(function(){
\r
107 routeUtil.changeTargetServiceUrl();
\r
113 $("select[name='protocol']").change(function(){
\r
115 routeUtil.changeTargetServiceUrl();
\r
121 $("input[name='oriService']").blur(function(){
\r
122 var oriService=$.trim($(this).val());
\r
123 if(oriService==""){
\r
124 $("input[name='serviceName']").val("");
\r
125 $("input[name='version']").val("");
\r
126 $("input[name='server']").val("");
\r
127 $("input[name='url']").val("");
\r
133 var reg=/^(|http:\/\/)(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)(([0-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))):(\d{1,5})\/.*$/
\r
134 var reg_standard_match=/^(.*:\d{1,5})\/api\/(.*)\/(v.*)$/
\r
135 var reg_unstandard_match=/^(.*:\d{1,5})(\/.*)$/
\r
136 if(reg.test(oriService)){
\r
137 if(reg_standard_match.test(oriService)){
\r
139 var group = oriService.match(reg_standard_match);
\r
140 $("input[name='serviceName']").val(group[2]);
\r
141 $("input[name='server']").val(group[1].replace("http://",""));
\r
144 var version=group[3];
\r
145 var reg_endName_match=/^(.*?)\/.*$/
\r
146 if(reg_endName_match.test(version)){
\r
147 version = version.match(reg_endName_match)[1];
\r
149 $("input[name='version']").val(version);
\r
150 $("input[name='url']").val("/api/"+group[2]+"/"+version);
\r
152 if(!$("input[name='version']").hasClass("form-input-focus")){
\r
153 $("input[name='version']").addClass("form-input-focus");
\r
154 $("input[name='version']").prev().addClass("item-tip-focus");
\r
162 var group = oriService.match(reg_unstandard_match);
\r
163 var reg_endName_match=/^(.*?)\/$/
\r
165 if(url!="/" && reg_endName_match.test(url)){
\r
166 url = url.match(reg_endName_match)[1];
\r
170 $("input[name='serviceName']").val("");
\r
171 $("input[name='version']").val("");
\r
172 $("input[name='server']").val(group[1].replace("http://",""));
\r
173 $("input[name='url']").val(url);
\r
176 if(!$("input[name='server']").hasClass("form-input-focus")){
\r
177 $("input[name='server']").addClass("form-input-focus");
\r
178 $("input[name='server']").prev().addClass("item-tip-focus");
\r
186 $("input[name='iuioriService']").blur(function(){
\r
187 var oriService=$.trim($(this).val());
\r
188 if(oriService==""){
\r
189 $("input[name='iuiserviceName']").val("");
\r
190 $("input[name='iuiserver']").val("");
\r
191 $("input[name='iuiurl']").val("");
\r
197 var reg=/^(|http:\/\/)(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)(([0-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))):(\d{1,5})\/.*$/
\r
198 var reg_standard_match=/^(.*:\d{1,5})\/iui\/(.*|.*\/)$/
\r
199 var reg_unstandard_match=/^(.*:\d{1,5})(\/.*)$/
\r
200 if(reg.test(oriService)){
\r
201 if(reg_standard_match.test(oriService)){
\r
203 var group = oriService.match(reg_standard_match);
\r
206 $("input[name='iuiserver']").val(group[1].replace("http://",""));
\r
209 var serviceName=group[2];
\r
210 var reg_endName_match=/^(.*?)\/.*$/
\r
211 if(reg_endName_match.test(serviceName)){
\r
212 serviceName = serviceName.match(reg_endName_match)[1];
\r
214 $("input[name='iuiserviceName']").val(serviceName);
\r
215 $("input[name='iuiurl']").val("/iui/"+serviceName);
\r
220 var group = oriService.match(reg_unstandard_match);
\r
222 var reg_endName_match=/^(.*?)\/$/
\r
224 if(url!="/" && reg_endName_match.test(url)){
\r
225 url = url.match(reg_endName_match)[1];
\r
227 $("input[name='iuiserver']").val(group[1].replace("http://",""));
\r
228 $("input[name='iuiurl']").val(url);
\r
231 if(!$("input[name='iuiserver']").hasClass("form-input-focus")){
\r
232 $("input[name='iuiserver']").addClass("form-input-focus");
\r
233 $("input[name='iuiserver']").prev().addClass("item-tip-focus");
\r
240 $("input[name='customoriService']").blur(function(){
\r
241 var oriService=$.trim($(this).val());
\r
242 if(oriService==""){
\r
243 $("input[name='customserviceName']").val("");
\r
244 $("input[name='customserver']").val("");
\r
245 $("input[name='customurl']").val("");
\r
251 var reg=/^(|http:\/\/)(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)(([0-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))):(\d{1,5})\/.*$/
\r
253 var reg_unstandard_match=/^(.*:\d{1,5})(\/.*)$/
\r
254 if(reg.test(oriService)){
\r
257 var group = oriService.match(reg_unstandard_match);
\r
259 var reg_endName_match=/^(.*?)\/$/
\r
261 if(url!="/" && reg_endName_match.test(url)){
\r
262 url = url.match(reg_endName_match)[1];
\r
264 $("input[name='customserver']").val(group[1].replace("http://",""));
\r
265 $("input[name='customurl']").val(url);
\r
266 $("input[name='customserviceName']").val(url);
\r
269 if(!$("input[name='customserver']").hasClass("form-input-focus")){
\r
270 $("input[name='customserver']").addClass("form-input-focus");
\r
271 $("input[name='customserver']").prev().addClass("item-tip-focus");
\r
280 jQuery.validator.addMethod("ip", function(value, element) {
\r
281 return this.optional(element) || /^(([-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)(([0-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))):(\d{1,5})$/.test(value);
\r
282 }, $.i18n.prop('org_openo_msb_route_validator_ip_format'));
\r
286 jQuery.validator.addMethod("url_head", function(value, element) {
\r
287 return this.optional(element) || /^\/.+((?!\/).)$/i.test(value) || /^\/$/i.test(value);
\r
288 }, $.i18n.prop('org_openo_msb_route_validator_url_head_format'));
\r
291 jQuery.validator.addMethod("url_head_only", function(value, element) {
\r
292 return this.optional(element) || /^\/.*$/i.test(value);
\r
293 }, $.i18n.prop('org_openo_msb_route_validator_url_head_only_format'));
\r
295 jQuery.validator.addMethod("version", function(value, element) {
\r
296 return this.optional(element) || /^v\d+(\.\d+)?$/i.test(value);
\r
297 }, $.i18n.prop('org_openo_msb_route_form_version_tip'));
\r
299 jQuery.validator.addMethod("service_url", function(value, element) {
\r
300 return this.optional(element) || /^(|http:\/\/)(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)(([0-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))):(\d{1,5})\/.*$/.test(value);
\r
301 }, $.i18n.prop('org_openo_msb_route_validator_url_format'));
\r
303 jQuery.validator.addMethod("url_line", function(value, element) {
\r
304 return this.optional(element) || /^((?!\/).)*$/.test(value);
\r
305 }, $.i18n.prop('org_openo_msb_route_validator_url_line_format'));
\r
307 jQuery.validator.addMethod("content", function(value, element) {
\r
308 return this.optional(element) || /^([0-9a-zA-Z]|-|_)*$/i.test(value);
\r
309 }, $.i18n.prop('org_openo_msb_route_validator_content_format'));
\r
311 jQuery.validator.addMethod("custom_content", function(value, element) {
\r
312 return this.optional(element) || /^([0-9a-zA-Z]|-|_|\/)*$/i.test(value);
\r
313 }, $.i18n.prop('org_openo_msb_route_validator_content_format'));
\r
318 var form = $('#routeForm');
\r
319 var error = $('.alert-danger', form);
\r
320 var success = $('.alert-success', form);
\r
322 var iuiform = $('#iuirouteForm');
\r
323 var iuierror = $('.alert-danger', iuiform);
\r
324 var iuisuccess = $('.alert-success', iuiform);
\r
327 var customform = $('#customrouteForm');
\r
328 var customerror = $('.alert-danger', customform);
\r
329 var customsuccess = $('.alert-success', customform);
\r
331 var msbform = $('#msbForm');
\r
332 var msberror = $('.alert-danger', msbform);
\r
333 var msbsuccess = $('.alert-success', msbform);
\r
337 doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.
\r
338 errorElement: 'span', //default input error message container
\r
339 errorClass: 'help-block', // default input error message class
\r
340 focusInvalid: false, // do not focus the last invalid input
\r
373 required: "Please enter the service name"
\r
376 required: "Please enter the URL address"
\r
380 required:"Please enter the Host address"
\r
385 errorPlacement: function (error, element) { // render error placement for each input type
\r
386 error.insertAfter(element); // for other inputs, just perform default behavior
\r
389 invalidHandler: function (event, validator) { //display error alert on form submit
\r
392 //ZteFrameWork.scrollTo(error, -200);
\r
395 highlight: function (element) { // hightlight error inputs
\r
397 .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group
\r
400 unhighlight: function (element) { // revert the change done by hightlight
\r
402 .closest('.form-group').removeClass('has-error'); // set error class to the control group
\r
405 success: function (label) {
\r
407 .addClass('valid') // mark the current input as valid and display OK icon
\r
408 .closest('.form-group').removeClass('has-error'); // set success class to the control group
\r
410 submitHandler: function (form) {
\r
413 //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax
\r
419 doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.
\r
420 errorElement: 'span', //default input error message container
\r
421 errorClass: 'help-block', // default input error message class
\r
422 focusInvalid: false, // do not focus the last invalid input
\r
446 required: "Please enter the service name"
\r
449 required:"Please enter the URL address"
\r
453 required: "Please enter the Host address"
\r
457 errorPlacement: function (iuierror, element) { // render error placement for each input type
\r
458 iuierror.insertAfter(element); // for other inputs, just perform default behavior
\r
461 invalidHandler: function (event, validator) { //display error alert on form submit
\r
464 //ZteFrameWork.scrollTo(error, -200);
\r
467 highlight: function (element) { // hightlight error inputs
\r
469 .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group
\r
472 unhighlight: function (element) { // revert the change done by hightlight
\r
474 .closest('.form-group').removeClass('has-error'); // set error class to the control group
\r
477 success: function (label) {
\r
479 .addClass('valid') // mark the current input as valid and display OK icon
\r
480 .closest('.form-group').removeClass('has-error'); // set success class to the control group
\r
482 submitHandler: function (form) {
\r
485 //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax
\r
490 customform.validate({
\r
491 doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.
\r
492 errorElement: 'span', //default input error message container
\r
493 errorClass: 'help-block', // default input error message class
\r
494 focusInvalid: false, // do not focus the last invalid input
\r
496 /*customoriService:{
\r
500 customserviceName:{
\r
504 custom_content:true
\r
517 customserviceName:{
\r
518 required: "Please enter the service name"
\r
521 required: "Please enter the URL address"
\r
526 errorPlacement: function (customerror, element) { // render error placement for each input type
\r
527 customerror.insertAfter(element); // for other inputs, just perform default behavior
\r
530 invalidHandler: function (event, validator) { //display error alert on form submit
\r
531 customsuccess.hide();
\r
532 customerror.show();
\r
533 //ZteFrameWork.scrollTo(error, -200);
\r
536 highlight: function (element) { // hightlight error inputs
\r
538 .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group
\r
541 unhighlight: function (element) { // revert the change done by hightlight
\r
543 .closest('.form-group').removeClass('has-error'); // set error class to the control group
\r
546 success: function (label) {
\r
548 .addClass('valid') // mark the current input as valid and display OK icon
\r
549 .closest('.form-group').removeClass('has-error'); // set success class to the control group
\r
551 submitHandler: function (form) {
\r
552 customsuccess.show();
\r
553 customerror.hide();
\r
554 //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax
\r
561 doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.
\r
562 errorElement: 'span', //default input error message container
\r
563 errorClass: 'help-block', // default input error message class
\r
564 focusInvalid: false, // do not focus the last invalid input
\r
570 custom_content:true,
\r
598 required: "Please enter the service name"
\r
601 required: "Please select a service protocol"
\r
604 required: "Please select a service type"
\r
608 digits:"Please enter an integer",
\r
609 min: "Not a negative"
\r
613 errorPlacement: function (msberror, element) { // render error placement for each input type
\r
614 msberror.insertAfter(element); // for other inputs, just perform default behavior
\r
617 invalidHandler: function (event, validator) { //display error alert on form submit
\r
620 //ZteFrameWork.scrollTo(error, -200);
\r
623 highlight: function (element) { // hightlight error inputs
\r
625 .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group
\r
628 unhighlight: function (element) { // revert the change done by hightlight
\r
630 .closest('.form-group').removeClass('has-error'); // set error class to the control group
\r
633 success: function (label) {
\r
635 .addClass('valid') // mark the current input as valid and display OK icon
\r
636 .closest('.form-group').removeClass('has-error'); // set success class to the control group
\r
638 submitHandler: function (form) {
\r
641 //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax
\r