diff options
author | Andy Rickert <andrew_rickert@brown.edu> | 2020-05-13 16:59:06 -0700 |
---|---|---|
committer | Andy Rickert <andrew_rickert@brown.edu> | 2020-05-13 16:59:06 -0700 |
commit | 2cc452ccb09147cd56f19b5ddadd82c3e81a9123 (patch) | |
tree | 2fcb09ddcf2bdce290b33f65e19a7ad6bae79830 | |
parent | a1d6cf23a902215b91433d26724a75a1844bd4dd (diff) |
building infrastucure for buckets
-rw-r--r-- | solr-8.3.1/bin/solr-8983.pid | 2 | ||||
-rw-r--r-- | solr-8.3.1/server/solr/dash/conf/schema.xml | 2 | ||||
-rw-r--r-- | src/client/views/search/SearchBox.tsx | 20 | ||||
-rw-r--r-- | src/client/views/search/SearchItem.tsx | 57 | ||||
-rw-r--r-- | src/server/ApiManagers/SearchManager.ts | 5 | ||||
-rw-r--r-- | src/server/Websocket/Websocket.ts | 9 |
6 files changed, 84 insertions, 11 deletions
diff --git a/solr-8.3.1/bin/solr-8983.pid b/solr-8.3.1/bin/solr-8983.pid index 19d1e65cc..83b9efec3 100644 --- a/solr-8.3.1/bin/solr-8983.pid +++ b/solr-8.3.1/bin/solr-8983.pid @@ -1 +1 @@ -5999 +9117 diff --git a/solr-8.3.1/server/solr/dash/conf/schema.xml b/solr-8.3.1/server/solr/dash/conf/schema.xml index 314ee8f5d..3424ee7f7 100644 --- a/solr-8.3.1/server/solr/dash/conf/schema.xml +++ b/solr-8.3.1/server/solr/dash/conf/schema.xml @@ -44,7 +44,7 @@ <field name="text" type="text" indexed="true" stored="false" uninvertible="false" multiValued="true"/> <field name="id" type="string" indexed="true" stored="true" uninvertible="false" required="true"/> <field name="_version_" type="plong" indexed="true" stored="true"/> - <field name="proto_i" type="string" indexed="true" stored="true" uninvertible="false" docValues="false" /> + <field name="proto" type="string" indexed="true" stored="true" uninvertible="false" docValues="false" /> <dynamicField name="*_t" type="text" indexed="true" stored="true" uninvertible="false" docValues="false"/> diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index 632bcd211..016ff254b 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -550,6 +550,14 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc // indicates if things are placeholders this._isSearch = Array<undefined>(this._numTotalResults === -1 ? 0 : this._numTotalResults); } + let bucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: `bucket` }); + bucket.targetDoc = bucket; + + bucket._viewType === CollectionViewType.Stacking; + + bucket.isBucket=true; + + Doc.AddDocToList(this.dataDoc, this.props.fieldKey, bucket); for (let i = 0; i < this._numTotalResults; i++) { //if the index is out of the window then put a placeholder in @@ -562,6 +570,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc } else { if (this._isSearch[i] !== "search") { + let result: [Doc, string[], string[]] | undefined = undefined; if (i >= this._results.length) { this.getResults(StrCast(this.layoutDoc._searchString)); @@ -576,7 +585,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc this._visibleDocuments[i] = result[0]; //<SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />; result[0].targetDoc=result[0]; - Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]); + + Doc.AddDocToList(bucket, this.props.fieldKey, result[0]); this._isSearch[i] = "search"; } } @@ -591,7 +601,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc //this._visibleElements[i] = <SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />; this._visibleDocuments[i]=result[0]; result[0].targetDoc=result[0]; - Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]) + + Doc.AddDocToList(bucket, this.props.fieldKey, result[0]); this._isSearch[i] = "search"; } } @@ -927,7 +938,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc return this.props.PanelHeight() - 50; } selectElement = (doc: Doc) => { - //this.gotoDocument(this.childDocs.indexOf(doc), NumCast(this.layoutDoc._itemIndex)); + //this.gotoDocument(this.childDocs.indexOf(doc), NumCasst(this.layoutDoc._itemIndex)); } addDocument = (doc: Doc) => { @@ -972,11 +983,12 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc Document={this.props.Document} PanelHeight={this.panelHeight} moveDocument={returnFalse} + NativeHeight={()=>400} childLayoutTemplate={this.childLayoutTemplate} addDocument={this.addDocument} removeDocument={returnFalse} focus={this.selectElement} - ScreenToLocalTransform={this.getTransform} /> + ScreenToLocalTransform={Transform.Identity} /> <div className="searchBox-results" onScroll={this.resultsScrolled} style={{ display: this._resultsOpen ? "flex" : "none", height: this.resFull ? "auto" : this.resultHeight, diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx index c3010e6c4..564df4232 100644 --- a/src/client/views/search/SearchItem.tsx +++ b/src/client/views/search/SearchItem.tsx @@ -15,7 +15,7 @@ import { SearchUtil } from "../../util/SearchUtil"; import { Transform } from "../../util/Transform"; import { SEARCH_THUMBNAIL_SIZE } from "../../views/globalCssVariables.scss"; import { CollectionDockingView } from "../collections/CollectionDockingView"; -import { CollectionViewType } from "../collections/CollectionView"; +import { CollectionViewType, CollectionView } from "../collections/CollectionView"; import { ParentDocSelector } from "../collections/ParentDocumentSelector"; import { ContextMenu } from "../ContextMenu"; import { ContentFittingDocumentView } from "../nodes/ContentFittingDocumentView"; @@ -26,6 +26,10 @@ import { FieldViewProps, FieldView } from "../nodes/FieldView"; import { ViewBoxBaseComponent } from "../DocComponent"; import { makeInterface, createSchema } from "../../../new_fields/Schema"; import { documentSchema } from "../../../new_fields/documentSchemas"; +import { PrefetchProxy } from "../../../new_fields/Proxy"; +import { Docs } from "../../documents/Documents"; +import { ScriptField } from "../../../new_fields/ScriptField"; +import { CollectionStackingView } from "../collections/CollectionStackingView"; export interface SearchItemProps { doc: Doc; @@ -53,6 +57,7 @@ export class SelectorContextMenu extends React.Component<SearchItemProps> { constructor(props: SearchItemProps) { super(props); this.fetchDocuments(); + } async fetchDocuments() { @@ -139,8 +144,25 @@ const SearchDocument = makeInterface(documentSchema); @observer export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchema>(SearchDocument) { + public static LayoutString(fieldKey: string) { return FieldView.LayoutString(SearchItem, fieldKey); } + constructor(props:any){ + super(props); + this.targetDoc._viewType= CollectionViewType.Stacking; + this.rootDoc._viewType = CollectionViewType.Stacking; + if (!this.searchItemTemplate) { // create exactly one presElmentBox template to use by any and all presentations. + Doc.UserDoc().searchItemTemplate = new PrefetchProxy(Docs.Create.SearchItemBoxDocument({ title: "search item template", backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" })); + // this script will be called by each presElement to get rendering-specific info that the PresBox knows about but which isn't written to the PresElement + // this is a design choice -- we could write this data to the presElements which would require a reaction to keep it up to date, and it would prevent + // the preselement docs from being part of multiple presentations since they would all have the same field, or we'd have to keep per-presentation data + // stored on each pres element. + (this.searchItemTemplate as Doc).lookupField = ScriptField.MakeFunction("lookupSearchBoxField(container, field, data)", + { field: "string", data: Doc.name, container: Doc.name }); + } + + } + @observable _selected: boolean = false; onClick = () => { @@ -302,9 +324,41 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem @computed get searchElementDoc() { return this.rootDoc; } @computed get targetDoc() { return this.searchElementDoc?.targetDoc as Doc; } + @computed get searchItemTemplate() { return Cast(Doc.UserDoc().searchItemTemplate, Doc, null); } + childLayoutTemplate = () => this.layoutDoc._viewType === CollectionViewType.Stacking ? this.searchItemTemplate: undefined; + getTransform = () => { + return this.props.ScreenToLocalTransform().translate(-5, -65);// listBox padding-left and pres-box-cont minHeight + } + panelHeight = () => { + return this.props.PanelHeight(); + } + selectElement = (doc: Doc) => { + //this.gotoDocument(this.childDocs.indexOf(doc), NumCast(this.layoutDoc._itemIndex)); + } + + addDocument = (doc: Doc) => { + const newPinDoc = Doc.MakeAlias(doc); + newPinDoc.presentationTargetDoc = doc; + return Doc.AddDocToList(this.dataDoc, this.fieldKey, newPinDoc); + } render() { // const doc1 = Cast(this.targetDoc!.anchor1, Doc); // const doc2 = Cast(this.targetDoc!.anchor2, Doc); + if (this.targetDoc.isBucket === true){ + this.props.Document._viewType=CollectionViewType.Stacking; + this.props.Document._height=160; + + return <CollectionView {...this.props} + Document={this.props.Document} + PanelHeight={this.panelHeight} + moveDocument={returnFalse} + childLayoutTemplate={this.childLayoutTemplate} + addDocument={this.addDocument} + removeDocument={returnFalse} + focus={this.selectElement} + ScreenToLocalTransform={this.getTransform} /> + } + else { return <div className="searchItem-overview" onPointerDown={this.pointerDown} onContextMenu={this.onContextMenu}> <div className="searchItem" onPointerDown={this.nextHighlight} onPointerEnter={this.highlightDoc} onPointerLeave={this.unHighlightDoc}> <div className="searchItem-body" onClick={this.onClick}> @@ -327,5 +381,6 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem </div> </div> </div>; + } } }
\ No newline at end of file diff --git a/src/server/ApiManagers/SearchManager.ts b/src/server/ApiManagers/SearchManager.ts index 753c31fcf..6638c50e4 100644 --- a/src/server/ApiManagers/SearchManager.ts +++ b/src/server/ApiManagers/SearchManager.ts @@ -176,7 +176,7 @@ export namespace SolrManager { "audio": ["_t", "url"], "web": ["_t", "url"], "date": ["_d", value => new Date(value.date).toISOString()], - "proxy": ["_i", "fieldId"], + // "proxy": ["_i", "fieldId"], "list": ["_l", list => { const results = []; for (const value of list.fields) { @@ -193,8 +193,11 @@ export namespace SolrManager { if (val === null || val === undefined) { return; } + console.log(val); const type = val.__type || typeof val; + console.log(type); let suffix = suffixMap[type]; + console.log(suffix); if (!suffix) { return; } diff --git a/src/server/Websocket/Websocket.ts b/src/server/Websocket/Websocket.ts index 844535056..f92c2a1f3 100644 --- a/src/server/Websocket/Websocket.ts +++ b/src/server/Websocket/Websocket.ts @@ -216,7 +216,7 @@ export namespace WebSocket { "script": ["_t", value => value.script.originalScript], "RichTextField": ["_t", value => value.Text], "date": ["_d", value => new Date(value.date).toISOString()], - "proxy": ["_i", "fieldId"], + // "proxy": ["_i", "fieldId"], "list": ["_l", list => { const results = []; for (const value of list.fields) { @@ -230,15 +230,18 @@ export namespace WebSocket { }; function ToSearchTerm(val: any): { suffix: string, value: any } | undefined { + // console.log(val); + if (val === null || val === undefined) { return; } const type = val.__type || typeof val; + // console.log(type); + let suffix = suffixMap[type]; if (!suffix) { return; } - if (Array.isArray(suffix)) { const accessor = suffix[1]; if (typeof accessor === "function") { @@ -248,7 +251,7 @@ export namespace WebSocket { } suffix = suffix[0]; } - + // console.log(suffix); return { suffix, value: val }; } |