From 4574b7f03ccc85c4bebdbfd9475788456086704f Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 8 Aug 2024 12:27:40 -0400 Subject: many changes to add typing in place of 'any's etc --- src/client/util/SettingsManager.tsx | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/client/util/SettingsManager.tsx') diff --git a/src/client/util/SettingsManager.tsx b/src/client/util/SettingsManager.tsx index 278931cdd..2d8763b63 100644 --- a/src/client/util/SettingsManager.tsx +++ b/src/client/util/SettingsManager.tsx @@ -1,5 +1,3 @@ -/* eslint-disable jsx-a11y/no-static-element-interactions */ -/* eslint-disable jsx-a11y/click-events-have-key-events */ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { Button, ColorPicker, Dropdown, DropdownType, EditableText, Group, NumberDropdown, Size, Toggle, ToggleType, Type } from 'browndash-components'; import { action, computed, makeObservable, observable, reaction, runInAction } from 'mobx'; -- cgit v1.2.3-70-g09d2 From 3f31aaa6b667e7b5f31b2f2b4e13a0879348602c Mon Sep 17 00:00:00 2001 From: bobzel Date: Mon, 26 Aug 2024 16:46:13 -0400 Subject: added recognizeFaces for face images --- src/client/util/CurrentUserUtils.ts | 2 +- src/client/util/SettingsManager.tsx | 11 ++++++ src/client/views/StyleProvider.tsx | 2 + .../collectionFreeForm/FaceCollectionBox.scss | 11 +++++- .../collectionFreeForm/FaceCollectionBox.tsx | 45 +++++++++++++++------- src/client/views/search/FaceRecognitionHandler.tsx | 1 + 6 files changed, 55 insertions(+), 17 deletions(-) (limited to 'src/client/util/SettingsManager.tsx') diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index 0681a21cb..dc0c95121 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -497,7 +497,7 @@ pie title Minerals in my tap water static setupFaceCollection(doc: Doc, field: string) { return DocUtils.AssignDocField(doc, field, (opts) => Docs.Create.FaceCollectionDocument(opts), { - dontRegisterView: true, backgroundColor: "dimgray", ignoreClick: true, title: "Face Collection", isSystem: true, childDragAction: dropActionType.embed, + dontRegisterView: true, ignoreClick: true, title: "Face Collection", isSystem: true, childDragAction: dropActionType.embed, _lockedPosition: true, _type_collection: CollectionViewType.Schema }); } diff --git a/src/client/util/SettingsManager.tsx b/src/client/util/SettingsManager.tsx index 2d8763b63..fde8869e3 100644 --- a/src/client/util/SettingsManager.tsx +++ b/src/client/util/SettingsManager.tsx @@ -231,6 +231,17 @@ export class SettingsManager extends React.Component { size={Size.XSMALL} color={SettingsManager.userColor} /> + { + Doc.UserDoc().recognizeFaceImages = !Doc.UserDoc().recognizeFaceImages; + }} + toggleStatus={BoolCast(Doc.UserDoc().recognizeFaceImages)} + size={Size.XSMALL} + color={SettingsManager.userColor} + /> , props: Opt() { } private _dropDisposer?: DragManager.DragDropDisposer; private _oldWheel: HTMLElement | null = null; + private _disposers: { [key: string]: IReactionDisposer } = {}; + private _lastHeight = 0; constructor(props: FieldViewProps) { super(props); @@ -50,13 +52,17 @@ export class UniqueFaceBox extends ViewBoxBaseComponent() { } @observable _headerRef: HTMLDivElement | null = null; @observable _listRef: HTMLDivElement | null = null; - _disposers: { [key: string]: IReactionDisposer } = {}; - _lastHeight = 0; - observer = new ResizeObserver(() => this._props.setHeight?.((this.props.Document._face_showImages ? 20 : 0) + (!this._headerRef ? 0 : DivHeight(this._headerRef)) + (!this._listRef ? 0 : DivHeight(this._listRef)))); + observer = new ResizeObserver(a => { + this._props.setHeight?.( + (this.props.Document._face_showImages ? 20 : 0) + // + (!this._headerRef ? 0 : DivHeight(this._headerRef)) + + (!this._listRef ? 0 : DivHeight(this._listRef)) + ); + }); componentDidMount(): void { this._disposers.refList = reaction( - () => ({ refList: [this._headerRef, this._listRef], autoHeight: this.layoutDoc._layout_autoHeight && !DocumentView.LightboxContains(this.DocumentView?.()) }), + () => ({ refList: [this._headerRef, this._listRef], autoHeight: this.layoutDoc._layout_autoHeight }), ({ refList, autoHeight }) => { this.observer.disconnect(); if (autoHeight) refList.filter(r => r).forEach(r => this.observer.observe(r!)); @@ -66,7 +72,8 @@ export class UniqueFaceBox extends ViewBoxBaseComponent() { } componentWillUnmount(): void { - //this._disposers?.(); + this.observer.disconnect(); + Object.keys(this._disposers).forEach(key => this._disposers[key]()); } protected createDropTarget = (ele: HTMLDivElement) => { this._dropDisposer?.(); @@ -213,17 +220,27 @@ export class FaceCollectionBox extends ViewBoxBaseComponent() { moveDocument = (doc: Doc | Doc[], targetCollection: Doc | undefined, addDocument: (doc: Doc | Doc[]) => boolean): boolean => !!(this._props.removeDocument?.(doc) && addDocument?.(doc)); + stackingStyleProvider = (doc: Doc | undefined, props: Opt, property: string) => { + if (doc === Doc.ActiveDashboard) return this._props.styleProvider?.(this.Document, this._props, property); + return this._props.styleProvider?.(doc, this._props, property); + }; render() { return !Doc.ActiveDashboard ? null : ( - +
+
+
(Doc.UserDoc().recognizeFaceImages = !Doc.UserDoc().recognizeFaceImages))}>{`Face Recgognition is ${Doc.UserDoc().recognizeFaceImages ? 'on' : 'off'}`}
+
+ +
); } } diff --git a/src/client/views/search/FaceRecognitionHandler.tsx b/src/client/views/search/FaceRecognitionHandler.tsx index f613f78ce..7c8043219 100644 --- a/src/client/views/search/FaceRecognitionHandler.tsx +++ b/src/client/views/search/FaceRecognitionHandler.tsx @@ -230,6 +230,7 @@ export class FaceRecognitionHandler { * @param imgDoc The document being analyzed. */ private classifyFacesInImage = async (imgDoc: Doc) => { + if (!Doc.UserDoc().recognizeFaceImages) return; const activeDashboard = Doc.ActiveDashboard; if (!this._apiModelReady || !activeDashboard) { this._pendingAPIModelReadyDocs.push(imgDoc); -- cgit v1.2.3-70-g09d2