diff --git a/common/constants.js b/common/constants.js index c1fe2db5b6981123c9811587a0523a859b95c234..94fd8fe4ef1be3f2f084644fca15e257782613da 100644 --- a/common/constants.js +++ b/common/constants.js @@ -103,6 +103,8 @@ These outlines are based on the authoritative Terms and Conditions are found <ht If you do not accept the Terms & Conditions you are not permitted to access or use the KG to search for, to submit, to post, or to download any materials found there-in. `, + NEHUBA_DRAG_DROP_TEXT: `Drag and drop any .nii.gz, .nii or .swc files.`, + LOADING_TXT: `Loading ...`, CANNOT_DECIPHER_HEMISPHERE: 'Cannot decipher region hemisphere.', diff --git a/docs/releases/v2.7.6.md b/docs/releases/v2.7.6.md index 2afb0eaafcb7ec0efb5484e7abbbd8b30a4ed2dc..269ac57ae61a78c2274421b81525ae672cbb89a5 100644 --- a/docs/releases/v2.7.6.md +++ b/docs/releases/v2.7.6.md @@ -4,6 +4,10 @@ - Emitting navigation state for plugin API +## Bugfix + +- Fixed drag and drop in nehuba viewer + ## Under the hood - bumped siibra-api version for updated julich brain hierarchy diff --git a/src/dragDropFile/dragDrop.directive.ts b/src/dragDropFile/dragDrop.directive.ts index 99e82c0c23b1cfbf957e74f872e37e7f3485a847..3eca500f41233a388461aee17a6998d62c1ea24b 100644 --- a/src/dragDropFile/dragDrop.directive.ts +++ b/src/dragDropFile/dragDrop.directive.ts @@ -1,6 +1,6 @@ import { Directive, ElementRef, EventEmitter, HostBinding, HostListener, Input, OnDestroy, OnInit, Output } from "@angular/core"; import { fromEvent, merge, Observable, of, Subscription } from "rxjs"; -import { debounceTime, map, scan, switchMap } from "rxjs/operators"; +import { debounceTime, distinctUntilChanged, map, scan, switchMap } from "rxjs/operators"; import {MatSnackBar, MatSnackBarRef, SimpleSnackBar} from "@angular/material/snack-bar"; @Directive({ @@ -8,7 +8,7 @@ import {MatSnackBar, MatSnackBarRef, SimpleSnackBar} from "@angular/material/sna exportAs: 'dragDropFile' }) -export class DragDropFileDirective implements OnInit, OnDestroy { +export class DragDropFileDirective implements OnDestroy { @Input() public snackText: string @@ -49,30 +49,6 @@ export class DragDropFileDirective implements OnInit, OnDestroy { private subscriptions: Subscription[] = [] - public ngOnInit() { - this.subscriptions.push( - this.dragover$.pipe( - debounceTime(16), - ).subscribe(flag => { - if (flag) { - this.snackbarRef = this.snackBar.open(this.snackText || `Drop file(s) here.`, 'Dismiss') - - /** - * In buggy scenarios, user could at least dismiss by action - */ - this.snackbarRef.afterDismissed().subscribe(reason => { - if (reason.dismissedByAction) { - this.reset() - } - }) - this.opacity = 0.2 - } else { - this.reset() - } - }), - ) - } - public ngOnDestroy() { while (this.subscriptions.length > 0) { this.subscriptions.pop().unsubscribe() @@ -96,5 +72,33 @@ export class DragDropFileDirective implements OnInit, OnDestroy { map(val => val > 0), )), ) + + this.subscriptions.push( + this.dragover$.pipe( + debounceTime(16), + distinctUntilChanged(), + ).subscribe(flag => { + if (flag) { + this.snackbarRef = this.snackBar.open( + this.snackText || `Drop file(s) here.`, 'Dismiss', + { + panelClass: 'sxplr-pe-none' + } + ) + + /** + * In buggy scenarios, user could at least dismiss by action + */ + this.snackbarRef.afterDismissed().subscribe(reason => { + if (reason.dismissedByAction) { + this.reset() + } + }) + this.opacity = 0.2 + } else { + this.reset() + } + }), + ) } } diff --git a/src/extra_styles.css b/src/extra_styles.css index 643ab1e507c31fc6e833ca777748a16714e83982..cc4b25a0e51f8e824d28f00ee4e147661e4ded49 100644 --- a/src/extra_styles.css +++ b/src/extra_styles.css @@ -876,3 +876,9 @@ how-to-cite img { max-width: 100vw; } + +/* this is required to set snackbar to be none-interactive */ +.cdk-overlay-pane:has(.sxplr-pe-none) +{ + pointer-events: none; +} diff --git a/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.component.ts b/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.component.ts index 5c16b0a065f1f5b2d14be81d724230ed30b7b301..4edb009c326942d3da7de38ba32d4486ecad1f44 100644 --- a/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.component.ts +++ b/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.component.ts @@ -3,7 +3,7 @@ import { select, Store } from "@ngrx/store"; import { Subscription } from "rxjs"; import { ClickInterceptor, CLICK_INTERCEPTOR_INJECTOR } from "src/util"; import { distinctUntilChanged, startWith } from "rxjs/operators"; -import { ARIA_LABELS } from 'common/constants' +import { ARIA_LABELS, CONST } from 'common/constants' import { EnumViewerEvt, IViewer, TViewerEvent } from "../../viewer.interface"; import { NehubaViewerContainerDirective, TMouseoverEvent } from "../nehubaViewerInterface/nehubaViewerInterface.directive"; import { NehubaMeshService } from "../mesh.service"; @@ -21,8 +21,9 @@ import { NehubaConfig, getParcNgId, getRegionLabelIndex } from "../config.servic import { SET_MESHES_TO_LOAD } from "../constants"; import { annotation, atlasAppearance, atlasSelection, userInteraction } from "src/state"; import { linearTransform, TVALID_LINEAR_XFORM_DST, TVALID_LINEAR_XFORM_SRC } from "src/atlasComponents/sapi/core/space/interspaceLinearXform"; +import { DragDropFileDirective } from 'src/dragDropFile/dragDrop.directive' -export const INVALID_FILE_INPUT = `Exactly one (1) nifti file is required!` +export const INVALID_FILE_INPUT = `Exactly one (1) file is required!` @Component({ selector: 'iav-cmp-viewer-nehuba-glue', @@ -66,7 +67,11 @@ export const INVALID_FILE_INPUT = `Exactly one (1) nifti file is required!` export class NehubaGlueCmp implements IViewer<'nehuba'>, OnDestroy, AfterViewInit { - @ViewChild('layerCtrlTmpl', { read: TemplateRef }) layerCtrlTmpl: TemplateRef<any> + @ViewChild('layerCtrlTmpl', { static: true }) + layerCtrlTmpl: TemplateRef<any> + + @ViewChild(DragDropFileDirective, { static: true }) + dragDropDirective: DragDropFileDirective public ARIA_LABELS = ARIA_LABELS @@ -163,6 +168,12 @@ export class NehubaGlueCmp implements IViewer<'nehuba'>, OnDestroy, AfterViewIni ngAfterViewInit(): void { this.setupNehubaEvRelay() + /** + * TODO directly dynamic input binding does not seem to work ... + * even though static input binding works (i.e. [comp-input]="var" does not work, comp-input="value" works) + * + */ + this.dragDropDirective.snackText = CONST.NEHUBA_DRAG_DROP_TEXT } ngOnDestroy(): void { diff --git a/worker/worker-nifti.js b/worker/worker-nifti.js index 56f0aabaef84833182d543db3b0f08a56f147f42..c754e6e885008c3310ad0c1d4821ebb893219946 100644 --- a/worker/worker-nifti.js +++ b/worker/worker-nifti.js @@ -244,7 +244,7 @@ if (val < min) min = val if (val > max) max = val } catch (e) { - console.error(`error in while true block`) + // erroring here is expected. Since we will overread the buffer. break } pointer.offset += increment