You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2017/02/05 11:10:01 UTC
svn commit: r1781731 [19/45] - in /ofbiz/trunk:
applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/ideal/
applications/accounting/webapp/ap/error/
applications/accounting/webapp/ar/error/
applications/commonext/webapp/ofbizset...
Modified: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/cores.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/cores.js?rev=1781731&r1=1781730&r2=1781731&view=diff
==============================================================================
--- ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/cores.js (original)
+++ ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/cores.js Sun Feb 5 11:09:59 2017
@@ -1,478 +1,478 @@
-/*
- 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.
-*/
-
-// @todo test optimize (delete stuff, watch button appear, test button/form)
-solrAdminApp.controller('CoreAdminController',
- function($scope, $routeParams, $location, $timeout, $route, Cores, Update, Constants){
- $scope.resetMenu("cores", Constants.IS_ROOT_PAGE);
- $scope.selectedCore = $routeParams.corename; // use 'corename' not 'core' to distinguish from /solr/:core/
- $scope.refresh = function() {
- Cores.get(function(data) {
- var coreCount = 0;
- var cores = data.status;
- for (_obj in cores) coreCount++;
- $scope.hasCores = coreCount >0;
- if (!$scope.selectedCore && coreCount==0) {
- $scope.showAddCore();
- return;
- } else if (!$scope.selectedCore) {
- for (firstCore in cores) break;
- $scope.selectedCore = firstCore;
- $location.path("/~cores/" + $scope.selectedCore).replace();
- }
- $scope.core = cores[$scope.selectedCore];
- $scope.corelist = [];
- $scope.swapCorelist = [];
- for (var core in cores) {
- $scope.corelist.push(cores[core]);
- if (cores[core] != $scope.core) {
- $scope.swapCorelist.push(cores[core]);
- }
- }
- if ($scope.swapCorelist.length>0) {
- $scope.swapOther = $scope.swapCorelist[0].name;
- }
- });
- };
- $scope.showAddCore = function() {
- $scope.hideAll();
- $scope.showAdd = true;
- $scope.newCore = {
- name: "new_core",
- dataDir: "data",
- instanceDir: "new_core",
- config: "solrconfig.xml",
- schema: "schema.xml",
- collection: "",
- shard: ""
- };
- };
-
- $scope.addCore = function() {
- if (!$scope.newCore.name) {
- $scope.addMessage = "Please provide a core name";
- } else if (false) { //@todo detect whether core exists
- $scope.AddMessage = "A core with that name already exists";
- } else {
- var params = {
- name: $scope.newCore.name,
- instanceDir: $scope.newCore.instanceDir,
- config: $scope.newCore.config,
- schema: $scope.newCore.schema,
- dataDir: $scope.newCore.dataDir
- };
- if ($scope.isCloud) {
- params.collection = $scope.newCore.collection;
- params.shard = $scope.newCore.shard;
- }
- Cores.add(params, function(data) {
- $location.path("/~cores/" + $scope.newCore.name);
- $scope.cancelAddCore();
- });
- }
- };
-
- $scope.cancelAddCore = function() {
- delete $scope.addMessage;
- $scope.showAdd = false
- };
-
- $scope.unloadCore = function() {
- var answer = confirm( 'Do you really want to unload Core "' + $scope.selectedCore + '"?' );
- if( !answer ) return;
- Cores.unload({core: $scope.selectedCore}, function(data) {
- $location.path("/~cores");
- });
- };
-
- $scope.showRenameCore = function() {
- $scope.hideAll();
- $scope.showRename = true;
- };
-
- $scope.renameCore = function() {
- if (!$scope.other) {
- $scope.renameMessage = "Please provide a new name for the " + $scope.selectedCore + " core";
- } else if ($scope.other == $scope.selectedCore) {
- $scope.renameMessage = "New name must be different from the current one";
- } else {
- Cores.rename({core:$scope.selectedCore, other: $scope.other}, function(data) {
- $location.path("/~cores/" + $scope.other);
- $scope.cancelRename();
- });
- }
- };
-
- $scope.cancelRenameCore = function() {
- $scope.showRename = false;
- delete $scope.renameMessage;
- $scope.other = "";
- };
-
- $scope.showSwapCores = function() {
- $scope.hideAll();
- $scope.showSwap = true;
- };
-
- $scope.swapCores = function() {
- if (!$scope.swapOther) {
- $scope.swapMessage = "Please select a core to swap with";
- } else if ($scope.swapOther == $scope.selectedCore) {
- $scope.swapMessage = "Cannot swap with the same core";
- } else {
- Cores.swap({core: $scope.selectedCore, other: $scope.swapOther}, function(data) {
- $location.path("/~cores/" + $scope.swapOther);
- delete $scope.swapOther;
- $scope.cancelSwapCores();
- });
- }
- };
-
- $scope.cancelSwapCores = function() {
- delete $scope.swapMessage;
- $scope.showSwap = false;
- }
-
- $scope.reloadCore = function() {
- if ($scope.initFailures[$scope.selectedCore]) {
- delete $scope.initFailures[$scope.selectedCore];
- $scope.showInitFailures = Object.keys(data.initFailures).length>0;
- }
- Cores.reload({core: $scope.selectedCore},
- function(data) {
- if (data.error) {
- $scope.reloadFailure = true;
- $timeout(function() {
- $scope.reloadFailure = false;
- $route.reload();
- }, 1000);
- } else {
- $scope.reloadSuccess = true;
- $timeout(function () {
- $scope.reloadSuccess = false;
- $route.reload();
- }, 1000);
- }
- });
- };
-
- $scope.hideAll = function() {
- $scope.showRename = false;
- $scope.showAdd = false;
- $scope.showSwap = false;
- };
-
- $scope.optimizeCore = function() {
- Update.optimize({core: $scope.selectedCore},
- function(successData) {
- $scope.optimizeSuccess = true;
- $timeout(function() {$scope.optimizeSuccess=false}, 1000);
- $scope.refresh();
- },
- function(failureData) {
- $scope.optimizeFailure = true;
- $timeout(function () {$scope.optimizeFailure=false}, 1000);
- $scope.refresh();
- });
- };
-
- $scope.refresh();
- }
-);
-
-/**************
- 'cores_load_data',
- function( event, params )
- {
- $.ajax
- (
- {
- url : app.config.solr_path + app.config.core_admin_path + '?wt=json',
- dataType : 'json',
- success : function( response, text_status, xhr )
- {
- if( params.only_failures )
- {
- app.check_for_init_failures( response );
- return true;
- }
-
-
-=========== NO CORES
- error : function()
- {
- sammy.trigger
- (
- 'cores_load_template',
- {
- content_element : content_element,
- callback : function()
- {
- var cores_element = $( '#cores', content_element );
- var navigation_element = $( '#navigation', cores_element );
- var data_element = $( '#data', cores_element );
- var core_data_element = $( '#core-data', data_element );
- var index_data_element = $( '#index-data', data_element );
-
- // layout
-
- var ui_block = $( '#ui-block' );
- var actions_element = $( '.actions', cores_element );
- var div_action = $( 'div.action', actions_element );
-
- ui_block
- .css( 'opacity', 0.7 )
- .width( cores_element.width() + 10 )
- .height( cores_element.height() );
-
- if( $( '#cloud.global' ).is( ':visible' ) )
- {
- $( '.cloud', div_action )
- .show();
- }
-
- $( 'button.action', actions_element )
- .die( 'click' )
- .live
- (
- 'click',
- function( event )
- {
- var self = $( this );
-
- self
- .toggleClass( 'open' );
-
- $( '.action.' + self.attr( 'id' ), actions_element )
- .trigger( 'open' );
-
- return false;
- }
- );
-
- div_action
- .die( 'close' )
- .live
- (
- 'close',
- function( event )
- {
- div_action.hide();
- ui_block.hide();
- }
- )
- .die( 'open' )
- .live
- (
- 'open',
- function( event )
- {
- var self = $( this );
- var rel = $( '#' + self.data( 'rel' ) );
-
- self
- .trigger( 'close' )
- .show()
- .css( 'left', rel.position().left );
-
- ui_block
- .show();
- }
- );
-
- $( 'form button.reset', actions_element )
- .die( 'click' )
- .live
- (
- 'click',
- function( event )
- {
- $( this ).closest( 'div.action' )
- .trigger( 'close' );
- }
- );
-
- $( 'form', div_action )
- .ajaxForm
- (
- {
- url : app.config.solr_path + app.config.core_admin_path + '?wt=json&indexInfo=false',
- dataType : 'json',
- beforeSubmit : function( array, form, options )
- {
- $( 'button[type="submit"] span', form )
- .addClass( 'loader' );
- },
- success : function( response, status_text, xhr, form )
- {
- delete app.cores_data;
- sammy.refresh();
-
- $( 'button.reset', form )
- .trigger( 'click' );
- },
- error : function( xhr, text_status, error_thrown )
- {
- var response = null;
- eval( 'response = ' + xhr.responseText + ';' );
-
- var error_elem = $( '.error', div_action.filter( ':visible' ) );
- error_elem.show();
- $( 'span', error_elem ).text( response.error.msg );
- },
- complete : function()
- {
- $( 'button span.loader', actions_element )
- .removeClass( 'loader' );
- }
- }
- );
-
- // --
-
- $( '#add', content_element )
- .trigger( 'click' );
-
- $( '[data-rel="add"] input[type="text"]:first', content_element )
- .focus();
- }
- }
- );
- }
- }
- );
- }
-);
-
-// #/~cores
-sammy.get
-(
- /^#\/(~cores)\//,
- function( context )
- {
- var content_element = $( '#content' );
-
- var path_parts = this.path.match( /^(.+\/~cores\/)(.*)$/ );
- var current_core = path_parts[2];
-
- sammy.trigger
- (
- 'cores_load_data',
- {
- error : function()
- {
- context.redirect( '#/' + context.params.splat[0] );
- },
- success : function( cores )
- {
- sammy.trigger
- (
- 'cores_load_template',
- {
- content_element : content_element,
- callback : function()
- {
- var cores_element = $( '#cores', content_element );
- var navigation_element = $( '#navigation', cores_element );
- var data_element = $( '#data', cores_element );
- var core_data_element = $( '#core-data', data_element );
- var index_data_element = $( '#index-data', data_element );
-
- cores_element
- .removeClass( 'empty' );
-
- var core_data = cores[current_core];
- var core_basepath = $( '#' + current_core, app.menu_element ).attr( 'data-basepath' );
-
- var core_names = [];
- var core_selects = $( '#actions select', cores_element );
-
- $( 'option[value="' + current_core + '"]', core_selects.filter( '.other' ) )
- .remove();
-
- $( 'input[data-core="current"]', cores_element )
- .val( current_core );
-
- // layout
-
- var ui_block = $( '#ui-block' );
- var actions_element = $( '.actions', cores_element );
- var div_action = $( 'div.action', actions_element );
-
- ui_block
- .css( 'opacity', 0.7 )
- .width( cores_element.width() + 10 )
- .height( cores_element.height() );
-
- if( $( '#cloud.global' ).is( ':visible' ) )
- {
- $( '.cloud', div_action )
- .show();
- }
-
- var form_callback = {
-
- rename : function( form, response )
- {
- var url = path_parts[1] + $( 'input[name="other"]', form ).val();
- context.redirect( url );
- }
-
- };
-
- $( 'form', div_action )
- .ajaxForm
- (
- {
- url : app.config.solr_path + app.config.core_admin_path + '?wt=json&indexInfo=false',
- success : function( response, status_text, xhr, form )
- {
- var action = $( 'input[name="action"]', form ).val().toLowerCase();
-
- delete app.cores_data;
-
- if( form_callback[action] )
- {
- form_callback[action]( form, response );
- }
- else
- {
- sammy.refresh();
- }
-
- $( 'button.reset', form )
- .trigger( 'click' );
- },
- );
-
- $( '#actions #unload', cores_element )
- var ret = confirm( 'Do you really want to unload Core "' + current_core + '"?' );
- if( !ret )
- return false;
-
- url : app.config.solr_path + app.config.core_admin_path + '?wt=json&action=UNLOAD&core=' + current_core,
- success : function( response, text_status, xhr )
- {
- delete app.cores_data;
- context.redirect( path_parts[1].substr( 0, path_parts[1].length - 1 ) );
- },
-
- optimize_button
- url : core_basepath + '/update?optimize=true&waitFlush=true&wt=json',
- success : function( response, text_status, xhr )
-
-******/
+/*
+ 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.
+*/
+
+// @todo test optimize (delete stuff, watch button appear, test button/form)
+solrAdminApp.controller('CoreAdminController',
+ function($scope, $routeParams, $location, $timeout, $route, Cores, Update, Constants){
+ $scope.resetMenu("cores", Constants.IS_ROOT_PAGE);
+ $scope.selectedCore = $routeParams.corename; // use 'corename' not 'core' to distinguish from /solr/:core/
+ $scope.refresh = function() {
+ Cores.get(function(data) {
+ var coreCount = 0;
+ var cores = data.status;
+ for (_obj in cores) coreCount++;
+ $scope.hasCores = coreCount >0;
+ if (!$scope.selectedCore && coreCount==0) {
+ $scope.showAddCore();
+ return;
+ } else if (!$scope.selectedCore) {
+ for (firstCore in cores) break;
+ $scope.selectedCore = firstCore;
+ $location.path("/~cores/" + $scope.selectedCore).replace();
+ }
+ $scope.core = cores[$scope.selectedCore];
+ $scope.corelist = [];
+ $scope.swapCorelist = [];
+ for (var core in cores) {
+ $scope.corelist.push(cores[core]);
+ if (cores[core] != $scope.core) {
+ $scope.swapCorelist.push(cores[core]);
+ }
+ }
+ if ($scope.swapCorelist.length>0) {
+ $scope.swapOther = $scope.swapCorelist[0].name;
+ }
+ });
+ };
+ $scope.showAddCore = function() {
+ $scope.hideAll();
+ $scope.showAdd = true;
+ $scope.newCore = {
+ name: "new_core",
+ dataDir: "data",
+ instanceDir: "new_core",
+ config: "solrconfig.xml",
+ schema: "schema.xml",
+ collection: "",
+ shard: ""
+ };
+ };
+
+ $scope.addCore = function() {
+ if (!$scope.newCore.name) {
+ $scope.addMessage = "Please provide a core name";
+ } else if (false) { //@todo detect whether core exists
+ $scope.AddMessage = "A core with that name already exists";
+ } else {
+ var params = {
+ name: $scope.newCore.name,
+ instanceDir: $scope.newCore.instanceDir,
+ config: $scope.newCore.config,
+ schema: $scope.newCore.schema,
+ dataDir: $scope.newCore.dataDir
+ };
+ if ($scope.isCloud) {
+ params.collection = $scope.newCore.collection;
+ params.shard = $scope.newCore.shard;
+ }
+ Cores.add(params, function(data) {
+ $location.path("/~cores/" + $scope.newCore.name);
+ $scope.cancelAddCore();
+ });
+ }
+ };
+
+ $scope.cancelAddCore = function() {
+ delete $scope.addMessage;
+ $scope.showAdd = false
+ };
+
+ $scope.unloadCore = function() {
+ var answer = confirm( 'Do you really want to unload Core "' + $scope.selectedCore + '"?' );
+ if( !answer ) return;
+ Cores.unload({core: $scope.selectedCore}, function(data) {
+ $location.path("/~cores");
+ });
+ };
+
+ $scope.showRenameCore = function() {
+ $scope.hideAll();
+ $scope.showRename = true;
+ };
+
+ $scope.renameCore = function() {
+ if (!$scope.other) {
+ $scope.renameMessage = "Please provide a new name for the " + $scope.selectedCore + " core";
+ } else if ($scope.other == $scope.selectedCore) {
+ $scope.renameMessage = "New name must be different from the current one";
+ } else {
+ Cores.rename({core:$scope.selectedCore, other: $scope.other}, function(data) {
+ $location.path("/~cores/" + $scope.other);
+ $scope.cancelRename();
+ });
+ }
+ };
+
+ $scope.cancelRenameCore = function() {
+ $scope.showRename = false;
+ delete $scope.renameMessage;
+ $scope.other = "";
+ };
+
+ $scope.showSwapCores = function() {
+ $scope.hideAll();
+ $scope.showSwap = true;
+ };
+
+ $scope.swapCores = function() {
+ if (!$scope.swapOther) {
+ $scope.swapMessage = "Please select a core to swap with";
+ } else if ($scope.swapOther == $scope.selectedCore) {
+ $scope.swapMessage = "Cannot swap with the same core";
+ } else {
+ Cores.swap({core: $scope.selectedCore, other: $scope.swapOther}, function(data) {
+ $location.path("/~cores/" + $scope.swapOther);
+ delete $scope.swapOther;
+ $scope.cancelSwapCores();
+ });
+ }
+ };
+
+ $scope.cancelSwapCores = function() {
+ delete $scope.swapMessage;
+ $scope.showSwap = false;
+ }
+
+ $scope.reloadCore = function() {
+ if ($scope.initFailures[$scope.selectedCore]) {
+ delete $scope.initFailures[$scope.selectedCore];
+ $scope.showInitFailures = Object.keys(data.initFailures).length>0;
+ }
+ Cores.reload({core: $scope.selectedCore},
+ function(data) {
+ if (data.error) {
+ $scope.reloadFailure = true;
+ $timeout(function() {
+ $scope.reloadFailure = false;
+ $route.reload();
+ }, 1000);
+ } else {
+ $scope.reloadSuccess = true;
+ $timeout(function () {
+ $scope.reloadSuccess = false;
+ $route.reload();
+ }, 1000);
+ }
+ });
+ };
+
+ $scope.hideAll = function() {
+ $scope.showRename = false;
+ $scope.showAdd = false;
+ $scope.showSwap = false;
+ };
+
+ $scope.optimizeCore = function() {
+ Update.optimize({core: $scope.selectedCore},
+ function(successData) {
+ $scope.optimizeSuccess = true;
+ $timeout(function() {$scope.optimizeSuccess=false}, 1000);
+ $scope.refresh();
+ },
+ function(failureData) {
+ $scope.optimizeFailure = true;
+ $timeout(function () {$scope.optimizeFailure=false}, 1000);
+ $scope.refresh();
+ });
+ };
+
+ $scope.refresh();
+ }
+);
+
+/**************
+ 'cores_load_data',
+ function( event, params )
+ {
+ $.ajax
+ (
+ {
+ url : app.config.solr_path + app.config.core_admin_path + '?wt=json',
+ dataType : 'json',
+ success : function( response, text_status, xhr )
+ {
+ if( params.only_failures )
+ {
+ app.check_for_init_failures( response );
+ return true;
+ }
+
+
+=========== NO CORES
+ error : function()
+ {
+ sammy.trigger
+ (
+ 'cores_load_template',
+ {
+ content_element : content_element,
+ callback : function()
+ {
+ var cores_element = $( '#cores', content_element );
+ var navigation_element = $( '#navigation', cores_element );
+ var data_element = $( '#data', cores_element );
+ var core_data_element = $( '#core-data', data_element );
+ var index_data_element = $( '#index-data', data_element );
+
+ // layout
+
+ var ui_block = $( '#ui-block' );
+ var actions_element = $( '.actions', cores_element );
+ var div_action = $( 'div.action', actions_element );
+
+ ui_block
+ .css( 'opacity', 0.7 )
+ .width( cores_element.width() + 10 )
+ .height( cores_element.height() );
+
+ if( $( '#cloud.global' ).is( ':visible' ) )
+ {
+ $( '.cloud', div_action )
+ .show();
+ }
+
+ $( 'button.action', actions_element )
+ .die( 'click' )
+ .live
+ (
+ 'click',
+ function( event )
+ {
+ var self = $( this );
+
+ self
+ .toggleClass( 'open' );
+
+ $( '.action.' + self.attr( 'id' ), actions_element )
+ .trigger( 'open' );
+
+ return false;
+ }
+ );
+
+ div_action
+ .die( 'close' )
+ .live
+ (
+ 'close',
+ function( event )
+ {
+ div_action.hide();
+ ui_block.hide();
+ }
+ )
+ .die( 'open' )
+ .live
+ (
+ 'open',
+ function( event )
+ {
+ var self = $( this );
+ var rel = $( '#' + self.data( 'rel' ) );
+
+ self
+ .trigger( 'close' )
+ .show()
+ .css( 'left', rel.position().left );
+
+ ui_block
+ .show();
+ }
+ );
+
+ $( 'form button.reset', actions_element )
+ .die( 'click' )
+ .live
+ (
+ 'click',
+ function( event )
+ {
+ $( this ).closest( 'div.action' )
+ .trigger( 'close' );
+ }
+ );
+
+ $( 'form', div_action )
+ .ajaxForm
+ (
+ {
+ url : app.config.solr_path + app.config.core_admin_path + '?wt=json&indexInfo=false',
+ dataType : 'json',
+ beforeSubmit : function( array, form, options )
+ {
+ $( 'button[type="submit"] span', form )
+ .addClass( 'loader' );
+ },
+ success : function( response, status_text, xhr, form )
+ {
+ delete app.cores_data;
+ sammy.refresh();
+
+ $( 'button.reset', form )
+ .trigger( 'click' );
+ },
+ error : function( xhr, text_status, error_thrown )
+ {
+ var response = null;
+ eval( 'response = ' + xhr.responseText + ';' );
+
+ var error_elem = $( '.error', div_action.filter( ':visible' ) );
+ error_elem.show();
+ $( 'span', error_elem ).text( response.error.msg );
+ },
+ complete : function()
+ {
+ $( 'button span.loader', actions_element )
+ .removeClass( 'loader' );
+ }
+ }
+ );
+
+ // --
+
+ $( '#add', content_element )
+ .trigger( 'click' );
+
+ $( '[data-rel="add"] input[type="text"]:first', content_element )
+ .focus();
+ }
+ }
+ );
+ }
+ }
+ );
+ }
+);
+
+// #/~cores
+sammy.get
+(
+ /^#\/(~cores)\//,
+ function( context )
+ {
+ var content_element = $( '#content' );
+
+ var path_parts = this.path.match( /^(.+\/~cores\/)(.*)$/ );
+ var current_core = path_parts[2];
+
+ sammy.trigger
+ (
+ 'cores_load_data',
+ {
+ error : function()
+ {
+ context.redirect( '#/' + context.params.splat[0] );
+ },
+ success : function( cores )
+ {
+ sammy.trigger
+ (
+ 'cores_load_template',
+ {
+ content_element : content_element,
+ callback : function()
+ {
+ var cores_element = $( '#cores', content_element );
+ var navigation_element = $( '#navigation', cores_element );
+ var data_element = $( '#data', cores_element );
+ var core_data_element = $( '#core-data', data_element );
+ var index_data_element = $( '#index-data', data_element );
+
+ cores_element
+ .removeClass( 'empty' );
+
+ var core_data = cores[current_core];
+ var core_basepath = $( '#' + current_core, app.menu_element ).attr( 'data-basepath' );
+
+ var core_names = [];
+ var core_selects = $( '#actions select', cores_element );
+
+ $( 'option[value="' + current_core + '"]', core_selects.filter( '.other' ) )
+ .remove();
+
+ $( 'input[data-core="current"]', cores_element )
+ .val( current_core );
+
+ // layout
+
+ var ui_block = $( '#ui-block' );
+ var actions_element = $( '.actions', cores_element );
+ var div_action = $( 'div.action', actions_element );
+
+ ui_block
+ .css( 'opacity', 0.7 )
+ .width( cores_element.width() + 10 )
+ .height( cores_element.height() );
+
+ if( $( '#cloud.global' ).is( ':visible' ) )
+ {
+ $( '.cloud', div_action )
+ .show();
+ }
+
+ var form_callback = {
+
+ rename : function( form, response )
+ {
+ var url = path_parts[1] + $( 'input[name="other"]', form ).val();
+ context.redirect( url );
+ }
+
+ };
+
+ $( 'form', div_action )
+ .ajaxForm
+ (
+ {
+ url : app.config.solr_path + app.config.core_admin_path + '?wt=json&indexInfo=false',
+ success : function( response, status_text, xhr, form )
+ {
+ var action = $( 'input[name="action"]', form ).val().toLowerCase();
+
+ delete app.cores_data;
+
+ if( form_callback[action] )
+ {
+ form_callback[action]( form, response );
+ }
+ else
+ {
+ sammy.refresh();
+ }
+
+ $( 'button.reset', form )
+ .trigger( 'click' );
+ },
+ );
+
+ $( '#actions #unload', cores_element )
+ var ret = confirm( 'Do you really want to unload Core "' + current_core + '"?' );
+ if( !ret )
+ return false;
+
+ url : app.config.solr_path + app.config.core_admin_path + '?wt=json&action=UNLOAD&core=' + current_core,
+ success : function( response, text_status, xhr )
+ {
+ delete app.cores_data;
+ context.redirect( path_parts[1].substr( 0, path_parts[1].length - 1 ) );
+ },
+
+ optimize_button
+ url : core_basepath + '/update?optimize=true&waitFlush=true&wt=json',
+ success : function( response, text_status, xhr )
+
+******/
Propchange: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/cores.js
------------------------------------------------------------------------------
svn:eol-style = native
Modified: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/dataimport.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/dataimport.js?rev=1781731&r1=1781730&r2=1781731&view=diff
==============================================================================
--- ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/dataimport.js (original)
+++ ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/dataimport.js Sun Feb 5 11:09:59 2017
@@ -1,303 +1,303 @@
-/*
- 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 dataimport_timeout = 2000;
-
-solrAdminApp.controller('DataImportController',
- function($scope, $rootScope, $routeParams, $location, $timeout, $interval, $cookies, Mbeans, DataImport, Constants) {
- $scope.resetMenu("dataimport", Constants.IS_COLLECTION_PAGE);
-
- $scope.refresh = function () {
- Mbeans.info({core: $routeParams.core, cat: 'QUERYHANDLER'}, function (data) {
- var mbeans = data['solr-mbeans'][1];
- $scope.handlers = [];
- for (var key in mbeans) {
- if (mbeans[key]['class'] !== key && mbeans[key]['class'] === 'org.apache.solr.handler.dataimport.DataImportHandler') {
- $scope.handlers.push(key);
- }
- }
- $scope.hasHandlers = $scope.handlers.length > 0;
-
- if (!$routeParams.handler) {
- $location.path("/" + $routeParams.core + "/dataimport/" + $scope.handlers[0]);
- } else {
- $scope.currentHandler = $routeParams.handler;
- }
- });
-
- $scope.handler = $routeParams.handler;
- if ($scope.handler && $scope.handler[0]=="/") {
- $scope.handler = $scope.handler.substr(1);
- }
- if ($scope.handler) {
- DataImport.config({core: $routeParams.core, name: $scope.handler}, function (data) {
- try {
- $scope.config = data.config;
- var xml = $.parseXML(data.config);
- $scope.entities = [];
- $('document > entity', xml).each(function (i, element) {
- $scope.entities.push($(element).attr('name'));
- });
- $scope.refreshStatus();
- } catch (err) {
- console.log(err);
- }
- });
- }
- $scope.lastUpdate = "unknown";
- $scope.lastUpdateUTC = "";
- };
-
- $scope.toggleDebug = function () {
- $scope.isDebugMode = !$scope.isDebugMode;
- if ($scope.isDebugMode) {
- // also enable Debug checkbox
- $scope.form.showDebug = true;
- }
- $scope.showConfiguration = true;
- }
-
- $scope.toggleConfiguration = function () {
- $scope.showConfiguration = !$scope.showConfiguration;
- }
-
- $scope.toggleRawStatus = function () {
- $scope.showRawStatus = !$scope.showRawStatus;
- }
-
- $scope.toggleRawDebug = function () {
- $scope.showRawDebug = !$scope.showRawDebug;
- }
-
- $scope.reload = function () {
- DataImport.reload({core: $routeParams.core, name: $scope.handler}, function () {
- $scope.reloaded = true;
- $timeout(function () {
- $scope.reloaded = false;
- }, 5000);
- $scope.refresh();
- });
- }
-
- $scope.form = {
- command: "full-import",
- verbose: false,
- clean: true,
- commit: true,
- optimize: false,
- showDebug: false,
- custom: "",
- core: $routeParams.core
- };
-
- $scope.submit = function () {
- var params = {};
- for (var key in $scope.form) {
- if (key == "showDebug") {
- if ($scope.form.showDebug) {
- params["debug"] = true;
- }
- } else {
- params[key] = $scope.form[key];
- }
- }
- if (params.custom.length) {
- var customParams = $scope.form.custom.split("&");
- for (var i in customParams) {
- var parts = customParams[i].split("=");
- params[parts[0]] = parts[1];
- }
- }
- delete params.custom;
-
- if ($scope.isDebugMode) {
- params.dataConfig = $scope.config;
- }
-
- params.core = $routeParams.core;
- params.name = $scope.handler;
-
- DataImport.post(params, function (data) {
- $scope.rawResponse = JSON.stringify(data, null, 2);
- $scope.refreshStatus();
- });
- };
-
- $scope.abort = function () {
- $scope.isAborting = true;
- DataImport.abort({core: $routeParams.core, name: $scope.handler}, function () {
- $timeout(function () {
- $scope.isAborting = false;
- $scope.refreshStatus();
- }, 4000);
- });
- }
-
- $scope.refreshStatus = function () {
-
- console.log("Refresh Status");
-
- $scope.isStatusLoading = true;
- DataImport.status({core: $routeParams.core, name: $scope.handler}, function (data) {
- if (data[0] == "<") {
- $scope.hasHandlers = false;
- return;
- }
-
- var now = new Date();
- $scope.lastUpdate = now.toTimeString().split(' ').shift();
- $scope.lastUpdateUTC = now.toUTCString();
- var messages = data.statusMessages;
- var messagesCount = 0;
- for( var key in messages ) { messagesCount++; }
-
- if (data.status == 'busy') {
- $scope.status = "indexing";
-
- $scope.timeElapsed = data.statusMessages['Time Elapsed'];
- $scope.elapsedSeconds = parseSeconds($scope.timeElapsed);
-
- var info = $scope.timeElapsed ? 'Indexing since ' + $scope.timeElapsed : 'Indexing ...';
- $scope.info = showInfo(messages, true, info, $scope.elapsedSeconds);
-
- } else if (messages.RolledBack) {
- $scope.status = "failure";
- $scope.info = showInfo(messages, true);
- } else if (messages.Aborted) {
- $scope.status = "aborted";
- $scope.info = showInfo(messages, true, 'Aborting current Import ...');
- } else if (data.status == "idle" && messagesCount != 0) {
- $scope.status = "success";
- $scope.info = showInfo(messages, true);
- } else {
- $scope.status = "idle";
- $scope.info = showInfo(messages, false, 'No information available (idle)');
- }
-
- delete data.$promise;
- delete data.$resolved;
-
- $scope.rawStatus = JSON.stringify(data, null, 2);
-
- $scope.isStatusLoading = false;
- $scope.statusUpdated = true;
- $timeout(function () {
- $scope.statusUpdated = false;
- }, dataimport_timeout / 2);
- });
- };
-
- $scope.updateAutoRefresh = function () {
- $scope.autorefresh = !$scope.autorefresh;
- $cookies.dataimport_autorefresh = $scope.autorefresh ? true : null;
- if ($scope.autorefresh) {
- $scope.refreshTimeout = $interval($scope.refreshStatus, dataimport_timeout);
- var onRouteChangeOff = $scope.$on('$routeChangeStart', function() {
- $interval.cancel($scope.refreshTimeout);
- onRouteChangeOff();
- });
-
- } else if ($scope.refreshTimeout) {
- $interval.cancel($scope.refreshTimeout);
- }
- $scope.refreshStatus();
- };
-
- $scope.refresh();
-
-});
-
-var showInfo = function (messages, showFull, info_text, elapsed_seconds) {
-
- var info = {};
- if (info_text) {
- info.text = info_text;
- } else {
- info.text = messages[''] || '';
- // format numbers included in status nicely
- /* @todo this pretty printing is hard to work out how to do in an Angularesque way:
- info.text = info.text.replace(/\d{4,}/g,
- function (match, position, string) {
- return app.format_number(parseInt(match, 10));
- }
- );
- */
-
- var time_taken_text = messages['Time taken'];
- info.timeTaken = parseSeconds(time_taken_text);
- }
- info.showDetails = false;
-
- if (showFull) {
- if (!elapsed_seconds) {
- var time_taken_text = messages['Time taken'];
- elapsed_seconds = parseSeconds(time_taken_text);
- }
-
- info.showDetails = true;
-
- var document_config = {
- 'Requests': 'Total Requests made to DataSource',
- 'Fetched': 'Total Rows Fetched',
- 'Skipped': 'Total Documents Skipped',
- 'Processed': 'Total Documents Processed'
- };
-
- info.docs = [];
- for (var key in document_config) {
- var value = parseInt(messages[document_config[key]], 10);
- var doc = {desc: document_config[key], name: key, value: value};
- if (elapsed_seconds && key != 'Skipped') {
- doc.speed = Math.round(value / elapsed_seconds);
- }
- info.docs.push(doc);
- }
-
- var dates_config = {
- 'Started': 'Full Dump Started',
- 'Aborted': 'Aborted',
- 'Rolledback': 'Rolledback'
- };
-
- info.dates = [];
- for (var key in dates_config) {
- var value = messages[dates_config[key]];
- if (value) {
- value = value.replace(" ", "T")+".000Z";
- console.log(value);
- var date = {desc: dates_config[key], name: key, value: value};
- info.dates.push(date);
- }
- }
- }
- return info;
-}
-
-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;
-}
+/*
+ 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 dataimport_timeout = 2000;
+
+solrAdminApp.controller('DataImportController',
+ function($scope, $rootScope, $routeParams, $location, $timeout, $interval, $cookies, Mbeans, DataImport, Constants) {
+ $scope.resetMenu("dataimport", Constants.IS_COLLECTION_PAGE);
+
+ $scope.refresh = function () {
+ Mbeans.info({core: $routeParams.core, cat: 'QUERYHANDLER'}, function (data) {
+ var mbeans = data['solr-mbeans'][1];
+ $scope.handlers = [];
+ for (var key in mbeans) {
+ if (mbeans[key]['class'] !== key && mbeans[key]['class'] === 'org.apache.solr.handler.dataimport.DataImportHandler') {
+ $scope.handlers.push(key);
+ }
+ }
+ $scope.hasHandlers = $scope.handlers.length > 0;
+
+ if (!$routeParams.handler) {
+ $location.path("/" + $routeParams.core + "/dataimport/" + $scope.handlers[0]);
+ } else {
+ $scope.currentHandler = $routeParams.handler;
+ }
+ });
+
+ $scope.handler = $routeParams.handler;
+ if ($scope.handler && $scope.handler[0]=="/") {
+ $scope.handler = $scope.handler.substr(1);
+ }
+ if ($scope.handler) {
+ DataImport.config({core: $routeParams.core, name: $scope.handler}, function (data) {
+ try {
+ $scope.config = data.config;
+ var xml = $.parseXML(data.config);
+ $scope.entities = [];
+ $('document > entity', xml).each(function (i, element) {
+ $scope.entities.push($(element).attr('name'));
+ });
+ $scope.refreshStatus();
+ } catch (err) {
+ console.log(err);
+ }
+ });
+ }
+ $scope.lastUpdate = "unknown";
+ $scope.lastUpdateUTC = "";
+ };
+
+ $scope.toggleDebug = function () {
+ $scope.isDebugMode = !$scope.isDebugMode;
+ if ($scope.isDebugMode) {
+ // also enable Debug checkbox
+ $scope.form.showDebug = true;
+ }
+ $scope.showConfiguration = true;
+ }
+
+ $scope.toggleConfiguration = function () {
+ $scope.showConfiguration = !$scope.showConfiguration;
+ }
+
+ $scope.toggleRawStatus = function () {
+ $scope.showRawStatus = !$scope.showRawStatus;
+ }
+
+ $scope.toggleRawDebug = function () {
+ $scope.showRawDebug = !$scope.showRawDebug;
+ }
+
+ $scope.reload = function () {
+ DataImport.reload({core: $routeParams.core, name: $scope.handler}, function () {
+ $scope.reloaded = true;
+ $timeout(function () {
+ $scope.reloaded = false;
+ }, 5000);
+ $scope.refresh();
+ });
+ }
+
+ $scope.form = {
+ command: "full-import",
+ verbose: false,
+ clean: true,
+ commit: true,
+ optimize: false,
+ showDebug: false,
+ custom: "",
+ core: $routeParams.core
+ };
+
+ $scope.submit = function () {
+ var params = {};
+ for (var key in $scope.form) {
+ if (key == "showDebug") {
+ if ($scope.form.showDebug) {
+ params["debug"] = true;
+ }
+ } else {
+ params[key] = $scope.form[key];
+ }
+ }
+ if (params.custom.length) {
+ var customParams = $scope.form.custom.split("&");
+ for (var i in customParams) {
+ var parts = customParams[i].split("=");
+ params[parts[0]] = parts[1];
+ }
+ }
+ delete params.custom;
+
+ if ($scope.isDebugMode) {
+ params.dataConfig = $scope.config;
+ }
+
+ params.core = $routeParams.core;
+ params.name = $scope.handler;
+
+ DataImport.post(params, function (data) {
+ $scope.rawResponse = JSON.stringify(data, null, 2);
+ $scope.refreshStatus();
+ });
+ };
+
+ $scope.abort = function () {
+ $scope.isAborting = true;
+ DataImport.abort({core: $routeParams.core, name: $scope.handler}, function () {
+ $timeout(function () {
+ $scope.isAborting = false;
+ $scope.refreshStatus();
+ }, 4000);
+ });
+ }
+
+ $scope.refreshStatus = function () {
+
+ console.log("Refresh Status");
+
+ $scope.isStatusLoading = true;
+ DataImport.status({core: $routeParams.core, name: $scope.handler}, function (data) {
+ if (data[0] == "<") {
+ $scope.hasHandlers = false;
+ return;
+ }
+
+ var now = new Date();
+ $scope.lastUpdate = now.toTimeString().split(' ').shift();
+ $scope.lastUpdateUTC = now.toUTCString();
+ var messages = data.statusMessages;
+ var messagesCount = 0;
+ for( var key in messages ) { messagesCount++; }
+
+ if (data.status == 'busy') {
+ $scope.status = "indexing";
+
+ $scope.timeElapsed = data.statusMessages['Time Elapsed'];
+ $scope.elapsedSeconds = parseSeconds($scope.timeElapsed);
+
+ var info = $scope.timeElapsed ? 'Indexing since ' + $scope.timeElapsed : 'Indexing ...';
+ $scope.info = showInfo(messages, true, info, $scope.elapsedSeconds);
+
+ } else if (messages.RolledBack) {
+ $scope.status = "failure";
+ $scope.info = showInfo(messages, true);
+ } else if (messages.Aborted) {
+ $scope.status = "aborted";
+ $scope.info = showInfo(messages, true, 'Aborting current Import ...');
+ } else if (data.status == "idle" && messagesCount != 0) {
+ $scope.status = "success";
+ $scope.info = showInfo(messages, true);
+ } else {
+ $scope.status = "idle";
+ $scope.info = showInfo(messages, false, 'No information available (idle)');
+ }
+
+ delete data.$promise;
+ delete data.$resolved;
+
+ $scope.rawStatus = JSON.stringify(data, null, 2);
+
+ $scope.isStatusLoading = false;
+ $scope.statusUpdated = true;
+ $timeout(function () {
+ $scope.statusUpdated = false;
+ }, dataimport_timeout / 2);
+ });
+ };
+
+ $scope.updateAutoRefresh = function () {
+ $scope.autorefresh = !$scope.autorefresh;
+ $cookies.dataimport_autorefresh = $scope.autorefresh ? true : null;
+ if ($scope.autorefresh) {
+ $scope.refreshTimeout = $interval($scope.refreshStatus, dataimport_timeout);
+ var onRouteChangeOff = $scope.$on('$routeChangeStart', function() {
+ $interval.cancel($scope.refreshTimeout);
+ onRouteChangeOff();
+ });
+
+ } else if ($scope.refreshTimeout) {
+ $interval.cancel($scope.refreshTimeout);
+ }
+ $scope.refreshStatus();
+ };
+
+ $scope.refresh();
+
+});
+
+var showInfo = function (messages, showFull, info_text, elapsed_seconds) {
+
+ var info = {};
+ if (info_text) {
+ info.text = info_text;
+ } else {
+ info.text = messages[''] || '';
+ // format numbers included in status nicely
+ /* @todo this pretty printing is hard to work out how to do in an Angularesque way:
+ info.text = info.text.replace(/\d{4,}/g,
+ function (match, position, string) {
+ return app.format_number(parseInt(match, 10));
+ }
+ );
+ */
+
+ var time_taken_text = messages['Time taken'];
+ info.timeTaken = parseSeconds(time_taken_text);
+ }
+ info.showDetails = false;
+
+ if (showFull) {
+ if (!elapsed_seconds) {
+ var time_taken_text = messages['Time taken'];
+ elapsed_seconds = parseSeconds(time_taken_text);
+ }
+
+ info.showDetails = true;
+
+ var document_config = {
+ 'Requests': 'Total Requests made to DataSource',
+ 'Fetched': 'Total Rows Fetched',
+ 'Skipped': 'Total Documents Skipped',
+ 'Processed': 'Total Documents Processed'
+ };
+
+ info.docs = [];
+ for (var key in document_config) {
+ var value = parseInt(messages[document_config[key]], 10);
+ var doc = {desc: document_config[key], name: key, value: value};
+ if (elapsed_seconds && key != 'Skipped') {
+ doc.speed = Math.round(value / elapsed_seconds);
+ }
+ info.docs.push(doc);
+ }
+
+ var dates_config = {
+ 'Started': 'Full Dump Started',
+ 'Aborted': 'Aborted',
+ 'Rolledback': 'Rolledback'
+ };
+
+ info.dates = [];
+ for (var key in dates_config) {
+ var value = messages[dates_config[key]];
+ if (value) {
+ value = value.replace(" ", "T")+".000Z";
+ console.log(value);
+ var date = {desc: dates_config[key], name: key, value: value};
+ info.dates.push(date);
+ }
+ }
+ }
+ return info;
+}
+
+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;
+}
Propchange: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/dataimport.js
------------------------------------------------------------------------------
svn:eol-style = native
Modified: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/documents.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/documents.js?rev=1781731&r1=1781730&r2=1781731&view=diff
==============================================================================
--- ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/documents.js (original)
+++ ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/documents.js Sun Feb 5 11:09:59 2017
@@ -1,139 +1,139 @@
-/*
- 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.
- */
-//helper for formatting JSON and others
-
-var DOC_PLACEHOLDER = '<doc>\n' +
- '<field name="id">change.me</field>' +
- '<field name="title">change.me</field>' +
- '</doc>';
-
-var ADD_PLACEHOLDER = '<add>\n' + DOC_PLACEHOLDER + '</add>\n';
-
-solrAdminApp.controller('DocumentsController',
- function($scope, $rootScope, $routeParams, $location, Luke, Update, FileUpload, Constants) {
- $scope.resetMenu("documents", Constants.IS_COLLECTION_PAGE);
-
- $scope.refresh = function () {
- Luke.schema({core: $routeParams.core}, function(data) {
- //TODO: handle dynamic fields
- delete data.schema.fields._version_;
- $scope.fields = Object.keys(data.schema.fields);
- });
- $scope.document = "";
- $scope.handler = "/update";
- $scope.type = "json";
- $scope.commitWithin = 1000;
- $scope.overwrite = true;
- $scope.boost = "1.0";
- };
-
- $scope.refresh();
-
- $scope.changeDocumentType = function () {
- $scope.placeholder = "";
- if ($scope.type == 'json') {
- $scope.placeholder = '{"id":"change.me","title":"change.me"}';
- } else if ($scope.type == 'csv') {
- $scope.placeholder = "id,title\nchange.me,change.me";
- } else if ($scope.type == 'solr') {
- $scope.placeholder = ADD_PLACEHOLDER;
- } else if ($scope.type == 'xml') {
- $scope.placeholder = DOC_PLACEHOLDER;
- }
- };
-
- $scope.addWizardField = function () {
- if ($scope.document == "") $scope.document = "{}";
- var doc = JSON.parse($scope.document);
- doc[$scope.fieldName] = $scope.fieldData;
- $scope.document = JSON.stringify(doc, null, '\t');
- $scope.fieldData = "";
- };
-
- $scope.submit = function () {
- var contentType = "";
- var postData = "";
- var params = {};
- var doingFileUpload = false;
-
- if ($scope.handler[0] == '/') {
- params.handler = $scope.handler.substring(1);
- } else {
- params.handler = 'update';
- params.qt = $scope.handler;
- }
-
- params.commitWithin = $scope.commitWithin;
- params.boost = $scope.boost;
- params.overwrite = $scope.overwrite;
- params.core = $routeParams.core;
- params.wt = "json";
-
- if ($scope.type == "json" || $scope.type == "wizard") {
- postData = "[" + $scope.document + "]";
- contentType = "json";
- } else if ($scope.type == "csv") {
- postData = $scope.document;
- contentType = "csv";
- } else if ($scope.type == "xml") {
- postData = "<add>" + $scope.document + "</add>";
- contentType = "xml";
- } else if ($scope.type == "upload") {
- doingFileUpload = true;
- params.raw = $scope.literalParams;
- } else if ($scope.type == "solr") {
- postData = $scope.document;
- if (postData[0] == "<") {
- contentType = "xml";
- } else if (postData[0] == "{" || postData[0] == '[') {
- contentType = "json";
- } else {
- alert("Cannot identify content type")
- }
- }
- if (!doingFileUpload) {
- var callback = function (success) {
- $scope.responseStatus = "success";
- delete success.$promise;
- delete success.$resolved;
- $scope.response = JSON.stringify(success, null, ' ');
- };
- var failure = function (failure) {
- $scope.responseStatus = failure;
- };
- if (contentType == "json") {
- Update.postJson(params, postData, callback, failure);
- } else if (contentType == "xml") {
- Update.postXml(params, postData, callback, failure);
- } else if (contentType == "csv") {
- Update.postCsv(params, postData, callback, failure);
- }
- } else {
- var file = $scope.fileUpload;
- console.log('file is ' + JSON.stringify(file));
- var uploadUrl = "/fileUpload";
- FileUpload.upload(params, $scope.fileUpload, function (success) {
- $scope.responseStatus = "success";
- $scope.response = JSON.stringify(success, null, ' ');
- }, function (failure) {
- $scope.responseStatus = "failure";
- $scope.response = JSON.stringify(failure, null, ' ');
- });
- }
- }
- });
-
+/*
+ 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.
+ */
+//helper for formatting JSON and others
+
+var DOC_PLACEHOLDER = '<doc>\n' +
+ '<field name="id">change.me</field>' +
+ '<field name="title">change.me</field>' +
+ '</doc>';
+
+var ADD_PLACEHOLDER = '<add>\n' + DOC_PLACEHOLDER + '</add>\n';
+
+solrAdminApp.controller('DocumentsController',
+ function($scope, $rootScope, $routeParams, $location, Luke, Update, FileUpload, Constants) {
+ $scope.resetMenu("documents", Constants.IS_COLLECTION_PAGE);
+
+ $scope.refresh = function () {
+ Luke.schema({core: $routeParams.core}, function(data) {
+ //TODO: handle dynamic fields
+ delete data.schema.fields._version_;
+ $scope.fields = Object.keys(data.schema.fields);
+ });
+ $scope.document = "";
+ $scope.handler = "/update";
+ $scope.type = "json";
+ $scope.commitWithin = 1000;
+ $scope.overwrite = true;
+ $scope.boost = "1.0";
+ };
+
+ $scope.refresh();
+
+ $scope.changeDocumentType = function () {
+ $scope.placeholder = "";
+ if ($scope.type == 'json') {
+ $scope.placeholder = '{"id":"change.me","title":"change.me"}';
+ } else if ($scope.type == 'csv') {
+ $scope.placeholder = "id,title\nchange.me,change.me";
+ } else if ($scope.type == 'solr') {
+ $scope.placeholder = ADD_PLACEHOLDER;
+ } else if ($scope.type == 'xml') {
+ $scope.placeholder = DOC_PLACEHOLDER;
+ }
+ };
+
+ $scope.addWizardField = function () {
+ if ($scope.document == "") $scope.document = "{}";
+ var doc = JSON.parse($scope.document);
+ doc[$scope.fieldName] = $scope.fieldData;
+ $scope.document = JSON.stringify(doc, null, '\t');
+ $scope.fieldData = "";
+ };
+
+ $scope.submit = function () {
+ var contentType = "";
+ var postData = "";
+ var params = {};
+ var doingFileUpload = false;
+
+ if ($scope.handler[0] == '/') {
+ params.handler = $scope.handler.substring(1);
+ } else {
+ params.handler = 'update';
+ params.qt = $scope.handler;
+ }
+
+ params.commitWithin = $scope.commitWithin;
+ params.boost = $scope.boost;
+ params.overwrite = $scope.overwrite;
+ params.core = $routeParams.core;
+ params.wt = "json";
+
+ if ($scope.type == "json" || $scope.type == "wizard") {
+ postData = "[" + $scope.document + "]";
+ contentType = "json";
+ } else if ($scope.type == "csv") {
+ postData = $scope.document;
+ contentType = "csv";
+ } else if ($scope.type == "xml") {
+ postData = "<add>" + $scope.document + "</add>";
+ contentType = "xml";
+ } else if ($scope.type == "upload") {
+ doingFileUpload = true;
+ params.raw = $scope.literalParams;
+ } else if ($scope.type == "solr") {
+ postData = $scope.document;
+ if (postData[0] == "<") {
+ contentType = "xml";
+ } else if (postData[0] == "{" || postData[0] == '[') {
+ contentType = "json";
+ } else {
+ alert("Cannot identify content type")
+ }
+ }
+ if (!doingFileUpload) {
+ var callback = function (success) {
+ $scope.responseStatus = "success";
+ delete success.$promise;
+ delete success.$resolved;
+ $scope.response = JSON.stringify(success, null, ' ');
+ };
+ var failure = function (failure) {
+ $scope.responseStatus = failure;
+ };
+ if (contentType == "json") {
+ Update.postJson(params, postData, callback, failure);
+ } else if (contentType == "xml") {
+ Update.postXml(params, postData, callback, failure);
+ } else if (contentType == "csv") {
+ Update.postCsv(params, postData, callback, failure);
+ }
+ } else {
+ var file = $scope.fileUpload;
+ console.log('file is ' + JSON.stringify(file));
+ var uploadUrl = "/fileUpload";
+ FileUpload.upload(params, $scope.fileUpload, function (success) {
+ $scope.responseStatus = "success";
+ $scope.response = JSON.stringify(success, null, ' ');
+ }, function (failure) {
+ $scope.responseStatus = "failure";
+ $scope.response = JSON.stringify(failure, null, ' ');
+ });
+ }
+ }
+ });
+
Propchange: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/documents.js
------------------------------------------------------------------------------
svn:eol-style = native
Modified: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/files.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/files.js?rev=1781731&r1=1781730&r2=1781731&view=diff
==============================================================================
--- ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/files.js (original)
+++ ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/files.js Sun Feb 5 11:09:59 2017
@@ -1,100 +1,100 @@
-/*
- 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 contentTypeMap = { xml : 'text/xml', html : 'text/html', js : 'text/javascript', json : 'application/json', 'css' : 'text/css' };
-var languages = {js: "javascript", xml:"xml", xsl:"xml", vm: "xml", html: "xml", json: "json", css: "css"};
-
-solrAdminApp.controller('FilesController',
- function($scope, $rootScope, $routeParams, $location, Files, Constants) {
- $scope.resetMenu("files", Constants.IS_COLLECTION_PAGE);
-
- $scope.file = $location.search().file;
- $scope.content = null;
-
- $scope.baseurl = $location.protocol()+ "://" + $location.host() + ":" + $location.port();
-
- $scope.refresh = function () {
-
- var process = function (path, tree) {
- var params = {core: $routeParams.core};
- if (path.slice(-1) == '/') {
- params.file = path.slice(0, -1);
- } else if (path!='') {
- params.file = path;
- }
-
- Files.list(params, function (data) {
- var filenames = Object.keys(data.files);
- filenames.sort();
- for (var i in filenames) {
- var file = filenames[i];
- var filedata = data.files[file];
- var state = undefined;
- var children = undefined;
-
- if (filedata.directory) {
- file = file + "/";
- if ($scope.file && $scope.file.indexOf(path + file) == 0) {
- state = "open";
- } else {
- state = "closed";
- }
- children = [];
- process(path + file, children);
- }
- tree.push({
- data: {
- title: file,
- attr: { id: path + file}
- },
- children: children,
- state: state
- });
- }
- });
- }
- $scope.tree = [];
- process("", $scope.tree);
-
- if ($scope.file && $scope.file != '' && $scope.file.split('').pop()!='/') {
- var extension;
- if ($scope.file == "managed-schema") {
- extension = contentTypeMap['xml'];
- } else {
- extension = $scope.file.match( /\.(\w+)$/)[1] || '';
- }
- var contentType = (contentTypeMap[extension] || 'text/plain' ) + ';charset=utf-8';
-
- Files.get({core: $routeParams.core, file: $scope.file, contentType: contentType}, function(data) {
- $scope.content = data.data;
- $scope.url = $scope.baseurl + data.config.url + "?" + $.param(data.config.params);
- if (contentType.indexOf("text/plain") && (data.data.indexOf("<?xml")>=0) || data.data.indexOf("<!--")>=0) {
- $scope.lang = "xml";
- } else {
- $scope.lang = languages[extension] || "txt";
- }
- });
- }
- };
-
- $scope.showTreeLink = function(data) {
- var file = data.args[0].id;
- $location.search({file:file});
- };
-
- $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 contentTypeMap = { xml : 'text/xml', html : 'text/html', js : 'text/javascript', json : 'application/json', 'css' : 'text/css' };
+var languages = {js: "javascript", xml:"xml", xsl:"xml", vm: "xml", html: "xml", json: "json", css: "css"};
+
+solrAdminApp.controller('FilesController',
+ function($scope, $rootScope, $routeParams, $location, Files, Constants) {
+ $scope.resetMenu("files", Constants.IS_COLLECTION_PAGE);
+
+ $scope.file = $location.search().file;
+ $scope.content = null;
+
+ $scope.baseurl = $location.protocol()+ "://" + $location.host() + ":" + $location.port();
+
+ $scope.refresh = function () {
+
+ var process = function (path, tree) {
+ var params = {core: $routeParams.core};
+ if (path.slice(-1) == '/') {
+ params.file = path.slice(0, -1);
+ } else if (path!='') {
+ params.file = path;
+ }
+
+ Files.list(params, function (data) {
+ var filenames = Object.keys(data.files);
+ filenames.sort();
+ for (var i in filenames) {
+ var file = filenames[i];
+ var filedata = data.files[file];
+ var state = undefined;
+ var children = undefined;
+
+ if (filedata.directory) {
+ file = file + "/";
+ if ($scope.file && $scope.file.indexOf(path + file) == 0) {
+ state = "open";
+ } else {
+ state = "closed";
+ }
+ children = [];
+ process(path + file, children);
+ }
+ tree.push({
+ data: {
+ title: file,
+ attr: { id: path + file}
+ },
+ children: children,
+ state: state
+ });
+ }
+ });
+ }
+ $scope.tree = [];
+ process("", $scope.tree);
+
+ if ($scope.file && $scope.file != '' && $scope.file.split('').pop()!='/') {
+ var extension;
+ if ($scope.file == "managed-schema") {
+ extension = contentTypeMap['xml'];
+ } else {
+ extension = $scope.file.match( /\.(\w+)$/)[1] || '';
+ }
+ var contentType = (contentTypeMap[extension] || 'text/plain' ) + ';charset=utf-8';
+
+ Files.get({core: $routeParams.core, file: $scope.file, contentType: contentType}, function(data) {
+ $scope.content = data.data;
+ $scope.url = $scope.baseurl + data.config.url + "?" + $.param(data.config.params);
+ if (contentType.indexOf("text/plain") && (data.data.indexOf("<?xml")>=0) || data.data.indexOf("<!--")>=0) {
+ $scope.lang = "xml";
+ } else {
+ $scope.lang = languages[extension] || "txt";
+ }
+ });
+ }
+ };
+
+ $scope.showTreeLink = function(data) {
+ var file = data.args[0].id;
+ $location.search({file:file});
+ };
+
+ $scope.refresh();
+ });
Propchange: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/files.js
------------------------------------------------------------------------------
svn:eol-style = native
Modified: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/index.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/index.js?rev=1781731&r1=1781730&r2=1781731&view=diff
==============================================================================
--- ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/index.js (original)
+++ ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/index.js Sun Feb 5 11:09:59 2017
@@ -1,97 +1,97 @@
-/*
-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('IndexController', function($scope, System, Cores, Constants) {
- $scope.resetMenu("index", Constants.IS_ROOT_PAGE);
- $scope.reload = function() {
- System.get(function(data) {
- $scope.system = data;
-
- // load average
- var load_average = ( data.system.uptime || '' ).match( /load averages?: (\d+[.,]\d\d),? (\d+[.,]\d\d),? (\d+[.,]\d\d)/ );
- if (load_average) {
- for (var i=0;i<2;i++) {
- load_average[i]=load_average[i].replace(",","."); // for European users
- }
- $scope.load_average = load_average.slice(1);
- }
-
- // physical memory
- var memoryMax = parse_memory_value(data.system.totalPhysicalMemorySize);
- $scope.memoryTotal = parse_memory_value(data.system.totalPhysicalMemorySize - data.system.freePhysicalMemorySize);
- $scope.memoryPercentage = ($scope.memoryTotal / memoryMax * 100).toFixed(1)+ "%";
- $scope.memoryMax = pretty_print_bytes(memoryMax);
- $scope.memoryTotalDisplay = pretty_print_bytes($scope.memoryTotal);
-
- // swap space
- var swapMax = parse_memory_value(data.system.totalSwapSpaceSize);
- $scope.swapTotal = parse_memory_value(data.system.totalSwapSpaceSize - data.system.freeSwapSpaceSize);
- $scope.swapPercentage = ($scope.swapTotal / swapMax * 100).toFixed(1)+ "%";
- $scope.swapMax = pretty_print_bytes(swapMax);
- $scope.swapTotalDisplay = pretty_print_bytes($scope.swapTotal);
-
- // file handles
- $scope.fileDescriptorPercentage = (data.system.openFileDescriptorCount / data.system.maxFileDescriptorCount *100).toFixed(1) + "%";
-
- // java memory
- var javaMemoryMax = parse_memory_value(data.jvm.memory.raw.max || data.jvm.memory.max);
- $scope.javaMemoryTotal = parse_memory_value(data.jvm.memory.raw.total || data.jvm.memory.total);
- $scope.javaMemoryUsed = parse_memory_value(data.jvm.memory.raw.used || data.jvm.memory.used);
- $scope.javaMemoryTotalPercentage = ($scope.javaMemoryTotal / javaMemoryMax *100).toFixed(1) + "%";
- $scope.javaMemoryUsedPercentage = ($scope.javaMemoryUsed / $scope.javaMemoryTotal *100).toFixed(1) + "%";
- $scope.javaMemoryPercentage = ($scope.javaMemoryUsed / javaMemoryMax * 100).toFixed(1) + "%";
- $scope.javaMemoryTotalDisplay = pretty_print_bytes($scope.javaMemoryTotal);
- $scope.javaMemoryUsedDisplay = pretty_print_bytes($scope.javaMemoryUsed); // @todo These should really be an AngularJS Filter: {{ javaMemoryUsed | bytes }}
- $scope.javaMemoryMax = pretty_print_bytes(javaMemoryMax);
-
- // no info bar:
- $scope.noInfo = !(
- data.system.totalPhysicalMemorySize && data.system.freePhysicalMemorySize &&
- data.system.totalSwapSpaceSize && data.system.freeSwapSpaceSize &&
- data.system.openFileDescriptorCount && data.system.maxFileDescriptorCount);
-
- // command line args:
- $scope.commandLineArgs = data.jvm.jmx.commandLineArgs.sort();
- });
- };
- $scope.reload();
-});
-
-var parse_memory_value = function( value ) {
- if( value !== Number( value ) )
- {
- var units = 'BKMGTPEZY';
- var match = value.match( /^(\d+([,\.]\d+)?) (\w).*$/ );
- var value = parseFloat( match[1] ) * Math.pow( 1024, units.indexOf( match[3].toUpperCase() ) );
- }
-
- return value;
-};
-
-var pretty_print_bytes = function(byte_value) {
- var unit = null;
-
- byte_value /= 1024;
- byte_value /= 1024;
- unit = 'MB';
-
- if( 1024 <= byte_value ) {
- byte_value /= 1024;
- unit = 'GB';
- }
- return byte_value.toFixed( 2 ) + ' ' + unit;
-};
+/*
+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('IndexController', function($scope, System, Cores, Constants) {
+ $scope.resetMenu("index", Constants.IS_ROOT_PAGE);
+ $scope.reload = function() {
+ System.get(function(data) {
+ $scope.system = data;
+
+ // load average
+ var load_average = ( data.system.uptime || '' ).match( /load averages?: (\d+[.,]\d\d),? (\d+[.,]\d\d),? (\d+[.,]\d\d)/ );
+ if (load_average) {
+ for (var i=0;i<2;i++) {
+ load_average[i]=load_average[i].replace(",","."); // for European users
+ }
+ $scope.load_average = load_average.slice(1);
+ }
+
+ // physical memory
+ var memoryMax = parse_memory_value(data.system.totalPhysicalMemorySize);
+ $scope.memoryTotal = parse_memory_value(data.system.totalPhysicalMemorySize - data.system.freePhysicalMemorySize);
+ $scope.memoryPercentage = ($scope.memoryTotal / memoryMax * 100).toFixed(1)+ "%";
+ $scope.memoryMax = pretty_print_bytes(memoryMax);
+ $scope.memoryTotalDisplay = pretty_print_bytes($scope.memoryTotal);
+
+ // swap space
+ var swapMax = parse_memory_value(data.system.totalSwapSpaceSize);
+ $scope.swapTotal = parse_memory_value(data.system.totalSwapSpaceSize - data.system.freeSwapSpaceSize);
+ $scope.swapPercentage = ($scope.swapTotal / swapMax * 100).toFixed(1)+ "%";
+ $scope.swapMax = pretty_print_bytes(swapMax);
+ $scope.swapTotalDisplay = pretty_print_bytes($scope.swapTotal);
+
+ // file handles
+ $scope.fileDescriptorPercentage = (data.system.openFileDescriptorCount / data.system.maxFileDescriptorCount *100).toFixed(1) + "%";
+
+ // java memory
+ var javaMemoryMax = parse_memory_value(data.jvm.memory.raw.max || data.jvm.memory.max);
+ $scope.javaMemoryTotal = parse_memory_value(data.jvm.memory.raw.total || data.jvm.memory.total);
+ $scope.javaMemoryUsed = parse_memory_value(data.jvm.memory.raw.used || data.jvm.memory.used);
+ $scope.javaMemoryTotalPercentage = ($scope.javaMemoryTotal / javaMemoryMax *100).toFixed(1) + "%";
+ $scope.javaMemoryUsedPercentage = ($scope.javaMemoryUsed / $scope.javaMemoryTotal *100).toFixed(1) + "%";
+ $scope.javaMemoryPercentage = ($scope.javaMemoryUsed / javaMemoryMax * 100).toFixed(1) + "%";
+ $scope.javaMemoryTotalDisplay = pretty_print_bytes($scope.javaMemoryTotal);
+ $scope.javaMemoryUsedDisplay = pretty_print_bytes($scope.javaMemoryUsed); // @todo These should really be an AngularJS Filter: {{ javaMemoryUsed | bytes }}
+ $scope.javaMemoryMax = pretty_print_bytes(javaMemoryMax);
+
+ // no info bar:
+ $scope.noInfo = !(
+ data.system.totalPhysicalMemorySize && data.system.freePhysicalMemorySize &&
+ data.system.totalSwapSpaceSize && data.system.freeSwapSpaceSize &&
+ data.system.openFileDescriptorCount && data.system.maxFileDescriptorCount);
+
+ // command line args:
+ $scope.commandLineArgs = data.jvm.jmx.commandLineArgs.sort();
+ });
+ };
+ $scope.reload();
+});
+
+var parse_memory_value = function( value ) {
+ if( value !== Number( value ) )
+ {
+ var units = 'BKMGTPEZY';
+ var match = value.match( /^(\d+([,\.]\d+)?) (\w).*$/ );
+ var value = parseFloat( match[1] ) * Math.pow( 1024, units.indexOf( match[3].toUpperCase() ) );
+ }
+
+ return value;
+};
+
+var pretty_print_bytes = function(byte_value) {
+ var unit = null;
+
+ byte_value /= 1024;
+ byte_value /= 1024;
+ unit = 'MB';
+
+ if( 1024 <= byte_value ) {
+ byte_value /= 1024;
+ unit = 'GB';
+ }
+ return byte_value.toFixed( 2 ) + ' ' + unit;
+};
Propchange: ofbiz/trunk/plugins/solr/webapp/solr/js/angular/controllers/index.js
------------------------------------------------------------------------------
svn:eol-style = native