From 6dd228c117cf058e08d1666396ad86758ec971c9 Mon Sep 17 00:00:00 2001 From: Alexandre Rafalovitch Date: Mon, 15 Aug 2016 21:46:59 +1000 Subject: [PATCH] SOLR-8993: Admin UI support multiple DIH handlers Updated Upayavira's patch to the master and fixed one missing parameter --- solr/CHANGES.txt | 2 + .../web/js/angular/controllers/cores.js | 2 +- .../web/js/angular/controllers/dataimport.js | 37 +++++++++++-------- solr/webapp/web/js/angular/services.js | 2 +- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 130c3489328..86c2f084526 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -214,6 +214,8 @@ Bug Fixes * SOLR-9002: Admin UI now correctly displays json and text files in the collection/Files screen (Upayavira, Alexandre Rafalovitch) +* SOLR-8993: Admin UI now correctly supports multiple DIH handler end-points (Upayavira, Alexandre Rafalovitch) + Optimizations ---------------------- diff --git a/solr/webapp/web/js/angular/controllers/cores.js b/solr/webapp/web/js/angular/controllers/cores.js index 41863f2b591..d135395d8f2 100644 --- a/solr/webapp/web/js/angular/controllers/cores.js +++ b/solr/webapp/web/js/angular/controllers/cores.js @@ -17,7 +17,7 @@ // @todo test optimize (delete stuff, watch button appear, test button/form) solrAdminApp.controller('CoreAdminController', - function($scope, $routeParams, $location, $timeout, Cores, Update, Constants){ + 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() { diff --git a/solr/webapp/web/js/angular/controllers/dataimport.js b/solr/webapp/web/js/angular/controllers/dataimport.js index a051ad2178b..ce712ecb84b 100644 --- a/solr/webapp/web/js/angular/controllers/dataimport.js +++ b/solr/webapp/web/js/angular/controllers/dataimport.js @@ -39,20 +39,24 @@ solrAdminApp.controller('DataImportController', } }); - DataImport.config({core: $routeParams.core}, function (data) { - try { - var xml = $.parseXML(data.config); - } catch (err) { - $scope.hasHandlers = false; - return; - } - $scope.config = data.config; - $scope.entities = []; - $('document > entity', xml).each(function (i, element) { - $scope.entities.push($(element).attr('name')); + $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')); + }); + } catch (err) { + console.log(err); + } }); - }); - + } $scope.lastUpdate = "unknown"; $scope.lastUpdateUTC = ""; @@ -81,7 +85,7 @@ solrAdminApp.controller('DataImportController', } $scope.reload = function () { - DataImport.reload({core: $routeParams.core}, function () { + DataImport.reload({core: $routeParams.core, name: $scope.handler}, function () { $scope.reloaded = true; $timeout(function () { $scope.reloaded = false; @@ -126,6 +130,7 @@ solrAdminApp.controller('DataImportController', } params.core = $routeParams.core; + params.name = $scope.handler; DataImport.post(params, function (data) { $scope.rawResponse = JSON.stringify(data, null, 2); @@ -135,7 +140,7 @@ solrAdminApp.controller('DataImportController', $scope.abort = function () { $scope.isAborting = true; - DataImport.abort({core: $routeParams.core}, function () { + DataImport.abort({core: $routeParams.core, name: $scope.handler}, function () { $timeout(function () { $scope.isAborting = false; $scope.refreshStatus(); @@ -148,7 +153,7 @@ solrAdminApp.controller('DataImportController', console.log("Refresh Status"); $scope.isStatusLoading = true; - DataImport.status({core: $routeParams.core}, function (data) { + DataImport.status({core: $routeParams.core, name: $scope.handler}, function (data) { if (data[0] == "<") { $scope.hasHandlers = false; return; diff --git a/solr/webapp/web/js/angular/services.js b/solr/webapp/web/js/angular/services.js index 2413f946836..146939bec30 100644 --- a/solr/webapp/web/js/angular/services.js +++ b/solr/webapp/web/js/angular/services.js @@ -162,7 +162,7 @@ solrAdminServices.factory('System', }]) .factory('DataImport', ['$resource', function($resource) { - return $resource('/solr/:core/dataimport', {core: '@core', indent:'on', wt:'json', _:Date.now()}, { + return $resource('/solr/:core/:name', {core: '@core', name: '@name', indent:'on', wt:'json', _:Date.now()}, { "config": {params: {command: "show-config"}, headers: {doNotIntercept: "true"}, transformResponse: function(data) { return {config: data};