Skip to content
Snippets Groups Projects
Unverified Commit 31538adc authored by xgui3783's avatar xgui3783 Committed by GitHub
Browse files

Merge pull request #4 from FZJ-INM1-BDA/dev_resolve_screenshot_bug

Resolve screenshot taking background
parents 1b8032a2 1e45611e
No related branches found
No related tags found
No related merge requests found
import {ChangeDetectionStrategy, Component, Input, TemplateRef } from "@angular/core"; import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
ElementRef,
Input,
TemplateRef,
ViewChild
} from "@angular/core";
import { MatBottomSheet, MatDialog, MatDialogRef } from "@angular/material"; import { MatBottomSheet, MatDialog, MatDialogRef } from "@angular/material";
import { select, Store } from "@ngrx/store"; import { select, Store } from "@ngrx/store";
import { Observable } from "rxjs"; import { Observable } from "rxjs";
...@@ -21,18 +29,22 @@ export class SigninBanner { ...@@ -21,18 +29,22 @@ export class SigninBanner {
@Input() public darktheme: boolean @Input() public darktheme: boolean
@Input() public parcellationIsSelected: boolean @Input() public parcellationIsSelected: boolean
@ViewChild('takeScreenshotElement', {read: ElementRef}) takeScreenshotElement: ElementRef
public user$: Observable<IUser> public user$: Observable<IUser>
public userBtnTooltip$: Observable<string> public userBtnTooltip$: Observable<string>
public favDataEntries$: Observable<IDataEntry[]> public favDataEntries$: Observable<IDataEntry[]>
public pluginTooltipText: string = `Plugins and Tools` public pluginTooltipText: string = `Plugins and Tools`
public screenshotTooltipText: string = 'Take screenshot' public screenshotTooltipText: string = 'Take screenshot'
public takingScreenshot: boolean = false
constructor( constructor(
private store$: Store<IavRootStoreInterface>, private store$: Store<IavRootStoreInterface>,
private authService: AuthService, private authService: AuthService,
private dialog: MatDialog, private dialog: MatDialog,
public bottomSheet: MatBottomSheet, public bottomSheet: MatBottomSheet,
private changeDetectionRef: ChangeDetectorRef,
) { ) {
this.user$ = this.authService.user$ this.user$ = this.authService.user$
...@@ -60,6 +72,11 @@ export class SigninBanner { ...@@ -60,6 +72,11 @@ export class SigninBanner {
} }
} }
disableScreenshotTaking() {
this.takingScreenshot = false
this.changeDetectionRef.detectChanges()
}
private keyListenerConfigBase = { private keyListenerConfigBase = {
type: 'keydown', type: 'keydown',
stop: true, stop: true,
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
<mat-menu #pluginDropdownMenu> <mat-menu #pluginDropdownMenu>
<button mat-menu-item <button mat-menu-item
[disabled]="!parcellationIsSelected" [disabled]="!parcellationIsSelected"
(click)="takeScreenshotElement.startScreenshot()" (click)="takingScreenshot = true;"
[matTooltip]="screenshotTooltipText"> [matTooltip]="screenshotTooltipText">
<mat-icon fontSet="fas" fontIcon="fa-camera"> <mat-icon fontSet="fas" fontIcon="fa-camera">
</mat-icon> </mat-icon>
...@@ -126,15 +126,15 @@ ...@@ -126,15 +126,15 @@
</mat-dialog-actions> </mat-dialog-actions>
</ng-template> </ng-template>
<ng-template #settingTemplate> <ng-template #settingTemplate>
<h2 mat-dialog-title>Settings</h2> <h2 mat-dialog-title>Settings</h2>
<mat-dialog-content> <mat-dialog-content>
<!-- required to avoid showing an ugly vertical scroll bar --> <!-- required to avoid showing an ugly vertical scroll bar -->
<!-- TODO investigate why, then remove the friller class --> <!-- TODO investigate why, then remove the friller class -->
<config-component class="mb-4 d-block"> <config-component class="mb-4 d-block">
</config-component> </config-component>
</mat-dialog-content> </mat-dialog-content>
</ng-template> </ng-template>
<!-- saved dataset tmpl --> <!-- saved dataset tmpl -->
...@@ -172,5 +172,8 @@ ...@@ -172,5 +172,8 @@
<take-screenshot <take-screenshot
#takeScreenshotElement #takeScreenshotElement
class="position-fixed fixed-top"> *ngIf="takingScreenshot"
class="position-fixed fixed-top"
(screenshotTaking)="disableScreenshotTaking()"
(resetScreenshot)="$event? takingScreenshot = true : disableScreenshotTaking()">
</take-screenshot> </take-screenshot>
...@@ -2,10 +2,10 @@ import {DOCUMENT} from "@angular/common"; ...@@ -2,10 +2,10 @@ import {DOCUMENT} from "@angular/common";
import { import {
ChangeDetectorRef, ChangeDetectorRef,
Component, Component,
ElementRef, ElementRef, EventEmitter,
HostListener, HostListener,
Inject, Inject, OnDestroy,
OnInit, OnInit, Output,
Renderer2, Renderer2,
TemplateRef, TemplateRef,
ViewChild, ViewChild,
...@@ -19,11 +19,21 @@ import html2canvas from "html2canvas"; ...@@ -19,11 +19,21 @@ import html2canvas from "html2canvas";
styleUrls: ['./takeScreenshot.style.css'], styleUrls: ['./takeScreenshot.style.css'],
}) })
export class TakeScreenshotComponent implements OnInit { export class TakeScreenshotComponent implements OnInit, OnDestroy {
ngOnDestroy(): void {
if (this.resettingScreenshotTaking) this.resetScreenshot.emit(true)
this.resettingScreenshotTaking = false
}
@ViewChild('screenshotPreviewCard', {read: ElementRef}) public screenshotPreviewCard: ElementRef @ViewChild('screenshotPreviewCard', {read: ElementRef}) public screenshotPreviewCard: ElementRef
@ViewChild('previewImageDialog', {read: TemplateRef}) public previewImageDialogTemplateRef: TemplateRef<any> @ViewChild('previewImageDialog', {read: TemplateRef}) public previewImageDialogTemplateRef: TemplateRef<any>
@Output() screenshotTaking: EventEmitter<boolean> = new EventEmitter<boolean>()
@Output() resetScreenshot: EventEmitter<boolean> = new EventEmitter<boolean>()
private resettingScreenshotTaking: boolean = false
private dialogRef: MatDialogRef<any> private dialogRef: MatDialogRef<any>
public takingScreenshot: boolean = false public takingScreenshot: boolean = false
...@@ -67,6 +77,9 @@ export class TakeScreenshotComponent implements OnInit { ...@@ -67,6 +77,9 @@ export class TakeScreenshotComponent implements OnInit {
public ngOnInit(): void { public ngOnInit(): void {
this.windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth this.windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
this.windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight this.windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
this.startScreenshot()
} }
@HostListener('window:resize', ['$event']) @HostListener('window:resize', ['$event'])
...@@ -201,6 +214,7 @@ export class TakeScreenshotComponent implements OnInit { ...@@ -201,6 +214,7 @@ export class TakeScreenshotComponent implements OnInit {
.then(result => { .then(result => {
switch (result) { switch (result) {
case 'again': { case 'again': {
this.restartScreenshot()
this.startScreenshot() this.startScreenshot()
this.cdr.markForCheck() this.cdr.markForCheck()
break break
...@@ -241,12 +255,15 @@ export class TakeScreenshotComponent implements OnInit { ...@@ -241,12 +255,15 @@ export class TakeScreenshotComponent implements OnInit {
}) })
} }
public restartScreenshot() {
this.resettingScreenshotTaking = true
this.resetScreenshot.emit(false)
}
public cancelTakingScreenshot() { public cancelTakingScreenshot() {
this.takingScreenshot = false this.screenshotTaking.emit(false)
this.previewingScreenshot = false
this.loadingScreenshot = false
this.croppedCanvas = null
} }
public clearStateAfterScreenshot() { public clearStateAfterScreenshot() {
this.mouseIsDown = false this.mouseIsDown = false
this.isDragging = false this.isDragging = false
......
<div class="screenshotContainer overflow-hidden w-100 h-100" <div class="screenshotContainer overflow-hidden w-50 h-50"
(mousemove)="move($event)" (mousemove)="move($event)"
(mousedown)="mouseDown($event)" (mousedown)="mouseDown($event)"
(mouseup)="mouseUp($event)" (mouseup)="mouseUp($event)"
......
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