diff --git a/solr/webapp/web/js/angular/controllers/analysis.js b/solr/webapp/web/js/angular/controllers/analysis.js index da29bb521fb..dddfc3fabb5 100644 --- a/solr/webapp/web/js/angular/controllers/analysis.js +++ b/solr/webapp/web/js/angular/controllers/analysis.js @@ -34,10 +34,10 @@ solrAdminApp.controller('AnalysisController', value: "fieldtype=" + type, label: type}); } + $scope.core = $routeParams.core; }); $scope.parseQueryString(); - // @todo - if URL param, set $scope.verbose; // @todo - set defaultSearchField either to context["analysis.fieldname"] or context["analysis.fieldtype"] }; @@ -131,6 +131,7 @@ solrAdminApp.controller('AnalysisController', $location.search("analysis.fieldtype", name); $location.search("analysis.fieldname", null); } + $location.search("verbose_output", $scope.verbose ? "1" : "0"); }; $scope.parseQueryString = function () { @@ -147,10 +148,16 @@ solrAdminApp.controller('AnalysisController', $scope.queryText = search["analysis.query"]; if (search["analysis.fieldname"]) { $scope.fieldOrType = "fieldname=" + search["analysis.fieldname"]; + $scope.schemaBrowserUrl = "field=" + search["analysis.fieldname"]; } else { $scope.fieldOrType = "fieldtype=" + search["analysis.fieldtype"]; + $scope.schemaBrowserUrl = "type=" + search["analysis.fieldtype"]; + } + if (search["verbose_output"] == undefined) { + $scope.verbose = true; + } else { + $scope.verbose = search["verbose_output"] == "1"; } - $scope.verbose = search["verbose_output"] == "1"; if ($scope.fieldOrType || $scope.indexText || $scope.queryText) { params.core = $routeParams.core; @@ -163,348 +170,30 @@ solrAdminApp.controller('AnalysisController', } }; + $scope.changeFieldOrType = function() { + var parts = $scope.fieldOrType.split("="); + if (parts[0]=='fieldname') { + $scope.schemaBrowserUrl = "field=" + parts[1]; + } else { + $scope.schemaBrowserUrl = "type=" + parts[1]; + } + }; - $scope.toggleVerbose = function() {$scope.verbose = !$scope.verbose}; + $scope.toggleVerbose = function() { + $scope.verbose = !$scope.verbose; + $location.search("verbose_output", $scope.verbose ? "1" : "0"); + }; $scope.refresh(); } ); /*************** -// #/:core/analysis -sammy.get -( - var analysis_element = $( '#analysis', content_element ); - var analysis_form = $( 'form', analysis_element ); - var analysis_result = $( '#analysis-result', analysis_element ); - analysis_result.hide(); - var verbose_link = $( '.verbose_output a', analysis_element ); - - var type_or_name = $( '#type_or_name', analysis_form ); - var schema_browser_element = $( '#tor_schema' ); - var schema_browser_path = app.core_menu.find( '.schema-browser a' ).attr( 'href' ); - var schema_browser_map = { 'fieldname' : 'field', 'fieldtype' : 'type' }; - - type_or_name - .die( 'change' ) - .live - ( - 'change', - function( event ) - { - var info = $( this ).val().split( '=' ); - - schema_browser_element - .attr( 'href', schema_browser_path + '?' + schema_browser_map[info[0]] + '=' + info[1] ); - } - ); - -======================== - - $( '.analysis-error .head a', analysis_element ) - .die( 'click' ) - .live - ( - 'click', - function( event ) - { - $( this ).parents( '.analysis-error' ) - .toggleClass( 'expanded' ); - } - ); - -======================== - - var check_empty_spacer = function() - { - var spacer_holder = $( 'td.part.data.spacer .holder', analysis_result ); - - if( 0 === spacer_holder.size() ) - { - return false; - } - - var verbose_output = analysis_result.hasClass( 'verbose_output' ); - - spacer_holder - .each - ( - function( index, element ) - { - element = $( element ); - - if( verbose_output ) - { - var cell = element.parent(); - element.height( cell.height() ); - } - else - { - element.removeAttr( 'style' ); - } - } - ); - } -======================== - - verbose_link - .die( 'toggle' ) - .live - ( - 'toggle', - function( event, state ) - { - $( this ).parent() - .toggleClass( 'active', state ); - - analysis_result - .toggleClass( 'verbose_output', state ); - - check_empty_spacer(); - } - ) - .die( 'click' ) - .live - ( - 'click', - function( event ) - { - $( this ).parent() - .toggleClass( 'active' ); - - analysis_form.trigger( 'submit' ); - } - ); - - -======================== - analysis_form - .die( 'submit' ) - .live - ( - 'submit', - function( event ) - { - var params = analysis_form.formToArray(); -/**** -var params = { -"analysis.fieldvalue": $scope.indexText, -"analysis.query": $scope.queryText, -"analysis.fieldname": $scope.field, -"verbose_output": $scope.verbose ? 1:0}; - - var params = $.param( compute_analysis_params() ) - .replace( /[\w\.]+=\+*(&)/g, '$1' ) // remove empty parameters - .replace( /(&)+/, '$1' ) // reduce multiple ampersands - .replace( /^&/, '' ) // remove leading ampersand - .replace( /\+/g, '%20' ); // replace plus-signs with encoded whitespaces - -$location.path($params); -Analysis.fields({}, function(data) { - - var url = core_basepath + '/analysis/field?wt=json&analysis.showmatch=true&' + context.path.split( '?' ).pop(); - url = url.replace( /&verbose_output=\d/, '' ); - - for( var name in response.analysis.field_names ) - { - build_analysis_table( 'name', name, response.analysis.field_names[name] ); - } - - for( var name in response.analysis.field_types ) - { - build_analysis_table( 'type', name, response.analysis.field_types[name] ); - } - - check_empty_spacer(); - }, -}, function(error) { +function(error) { if (error.status == 404) { - $scope.analysisHandlerMissing = true; -// @todo #analysis-handler-missing.show(); + $scope.isHandlerMissing = true; } else { $scope.analysisError = error.error.msg; - // @todo #analysis-error.show(); } - - var generate_class_name = function( type ) - { - var classes = [type]; - if( 'text' !== type ) - { - classes.push( 'verbose_output' ); - } - return classes.join( ' ' ); - } - - var build_analysis_table = function( field_or_name, name, analysis_data ) - { - for( var type in analysis_data ) // index or query - { - var type_length = analysis_data[type].length; // number of stages in pipeline - if( 0 !== type_length ) - { - var global_elements_count = 0; - if( 'string' === typeof analysis_data[type][1] ) - { - analysis_data[type][1] = [{ 'text': analysis_data[type][1] }] - } - - for( var i = 1; i < type_length; i += 2 ) - { - var tmp_type_length = analysis_data[type][i].length; - for( var j = 0; j < tmp_type_length; j++ ) - { - global_elements_count = Math.max - ( - ( analysis_data[type][i][j].positionHistory || [] )[0] || 1, - global_elements_count - ); - } - } - - for( component in components(analysis_data[type])) // why i+=2?? - { - var colspan = 1; - var elements = analysis_data[type][i+1]; - var elements_count = global_elements_count; - - if( !elements[0] || !elements[0].positionHistory ) - { - colspan = elements_count; - elements_count = 1; - } - - var legend = []; - for( var key in elements[0] ) - { - var key_parts = key.split( '#' ); - var used_key = key_parts.pop(); - var short_key = used_key; - - if( 1 === key_parts.length ) - { - used_key = '' + used_key + ''; - } - - if( 'positionHistory' === short_key || 'match' === short_key ) - { - continue; - } - - legend.push - ( - - ); - } - - - // analyzer - var analyzer_name = analysis_data[type][i].replace( /(\$1)+$/g, '' ); - - var analyzer_short = -1 !== analyzer_name.indexOf( '$' ) - ? analyzer_name.split( '$' )[1] - : analyzer_name.split( '.' ).pop(); - analyzer_short = analyzer_short.match( /[A-Z]/g ).join( '' ); - - - - // data - var cell_content = '
/analysis/field
Handler to be registered and active!