diff options
Diffstat (limited to 'src/client')
4 files changed, 52 insertions, 48 deletions
diff --git a/src/client/northstar/utils/Extensions.ts b/src/client/northstar/utils/Extensions.ts index f1fddf6c8..04af36731 100644 --- a/src/client/northstar/utils/Extensions.ts +++ b/src/client/northstar/utils/Extensions.ts @@ -29,22 +29,22 @@ type BatchHandler<I> = BatchHandlerSync<I> | BatchHandlerAsync<I>; interface Array<T> { batch(batchSize: number): T[][]; - executeInBatches(batchSize: number, handler: BatchHandlerSync<T>): void; - convertInBatches<O>(batchSize: number, handler: BatchConverterSync<T, O>): O[]; - executeInBatchesAsync(batchSize: number, handler: BatchHandler<T>): Promise<void>; - convertInBatchesAsync<O>(batchSize: number, handler: BatchConverter<T, O>): Promise<O[]>; - executeInBatchesAtInterval(batchSize: number, handler: BatchHandler<T>, interval: number): Promise<void>; - convertInBatchesAtInterval<O>(batchSize: number, handler: BatchConverter<T, O>, interval: number): Promise<O[]>; + batchedForEach(batchSize: number, handler: BatchHandlerSync<T>): void; + batchedMap<O>(batchSize: number, handler: BatchConverterSync<T, O>): O[]; + batchedForEachAsync(batchSize: number, handler: BatchHandler<T>): Promise<void>; + batchedMapAsync<O>(batchSize: number, handler: BatchConverter<T, O>): Promise<O[]>; + batchedForEachInterval(batchSize: number, handler: BatchHandler<T>, interval: number): Promise<void>; + batchedMapInterval<O>(batchSize: number, handler: BatchConverter<T, O>, interval: number): Promise<O[]>; lastElement(): T; } Array.prototype.batch = extensions.Batch; -Array.prototype.executeInBatches = extensions.ExecuteInBatches; -Array.prototype.convertInBatches = extensions.ConvertInBatches; -Array.prototype.executeInBatchesAsync = extensions.ExecuteInBatchesAsync; -Array.prototype.convertInBatchesAsync = extensions.ConvertInBatchesAsync; -Array.prototype.executeInBatchesAtInterval = extensions.ExecuteInBatchesAtInterval; -Array.prototype.convertInBatchesAtInterval = extensions.ConvertInBatchesAtInterval; +Array.prototype.batchedForEach = extensions.ExecuteInBatches; +Array.prototype.batchedMap = extensions.ConvertInBatches; +Array.prototype.batchedForEachAsync = extensions.ExecuteInBatchesAsync; +Array.prototype.batchedMapAsync = extensions.ConvertInBatchesAsync; +Array.prototype.batchedForEachInterval = extensions.ExecuteInBatchesAtInterval; +Array.prototype.batchedMapInterval = extensions.ConvertInBatchesAtInterval; Array.prototype.lastElement = function <T>() { if (!this.length) { diff --git a/src/client/util/Import & Export/DirectoryImportBox.tsx b/src/client/util/Import & Export/DirectoryImportBox.tsx index 44075ecdd..d371766dd 100644 --- a/src/client/util/Import & Export/DirectoryImportBox.tsx +++ b/src/client/util/Import & Export/DirectoryImportBox.tsx @@ -103,7 +103,7 @@ export default class DirectoryImportBox extends React.Component<FieldViewProps> runInAction(() => this.phase = `Internal: uploading ${this.quota - this.completed} files to Dash...`); - const uploads = await validated.convertInBatchesAsync<FileResponse>(15, async (batch: File[]) => { + const uploads = await validated.batchedMapAsync<FileResponse>(15, async (batch: File[]) => { const formData = new FormData(); const parameters = { method: 'POST', body: formData }; diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx index 4d4f69b92..59fc11359 100644 --- a/src/client/views/collections/CollectionSubView.tsx +++ b/src/client/views/collections/CollectionSubView.tsx @@ -1,7 +1,7 @@ import { action, computed } from "mobx"; import * as rp from 'request-promise'; import CursorField from "../../../new_fields/CursorField"; -import { Doc, DocListCast } from "../../../new_fields/Doc"; +import { Doc, DocListCast, HeightSym } from "../../../new_fields/Doc"; import { Id } from "../../../new_fields/FieldSymbols"; import { List } from "../../../new_fields/List"; import { listSpec } from "../../../new_fields/Schema"; @@ -23,6 +23,7 @@ import { CollectionVideoView } from "./CollectionVideoView"; import { CollectionView } from "./CollectionView"; import React = require("react"); import { GooglePhotos } from "../../apis/google_docs/GooglePhotosClientUtils"; +import { CollectionDockingView } from "./CollectionDockingView"; export interface CollectionViewProps extends FieldViewProps { addDocument: (document: Doc, allowDuplicates?: boolean) => boolean; @@ -212,11 +213,14 @@ export function CollectionSubView<T>(schemaCtor: (doc: Doc) => T) { if ((matches = /(https:\/\/)?docs\.google\.com\/document\/d\/([^\\]+)\/edit/g.exec(text)) !== null) { let newBox = Docs.Create.TextDocument({ ...options, width: 400, height: 200, title: "Awaiting title from Google Docs..." }); let proto = newBox.proto!; - proto.autoHeight = true; - proto[GoogleRef] = matches[2]; + const documentId = matches[2]; + proto[GoogleRef] = documentId; proto.data = "Please select this document and then click on its pull button to load its contents from from Google Docs..."; proto.backgroundColor = "#eeeeff"; this.props.addDocument(newBox); + // const parent = Docs.Create.StackingDocument([newBox], { title: `Google Doc Import (${documentId})` }); + // CollectionDockingView.Instance.AddRightSplit(parent, undefined); + // proto.height = parent[HeightSym](); return; } if ((matches = /(https:\/\/)?photos\.google\.com\/(u\/3\/)?album\/([^\\]+)/g.exec(text)) !== null) { diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index b4ca6d797..9c7e8d22f 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -523,38 +523,38 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) { let y = this.Document.panY || 0; let docs = this.childDocs || []; let [dx, dy] = this.getTransform().transformDirection(e.clientX - this._lastX, e.clientY - this._lastY); - if (!this.isAnnotationOverlay) { - PDFMenu.Instance.fadeOut(true); - let minx = docs.length ? NumCast(docs[0].x) : 0; - let maxx = docs.length ? NumCast(docs[0].width) + minx : minx; - let miny = docs.length ? NumCast(docs[0].y) : 0; - let maxy = docs.length ? NumCast(docs[0].height) + miny : miny; - let ranges = docs.filter(doc => doc).reduce((range, doc) => { - let x = NumCast(doc.x); - let xe = x + NumCast(doc.width); - let y = NumCast(doc.y); - let ye = y + NumCast(doc.height); - return [[range[0][0] > x ? x : range[0][0], range[0][1] < xe ? xe : range[0][1]], - [range[1][0] > y ? y : range[1][0], range[1][1] < ye ? ye : range[1][1]]]; - }, [[minx, maxx], [miny, maxy]]); - let ink = Cast(this.fieldExtensionDoc.ink, InkField); - if (ink && ink.inkData) { - ink.inkData.forEach((value: StrokeData, key: string) => { - let bounds = InkingCanvas.StrokeRect(value); - ranges[0] = [Math.min(ranges[0][0], bounds.left), Math.max(ranges[0][1], bounds.right)]; - ranges[1] = [Math.min(ranges[1][0], bounds.top), Math.max(ranges[1][1], bounds.bottom)]; - }); - } - - let panelDim = this.props.ScreenToLocalTransform().transformDirection(this._pwidth / this.zoomScaling(), - this._pheight / this.zoomScaling()); - let panelwidth = panelDim[0]; - let panelheight = panelDim[1]; - if (ranges[0][0] - dx > (this.panX() + panelwidth / 2)) x = ranges[0][1] + panelwidth / 2; - if (ranges[0][1] - dx < (this.panX() - panelwidth / 2)) x = ranges[0][0] - panelwidth / 2; - if (ranges[1][0] - dy > (this.panY() + panelheight / 2)) y = ranges[1][1] + panelheight / 2; - if (ranges[1][1] - dy < (this.panY() - panelheight / 2)) y = ranges[1][0] - panelheight / 2; - } + // if (!this.isAnnotationOverlay) { + // PDFMenu.Instance.fadeOut(true); + // let minx = docs.length ? NumCast(docs[0].x) : 0; + // let maxx = docs.length ? NumCast(docs[0].width) + minx : minx; + // let miny = docs.length ? NumCast(docs[0].y) : 0; + // let maxy = docs.length ? NumCast(docs[0].height) + miny : miny; + // let ranges = docs.filter(doc => doc).reduce((range, doc) => { + // let x = NumCast(doc.x); + // let xe = x + NumCast(doc.width); + // let y = NumCast(doc.y); + // let ye = y + NumCast(doc.height); + // return [[range[0][0] > x ? x : range[0][0], range[0][1] < xe ? xe : range[0][1]], + // [range[1][0] > y ? y : range[1][0], range[1][1] < ye ? ye : range[1][1]]]; + // }, [[minx, maxx], [miny, maxy]]); + // let ink = Cast(this.fieldExtensionDoc.ink, InkField); + // if (ink && ink.inkData) { + // ink.inkData.forEach((value: StrokeData, key: string) => { + // let bounds = InkingCanvas.StrokeRect(value); + // ranges[0] = [Math.min(ranges[0][0], bounds.left), Math.max(ranges[0][1], bounds.right)]; + // ranges[1] = [Math.min(ranges[1][0], bounds.top), Math.max(ranges[1][1], bounds.bottom)]; + // }); + // } + + // let panelDim = this.props.ScreenToLocalTransform().transformDirection(this._pwidth / this.zoomScaling(), + // this._pheight / this.zoomScaling()); + // let panelwidth = panelDim[0]; + // let panelheight = panelDim[1]; + // if (ranges[0][0] - dx > (this.panX() + panelwidth / 2)) x = ranges[0][1] + panelwidth / 2; + // if (ranges[0][1] - dx < (this.panX() - panelwidth / 2)) x = ranges[0][0] - panelwidth / 2; + // if (ranges[1][0] - dy > (this.panY() + panelheight / 2)) y = ranges[1][1] + panelheight / 2; + // if (ranges[1][1] - dy < (this.panY() - panelheight / 2)) y = ranges[1][0] - panelheight / 2; + // } this.setPan(x - dx, y - dy); this._lastX = e.pageX; this._lastY = e.pageY; |
