2 * Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
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 * Author: Zhaoxing Meng
17 * email: meng.zhaoxing1@zte.com.cn
21 $('#msbTable tbody').on('click', 'td.details-control', function () {
22 var tr = $(this).closest('tr');
23 var row = table.row( tr );
24 if ( row.child.isShown() ) {
25 // This row is already open - close it
27 tr.removeClass('shown');
31 var nodes=row.data()[1].match(/\d+.\d+.\d+.\d+:\d+:(-)?\d+/g)
33 row.child( routeUtil.formatDetail(nodes) ).show();
38 $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
39 //Get the name of the TAB has been activated
40 var activeTab = $(e.target).text();
41 if(this.id=="customTab" || this.id=="msbTab"){
42 $("#serviceContent").hide();
43 $("#upArrawDiv").hide();
46 $("#serviceContent").show();
47 $("#upArrawDiv").show();
48 $('#msbSubPage').attr("src","");
49 $(".stats_box .routeDiv").removeClass("active");
50 vm.selectedRouteType="";
51 vm.routeTargetTitle=$.i18n.prop("org_openo_msb_route_content_title");
57 $("[data-toggle='tooltip']").tooltip();
59 $('#metricsFullurl').on('show.bs.collapse', function () {
60 $('#metricsUrlCollapse').removeClass('fa-plus').addClass('fa-minus');
64 $('#metricsFullurl').on('hide.bs.collapse', function () {
65 $('#metricsUrlCollapse').removeClass('fa-minus').addClass('fa-plus');
68 $('#apiJsonFullurl').on('show.bs.collapse', function () {
69 $('#apiJsonCollapse').removeClass('fa-plus').addClass('fa-minus');
73 $('#apiJsonFullurl').on('hide.bs.collapse', function () {
74 $('#apiJsonCollapse').removeClass('fa-minus').addClass('fa-plus');
79 $(".form-tip").blur(function(){
80 if($.trim($(this).val())==""){
81 $(this).removeClass("form-input-focus");
82 $(this).prev().removeClass("item-tip-focus");
85 $(".form-tip").focus(function(){
86 if(!$(this).hasClass("form-input-focus")){
87 $(this).addClass("form-input-focus");
88 $(this).prev().addClass("item-tip-focus");
91 $(".item-tip").click(function(){
92 $(this).next().focus();
97 $("input[name='version']").blur(function(){
98 $(this).val($(this).val().toLowerCase());
99 routeUtil.changeTargetServiceUrl();
103 $("input[name='url']").blur(function(){
105 routeUtil.changeTargetServiceUrl();
108 $("input[name='serviceName']").blur(function(){
110 routeUtil.changeTargetServiceUrl();
116 $("select[name='protocol']").change(function(){
118 routeUtil.changeTargetServiceUrl();
124 $("input[name='oriService']").blur(function(){
125 var oriService=$.trim($(this).val());
127 $("input[name='serviceName']").val("");
128 $("input[name='version']").val("");
129 $("input[name='server']").val("");
130 $("input[name='url']").val("");
136 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})\/.*$/
137 var reg_standard_match=/^(.*:\d{1,5})\/api\/(.*)\/(v.*)$/
138 var reg_unstandard_match=/^(.*:\d{1,5})(\/.*)$/
139 if(reg.test(oriService)){
140 if(reg_standard_match.test(oriService)){
142 var group = oriService.match(reg_standard_match);
143 $("input[name='serviceName']").val(group[2]);
144 $("input[name='server']").val(group[1].replace("http://",""));
147 var version=group[3];
148 var reg_endName_match=/^(.*?)\/.*$/
149 if(reg_endName_match.test(version)){
150 version = version.match(reg_endName_match)[1];
152 $("input[name='version']").val(version);
153 $("input[name='url']").val("/api/"+group[2]+"/"+version);
155 if(!$("input[name='version']").hasClass("form-input-focus")){
156 $("input[name='version']").addClass("form-input-focus");
157 $("input[name='version']").prev().addClass("item-tip-focus");
165 var group = oriService.match(reg_unstandard_match);
166 var reg_endName_match=/^(.*?)\/$/
168 if(url!="/" && reg_endName_match.test(url)){
169 url = url.match(reg_endName_match)[1];
173 $("input[name='serviceName']").val("");
174 $("input[name='version']").val("");
175 $("input[name='server']").val(group[1].replace("http://",""));
176 $("input[name='url']").val(url);
179 if(!$("input[name='server']").hasClass("form-input-focus")){
180 $("input[name='server']").addClass("form-input-focus");
181 $("input[name='server']").prev().addClass("item-tip-focus");
189 $("input[name='iuioriService']").blur(function(){
190 var oriService=$.trim($(this).val());
192 $("input[name='iuiserviceName']").val("");
193 $("input[name='iuiserver']").val("");
194 $("input[name='iuiurl']").val("");
200 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})\/.*$/
201 var reg_standard_match=/^(.*:\d{1,5})\/iui\/(.*|.*\/)$/
202 var reg_unstandard_match=/^(.*:\d{1,5})(\/.*)$/
203 if(reg.test(oriService)){
204 if(reg_standard_match.test(oriService)){
206 var group = oriService.match(reg_standard_match);
209 $("input[name='iuiserver']").val(group[1].replace("http://",""));
212 var serviceName=group[2];
213 var reg_endName_match=/^(.*?)\/.*$/
214 if(reg_endName_match.test(serviceName)){
215 serviceName = serviceName.match(reg_endName_match)[1];
217 $("input[name='iuiserviceName']").val(serviceName);
218 $("input[name='iuiurl']").val("/iui/"+serviceName);
223 var group = oriService.match(reg_unstandard_match);
225 var reg_endName_match=/^(.*?)\/$/
227 if(url!="/" && reg_endName_match.test(url)){
228 url = url.match(reg_endName_match)[1];
230 $("input[name='iuiserver']").val(group[1].replace("http://",""));
231 $("input[name='iuiurl']").val(url);
234 if(!$("input[name='iuiserver']").hasClass("form-input-focus")){
235 $("input[name='iuiserver']").addClass("form-input-focus");
236 $("input[name='iuiserver']").prev().addClass("item-tip-focus");
243 $("input[name='customoriService']").blur(function(){
244 var oriService=$.trim($(this).val());
246 $("input[name='customserviceName']").val("");
247 $("input[name='customserver']").val("");
248 $("input[name='customurl']").val("");
254 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})\/.*$/
256 var reg_unstandard_match=/^(.*:\d{1,5})(\/.*)$/
257 if(reg.test(oriService)){
260 var group = oriService.match(reg_unstandard_match);
262 var reg_endName_match=/^(.*?)\/$/
264 if(url!="/" && reg_endName_match.test(url)){
265 url = url.match(reg_endName_match)[1];
267 $("input[name='customserver']").val(group[1].replace("http://",""));
268 $("input[name='customurl']").val(url);
269 $("input[name='customserviceName']").val(url);
272 if(!$("input[name='customserver']").hasClass("form-input-focus")){
273 $("input[name='customserver']").addClass("form-input-focus");
274 $("input[name='customserver']").prev().addClass("item-tip-focus");
283 jQuery.validator.addMethod("ip", function(value, element) {
284 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);
285 }, $.i18n.prop('org_openo_msb_route_validator_ip_format'));
289 jQuery.validator.addMethod("url_head", function(value, element) {
290 return this.optional(element) || /^\/.+((?!\/).)$/i.test(value) || /^\/$/i.test(value);
291 }, $.i18n.prop('org_openo_msb_route_validator_url_head_format'));
294 jQuery.validator.addMethod("url_head_only", function(value, element) {
295 return this.optional(element) || /^\/.*$/i.test(value);
296 }, $.i18n.prop('org_openo_msb_route_validator_url_head_only_format'));
298 jQuery.validator.addMethod("version", function(value, element) {
299 return this.optional(element) || /^v\d+(\.\d+)?$/i.test(value);
300 }, $.i18n.prop('org_openo_msb_route_form_version_tip'));
302 jQuery.validator.addMethod("service_url", function(value, element) {
303 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);
304 }, $.i18n.prop('org_openo_msb_route_validator_url_format'));
306 jQuery.validator.addMethod("url_line", function(value, element) {
307 return this.optional(element) || /^((?!\/).)*$/.test(value);
308 }, $.i18n.prop('org_openo_msb_route_validator_url_line_format'));
310 jQuery.validator.addMethod("content", function(value, element) {
311 return this.optional(element) || /^([0-9a-zA-Z]|-|_)*$/i.test(value);
312 }, $.i18n.prop('org_openo_msb_route_validator_content_format'));
314 jQuery.validator.addMethod("custom_content", function(value, element) {
315 return this.optional(element) || /^([0-9a-zA-Z]|-|_|\/)*$/i.test(value);
316 }, $.i18n.prop('org_openo_msb_route_validator_content_format'));
321 var form = $('#routeForm');
322 var error = $('.alert-danger', form);
323 var success = $('.alert-success', form);
325 var iuiform = $('#iuirouteForm');
326 var iuierror = $('.alert-danger', iuiform);
327 var iuisuccess = $('.alert-success', iuiform);
330 var customform = $('#customrouteForm');
331 var customerror = $('.alert-danger', customform);
332 var customsuccess = $('.alert-success', customform);
334 var msbform = $('#msbForm');
335 var msberror = $('.alert-danger', msbform);
336 var msbsuccess = $('.alert-success', msbform);
340 doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.
341 errorElement: 'span', //default input error message container
342 errorClass: 'help-block', // default input error message class
343 focusInvalid: false, // do not focus the last invalid input
376 required: "Please enter the service name"
379 required: "Please enter the URL address"
383 required:"Please enter the Host address"
388 errorPlacement: function (error, element) { // render error placement for each input type
389 error.insertAfter(element); // for other inputs, just perform default behavior
392 invalidHandler: function (event, validator) { //display error alert on form submit
395 //ZteFrameWork.scrollTo(error, -200);
398 highlight: function (element) { // hightlight error inputs
400 .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group
403 unhighlight: function (element) { // revert the change done by hightlight
405 .closest('.form-group').removeClass('has-error'); // set error class to the control group
408 success: function (label) {
410 .addClass('valid') // mark the current input as valid and display OK icon
411 .closest('.form-group').removeClass('has-error'); // set success class to the control group
413 submitHandler: function (form) {
416 //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax
422 doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.
423 errorElement: 'span', //default input error message container
424 errorClass: 'help-block', // default input error message class
425 focusInvalid: false, // do not focus the last invalid input
449 required: "Please enter the service name"
452 required:"Please enter the URL address"
456 required: "Please enter the Host address"
460 errorPlacement: function (iuierror, element) { // render error placement for each input type
461 iuierror.insertAfter(element); // for other inputs, just perform default behavior
464 invalidHandler: function (event, validator) { //display error alert on form submit
467 //ZteFrameWork.scrollTo(error, -200);
470 highlight: function (element) { // hightlight error inputs
472 .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group
475 unhighlight: function (element) { // revert the change done by hightlight
477 .closest('.form-group').removeClass('has-error'); // set error class to the control group
480 success: function (label) {
482 .addClass('valid') // mark the current input as valid and display OK icon
483 .closest('.form-group').removeClass('has-error'); // set success class to the control group
485 submitHandler: function (form) {
488 //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax
493 customform.validate({
494 doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.
495 errorElement: 'span', //default input error message container
496 errorClass: 'help-block', // default input error message class
497 focusInvalid: false, // do not focus the last invalid input
521 required: "Please enter the service name"
524 required: "Please enter the URL address"
529 errorPlacement: function (customerror, element) { // render error placement for each input type
530 customerror.insertAfter(element); // for other inputs, just perform default behavior
533 invalidHandler: function (event, validator) { //display error alert on form submit
534 customsuccess.hide();
536 //ZteFrameWork.scrollTo(error, -200);
539 highlight: function (element) { // hightlight error inputs
541 .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group
544 unhighlight: function (element) { // revert the change done by hightlight
546 .closest('.form-group').removeClass('has-error'); // set error class to the control group
549 success: function (label) {
551 .addClass('valid') // mark the current input as valid and display OK icon
552 .closest('.form-group').removeClass('has-error'); // set success class to the control group
554 submitHandler: function (form) {
555 customsuccess.show();
557 //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax
564 doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.
565 errorElement: 'span', //default input error message container
566 errorClass: 'help-block', // default input error message class
567 focusInvalid: false, // do not focus the last invalid input
601 required: "Please enter the service name"
604 required: "Please select a service protocol"
607 required: "Please select a service type"
611 digits:"Please enter an integer",
612 min: "Not a negative"
616 errorPlacement: function (msberror, element) { // render error placement for each input type
617 msberror.insertAfter(element); // for other inputs, just perform default behavior
620 invalidHandler: function (event, validator) { //display error alert on form submit
623 //ZteFrameWork.scrollTo(error, -200);
626 highlight: function (element) { // hightlight error inputs
628 .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group
631 unhighlight: function (element) { // revert the change done by hightlight
633 .closest('.form-group').removeClass('has-error'); // set error class to the control group
636 success: function (label) {
638 .addClass('valid') // mark the current input as valid and display OK icon
639 .closest('.form-group').removeClass('has-error'); // set success class to the control group
641 submitHandler: function (form) {
644 //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax