Modified: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/java-properties.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/java-properties.js?rev=1781731&r1=1781730&r2=1781731&view=diff ============================================================================== --- ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/java-properties.js (original) +++ ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/java-properties.js Sun Feb 5 11:09:59 2017 @@ -1,45 +1,45 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You 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. -*/ - -solrAdminApp.controller('JavaPropertiesController', - function($scope, Properties, Constants){ - $scope.resetMenu("java-props", Constants.IS_ROOT_PAGE); - $scope.refresh = function() { - Properties.get(function(data) { - var sysprops = data["system.properties"]; - var sep = sysprops["path.separator"] - var props = []; - for (var key in sysprops) { - var value = sysprops[key]; - var key = key.replace(/\./g, '.​'); - if (key.indexOf(".path")!=-1 || key.indexOf(".dirs")) { - var values = []; - var parts = value.split(sep); - for (var i in parts) { - values.push({pos:i, value:parts[i]}) - } - props.push({name: key, values: values}); - } else { - props.push({name: key, values: [value]}); - } - } - $scope.props = props; - }); - }; - - $scope.refresh(); - }); +/* + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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. +*/ + +solrAdminApp.controller('JavaPropertiesController', + function($scope, Properties, Constants){ + $scope.resetMenu("java-props", Constants.IS_ROOT_PAGE); + $scope.refresh = function() { + Properties.get(function(data) { + var sysprops = data["system.properties"]; + var sep = sysprops["path.separator"] + var props = []; + for (var key in sysprops) { + var value = sysprops[key]; + var key = key.replace(/\./g, '.​'); + if (key.indexOf(".path")!=-1 || key.indexOf(".dirs")) { + var values = []; + var parts = value.split(sep); + for (var i in parts) { + values.push({pos:i, value:parts[i]}) + } + props.push({name: key, values: values}); + } else { + props.push({name: key, values: [value]}); + } + } + $scope.props = props; + }); + }; + + $scope.refresh(); + }); Propchange: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/java-properties.js ------------------------------------------------------------------------------ svn:eol-style = native Modified: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/logging.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/logging.js?rev=1781731&r1=1781730&r2=1781731&view=diff ============================================================================== --- ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/logging.js (original) +++ ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/logging.js Sun Feb 5 11:09:59 2017 @@ -1,150 +1,150 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You 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. -*/ - -var format_time_content = function( time, timeZone ) { - var format_time_options = {}; - if (timeZone && timeZone!="Local") { - format_time_options.timeZone = timeZone; - } - return time.toLocaleString( undefined, format_time_options ); -} - -solrAdminApp.controller('LoggingController', - function($scope, $timeout, $cookies, Logging, Constants){ - $scope.resetMenu("logging", Constants.IS_ROOT_PAGE); - $scope.timezone = $cookies.logging_timezone || "Local"; - $scope.refresh = function() { - Logging.events(function(data) { - $scope.since = new Date(); - $scope.sinceDisplay = format_time_content($scope.since, "Local"); - var events = data.history.docs; - for (var i=0; i<events.length; i++) { - var event = events[i]; - var time = new Date(event.time); - event.local_time = format_time_content(time, "Local"); - event.utc_time = format_time_content(time, "UTC"); - event.loggerBase = event.logger.split( '.' ).pop(); - - if( !event.trace ) { - var lines = event.message.split( "\n" ); - if( lines.length > 1) { - event.trace = event.message; - event.message = lines[0]; - } - } - event.message = event.message.replace(/,/g, ',​'); - event.showTrace = false; - } - $scope.events = events; - $scope.watcher = data.watcher; - /* @todo sticky_mode - // state element is in viewport - sticky_mode = ( state.position().top <= $( window ).scrollTop() + $( window ).height() - ( $( 'body' ).height() - state.position().top ) ); - // initial request - if( 0 === since ) { - sticky_mode = true; - } - $scope.loggingEvents = events; - - if( sticky_mode ) - { - $( 'body' ) - .animate - ( - { scrollTop: state.position().top }, - 1000 - ); - } - */ - }); - $scope.timeout = $timeout($scope.refresh, 10000); - var onRouteChangeOff = $scope.$on('$routeChangeStart', function() { - $timeout.cancel($scope.timeout); - onRouteChangeOff(); - }); - }; - $scope.refresh(); - - $scope.toggleTimezone = function() { - $scope.timezone = ($scope.timezone=="Local") ? "UTC":"Local"; - $cookies.logging_timezone = $scope.timezone; - } - $scope.toggleRow = function(event) { - event.showTrace =! event.showTrace; - }; - } -) - -.controller('LoggingLevelController', - function($scope, Logging) { - $scope.resetMenu("logging-levels"); - - var packageOf = function(logger) { - var parts = logger.name.split("."); - return !parts.pop() ? "" : parts.join("."); - }; - - var shortNameOf = function(logger) {return logger.name.split(".").pop();} - - var makeTree = function(loggers, packag) { - var tree = []; - for (var i=0; i<loggers.length; i++) { - var logger = loggers[i]; - logger.packag = packageOf(logger); - logger.short = shortNameOf(logger); - if (logger.packag == packag) { - logger.children = makeTree(loggers, logger.name); - tree.push(logger); - } - } - return tree; - }; - - $scope.refresh = function() { - Logging.levels(function(data) { - $scope.logging = makeTree(data.loggers, ""); - $scope.watcher = data.watcher; - $scope.levels = []; - for (level in data.levels) { - $scope.levels.push({name:data.levels[level], pos:level}); - } - }); - }; - - $scope.toggleOptions = function(logger) { - if (logger.showOptions) { - logger.showOptions = false; - delete $scope.currentLogger; - } else { - if ($scope.currentLogger) { - $scope.currentLogger.showOptions = false; - } - logger.showOptions = true; - $scope.currentLogger = logger; - } - }; - - $scope.setLevel = function(logger, newLevel) { - var setString = logger.name + ":" + newLevel; - logger.showOptions = false; - Logging.setLevel({set: setString}, function(data) { - $scope.refresh(); - }); - }; - - $scope.refresh(); - }); +/* + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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. +*/ + +var format_time_content = function( time, timeZone ) { + var format_time_options = {}; + if (timeZone && timeZone!="Local") { + format_time_options.timeZone = timeZone; + } + return time.toLocaleString( undefined, format_time_options ); +} + +solrAdminApp.controller('LoggingController', + function($scope, $timeout, $cookies, Logging, Constants){ + $scope.resetMenu("logging", Constants.IS_ROOT_PAGE); + $scope.timezone = $cookies.logging_timezone || "Local"; + $scope.refresh = function() { + Logging.events(function(data) { + $scope.since = new Date(); + $scope.sinceDisplay = format_time_content($scope.since, "Local"); + var events = data.history.docs; + for (var i=0; i<events.length; i++) { + var event = events[i]; + var time = new Date(event.time); + event.local_time = format_time_content(time, "Local"); + event.utc_time = format_time_content(time, "UTC"); + event.loggerBase = event.logger.split( '.' ).pop(); + + if( !event.trace ) { + var lines = event.message.split( "\n" ); + if( lines.length > 1) { + event.trace = event.message; + event.message = lines[0]; + } + } + event.message = event.message.replace(/,/g, ',​'); + event.showTrace = false; + } + $scope.events = events; + $scope.watcher = data.watcher; + /* @todo sticky_mode + // state element is in viewport + sticky_mode = ( state.position().top <= $( window ).scrollTop() + $( window ).height() - ( $( 'body' ).height() - state.position().top ) ); + // initial request + if( 0 === since ) { + sticky_mode = true; + } + $scope.loggingEvents = events; + + if( sticky_mode ) + { + $( 'body' ) + .animate + ( + { scrollTop: state.position().top }, + 1000 + ); + } + */ + }); + $scope.timeout = $timeout($scope.refresh, 10000); + var onRouteChangeOff = $scope.$on('$routeChangeStart', function() { + $timeout.cancel($scope.timeout); + onRouteChangeOff(); + }); + }; + $scope.refresh(); + + $scope.toggleTimezone = function() { + $scope.timezone = ($scope.timezone=="Local") ? "UTC":"Local"; + $cookies.logging_timezone = $scope.timezone; + } + $scope.toggleRow = function(event) { + event.showTrace =! event.showTrace; + }; + } +) + +.controller('LoggingLevelController', + function($scope, Logging) { + $scope.resetMenu("logging-levels"); + + var packageOf = function(logger) { + var parts = logger.name.split("."); + return !parts.pop() ? "" : parts.join("."); + }; + + var shortNameOf = function(logger) {return logger.name.split(".").pop();} + + var makeTree = function(loggers, packag) { + var tree = []; + for (var i=0; i<loggers.length; i++) { + var logger = loggers[i]; + logger.packag = packageOf(logger); + logger.short = shortNameOf(logger); + if (logger.packag == packag) { + logger.children = makeTree(loggers, logger.name); + tree.push(logger); + } + } + return tree; + }; + + $scope.refresh = function() { + Logging.levels(function(data) { + $scope.logging = makeTree(data.loggers, ""); + $scope.watcher = data.watcher; + $scope.levels = []; + for (level in data.levels) { + $scope.levels.push({name:data.levels[level], pos:level}); + } + }); + }; + + $scope.toggleOptions = function(logger) { + if (logger.showOptions) { + logger.showOptions = false; + delete $scope.currentLogger; + } else { + if ($scope.currentLogger) { + $scope.currentLogger.showOptions = false; + } + logger.showOptions = true; + $scope.currentLogger = logger; + } + }; + + $scope.setLevel = function(logger, newLevel) { + var setString = logger.name + ":" + newLevel; + logger.showOptions = false; + Logging.setLevel({set: setString}, function(data) { + $scope.refresh(); + }); + }; + + $scope.refresh(); + }); Propchange: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/logging.js ------------------------------------------------------------------------------ svn:eol-style = native Modified: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/plugins.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/plugins.js?rev=1781731&r1=1781730&r2=1781731&view=diff ============================================================================== --- ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/plugins.js (original) +++ ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/plugins.js Sun Feb 5 11:09:59 2017 @@ -1,166 +1,166 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You 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. -*/ - -solrAdminApp.controller('PluginsController', - function($scope, $rootScope, $routeParams, $location, Mbeans, Constants) { - $scope.resetMenu("plugins", Constants.IS_CORE_PAGE); - - if ($routeParams.legacytype) { - // support legacy URLs. Angular cannot change #path without reloading controller - $location.path("/"+$routeParams.core+"/plugins"); - $location.search("type", $routeParams.legacytype); - return; - } - - $scope.refresh = function() { - Mbeans.stats({core: $routeParams.core}, function (data) { - var type = $location.search().type; - $scope.types = getPluginTypes(data, type); - $scope.type = getSelectedType($scope.types, type); - - if ($scope.type && $routeParams.entry) { - $scope.plugins = $routeParams.entry.split(","); - openPlugins($scope.type, $scope.plugins); - } else { - $scope.plugins = []; - } - }); - }; - - $scope.selectPluginType = function(type) { - $location.search({entry:null, type: type.lower}); - $scope.type = type; - }; - - $scope.selectPlugin = function(plugin) { - plugin.open = !plugin.open; - - if (plugin.open) { - $scope.plugins.push(plugin.name); - } else { - $scope.plugins.splice($scope.plugins.indexOf(plugin.name), 1); - } - - if ($scope.plugins.length==0) { - $location.search("entry", null); - } else { - $location.search("entry", $scope.plugins.join(',')); - } - } - - $scope.startRecording = function() { - $scope.isRecording = true; - Mbeans.reference({core: $routeParams.core}, function(data) { - $scope.reference = data.reference; - console.log($scope.reference); - }) - } - - $scope.stopRecording = function() { - $scope.isRecording = false; - console.log($scope.reference); - Mbeans.delta({core: $routeParams.core}, $scope.reference, function(data) { - parseDelta($scope.types, data); - }); - } - - $scope.refresh(); - }); - -var getPluginTypes = function(data, selected) { - var keys = []; - var mbeans = data["solr-mbeans"]; - for (var i=0; i<mbeans.length; i+=2) { - var key = mbeans[i]; - var lower = key.toLowerCase(); - var plugins = getPlugins(mbeans[i+1]); - keys.push({name: key, - selected: lower == selected, - changes: 0, - lower: lower, - plugins: plugins - }); - } - keys.sort(function(a,b) {return a.name > b.name}); - return keys; -}; - -var getPlugins = function(data) { - var plugins = []; - for (var key in data) { - var pluginProperties = data[key]; - var stats = pluginProperties.stats; - delete pluginProperties.stats; - for (var stat in stats) { - // add breaking space after a bracket or @ to handle wrap long lines: - stats[stat] = new String(stats[stat]).replace( /([\(@])/g, '$1​'); - } - plugin = {name: key, changed: false, stats: stats, open:false}; - plugin.properties = pluginProperties; - plugins.push(plugin); - } - plugins.sort(function(a,b) {return a.name > b.name}); - return plugins; -}; - -var getSelectedType = function(types, selected) { - if (selected) { - for (var i in types) { - if (types[i].lower == selected) { - return types[i]; - } - } - } -}; - -var parseDelta = function(types, data) { - - var getByName = function(list, name) { - for (var i in list) { - if (list[i].name == name) return list[i]; - } - } - - var mbeans = data["solr-mbeans"] - for (var i=0; i<mbeans.length; i+=2) { - var typeName = mbeans[i]; - var type = getByName(types, typeName); - var plugins = mbeans[i+1]; - for (var key in plugins) { - var changedPlugin = plugins[key]; - if (changedPlugin._changed_) { - var plugin = getByName(type.plugins, key); - var stats = changedPlugin.stats; - delete changedPlugin.stats; - plugin.properties = changedPlugin; - for (var stat in stats) { - // add breaking space after a bracket or @ to handle wrap long lines: - plugin.stats[stat] = new String(stats[stat]).replace( /([\(@])/g, '$1​'); - } - plugin.changed = true; - type.changes++; - } - } - } -}; - -var openPlugins = function(type, selected) { - for (var i in type.plugins) { - var plugin = type.plugins[i]; - plugin.open = selected.indexOf(plugin.name)>=0; - } -} +/* + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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. +*/ + +solrAdminApp.controller('PluginsController', + function($scope, $rootScope, $routeParams, $location, Mbeans, Constants) { + $scope.resetMenu("plugins", Constants.IS_CORE_PAGE); + + if ($routeParams.legacytype) { + // support legacy URLs. Angular cannot change #path without reloading controller + $location.path("/"+$routeParams.core+"/plugins"); + $location.search("type", $routeParams.legacytype); + return; + } + + $scope.refresh = function() { + Mbeans.stats({core: $routeParams.core}, function (data) { + var type = $location.search().type; + $scope.types = getPluginTypes(data, type); + $scope.type = getSelectedType($scope.types, type); + + if ($scope.type && $routeParams.entry) { + $scope.plugins = $routeParams.entry.split(","); + openPlugins($scope.type, $scope.plugins); + } else { + $scope.plugins = []; + } + }); + }; + + $scope.selectPluginType = function(type) { + $location.search({entry:null, type: type.lower}); + $scope.type = type; + }; + + $scope.selectPlugin = function(plugin) { + plugin.open = !plugin.open; + + if (plugin.open) { + $scope.plugins.push(plugin.name); + } else { + $scope.plugins.splice($scope.plugins.indexOf(plugin.name), 1); + } + + if ($scope.plugins.length==0) { + $location.search("entry", null); + } else { + $location.search("entry", $scope.plugins.join(',')); + } + } + + $scope.startRecording = function() { + $scope.isRecording = true; + Mbeans.reference({core: $routeParams.core}, function(data) { + $scope.reference = data.reference; + console.log($scope.reference); + }) + } + + $scope.stopRecording = function() { + $scope.isRecording = false; + console.log($scope.reference); + Mbeans.delta({core: $routeParams.core}, $scope.reference, function(data) { + parseDelta($scope.types, data); + }); + } + + $scope.refresh(); + }); + +var getPluginTypes = function(data, selected) { + var keys = []; + var mbeans = data["solr-mbeans"]; + for (var i=0; i<mbeans.length; i+=2) { + var key = mbeans[i]; + var lower = key.toLowerCase(); + var plugins = getPlugins(mbeans[i+1]); + keys.push({name: key, + selected: lower == selected, + changes: 0, + lower: lower, + plugins: plugins + }); + } + keys.sort(function(a,b) {return a.name > b.name}); + return keys; +}; + +var getPlugins = function(data) { + var plugins = []; + for (var key in data) { + var pluginProperties = data[key]; + var stats = pluginProperties.stats; + delete pluginProperties.stats; + for (var stat in stats) { + // add breaking space after a bracket or @ to handle wrap long lines: + stats[stat] = new String(stats[stat]).replace( /([\(@])/g, '$1​'); + } + plugin = {name: key, changed: false, stats: stats, open:false}; + plugin.properties = pluginProperties; + plugins.push(plugin); + } + plugins.sort(function(a,b) {return a.name > b.name}); + return plugins; +}; + +var getSelectedType = function(types, selected) { + if (selected) { + for (var i in types) { + if (types[i].lower == selected) { + return types[i]; + } + } + } +}; + +var parseDelta = function(types, data) { + + var getByName = function(list, name) { + for (var i in list) { + if (list[i].name == name) return list[i]; + } + } + + var mbeans = data["solr-mbeans"] + for (var i=0; i<mbeans.length; i+=2) { + var typeName = mbeans[i]; + var type = getByName(types, typeName); + var plugins = mbeans[i+1]; + for (var key in plugins) { + var changedPlugin = plugins[key]; + if (changedPlugin._changed_) { + var plugin = getByName(type.plugins, key); + var stats = changedPlugin.stats; + delete changedPlugin.stats; + plugin.properties = changedPlugin; + for (var stat in stats) { + // add breaking space after a bracket or @ to handle wrap long lines: + plugin.stats[stat] = new String(stats[stat]).replace( /([\(@])/g, '$1​'); + } + plugin.changed = true; + type.changes++; + } + } + } +}; + +var openPlugins = function(type, selected) { + for (var i in type.plugins) { + var plugin = type.plugins[i]; + plugin.open = selected.indexOf(plugin.name)>=0; + } +} Propchange: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/plugins.js ------------------------------------------------------------------------------ svn:eol-style = native Modified: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/query.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/query.js?rev=1781731&r1=1781730&r2=1781731&view=diff ============================================================================== --- ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/query.js (original) +++ ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/query.js Sun Feb 5 11:09:59 2017 @@ -1,114 +1,114 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You 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. -*/ - -solrAdminApp.controller('QueryController', - function($scope, $routeParams, $location, Query, Constants){ - $scope.resetMenu("query", Constants.IS_COLLECTION_PAGE); - - // @todo read URL parameters into scope - $scope.query = {wt: 'json', q:'*:*', indent:'on'}; - $scope.filters = [{fq:""}]; - $scope.dismax = {defType: "dismax"}; - $scope.edismax = {defType: "edismax", stopwords: true, lowercaseOperators: true}; - $scope.hl = {hl:"on"}; - $scope.facet = {facet: "on"}; - $scope.spatial = {}; - $scope.spellcheck = {spellcheck:"on"}; - $scope.qt = "/select"; - - $scope.doQuery = function() { - var params = {}; - - var set = function(key, value) { - if (params[key]) { - params[key].push(value); - } else { - params[key] = [value]; - } - } - var copy = function(params, query) { - for (var key in query) { - terms = query[key]; - if (terms.length > 0 && key[0]!="$") { - set(key, terms); - } - } - }; - - copy(params, $scope.query); - - if ($scope.isDismax) copy(params, $scope.dismax); - if ($scope.isEdismax) copy(params, $scope.edismax); - if ($scope.isHighlight) copy(params, $scope.hl); - if ($scope.isFacet) copy(params, $scope.facet); - if ($scope.isSpatial) copy(params, $scope.spatial); - if ($scope.isSpellcheck) copy(params, $scope.spellcheck); - - if ($scope.rawParams) { - var rawParams = $scope.rawParams.split(/[&\n]/); - for (var i in rawParams) { - var param = rawParams[i]; - var equalPos = param.indexOf("="); - if (equalPos > -1) { - set(param.substring(0, equalPos), param.substring(equalPos+1)); - } else { - set(param, ""); // Use empty value for params without "=" - } - } - } - - var qt = $scope.qt ? $scope.qt : "/select"; - - for (var filter in $scope.filters) { - copy(params, $scope.filters[filter]); - } - - params.core = $routeParams.core; - if (qt[0] == '/') { - params.handler = qt.substring(1); - } else { // Support legacy style handleSelect=true configs - params.handler = "select"; - set("qt", qt); - } - var url = Query.url(params); - Query.query(params, function(data) { - $scope.lang = $scope.query.wt; - $scope.response = data; - $scope.url = $location.protocol() + "://" + - $location.host() + ":" + - $location.port() + url; - }); - }; - - if ($location.search().q) { - $scope.query.q = $location.search()["q"]; - $scope.doQuery(); - } - - $scope.removeFilter = function(index) { - if ($scope.filters.length === 1) { - $scope.filters = [{fq: ""}]; - } else { - $scope.filters.splice(index, 1); - } - }; - - $scope.addFilter = function(index) { - $scope.filters.splice(index+1, 0, {fq:""}); - }; - } -); +/* + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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. +*/ + +solrAdminApp.controller('QueryController', + function($scope, $routeParams, $location, Query, Constants){ + $scope.resetMenu("query", Constants.IS_COLLECTION_PAGE); + + // @todo read URL parameters into scope + $scope.query = {wt: 'json', q:'*:*', indent:'on'}; + $scope.filters = [{fq:""}]; + $scope.dismax = {defType: "dismax"}; + $scope.edismax = {defType: "edismax", stopwords: true, lowercaseOperators: true}; + $scope.hl = {hl:"on"}; + $scope.facet = {facet: "on"}; + $scope.spatial = {}; + $scope.spellcheck = {spellcheck:"on"}; + $scope.qt = "/select"; + + $scope.doQuery = function() { + var params = {}; + + var set = function(key, value) { + if (params[key]) { + params[key].push(value); + } else { + params[key] = [value]; + } + } + var copy = function(params, query) { + for (var key in query) { + terms = query[key]; + if (terms.length > 0 && key[0]!="$") { + set(key, terms); + } + } + }; + + copy(params, $scope.query); + + if ($scope.isDismax) copy(params, $scope.dismax); + if ($scope.isEdismax) copy(params, $scope.edismax); + if ($scope.isHighlight) copy(params, $scope.hl); + if ($scope.isFacet) copy(params, $scope.facet); + if ($scope.isSpatial) copy(params, $scope.spatial); + if ($scope.isSpellcheck) copy(params, $scope.spellcheck); + + if ($scope.rawParams) { + var rawParams = $scope.rawParams.split(/[&\n]/); + for (var i in rawParams) { + var param = rawParams[i]; + var equalPos = param.indexOf("="); + if (equalPos > -1) { + set(param.substring(0, equalPos), param.substring(equalPos+1)); + } else { + set(param, ""); // Use empty value for params without "=" + } + } + } + + var qt = $scope.qt ? $scope.qt : "/select"; + + for (var filter in $scope.filters) { + copy(params, $scope.filters[filter]); + } + + params.core = $routeParams.core; + if (qt[0] == '/') { + params.handler = qt.substring(1); + } else { // Support legacy style handleSelect=true configs + params.handler = "select"; + set("qt", qt); + } + var url = Query.url(params); + Query.query(params, function(data) { + $scope.lang = $scope.query.wt; + $scope.response = data; + $scope.url = $location.protocol() + "://" + + $location.host() + ":" + + $location.port() + url; + }); + }; + + if ($location.search().q) { + $scope.query.q = $location.search()["q"]; + $scope.doQuery(); + } + + $scope.removeFilter = function(index) { + if ($scope.filters.length === 1) { + $scope.filters = [{fq: ""}]; + } else { + $scope.filters.splice(index, 1); + } + }; + + $scope.addFilter = function(index) { + $scope.filters.splice(index+1, 0, {fq:""}); + }; + } +); Propchange: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/query.js ------------------------------------------------------------------------------ svn:eol-style = native Modified: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/replication.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/replication.js?rev=1781731&r1=1781730&r2=1781731&view=diff ============================================================================== --- ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/replication.js (original) +++ ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/replication.js Sun Feb 5 11:09:59 2017 @@ -1,235 +1,235 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You 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. -*/ - -solrAdminApp.controller('ReplicationController', - function($scope, $rootScope, $routeParams, $interval, $timeout, Replication, Constants) { - $scope.resetMenu("replication", Constants.IS_CORE_PAGE); - - $scope.iterationCount = 1; - - $scope.refresh = function() { - Replication.details({core:$routeParams.core}, function(response) { - var timeout; - var interval; - if ($scope.interval) $interval.cancel($scope.interval); - $scope.isSlave = (response.details.isSlave === 'true'); - if ($scope.isSlave) { - $scope.progress = getProgressDetails(response.details.slave); - $scope.iterations = getIterations(response.details.slave); - $scope.versions = getSlaveVersions(response.details); - $scope.settings = getSlaveSettings(response.details); - if ($scope.settings.isReplicating) { - timeout = $timeout($scope.refresh, 1000); - } else if(!$scope.settings.isPollingDisabled && $scope.settings.pollInterval) { - interval = $scope.interval = $interval(function() { - $scope.settings.tick--; - }, 1000, $scope.settings.tick); - timeout = $timeout($scope.refresh, 1000*(1+$scope.settings.tick)); - } - } else { - $scope.versions = getMasterVersions(response.details); - } - $scope.master = getMasterSettings(response.details, $scope.isSlave); - - var onRouteChangeOff = $scope.$on('$routeChangeStart', function() { - if (interval) $interval.cancel(interval); - if (timeout) $timeout.cancel(timeout); - onRouteChangeOff(); - }); - }); - - }; - - $scope.execute = function(command) { - Replication.command({core:$routeParams.core, command:command}, function(data){$scope.refresh()}); - } - - $scope.showIterations = function() { $scope.iterationCount = 100000}; // limitTo should accept undefined, but doesn't work. - $scope.hideIterations = function() { $scope.iterationCount = 1}; - - $scope.refresh(); - }); - -var getProgressDetails = function(progress) { - - progress.timeRemaining = parseSeconds(progress.timeRemaining); - progress.totalPercent = parseInt(progress.totalPercent); - if (progress.totalPercent === 0) { - progress.totalPercentWidth = "1px"; - } else { - progress.totalPercentWidth = progress.totalPercent + "%"; - } - progress.currentFileSizePercent = parseInt(progress.currentFileSizePercent); - - if (!progress.indexReplicatedAtList) { - progress.indexReplicatedAtList = []; - } - - if (!progress.replicationFailedAtList) { - progress.replicationFailedAtList = []; - } - return progress; -}; - -var getIterations = function(slave) { - - var iterations = []; - - var find = function(list, date) { - return list.filter(function(e) {return e.date == date}); - }; - - for (var i in slave.indexReplicatedAtList) { - var date = slave.indexReplicatedAtList[i]; - var iteration = {date:date, status:"replicated", latest: false}; - if (date == slave.indexReplicatedAt) { - iteration.latest = true; - } - iterations.push(iteration); - } - - for (var i in slave.replicationFailedAtList) { - var failedDate = slave.replicationFailedAtList[i]; - var matchingIterations = find(iterations, failedDate); - if (matchingIterations) { - iteration = matchingIterations[0]; - } else { - iteration = {date: failedDate, latest:false}; - iterations.push(iteration); - } - iteration.status = "failed"; - if (failedDate == slave.replicationFailedAt) { - iteration.latest = true; - } - } - iterations.sort(function(a,b){ return a.date> b.date;}).reverse(); - return iterations; -}; - -var getMasterVersions = function(data) { - versions = {masterSearch:{}, master:{}}; - - versions.masterSearch.version = data.indexVersion; - versions.masterSearch.generation = data.generation; - versions.masterSearch.size = data.indexSize; - - versions.master.version = data.master.replicableVersion || '-'; - versions.master.generation = data.master.replicableGeneration || '-'; - versions.master.size = '-'; - - return versions; -}; - -var getSlaveVersions = function(data) { - versions = {masterSearch: {}, master: {}, slave: {}}; - - versions.slave.version = data.indexVersion; - versions.slave.generation = data.generation; - versions.slave.size = data.indexSize; - - versions.master.version = data.slave.masterDetails.replicableVersion || '-'; - versions.master.generation = data.slave.masterDetails.replicableGeneration || '-'; - versions.master.size = '-'; - - versions.masterSearch.version = data.slave.masterDetails.indexVersion; - versions.masterSearch.generation = data.slave.masterDetails.generation; - versions.masterSearch.size = data.slave.masterDetails.indexSize; - - versions.changedVersion = data.indexVersion !== data.slave.masterDetails.indexVersion; - versions.changedGeneration = data.generation !== data.slave.masterDetails.generation; - - return versions; -}; - -var parseDateToEpoch = function(date) { - // ["Sat Mar 03 11:00:00 CET 2012", "Sat", "Mar", "03", "11:00:00", "CET", "2012"] - var parts = date.match( /^(\w+)\s+(\w+)\s+(\d+)\s+(\d+\:\d+\:\d+)\s+(\w+)\s+(\d+)$/ ); - - // "Sat Mar 03 2012 10:37:33" - var d = new Date( parts[1] + ' ' + parts[2] + ' ' + parts[3] + ' ' + parts[6] + ' ' + parts[4] ); - return d.getTime(); -} - -var parseSeconds = function(time) { - var seconds = 0; - var arr = new String(time || '').split('.'); - var parts = arr[0].split(':').reverse(); - - for (var i = 0; i < parts.length; i++) { - seconds += ( parseInt(parts[i], 10) || 0 ) * Math.pow(60, i); - } - - if (arr[1] && 5 <= parseInt(arr[1][0], 10)) { - seconds++; // treat more or equal than .5 as additional second - - } - - return seconds; -} - -var getSlaveSettings = function(data) { - var settings = {}; - settings.masterUrl = data.slave.masterUrl; - settings.isPollingDisabled = data.slave.isPollingDisabled == 'true'; - settings.pollInterval = data.slave.pollInterval; - settings.isReplicating = data.slave.isReplicating == 'true'; - settings.nextExecutionAt = data.slave.nextExecutionAt; - - if(settings.isReplicating) { - settings.isApprox = true; - settings.tick = parseSeconds(settings.pollInterval); - } else if (!settings.isPollingDisabled && settings.pollInterval) { - if( settings.nextExecutionAt ) { - settings.nextExecutionAtEpoch = parseDateToEpoch(settings.nextExecutionAt); - settings.currentTime = parseDateToEpoch(data.slave.currentDate); - - if( settings.nextExecutionAtEpoch > settings.currentTime) { - settings.isApprox = false; - settings.tick = ( settings.nextExecutionAtEpoch - settings.currentTime) / 1000; - } - } - } - return settings; -}; - -var getMasterSettings = function(details, isSlave) { - var master = {}; - var masterData = isSlave ? details.slave.masterDetails.master : details.master; - master.replicationEnabled = masterData.replicationEnabled == "true"; - master.replicateAfter = masterData.replicateAfter.join(", "); - - if (masterData.confFiles) { - master.files = []; - var confFiles = masterData.confFiles.split(','); - for (var i=0; i<confFiles.length; i++) { - var file = confFiles[i]; - var short = file; - var title = file; - if (file.indexOf(":")>=0) { - title = file.replace(':', ' » '); - var parts = file.split(':'); - if (isSlave) { - short = parts[1]; - } else { - short = parts[0]; - } - } - master.files.push({title:title, name:short}); - } - } - return master; -} +/* + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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. +*/ + +solrAdminApp.controller('ReplicationController', + function($scope, $rootScope, $routeParams, $interval, $timeout, Replication, Constants) { + $scope.resetMenu("replication", Constants.IS_CORE_PAGE); + + $scope.iterationCount = 1; + + $scope.refresh = function() { + Replication.details({core:$routeParams.core}, function(response) { + var timeout; + var interval; + if ($scope.interval) $interval.cancel($scope.interval); + $scope.isSlave = (response.details.isSlave === 'true'); + if ($scope.isSlave) { + $scope.progress = getProgressDetails(response.details.slave); + $scope.iterations = getIterations(response.details.slave); + $scope.versions = getSlaveVersions(response.details); + $scope.settings = getSlaveSettings(response.details); + if ($scope.settings.isReplicating) { + timeout = $timeout($scope.refresh, 1000); + } else if(!$scope.settings.isPollingDisabled && $scope.settings.pollInterval) { + interval = $scope.interval = $interval(function() { + $scope.settings.tick--; + }, 1000, $scope.settings.tick); + timeout = $timeout($scope.refresh, 1000*(1+$scope.settings.tick)); + } + } else { + $scope.versions = getMasterVersions(response.details); + } + $scope.master = getMasterSettings(response.details, $scope.isSlave); + + var onRouteChangeOff = $scope.$on('$routeChangeStart', function() { + if (interval) $interval.cancel(interval); + if (timeout) $timeout.cancel(timeout); + onRouteChangeOff(); + }); + }); + + }; + + $scope.execute = function(command) { + Replication.command({core:$routeParams.core, command:command}, function(data){$scope.refresh()}); + } + + $scope.showIterations = function() { $scope.iterationCount = 100000}; // limitTo should accept undefined, but doesn't work. + $scope.hideIterations = function() { $scope.iterationCount = 1}; + + $scope.refresh(); + }); + +var getProgressDetails = function(progress) { + + progress.timeRemaining = parseSeconds(progress.timeRemaining); + progress.totalPercent = parseInt(progress.totalPercent); + if (progress.totalPercent === 0) { + progress.totalPercentWidth = "1px"; + } else { + progress.totalPercentWidth = progress.totalPercent + "%"; + } + progress.currentFileSizePercent = parseInt(progress.currentFileSizePercent); + + if (!progress.indexReplicatedAtList) { + progress.indexReplicatedAtList = []; + } + + if (!progress.replicationFailedAtList) { + progress.replicationFailedAtList = []; + } + return progress; +}; + +var getIterations = function(slave) { + + var iterations = []; + + var find = function(list, date) { + return list.filter(function(e) {return e.date == date}); + }; + + for (var i in slave.indexReplicatedAtList) { + var date = slave.indexReplicatedAtList[i]; + var iteration = {date:date, status:"replicated", latest: false}; + if (date == slave.indexReplicatedAt) { + iteration.latest = true; + } + iterations.push(iteration); + } + + for (var i in slave.replicationFailedAtList) { + var failedDate = slave.replicationFailedAtList[i]; + var matchingIterations = find(iterations, failedDate); + if (matchingIterations) { + iteration = matchingIterations[0]; + } else { + iteration = {date: failedDate, latest:false}; + iterations.push(iteration); + } + iteration.status = "failed"; + if (failedDate == slave.replicationFailedAt) { + iteration.latest = true; + } + } + iterations.sort(function(a,b){ return a.date> b.date;}).reverse(); + return iterations; +}; + +var getMasterVersions = function(data) { + versions = {masterSearch:{}, master:{}}; + + versions.masterSearch.version = data.indexVersion; + versions.masterSearch.generation = data.generation; + versions.masterSearch.size = data.indexSize; + + versions.master.version = data.master.replicableVersion || '-'; + versions.master.generation = data.master.replicableGeneration || '-'; + versions.master.size = '-'; + + return versions; +}; + +var getSlaveVersions = function(data) { + versions = {masterSearch: {}, master: {}, slave: {}}; + + versions.slave.version = data.indexVersion; + versions.slave.generation = data.generation; + versions.slave.size = data.indexSize; + + versions.master.version = data.slave.masterDetails.replicableVersion || '-'; + versions.master.generation = data.slave.masterDetails.replicableGeneration || '-'; + versions.master.size = '-'; + + versions.masterSearch.version = data.slave.masterDetails.indexVersion; + versions.masterSearch.generation = data.slave.masterDetails.generation; + versions.masterSearch.size = data.slave.masterDetails.indexSize; + + versions.changedVersion = data.indexVersion !== data.slave.masterDetails.indexVersion; + versions.changedGeneration = data.generation !== data.slave.masterDetails.generation; + + return versions; +}; + +var parseDateToEpoch = function(date) { + // ["Sat Mar 03 11:00:00 CET 2012", "Sat", "Mar", "03", "11:00:00", "CET", "2012"] + var parts = date.match( /^(\w+)\s+(\w+)\s+(\d+)\s+(\d+\:\d+\:\d+)\s+(\w+)\s+(\d+)$/ ); + + // "Sat Mar 03 2012 10:37:33" + var d = new Date( parts[1] + ' ' + parts[2] + ' ' + parts[3] + ' ' + parts[6] + ' ' + parts[4] ); + return d.getTime(); +} + +var parseSeconds = function(time) { + var seconds = 0; + var arr = new String(time || '').split('.'); + var parts = arr[0].split(':').reverse(); + + for (var i = 0; i < parts.length; i++) { + seconds += ( parseInt(parts[i], 10) || 0 ) * Math.pow(60, i); + } + + if (arr[1] && 5 <= parseInt(arr[1][0], 10)) { + seconds++; // treat more or equal than .5 as additional second + + } + + return seconds; +} + +var getSlaveSettings = function(data) { + var settings = {}; + settings.masterUrl = data.slave.masterUrl; + settings.isPollingDisabled = data.slave.isPollingDisabled == 'true'; + settings.pollInterval = data.slave.pollInterval; + settings.isReplicating = data.slave.isReplicating == 'true'; + settings.nextExecutionAt = data.slave.nextExecutionAt; + + if(settings.isReplicating) { + settings.isApprox = true; + settings.tick = parseSeconds(settings.pollInterval); + } else if (!settings.isPollingDisabled && settings.pollInterval) { + if( settings.nextExecutionAt ) { + settings.nextExecutionAtEpoch = parseDateToEpoch(settings.nextExecutionAt); + settings.currentTime = parseDateToEpoch(data.slave.currentDate); + + if( settings.nextExecutionAtEpoch > settings.currentTime) { + settings.isApprox = false; + settings.tick = ( settings.nextExecutionAtEpoch - settings.currentTime) / 1000; + } + } + } + return settings; +}; + +var getMasterSettings = function(details, isSlave) { + var master = {}; + var masterData = isSlave ? details.slave.masterDetails.master : details.master; + master.replicationEnabled = masterData.replicationEnabled == "true"; + master.replicateAfter = masterData.replicateAfter.join(", "); + + if (masterData.confFiles) { + master.files = []; + var confFiles = masterData.confFiles.split(','); + for (var i=0; i<confFiles.length; i++) { + var file = confFiles[i]; + var short = file; + var title = file; + if (file.indexOf(":")>=0) { + title = file.replace(':', ' » '); + var parts = file.split(':'); + if (isSlave) { + short = parts[1]; + } else { + short = parts[0]; + } + } + master.files.push({title:title, name:short}); + } + } + return master; +} Propchange: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/replication.js ------------------------------------------------------------------------------ svn:eol-style = native |
Free forum by Nabble | Edit this page |