aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryipstanley <stanley_yip@brown.edu>2019-07-16 22:27:25 -0400
committeryipstanley <stanley_yip@brown.edu>2019-07-16 22:27:25 -0400
commit9794f4c8aa4f2dfd8bee40e342fb1b26656a3caa (patch)
tree5fffaa5a21b35ac21c12eae1a3243ce81adc49ee
parentfd003a789941d2008d895a5e047cdd224540156a (diff)
parentf0f020501c782a4989fc1dc47031acb40335532c (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web
-rw-r--r--src/client/views/InkingCanvas.tsx2
-rw-r--r--src/client/views/SearchBox.tsx2
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx2
-rw-r--r--src/client/views/nodes/VideoBox.tsx2
-rw-r--r--src/client/views/pdf/PDFViewer.tsx2
-rw-r--r--src/client/views/search/SearchBox.tsx19
-rw-r--r--src/new_fields/Doc.ts2
-rw-r--r--src/new_fields/Schema.ts2
-rw-r--r--src/server/index.ts6
9 files changed, 24 insertions, 15 deletions
diff --git a/src/client/views/InkingCanvas.tsx b/src/client/views/InkingCanvas.tsx
index 37a6bbab7..3e0d7b476 100644
--- a/src/client/views/InkingCanvas.tsx
+++ b/src/client/views/InkingCanvas.tsx
@@ -152,7 +152,7 @@ export class InkingCanvas extends React.Component<InkCanvasProps> {
get drawnPaths() {
let curPage = NumCast(this.props.Document.curPage, -1);
let paths = Array.from(this.inkData).reduce((paths, [id, strokeData]) => {
- if (strokeData.page === -1 || Math.round(strokeData.page) === Math.round(curPage)) {
+ if (strokeData.page === -1 || (Math.abs(Math.round(strokeData.page) - Math.round(curPage)) < 3)) {
paths.push(<InkingStroke key={id} id={id}
line={strokeData.pathData}
count={strokeData.pathData.length}
diff --git a/src/client/views/SearchBox.tsx b/src/client/views/SearchBox.tsx
index 8fb43021a..1b9be841f 100644
--- a/src/client/views/SearchBox.tsx
+++ b/src/client/views/SearchBox.tsx
@@ -163,7 +163,7 @@ export class SearchBox extends React.Component {
</div>
{this._resultsOpen ? (
<div className="searchBox-results">
- {this._results.map(result => <SearchItem doc={result} key={result[Id]} />)}
+ {this._results.map(result => <SearchItem doc={result} key={result[Id]} highlighting={[]} />)}
</div>
) : null}
</div>
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 19e280444..06055a04d 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -429,7 +429,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
let docviews = docs.reduce((prev, doc) => {
if (!(doc instanceof Doc)) return prev;
var page = NumCast(doc.page, -1);
- if (Math.round(page) === Math.round(curPage) || page === -1) {
+ if ((Math.abs(Math.round(page) - Math.round(curPage)) < 3) || page === -1) {
let minim = BoolCast(doc.isMinimized, false);
if (minim === undefined || !minim) {
const pos = script ? this.getCalculatedPositions(script, { doc, index: prev.length, collection: this.Document, docs, state }) : {};
diff --git a/src/client/views/nodes/VideoBox.tsx b/src/client/views/nodes/VideoBox.tsx
index 9806b10b5..7796c6744 100644
--- a/src/client/views/nodes/VideoBox.tsx
+++ b/src/client/views/nodes/VideoBox.tsx
@@ -186,7 +186,7 @@ export class VideoBox extends DocComponent<FieldViewProps, VideoDocument>(VideoD
let style = "videoBox-content" + (this._fullScreen ? "-fullScreen" : "") + interactive;
return !field ? <div>Loading</div> :
<video className={`${style}`} ref={this.setVideoRef} onCanPlay={this.videoLoad} controls={VideoBox._showControls}
- onPlay={() => this.Play()} onSeeked={this.updateTimecode} onPause={() => this.Pause()}>
+ onPlay={() => this.Play()} onSeeked={this.updateTimecode} onPause={() => this.Pause()} onClick={e => e.preventDefault()}>
<source src={field.url.href} type="video/mp4" />
Not supported.
</video>;
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index c560e581c..1e29863d9 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -349,7 +349,7 @@ export class Viewer extends React.Component<IViewerProps> {
<img key={res.path} src={res.path} onError={handleError}
style={{ width: `${parseInt(res.width) * scale}px`, height: `${parseInt(res.height) * scale}px` }} />);
} catch (e) {
-
+ console.log(e);
}
}
}
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 108492e90..8399605fb 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -24,7 +24,7 @@ export class SearchBox extends React.Component {
@observable private _resultsOpen: boolean = false;
@observable private _searchbarOpen: boolean = false;
@observable private _results: [Doc, string[]][] = [];
- private _resultsSet = new Set<Doc>();
+ private _resultsSet = new Map<Doc, number>();
@observable private _openNoResults: boolean = false;
@observable private _visibleElements: JSX.Element[] = [];
@@ -143,16 +143,23 @@ export class SearchBox extends React.Component {
this._numTotalResults = res.numFound;
}
- const highlighing = res.highlighting || {};
+ const highlighting = res.highlighting || {};
+ const highlightList = res.docs.map(doc => highlighting[doc[Id]]);
const docs = await Promise.all(res.docs.map(doc => Cast(doc.extendsDoc, Doc, doc as any)));
+ const highlights: typeof res.highlighting = {};
+ docs.forEach((doc, index) => highlights[doc[Id]] = highlightList[index]);
let filteredDocs = FilterBox.Instance.filterDocsByType(docs);
runInAction(() => {
// this._results.push(...filteredDocs);
filteredDocs.forEach(doc => {
- if (!this._resultsSet.has(doc)) {
- const highlight = highlighing[doc[Id]];
- this._results.push([doc, highlight ? Object.keys(highlight).map(key => key.substring(0, key.length - 2)) : []]);
- this._resultsSet.add(doc);
+ const index = this._resultsSet.get(doc);
+ const highlight = highlights[doc[Id]];
+ const hlights = highlight ? Object.keys(highlight).map(key => key.substring(0, key.length - 2)) : []
+ if (index === undefined) {
+ this._resultsSet.set(doc, this._results.length);
+ this._results.push([doc, hlights]);
+ } else {
+ this._results[index][1].push(...hlights);
}
});
});
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index 0d9fa540f..1dd721396 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -371,6 +371,8 @@ export namespace Doc {
copy[key] = field;
} else if (field instanceof ObjectField) {
copy[key] = ObjectField.MakeCopy(field);
+ } else if (field instanceof Promise) {
+ field.then(f => (copy[key] === undefined) && (copy[key] = f)); //TODO what should we do here?
} else {
copy[key] = field;
}
diff --git a/src/new_fields/Schema.ts b/src/new_fields/Schema.ts
index 2355304d5..b1a449e08 100644
--- a/src/new_fields/Schema.ts
+++ b/src/new_fields/Schema.ts
@@ -104,7 +104,7 @@ export function makeStrictInterface<T extends Interface>(schema: T): (doc: Doc)
}
export function createSchema<T extends Interface>(schema: T): T & { proto: ToConstructor<Doc> } {
- schema.proto = Doc;
+ (schema as any).proto = Doc;
return schema as any;
}
diff --git a/src/server/index.ts b/src/server/index.ts
index d70f87bd9..51fafbdc3 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -183,7 +183,7 @@ app.get("/whosOnline", (req, res) => {
app.get("/thumbnail/:filename", (req, res) => {
let filename = req.params.filename;
let noExt = filename.substring(0, filename.length - ".png".length);
- let pagenumber = parseInt(noExt[noExt.length - 1]);
+ let pagenumber = parseInt(noExt.split('-')[1]);
fs.exists(uploadDir + filename, (exists: boolean) => {
console.log(`${uploadDir + filename} ${exists ? "exists" : "does not exist"}`);
if (exists) {
@@ -191,14 +191,14 @@ app.get("/thumbnail/:filename", (req, res) => {
probe(input, (err: any, result: any) => {
if (err) {
console.log(err);
- console.log(filename);
+ console.log(`error on ${filename}`);
return;
}
res.send({ path: "/files/" + filename, width: result.width, height: result.height });
});
}
else {
- LoadPage(uploadDir + filename.substring(0, filename.length - "-n.png".length) + ".pdf", pagenumber, res);
+ LoadPage(uploadDir + filename.substring(0, filename.length - noExt.split('-')[1].length - ".PNG".length - 1) + ".pdf", pagenumber, res);
}
});
});