Skip to content
Snippets Groups Projects
Commit 06665b19 authored by Xiao Gui's avatar Xiao Gui
Browse files

fix drag and drop file over nehuba viewer

parent e18502bb
No related branches found
No related tags found
No related merge requests found
...@@ -103,6 +103,8 @@ These outlines are based on the authoritative Terms and Conditions are found <ht ...@@ -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. 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 ...`, LOADING_TXT: `Loading ...`,
CANNOT_DECIPHER_HEMISPHERE: 'Cannot decipher region hemisphere.', CANNOT_DECIPHER_HEMISPHERE: 'Cannot decipher region hemisphere.',
......
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
- Emitting navigation state for plugin API - Emitting navigation state for plugin API
## Bugfix
- Fixed drag and drop in nehuba viewer
## Under the hood ## Under the hood
- bumped siibra-api version for updated julich brain hierarchy - bumped siibra-api version for updated julich brain hierarchy
......
import { Directive, ElementRef, EventEmitter, HostBinding, HostListener, Input, OnDestroy, OnInit, Output } from "@angular/core"; import { Directive, ElementRef, EventEmitter, HostBinding, HostListener, Input, OnDestroy, OnInit, Output } from "@angular/core";
import { fromEvent, merge, Observable, of, Subscription } from "rxjs"; 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"; import {MatSnackBar, MatSnackBarRef, SimpleSnackBar} from "@angular/material/snack-bar";
@Directive({ @Directive({
...@@ -8,7 +8,7 @@ import {MatSnackBar, MatSnackBarRef, SimpleSnackBar} from "@angular/material/sna ...@@ -8,7 +8,7 @@ import {MatSnackBar, MatSnackBarRef, SimpleSnackBar} from "@angular/material/sna
exportAs: 'dragDropFile' exportAs: 'dragDropFile'
}) })
export class DragDropFileDirective implements OnInit, OnDestroy { export class DragDropFileDirective implements OnDestroy {
@Input() @Input()
public snackText: string public snackText: string
...@@ -49,30 +49,6 @@ export class DragDropFileDirective implements OnInit, OnDestroy { ...@@ -49,30 +49,6 @@ export class DragDropFileDirective implements OnInit, OnDestroy {
private subscriptions: Subscription[] = [] 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() { public ngOnDestroy() {
while (this.subscriptions.length > 0) { while (this.subscriptions.length > 0) {
this.subscriptions.pop().unsubscribe() this.subscriptions.pop().unsubscribe()
...@@ -96,5 +72,33 @@ export class DragDropFileDirective implements OnInit, OnDestroy { ...@@ -96,5 +72,33 @@ export class DragDropFileDirective implements OnInit, OnDestroy {
map(val => val > 0), 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()
}
}),
)
} }
} }
...@@ -876,3 +876,9 @@ how-to-cite img ...@@ -876,3 +876,9 @@ how-to-cite img
{ {
max-width: 100vw; max-width: 100vw;
} }
/* this is required to set snackbar to be none-interactive */
.cdk-overlay-pane:has(.sxplr-pe-none)
{
pointer-events: none;
}
...@@ -3,7 +3,7 @@ import { select, Store } from "@ngrx/store"; ...@@ -3,7 +3,7 @@ import { select, Store } from "@ngrx/store";
import { Subscription } from "rxjs"; import { Subscription } from "rxjs";
import { ClickInterceptor, CLICK_INTERCEPTOR_INJECTOR } from "src/util"; import { ClickInterceptor, CLICK_INTERCEPTOR_INJECTOR } from "src/util";
import { distinctUntilChanged, startWith } from "rxjs/operators"; 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 { EnumViewerEvt, IViewer, TViewerEvent } from "../../viewer.interface";
import { NehubaViewerContainerDirective, TMouseoverEvent } from "../nehubaViewerInterface/nehubaViewerInterface.directive"; import { NehubaViewerContainerDirective, TMouseoverEvent } from "../nehubaViewerInterface/nehubaViewerInterface.directive";
import { NehubaMeshService } from "../mesh.service"; import { NehubaMeshService } from "../mesh.service";
...@@ -21,8 +21,9 @@ import { NehubaConfig, getParcNgId, getRegionLabelIndex } from "../config.servic ...@@ -21,8 +21,9 @@ import { NehubaConfig, getParcNgId, getRegionLabelIndex } from "../config.servic
import { SET_MESHES_TO_LOAD } from "../constants"; import { SET_MESHES_TO_LOAD } from "../constants";
import { annotation, atlasAppearance, atlasSelection, userInteraction } from "src/state"; 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 { 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({ @Component({
selector: 'iav-cmp-viewer-nehuba-glue', selector: 'iav-cmp-viewer-nehuba-glue',
...@@ -66,7 +67,11 @@ export const INVALID_FILE_INPUT = `Exactly one (1) nifti file is required!` ...@@ -66,7 +67,11 @@ export const INVALID_FILE_INPUT = `Exactly one (1) nifti file is required!`
export class NehubaGlueCmp implements IViewer<'nehuba'>, OnDestroy, AfterViewInit { 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 public ARIA_LABELS = ARIA_LABELS
...@@ -163,6 +168,12 @@ export class NehubaGlueCmp implements IViewer<'nehuba'>, OnDestroy, AfterViewIni ...@@ -163,6 +168,12 @@ export class NehubaGlueCmp implements IViewer<'nehuba'>, OnDestroy, AfterViewIni
ngAfterViewInit(): void { ngAfterViewInit(): void {
this.setupNehubaEvRelay() 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 { ngOnDestroy(): void {
......
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
if (val < min) min = val if (val < min) min = val
if (val > max) max = val if (val > max) max = val
} catch (e) { } catch (e) {
console.error(`error in while true block`) // erroring here is expected. Since we will overread the buffer.
break break
} }
pointer.offset += increment pointer.offset += increment
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment