Skip to content

Commit

Permalink
feat: Add tiling window manager with slider
Browse files Browse the repository at this point in the history
  • Loading branch information
dominik003 authored and romeonicholas committed Nov 28, 2023
1 parent 622ef0d commit dfe6c10
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { Component, OnInit } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { debounceTime, fromEvent } from 'rxjs';
import { SessionViewerService, ViewerSession } from '../session-viewer.service';
import { debounceTime, fromEvent } from 'rxjs';
import { SessionViewerService, ViewerSession } from '../session-viewer.service';

@Component({
selector: 'app-floating-window-manager',
templateUrl: './floating-window-manager.component.html',
})
@UntilDestroy()
export class FloatingWindowManagerComponent implements OnInit {
draggingActive = false;

constructor(public sessionViewerService: SessionViewerService) {}

ngOnInit(): void {
Expand All @@ -23,11 +28,11 @@ export class FloatingWindowManagerComponent implements OnInit {
}

dragStart(): void {
this.sessionViewerService.disableAllSessions();
this.draggingActive = true;
}

dragStop(): void {
this.sessionViewerService.enableAllSessions();
this.draggingActive = false;
}

trackBySessionId(_: number, session: ViewerSession): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,16 @@
></div>
<iframe
[title]="
(session.version?.tool?.name ?? 'Unknown tool') +
', version' +
(session.version?.name ?? 'unknown version') +
', ' +
(session.version?.tool?.name ?? 'unknown tool name') +
'-' +
(session.version?.tool?.name ?? 'unknown tool name') +
'-' +
session.type
"
[id]="'session-' + session.id"
[src]="session.safeResourceURL"
class="h-full w-full"
allow="clipboard-read; clipboard-write"
[ngClass]="{
'pointer-events-none': session.disabled
}"
>
</iframe>
</div>
19 changes: 0 additions & 19 deletions frontend/src/app/sessions/session/session-viewer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,6 @@ export class SessionViewerService {
this._sessions.next(updatedSessions);
}

disableAllSessions(): void {
this._sessions.next(
this._sessions.value?.map((curSession) => ({
...curSession,
disabled: true,
})),
);
}

enableAllSessions(): void {
this._sessions.next(
this._sessions.value?.map((curSession) => ({
...curSession,
disabled: false,
})),
);
}

resizeSessions(): void {
document.querySelectorAll('iframe').forEach((iframe) => {
const session = this._sessions.value?.find(
Expand Down Expand Up @@ -155,5 +137,4 @@ export type ViewerSession = Session & {
focused: boolean;
reloadToResize: boolean;
fullscreen: boolean;
disabled: boolean;
};
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@

<div
*ngIf="session.index < sessions.length - 1"
class="w-2 cursor-col-resize rounded bg-gray-300"
class="my-2 w-2 cursor-col-resize bg-gray-300"
(mousedown)="onMouseDown($event, session.index)"
></div>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export class TilingWindowManagerComponent implements OnInit {
}

onMouseDown(event: MouseEvent, index: number): void {
this.sessionViewerService.disableAllSessions();
const leftSession = this.getSessionByIndex(index);
const rightSession = this.getSessionByIndex(index + 1);

Expand Down Expand Up @@ -92,8 +91,6 @@ export class TilingWindowManagerComponent implements OnInit {
@HostListener('window:mouseup')
onMouseUp(): void {
if (this.isValidResizeState(this.resizeState)) {
// Only trigger if resize is active
this.sessionViewerService.enableAllSessions();
this.resizeState = {};
this.sessionViewerService.resizeSessions();
}
Expand Down

0 comments on commit dfe6c10

Please sign in to comment.