You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by st...@apache.org on 2013/11/18 11:32:00 UTC
svn commit: r1542968 - in /lucene/dev/branches/branch_4x: ./ solr/
solr/CHANGES.txt solr/webapp/ solr/webapp/web/css/styles/files.css
solr/webapp/web/js/scripts/files.js solr/webapp/web/tpl/files.html
Author: steffkes
Date: Mon Nov 18 10:31:59 2013
New Revision: 1542968
URL: http://svn.apache.org/r1542968
Log:
SOLR-5456: Admin UI - Allow creating new Files (merge r1542967)
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/solr/ (props changed)
lucene/dev/branches/branch_4x/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_4x/solr/webapp/ (props changed)
lucene/dev/branches/branch_4x/solr/webapp/web/css/styles/files.css
lucene/dev/branches/branch_4x/solr/webapp/web/js/scripts/files.js
lucene/dev/branches/branch_4x/solr/webapp/web/tpl/files.html
Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1542968&r1=1542967&r2=1542968&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Mon Nov 18 10:31:59 2013
@@ -57,6 +57,8 @@ New Features
* SOLR-5446: Admin UI - Allow changing Schema and Config (steffkes)
+* SOLR-5456: Admin UI - Allow creating new Files (steffkes)
+
Bug Fixes
----------------------
Modified: lucene/dev/branches/branch_4x/solr/webapp/web/css/styles/files.css
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/webapp/web/css/styles/files.css?rev=1542968&r1=1542967&r2=1542968&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/webapp/web/css/styles/files.css (original)
+++ lucene/dev/branches/branch_4x/solr/webapp/web/css/styles/files.css Mon Nov 18 10:31:59 2013
@@ -17,56 +17,72 @@ limitations under the License.
*/
-#content #files #tree
+#content #files #tree-holder
{
float: left;
width: 20%;
}
-#content #files .show #tree
+#content #files #new-file-holder
{
- overflow: hidden;
+ margin-top: 20px;
+ padding-bottom: 10px;
}
-#content #files #file-content
+#content #files #new-file-holder button span
{
+ background-image: url( ../../img/ico/plus-button.png );
+}
+
+#content #files #new-file-holder form
+{
+ box-shadow: 5px 5px 10px #c0c0c0;
+ -moz-box-shadow: 5px 5px 10px #c0c0c0;
+ -webkit-box-shadow: 5px 5px 10px #c0c0c0;
display: none;
- float: right;
- position: relative;
- width: 78%;
- min-height: 100px
+ padding: 10px;
}
-#content #files .show #file-content
+#content #files #new-file-holder form input
{
- display: block;
+ margin-bottom: 3px;
+ width: 98%;
}
-#content #files #file-content .close
+#content #files #new-file-holder .note
{
- background-image: url( ../../img/ico/cross-0.png );
- background-position: 50% 50%;
- display: block;
- height: 20px;
- position: absolute;
- right: 0;
- top: 0;
- width: 20px;
+ color: #c0c0c0;
+ margin-bottom: 5px;
}
-#content #files #file-content .close:hover
+#content #files form .buttons button
{
- background-image: url( ../../img/ico/cross-1.png );
+ float: right;
}
-#content #files #file-content .close span
+#content #files #file-content
{
display: none;
+ float: right;
+ position: relative;
+ width: 78%;
+ min-height: 100px
}
-#content #files #file-content form .buttons button
+#content #files .show #file-content
{
- float: right;
+ display: block;
+}
+
+#content #files #new-file-note
+{
+ background-color: #ffa662;
+ background-image: url( ../../img/ico/exclamation-button.png );
+ background-position: 10px 50%;
+ display: none;
+ margin-bottom: 10px;
+ padding: 10px;
+ padding-left: 31px;
}
#content #files #file-content textarea
Modified: lucene/dev/branches/branch_4x/solr/webapp/web/js/scripts/files.js
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/webapp/web/js/scripts/files.js?rev=1542968&r1=1542967&r2=1542968&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/webapp/web/js/scripts/files.js (original)
+++ lucene/dev/branches/branch_4x/solr/webapp/web/js/scripts/files.js Mon Nov 18 10:31:59 2013
@@ -27,6 +27,7 @@ sammy.get
var content_element = $( '#content' );
var file_endpoint = core_basepath + '/admin/file';
+ var file_exists = null;
var path = context.path.split( '?' );
var selected_file = null;
@@ -70,74 +71,118 @@ sammy.get
}
};
- $( '#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 = [];
+ var load_tree = function()
+ {
+ $( '#tree', frame_element )
+ .empty()
+ .jstree
+ (
+ {
+ plugins : [ 'json_data', 'sort' ],
+ json_data : {
+ ajax: {
+ url : file_endpoint + '?wt=json',
+ data : function( n )
+ {
+ if( -1 === n )
+ return null;
- for( var file in response.files )
+ return {
+ file : n.attr( 'data-file' )
+ };
+ },
+ success : function( response, status, xhr )
{
- var is_directory = response.files[file].directory;
- var prefix = xhr.data ? xhr.data.file + '/' : ''
+ 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,
+ var item = {
+ data: {
+ title : file,
+ attr : {
+ href : '#/' + current_core + '/files?file=' + prefix + file
+ }
+ },
attr : {
- href : '#/' + current_core + '/files?file=' + prefix + file
+ 'data-file' : prefix + file
}
- },
- attr : {
- 'data-file' : prefix + file
+ };
+
+ if( is_directory )
+ {
+ item.state = 'closed';
+ item.data.attr.href += '/';
}
- };
- if( is_directory )
- {
- item.state = 'closed';
- item.data.attr.href += '/';
+ files.push( item );
}
- files.push( item );
+ return files;
}
-
- return files;
- }
+ },
+ progressive_render : true
},
- progressive_render : true
- },
- core : {
- animation : 0
+ core : {
+ animation : 0
+ }
}
- }
- )
+ )
+ .on
+ (
+ 'loaded.jstree',
+ tree_callback
+ )
+ .on
+ (
+ 'open_node.jstree',
+ tree_callback
+ );
+ };
+ load_tree();
+
+ var new_file_form = $( '#new-file-holder form' );
+
+ $( '#new-file-holder > button' )
.on
(
- 'loaded.jstree',
- tree_callback
- )
+ 'click',
+ function( event )
+ {
+ new_file_form.toggle();
+ return false;
+ }
+ );
+
+ new_file_form
.on
(
- 'open_node.jstree',
- tree_callback
+ 'submit',
+ function( event )
+ {
+ $( 'body' )
+ .animate( { scrollTop: 0 }, 500 );
+
+ window.location.href = '#/' + current_core + '/files?file=' + $( 'input', this ).val();
+
+ return false;
+ }
);
+ if( selected_file )
+ {
+ $( '#new-file-holder input' )
+ .val
+ (
+ '/' !== selected_file.substr( -1 )
+ ? selected_file.replace( /[^\/]+$/, '' )
+ : selected_file
+ );
+ }
+
if( selected_file && '/' !== selected_file.substr( -1 ) )
{
frame_element
@@ -173,6 +218,8 @@ sammy.get
button
.addClass( 'success' );
+ load_file( !file_exists );
+
window.setTimeout
(
function()
@@ -186,10 +233,53 @@ sammy.get
}
);
- var load_file = function()
+ var change_button_label = function( form, label )
+ {
+ $( 'span[data-' + label + ']', form )
+ .each
+ (
+ function( index, element )
+ {
+ var self = $( this );
+ self.text( self.data( label ) );
+ }
+ );
+ }
+
+ var load_file = function( load_tree )
{
- $( 'form textarea', frame_element )
- .load( endpoint );
+ if( load_tree )
+ {
+ load_tree();
+ }
+
+ $.ajax
+ (
+ {
+ url : endpoint,
+ context : $( 'form', frame_element ),
+ beforeSend : function( xhr, settings )
+ {
+ },
+ success : function( response, text_status, xhr )
+ {
+ change_button_label( this, 'existing-title' );
+
+ $( 'textarea', this )
+ .val( xhr.responseText );
+ },
+ error : function( xhr, text_status, error_thrown)
+ {
+ change_button_label( this, 'new-title' );
+ },
+ complete : function( xhr, text_status )
+ {
+ file_exists = 200 === xhr.status;
+ $( '#new-file-note' )
+ .toggle( !file_exists );
+ }
+ }
+ );
}
load_file();
@@ -226,7 +316,7 @@ sammy.get
button
.addClass( 'success' );
- load_file();
+ load_file( !file_exists );
$( 'body' )
.animate( { scrollTop: 0 }, 500 );
Modified: lucene/dev/branches/branch_4x/solr/webapp/web/tpl/files.html
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/webapp/web/tpl/files.html?rev=1542968&r1=1542967&r2=1542968&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/webapp/web/tpl/files.html (original)
+++ lucene/dev/branches/branch_4x/solr/webapp/web/tpl/files.html Mon Nov 18 10:31:59 2013
@@ -18,11 +18,35 @@ limitations under the License.
<div id="frame">
- <div id="tree" class="tree">#tree</div>
+ <div id="tree-holder">
+
+ <div id="tree" class="tree">#tree</div>
+
+ <div id="new-file-holder">
+
+ <button><span>Create new file</span></button>
+
+ <form method="get">
+
+ <p class="note">Enter filename, on the next page you can input content or upload a file.</p>
+
+ <input type="text" name="file" placeholder="sample.xml">
+
+ <div class="buttons clearfix">
+ <button type="submit">Next âº</button>
+ </div>
+
+ </form>
+
+ </div>
+
+ </div>
<div id="file-content" class="clearfix">
<a id="url" class="address-bar" href="#"></a>
+ <p id="new-file-note">The requested file does (not yet) exist. <strong>Save file</strong> or <strong>Upload new file</strong> will create it.</p>
+
<form method="post" class="modify">
<textarea name="stream.body"></textarea>
@@ -38,7 +62,7 @@ limitations under the License.
<input type="file" name="fileupload">
<div class="buttons clearfix">
- <button><span>Replace current file</span></button>
+ <button><span data-new-title="Upload new file" data-existing-title="Replace current file">Replace current file</span></button>
</div>
</form>