-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add tailining window manager with slider
- Loading branch information
1 parent
896627d
commit 05c7bca
Showing
9 changed files
with
205 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { Pipe, PipeTransform } from '@angular/core'; | ||
|
||
@Pipe({ | ||
name: 'defaultValue', | ||
}) | ||
export class DefaultValuePipe implements PipeTransform { | ||
transform(value: string | undefined, defaultValue: string): string { | ||
return value ?? defaultValue; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...tend/src/app/sessions/session/tailing-window-manager/tailing-window-manager.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
.height { | ||
height: calc(100vh - 2vh - 65px - 110px); | ||
} |
52 changes: 52 additions & 0 deletions
52
...end/src/app/sessions/session/tailing-window-manager/tailing-window-manager.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!-- | ||
~ SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors | ||
~ SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
|
||
<div class="flex gap-0.5"> | ||
<ng-container *ngFor="let session of sessions; let i = index"> | ||
<div | ||
class="flex flex-col" | ||
[ngClass]="{ | ||
height: (fullscreenService.isFullscreen$ | async) === false, | ||
'h-screen': fullscreenService.isFullscreen$ | async | ||
}" | ||
[style.width]="widths[i] + 'px'" | ||
> | ||
<div | ||
class="flex items-center justify-between gap-2 rounded-t bg-slate-100 p-1" | ||
> | ||
<span> | ||
{{ session.version?.tool?.name }} {{ session.version?.name }}, | ||
{{ session.type }} | ||
<span *ngIf="session.type === 'readonly'" | ||
>(project {{ session.project!.name }})</span | ||
> | ||
</span> | ||
</div> | ||
|
||
<div class="relative grow"> | ||
<iframe | ||
[title]=" | ||
(session.version?.tool?.name | defaultValue: 'unknown tool name') + | ||
'-' + | ||
(session.version?.name | defaultValue: 'unknown version name') + | ||
'-' + | ||
session.type | ||
" | ||
[id]="'session-' + session.id" | ||
[src]="session.safeResourceURL" | ||
class="h-full w-full" | ||
allow="clipboard-read; clipboard-write" | ||
> | ||
</iframe> | ||
</div> | ||
</div> | ||
|
||
<div | ||
*ngIf="i < sessions.length - 1" | ||
class="my-2 w-2 cursor-col-resize bg-gray-300" | ||
(mousedown)="onMouseDown($event, i)" | ||
></div> | ||
</ng-container> | ||
</div> |
95 changes: 95 additions & 0 deletions
95
frontend/src/app/sessions/session/tailing-window-manager/tailing-window-manager.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { Component, HostListener, Input, OnInit } from '@angular/core'; | ||
import { Session } from 'src/app/schemes'; | ||
import { FullscreenService } from '../../service/fullscreen.service'; | ||
|
||
@Component({ | ||
selector: 'app-tailing-window-manager', | ||
templateUrl: './tailing-window-manager.component.html', | ||
styleUrls: ['./tailing-window-manager.component.css'], | ||
}) | ||
export class TailingWindowManagerComponent implements OnInit { | ||
@Input() sessions: Session[] = []; | ||
|
||
widths: number[] = []; | ||
resizeState = { | ||
index: undefined as number | undefined, | ||
startX: undefined as number | undefined, | ||
startWidths: [] as number[], | ||
}; | ||
|
||
lastInvocationTime = new Date().getTime(); | ||
throttleDuration = 10; | ||
|
||
existingMargin = 0; | ||
|
||
constructor(public fullscreenService: FullscreenService) {} | ||
|
||
ngOnInit(): void { | ||
this.fullscreenService.isFullscreen$.subscribe((isFullscreen) => { | ||
this.existingMargin = isFullscreen ? 0 : 27.48; | ||
this.updateWidths(); | ||
}); | ||
} | ||
|
||
onMouseDown(event: MouseEvent, index: number): void { | ||
this.resizeState = { | ||
index: index, | ||
startX: event.clientX, | ||
startWidths: [...this.widths], | ||
}; | ||
event.preventDefault(); | ||
|
||
Array.from(document.getElementsByTagName('iframe')).forEach((iframe) => { | ||
iframe.style.pointerEvents = 'none'; | ||
}); | ||
} | ||
|
||
@HostListener('window:mousemove', ['$event']) | ||
onMouseMove(event: MouseEvent): void { | ||
requestAnimationFrame(() => { | ||
if (this.resizeState.index !== undefined) { | ||
const time = new Date().getTime(); | ||
if (time - this.lastInvocationTime < this.throttleDuration) return; | ||
this.lastInvocationTime = time; | ||
|
||
const delta = event.clientX - this.resizeState.startX!; | ||
const leftPanelIndex = this.resizeState.index; | ||
const rightPanelIndex = this.resizeState.index + 1; | ||
|
||
this.widths[leftPanelIndex] = | ||
this.resizeState.startWidths[leftPanelIndex] + delta; | ||
this.widths[rightPanelIndex] = | ||
this.resizeState.startWidths[rightPanelIndex] - delta; | ||
} | ||
}); | ||
} | ||
|
||
@HostListener('window:mouseup') | ||
onMouseUp(): void { | ||
this.resizeState = { | ||
index: undefined, | ||
startX: undefined, | ||
startWidths: [], | ||
}; | ||
|
||
Array.from(document.getElementsByTagName('iframe')).forEach((iframe) => { | ||
iframe.style.pointerEvents = 'auto'; | ||
}); | ||
} | ||
|
||
@HostListener('window:resize') | ||
onResize() { | ||
this.updateWidths(); | ||
} | ||
|
||
private updateWidths() { | ||
this.widths = this.sessions.map( | ||
() => (window.innerWidth - this.existingMargin) / this.sessions.length, | ||
); | ||
} | ||
} |