scripts.sonar-accessor-min.js Maven / Gradle / Ivy
AJS.$.namespace("AJS.sonar.accessor");AJS.sonar.accessor.JSON_FORMAT="json";AJS.sonar.accessor.FORCE_SERVLET_QUERY=false;AJS.sonar.accessor.PARSE_JSON_RESPONSES=false;AJS.sonar.accessor.generateServerResourceApiUrl=function(){return"/api/resources?format="+AJS.sonar.accessor.JSON_FORMAT};AJS.sonar.accessor.generateServerMetricsApiUrl=function(){return"/api/metrics?format="+AJS.sonar.accessor.JSON_FORMAT};AJS.sonar.accessor.generateApiUrl=function(a,c){var d="";if(c!==""){d="&metrics="+c}var b="";if(a!==""){b="&resource="+a}return AJS.sonar.accessor.generateServerResourceApiUrl()+d+b+"&includetrends=true&includealerts=true"};AJS.sonar.accessor.getAjaxOptions=function(e,d,c,a){var b={type:"GET",dataTpe:AJS.sonar.accessor.JSON_FORMAT};if(a!==undefined){b.error=a}if(e.secured||AJS.sonar.accessor.FORCE_SERVLET_QUERY){b.url=e.baseUrl+"/plugins/servlet/sonar/querySonar";b.data={host:e.host,apiUrl:d};if(e.username!==undefined&&e.password!==undefined){b.data.username=e.username;b.data.password=e.password}if(c!==undefined){if(AJS.sonar.accessor.PARSE_JSON_RESPONSES){b.success=function(f){c(JSON.parse(f))}}else{if(c!==undefined){b.success=c}}}}else{b.url=e.host+d;if(c!==undefined){b.success=c}}return b};AJS.sonar.accessor.parseSonarServer=function(a,c){var b=c.match(/(http|https):\/\/(.*):(.*)@(.*)/);if(b!==null){return{baseUrl:a,username:b[2],password:b[3],host:b[1]+"://"+b[4],secured:true}}else{return{baseUrl:a,host:c,secured:false}}};