From cbe235516d21705ab91ab3fa20032ed0e4f865d2 Mon Sep 17 00:00:00 2001 From: Grant Ingersoll Date: Wed, 26 Jun 2013 16:27:43 +0000 Subject: [PATCH] SOLR-4921: UI now supports adding documents to a collection git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1496994 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 2 + solr/webapp/web/admin.html | 1 + solr/webapp/web/css/styles/documents.css | 178 +++++++++ solr/webapp/web/css/styles/menu.css | 1 + solr/webapp/web/img/ico/documents-stack.png | Bin 0 -> 594 bytes .../web/js/lib/jquery.ajaxfileupload.js | 182 +++++++++ solr/webapp/web/js/main.js | 2 + solr/webapp/web/js/scripts/app.js | 30 +- solr/webapp/web/js/scripts/documents.js | 370 ++++++++++++++++++ solr/webapp/web/tpl/documents.html | 107 +++++ 10 files changed, 859 insertions(+), 14 deletions(-) create mode 100644 solr/webapp/web/css/styles/documents.css create mode 100644 solr/webapp/web/img/ico/documents-stack.png create mode 100644 solr/webapp/web/js/lib/jquery.ajaxfileupload.js create mode 100644 solr/webapp/web/js/scripts/documents.js create mode 100644 solr/webapp/web/tpl/documents.html diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 3e72788b93e..27e4606b26e 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -116,6 +116,8 @@ New Features false to an update processor's configuration in solrconfig.xml. (Steve Rowe, hossman) +* SOLR-4921: Admin UI now supports adding documents to Solr (gsingers, steffkes) + Bug Fixes ---------------------- diff --git a/solr/webapp/web/admin.html b/solr/webapp/web/admin.html index c99f7f9e0f0..2db54e958a3 100644 --- a/solr/webapp/web/admin.html +++ b/solr/webapp/web/admin.html @@ -35,6 +35,7 @@ limitations under the License. + diff --git a/solr/webapp/web/css/styles/documents.css b/solr/webapp/web/css/styles/documents.css new file mode 100644 index 00000000000..ac7e5162212 --- /dev/null +++ b/solr/webapp/web/css/styles/documents.css @@ -0,0 +1,178 @@ +#content #documents +{ + background-image: url( ../../img/div.gif ); + background-position: 45% 0; + background-repeat: repeat-y; +} + +#content #documents #form +{ + float: left; + /*width: 21%;*/ +} + +#content #documents #form label +{ + cursor: pointer; + display: block; + margin-top: 5px; +} + +#content #documents #form input, +#content #documents #form select, +#content #documents #form textarea +{ + margin-bottom: 2px; + /*width: 100%;*/ +} + +#content #documents #form input, +#content #documents #form textarea +{ + margin-bottom: 2px; + /*width: 98%;*/ +} + +#content #documents #form #start +{ + float: left; + /*width: 45%;*/ +} + +#content #documents #form #rows +{ + float: right; + /* width: 45%;*/ +} + +#content #documents #form .checkbox input +{ + margin-bottom: 0; + width: auto; +} + +#content #documents #form fieldset, +#content #documents #form .optional.expanded +{ + border: 1px solid #fff; + border-top: 1px solid #c0c0c0; + margin-bottom: 5px; +} + +#content #documents #form fieldset.common +{ + margin-top: 10px; +} + +#content #documents #form fieldset legend, +#content #documents #form .optional.expanded legend +{ + display: block; + margin-left: 10px; + padding: 0px 5px; +} + +#content #documents #form fieldset legend label +{ + margin-top: 0; +} + +#content #documents #form fieldset .fieldset +{ + border-bottom: 1px solid #f0f0f0; + margin-bottom: 5px; + padding-bottom: 10px; +} + +#content #documents #form .optional +{ + border: 0; +} + +#content #documents #form .optional .fieldset +{ + display: none; +} + +#content #documents #form .optional legend +{ + margin-left: 0; + padding-left: 0; +} + +#content #documents #form .optional.expanded .fieldset +{ + display: block; +} + +#content #documents #file-upload{ + display: none; +} + +#content #documents #result +{ + display: none; + float: right; + width: 54%; +} + +#content #documents #result #url +{ + margin-bottom: 10px; + background-image: url( ../../img/ico/ui-address-bar.png ); + background-position: 5px 50%; + border: 1px solid #f0f0f0; + box-shadow: 1px 1px 0 #f0f0f0; + -moz-box-shadow: 1px 1px 0 #f0f0f0; + -webkit-box-shadow: 1px 1px 0 #f0f0f0; + color: #c0c0c0; + display: block; + overflow: hidden; + padding: 5px; + padding-left: 26px; + white-space: nowrap; +} + +#content #documents #result #url:focus, +#content #documents #result #url:hover +{ + border-color: #c0c0c0; + box-shadow: 1px 1px 0 #d8d8d8; + -moz-box-shadow: 1px 1px 0 #d8d8d8; + -webkit-box-shadow: 1px 1px 0 #d8d8d8; + color: #333; +} + +#content #documents #result #response +{ +} + +#content #documents #result #response pre +{ + padding-left: 20px; +} + +.description{ + font-weight: bold; +} + +#upload-only{ + display: none; +} + +#document-type{ + padding-bottom: 5px; +} + +#wizard{ + display: none; +} + +#wizard-fields div{ + padding-top: 5px; + padding-bottom: 5px; +} + +#wiz-field-data, #wiz-field-data span{ + vertical-align: top; +} \ 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 dfa54b296fe..c99cd815cf5 100644 --- a/solr/webapp/web/css/styles/menu.css +++ b/solr/webapp/web/css/styles/menu.css @@ -239,6 +239,7 @@ #core-menu .schema a { background-image: url( ../../img/ico/table.png ); } #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 .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/documents-stack.png b/solr/webapp/web/img/ico/documents-stack.png new file mode 100644 index 0000000000000000000000000000000000000000..a397f60aaa4cd92e7aa4cdd254f941839c73b863 GIT binary patch literal 594 zcmV-Y0#L(A8S8EY1du*=J8e* zv1ni%-`kn*`(~J@5o~gPo+hTJNz*iHx7!>Sa6L-B?ZR=KJEzr>xyJJLcBhby|05xC zyt8v?BguAM`gR<0@I9By(b4(&I;X*JIp63)m(2J&bD7Oj3ji((Z2&~WVXD{bbh^8H zxU{*sq4IAvPXQa4*M4Je;(T8$Qhy*Ia}ScqErdPezsxIhb9939SR_JG_*o|NAzN^P z4Ewd`^5Y{_s#QuPlai@aD$!~@PA%IO5`d@4Lvc|gnYkFTX<0p)uhVJj6M}37Ah-xF z1m>W#>pJxt1`Py*WSXXAeuIkC%?;@&Bq$6pfMp3d8IU4@7(l25Vh~&|Vn0~PKq%B< zW`&&VDd+%bN&$6&u=$xC55Tf?31E8)!xS_>}mWtwtmJRVXA>cTMsB@F4qHXjK%ip4|5xh g7gbpC-~R|O01K)~x6T?Z=>Px#07*qoM6N<$g5`w + // - Files are sandboxed. Doesn't matter how many, or where they are, on the page. + // - Allows for extra parameters to be included with the file + // - onStart callback can cancel the upload by returning false + */ + + +(function ($) { + $.fn.ajaxfileupload = function (options) { + var settings = { + params: {}, + action: '', + onStart: function () { + console.log('starting upload'); + console.log(this); + }, + onComplete: function (response) { + console.log('got response: '); + console.log(response); + console.log(this); + }, + onCancel: function () { + console.log('cancelling: '); + console.log(this); + }, + validate_extensions: true, + valid_extensions: ['gif', 'png', 'jpg', 'jpeg'], + submit_button: null, + upload_now: false + }; + + var uploading_file = false; + + if (options) { + $.extend(settings, options); + } + + + // 'this' is a jQuery collection of one or more (hopefully) + // file elements, but doesn't check for this yet + return this.each(function () { + var $element = $(this); + /* + // Internal handler that tries to parse the response + // and clean up after ourselves. + */ + var handleResponse = function (loadedFrame, element) { + var response, responseStr = loadedFrame.contentWindow.document.body.innerHTML; + try { + //response = $.parseJSON($.trim(responseStr)); + response = JSON.parse(responseStr); + } catch (e) { + response = responseStr; + } + + // Tear-down the wrapper form + element.siblings().remove(); + element.unwrap(); + + uploading_file = false; + + // Pass back to the user + settings.onComplete.apply(element, [response, settings.params]); + }; + /* + // Wraps element in a
tag, and inserts hidden inputs for each + // key:value pair in settings.params so they can be sent along with + // the upload. Then, creates an iframe that the whole thing is + // uploaded through. + */ + var wrapElement = function (element) { + // Create an iframe to submit through, using a semi-unique ID + var frame_id = 'ajaxUploader-iframe-' + Math.round(new Date().getTime() / 1000) + $('body').after('--> + + + + \ No newline at end of file