Apache Lucene open-source search software
SOLR-5446: Admin UI - Allow changing Schema and Config
Stefan Matheis2aec8731a47b
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex d63ea8bb02c..c1244373ce4 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -87,6 +87,8 @@ New Features* SOLR-5447: Add a QParserPlugin for Lucene's SimpleQueryParser.(Jack Conradson via shalin)+* SOLR-5446: Admin UI - Allow changing Schema and Config (steffkes)+Bug Fixes----------------------diff --git a/solr/webapp/web/admin.html b/solr/webapp/web/admin.htmlindex 13ee241b093..1180658a16f 100644--- a/solr/webapp/web/admin.html+++ b/solr/webapp/web/admin.html@@ -30,6 +30,7 @@ limitations under the License.<link rel="stylesheet" type="text/css" href="css/styles/cores.css?_=${version}"><link rel="stylesheet" type="text/css" href="css/styles/dashboard.css?_=${version}"><link rel="stylesheet" type="text/css" href="css/styles/dataimport.css?_=${version}">+ <link rel="stylesheet" type="text/css" href="css/styles/files.css?_=${version}"><link rel="stylesheet" type="text/css" href="css/styles/index.css?_=${version}"><link rel="stylesheet" type="text/css" href="css/styles/java-properties.css?_=${version}"><link rel="stylesheet" type="text/css" href="css/styles/logging.css?_=${version}">diff --git a/solr/webapp/web/css/styles/cloud.css b/solr/webapp/web/css/styles/cloud.cssindex 912143214eb..ac275298b38 100644--- a/solr/webapp/web/css/styles/cloud.css+++ b/solr/webapp/web/css/styles/cloud.css@@ -244,12 +244,6 @@ limitations under the License./* tree */-#content #cloud .tree a.active-{- background-color: #f0f0f0;- color: #00f;-}-#content #cloud #legend{border: 1px solid #f0f0f0;diff --git a/solr/webapp/web/css/styles/common.css b/solr/webapp/web/css/styles/common.cssindex 8e671caf706..8dcfeb2dd2c 100644--- a/solr/webapp/web/css/styles/common.css+++ b/solr/webapp/web/css/styles/common.css@@ -606,6 +606,12 @@ pre.syntax .tex .formulabackground:#beebff; border:1px solid #99defd; padding:0 2px 0 1px;}+#content .tree a.active+{+ background-color: #f0f0f0;+ color: #00f;+}+#content .tree a .jstree-icon{background-image: url( ../../img/ico/folder.png );diff --git a/solr/webapp/web/css/styles/files.css b/solr/webapp/web/css/styles/files.cssnew file mode 100644index 00000000000..8e11588fd7d--- /dev/null+++ b/solr/webapp/web/css/styles/files.css@@ -0,0 +1,102 @@+/*++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.++*/++#content #files #tree+{+ float: left;+ width: 20%;+}++#content #files .show #tree+{+ overflow: hidden;+}++#content #files #file-content+{+ display: none;+ float: right;+ position: relative;+ width: 78%;+ min-height: 100px+}++#content #files .show #file-content+{+ display: block;+}++#content #files #file-content .close+{+ background-image: url( ../../img/ico/cross-0.png );+ background-position: 50% 50%;+ display: block;+ height: 20px;+ position: absolute;+ right: 0;+ top: 0;+ width: 20px;+}++#content #files #file-content .close:hover+{+ background-image: url( ../../img/ico/cross-1.png );+}++#content #files #file-content .close span+{+ display: none;+}++#content #files #file-content form .buttons button+{+ float: right;+}++#content #files #file-content textarea+{+ display: block;+ height: 500px;+ margin-bottom: 10px;+ width: 99%;+}++#content #files #file-content button span+{+ background-image: url( ../../img/ico/disk-black.png );+}++#content #files #file-content form.upload+{+ border-top: 1px solid #c0c0c0;+ margin-top: 20px;+ padding-top: 20px;+ padding-bottom: 20px;+}++#content #files #file-content .upload input+{+ border: 0;+ float: left;+}++#content #files #file-content .upload button span+{+ background-image: url( ../../img/ico/drive-upload.png );+}\ No newline at end of filediff --git a/solr/webapp/web/css/styles/menu.css b/solr/webapp/web/css/styles/menu.cssindex 5e8057024c9..4fba2e86974 100644--- a/solr/webapp/web/css/styles/menu.css+++ b/solr/webapp/web/css/styles/menu.css@@ -275,6 +275,7 @@ limitations under the License.#core-menu .config a { background-image: url( ../../img/ico/gear.png ); }#core-menu .analysis a { background-image: url( ../../img/ico/funnel.png ); }#core-menu .documents a { background-image: url( ../../img/ico/documents-stack.png ); }+#core-menu .files a { background-image: url( ../../img/ico/folder.png ); }#core-menu .schema-browser a { background-image: url( ../../img/ico/book-open-text.png ); }#core-menu .replication a { background-image: url( ../../img/ico/node.png ); }#core-menu .distribution a { background-image: url( ../../img/ico/node-select.png ); }diff --git a/solr/webapp/web/img/ico/drive-upload.png b/solr/webapp/web/img/ico/drive-upload.pngnew file mode 100644index 00000000000..93589e4da36Binary files /dev/null and b/solr/webapp/web/img/ico/drive-upload.png differdiff --git a/solr/webapp/web/js/lib/jquery.ajaxfileupload.js b/solr/webapp/web/js/lib/jquery.ajaxfileupload.jsindex eb538534fe2..0488bf97a0c 100644--- a/solr/webapp/web/js/lib/jquery.ajaxfileupload.js+++ b/solr/webapp/web/js/lib/jquery.ajaxfileupload.js@@ -149,6 +149,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI// with uninit() later, to allow updating that settingsif ($element.data('ajaxUploader-setup') === true) return;+ /*$element.change(function () {// since a new image was selected, reset the markeruploading_file = false;@@ -159,6 +160,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIupload_file();}});+ //*/if (settings.submit_button == null) {// do nothingdiff --git a/solr/webapp/web/js/main.js b/solr/webapp/web/js/main.jsindex 792a185851b..c9b09952450 100644--- a/solr/webapp/web/js/main.js+++ b/solr/webapp/web/js/main.js@@ -41,6 +41,7 @@ require'lib/order!scripts/dataimport','lib/order!scripts/dashboard','lib/order!scripts/file',+ 'lib/order!scripts/files','lib/order!scripts/index','lib/order!scripts/java-properties','lib/order!scripts/logging',diff --git a/solr/webapp/web/js/require.js b/solr/webapp/web/js/require.jsindex 8ee0051c79a..9ddc7c314f9 100644--- a/solr/webapp/web/js/require.js+++ b/solr/webapp/web/js/require.js@@ -9388,7 +9388,8 @@ jQuery.extend({return this;},- url : s.url+ url : s.url,+ data : s.data};// Callback for when everything is donediff --git a/solr/webapp/web/js/scripts/app.js b/solr/webapp/web/js/scripts/app.jsindex 1d797aa2759..2ea303d98b6 100644--- a/solr/webapp/web/js/scripts/app.js+++ b/solr/webapp/web/js/scripts/app.js@@ -367,6 +367,7 @@ var solr_admin = function( app_config )'<li class="config"><a href="#/' + core_name + '/config"><span>Config</span></a></li>' + "\n" +'<li class="dataimport"><a href="#/' + core_name + '/dataimport"><span>Dataimport</span></a></li>' + "\n" +'<li class="documents"><a href="#/' + core_name + '/documents"><span>Documents</span></a></li>' + "\n" ++ '<li class="files"><a href="#/' + core_name + '/files"><span>Files</span></a></li>' + "\n" +'<li class="ping"><a rel="' + that.config.solr_path + '/' + core_name + '/admin/ping"><span>Ping</span></a></li>' + "\n" +'<li class="plugins"><a href="#/' + core_name + '/plugins"><span>Plugins / Stats</span></a></li>' + "\n" +'<li class="query"><a href="#/' + core_name + '/query"><span>Query</span></a></li>' + "\n" +diff --git a/solr/webapp/web/js/scripts/files.js b/solr/webapp/web/js/scripts/files.jsnew file mode 100644index 00000000000..02f2a945ffb--- /dev/null+++ b/solr/webapp/web/js/scripts/files.js@@ -0,0 +1,254 @@+/*+ 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.+*/++// #/:core/files+sammy.get+(+ new RegExp( app.core_regex_base + '\\/(files)$' ),+ function( context )+ {+ core_basepath = this.active_core.attr( 'data-basepath' );+ current_core = context.params.splat[0];++ var content_element = $( '#content' );++ var file_endpoint = core_basepath + '/admin/file';++ var path = context.path.split( '?' );+ var selected_file = null;+ if( path && path[1] )+ {+ selected_file = path[1].split( '=' ).pop();+ }++ $.get+ (+ 'tpl/files.html',+ function( template )+ {+ content_element+ .html( template );++ var frame_element = $( '#frame', content_element );++ var tree_callback = function( event, data )+ {+ $( 'li[data-file].jstree-closed', event.currentTarget )+ .filter+ (+ function( index, element )+ {+ return selected_file && 0 === selected_file.indexOf( $( element ).data( 'file' ) );+ }+ )+ .each+ (+ function( index, element )+ {+ data.inst.open_node( element );+ }+ );++ if( selected_file )+ {+ $( 'li[data-file="' + selected_file.replace( /\/$/, '' ) + '"] > a', event.currentTarget )+ .addClass( 'active' );+ }+ };++ $( '#tree', frame_element )+ .jstree+ (+ {+ plugins : [ 'json_data', 'sort' ],+ json_data : {+ ajax: {+ url : file_endpoint + '?wt=json',+ data : function( n )+ {+ if( -1 === n )+ return null;++ return {+ file : n.attr( 'data-file' )+ };+ },+ success : function( response, status, xhr )+ {+ var files = [];++ for( var file in response.files )+ {+ var is_directory = response.files[file].directory;+ var prefix = xhr.data ? xhr.data.file + '/' : ''++ var item = {+ data: {+ title : file,+ attr : {+ href : '#/' + current_core + '/files?file=' + prefix + file+ }+ },+ attr : {+ 'data-file' : prefix + file+ }+ };++ if( is_directory )+ {+ item.state = 'closed';+ item.data.attr.href += '/';+ }++ files.push( item );+ }++ return files;+ }+ },+ progressive_render : true+ },+ core : {+ animation : 0+ }+ }+ )+ .on+ (+ 'loaded.jstree',+ tree_callback+ )+ .on+ (+ 'open_node.jstree',+ tree_callback+ );++ if( selected_file && '/' !== selected_file.substr( -1 ) )+ {+ frame_element+ .addClass( 'show' );++ var endpoint = file_endpoint + '?file=' + selected_file;+ var public_url = window.location.protocol + '//' + window.location.host + endpoint;++ $( '#url', frame_element )+ .text( public_url )+ .attr( 'href', public_url );++ var form = $( 'form.modify', frame_element );++ form+ .attr( 'action', file_endpoint + '?wt=json&op=write&file=' + selected_file )+ .ajaxForm+ (+ {+ context : form,+ beforeSubmit: function( arr, form, options )+ {+ $( 'button span', form )+ .addClass( 'loader' );+ },+ success : function( response, status, xhr )+ {+ $( 'button span', this )+ .removeClass( 'loader' );++ var button = $( 'button', this );++ button+ .addClass( 'success' );++ window.setTimeout+ (+ function()+ {+ button+ .removeClass( 'success' );+ },+ 1000+ );+ }+ }+ );++ var load_file = function()+ {+ $( 'form textarea', frame_element )+ .load( endpoint );+ }+ load_file();++ $( 'form.upload', frame_element )+ .on+ (+ 'submit',+ function( event )+ {+ $( 'form input', frame_element )+ .ajaxfileupload+ (+ {+ action: endpoint + '&op=write&wt=json',+ validate_extensions: false,+ upload_now: true,+ onStart: function ()+ {+ $( 'form.upload button span', frame_element )+ .addClass( 'loader' );+ },+ onCancel: function ()+ {+ $( 'form.upload button span', frame_element )+ .removeClass( 'loader' );+ },+ onComplete: function( response )+ {+ $( 'form.upload button span', frame_element )+ .removeClass( 'loader' );++ var button = $( 'form.upload button', frame_element );++ button+ .addClass( 'success' );++ load_file();++ $( 'body' )+ .animate( { scrollTop: 0 }, 500 );++ window.setTimeout+ (+ function()+ {+ button+ .removeClass( 'success' );+ },+ 1000+ );+ }+ }+ );++ return false;+ }+ );+ }+ }+ );+ }+);\ No newline at end of filediff --git a/solr/webapp/web/tpl/files.html b/solr/webapp/web/tpl/files.htmlnew file mode 100644index 00000000000..6d0f63bf50b--- /dev/null+++ b/solr/webapp/web/tpl/files.html@@ -0,0 +1,50 @@+<!--+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.+-->+<div id="files" class="clearfix">++ <div id="frame">++ <div id="tree" class="tree">#tree</div>+ <div id="file-content" class="clearfix">++ <a id="url" class="address-bar" href="#"></a>++ <form method="post" class="modify">++ <textarea name="stream.body"></textarea>++ <div class="buttons clearfix">+ <button type="submit"><span>Save file</span></button>+ </div>++ </form>++ <form method="post" class="upload">++ <input type="file" name="fileupload">++ <div class="buttons clearfix">+ <button><span>Replace current file</span></button>+ </div>++ </form>++ </div>++ </div>++</div>\ No newline at end of file