From 2aec8731a47bbc973beb8a0360e626e053da1385 Mon Sep 17 00:00:00 2001 From: Stefan Matheis Date: Sun, 17 Nov 2013 13:23:23 +0000 Subject: [PATCH] SOLR-5446: Admin UI - Allow changing Schema and Config git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1542720 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 2 + solr/webapp/web/admin.html | 1 + solr/webapp/web/css/styles/cloud.css | 6 - solr/webapp/web/css/styles/common.css | 6 + solr/webapp/web/css/styles/files.css | 102 +++++++ solr/webapp/web/css/styles/menu.css | 1 + solr/webapp/web/img/ico/drive-upload.png | Bin 0 -> 746 bytes .../web/js/lib/jquery.ajaxfileupload.js | 2 + solr/webapp/web/js/main.js | 1 + solr/webapp/web/js/require.js | 3 +- solr/webapp/web/js/scripts/app.js | 1 + solr/webapp/web/js/scripts/files.js | 254 ++++++++++++++++++ solr/webapp/web/tpl/files.html | 50 ++++ 13 files changed, 422 insertions(+), 7 deletions(-) create mode 100644 solr/webapp/web/css/styles/files.css create mode 100644 solr/webapp/web/img/ico/drive-upload.png create mode 100644 solr/webapp/web/js/scripts/files.js create mode 100644 solr/webapp/web/tpl/files.html diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 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.html index 13ee241b093..1180658a16f 100644 --- a/solr/webapp/web/admin.html +++ b/solr/webapp/web/admin.html @@ -30,6 +30,7 @@ limitations under the License. + diff --git a/solr/webapp/web/css/styles/cloud.css b/solr/webapp/web/css/styles/cloud.css index 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.css index 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 .formula background:#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.css new file mode 100644 index 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 file diff --git a/solr/webapp/web/css/styles/menu.css b/solr/webapp/web/css/styles/menu.css index 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.png new file mode 100644 index 0000000000000000000000000000000000000000..93589e4da36620cdb65ac61873c97c76dd5fd355 GIT binary patch literal 746 zcmV1&W>84^hl#VOYFJ#X2yELbG1 z^bY$=b1=4x;W@7N`a{Idj-!jj3j*Zs?iL^#&4A-_;ZzVjacz5%0W4id)AwQS6k(8r z;rq`aCHh-5o`)ETKoEos4dw1-hSbzh_rUt*;l&^b%D(S^_FR{EL3oBem`6uZGh^F! z?#|6&wNf!rE*qGh>{rvhiaCk`7%?r!G1>Nq}h-9WXvOWMbkbF#{Moen1Z>xU$>;B3m~Do+`) zpb7BD!I^`6n~X-+AP&(Bqh4oQTf3Yr?8*WIY|{H67LTLX{SL*fgh7UYzJrxk7(^cw zMI3Rbu!2dpRjlx_y}f7v+cdwi4b@yiPjCRw^Fo&=UV#-Gm<(31?5b;8AeMCj@NBy_ zB^A)a9d(X_%Vx7}2MT@vTeMX0?`qI}cufu(p@X&+`n^3nJNq;qkEbllglQTii|qRB zIV6b`fngY13kxsE7hZ*cYPE_)BEiNI5$0j*w8H|vk(4Ot!!N2x}} zy1Keeu#wTx3!w|!cK&i;zV)&8wYXic*Q2FUsgLEsIz6NTa&SqKq|5k^a$R?w9DJf> c^``&>09jXAhv@$a5&!@I07*qoM6N<$g4fw%X8-^I literal 0 HcmV?d00001 diff --git a/solr/webapp/web/js/lib/jquery.ajaxfileupload.js b/solr/webapp/web/js/lib/jquery.ajaxfileupload.js index 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 settings if ($element.data('ajaxUploader-setup') === true) return; + /* $element.change(function () { // since a new image was selected, reset the marker uploading_file = false; @@ -159,6 +160,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI upload_file(); } }); + //*/ if (settings.submit_button == null) { // do nothing diff --git a/solr/webapp/web/js/main.js b/solr/webapp/web/js/main.js index 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.js index 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 done diff --git a/solr/webapp/web/js/scripts/app.js b/solr/webapp/web/js/scripts/app.js index 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 ) '
  • Config
  • ' + "\n" + '
  • Dataimport
  • ' + "\n" + '
  • Documents
  • ' + "\n" + + '
  • Files
  • ' + "\n" + '
  • Ping
  • ' + "\n" + '
  • Plugins / Stats
  • ' + "\n" + '
  • Query
  • ' + "\n" + diff --git a/solr/webapp/web/js/scripts/files.js b/solr/webapp/web/js/scripts/files.js new file mode 100644 index 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 file diff --git a/solr/webapp/web/tpl/files.html b/solr/webapp/web/tpl/files.html new file mode 100644 index 00000000000..6d0f63bf50b --- /dev/null +++ b/solr/webapp/web/tpl/files.html @@ -0,0 +1,50 @@ + +
    + +
    + +
    #tree
    +
    + + + +
    + + + +
    + +
    + +
    + +
    + + + +
    + +
    + +
    + +
    + +
    + +
    \ No newline at end of file