-
Notifications
You must be signed in to change notification settings - Fork 230
Add button for adding device panel vertically into view panel #2883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ import { | |
| KtdGridLayout, | ||
| KtdGridLayoutItem, | ||
| ktdTrackById, | ||
| ktdGridCompact, | ||
| } from '@katoid/angular-grid-layout'; | ||
| import {DisplayInfo} from '../../../../intercept/js/server_connector' | ||
|
|
||
|
|
@@ -237,16 +238,31 @@ export class ViewPaneComponent implements OnInit, OnDestroy, AfterViewInit { | |
| item: DeviceGridItem, | ||
| layout: DeviceGridItem[] | ||
| ): DeviceGridItem { | ||
| const lastMaxY = | ||
| let stackVertical = false; | ||
| const lastItemY = | ||
| layout.length !== 0 ? Math.max(...layout.map(obj => obj.y)) : 0; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
| const lastRowLayout = layout.filter(obj => obj.y === lastMaxY); | ||
| const lastMaxX = | ||
| const bottomBorder = | ||
| layout.length !== 0 ? Math.max(...layout.map(obj => obj.y + obj.h)) : 0; | ||
| const lastRowLayout = layout.filter(obj => obj.y === lastItemY); | ||
| const rightBorder = | ||
| layout.length !== 0 | ||
| ? Math.max(...lastRowLayout.map(obj => obj.x)) | ||
| : -item.w; | ||
| ? Math.max(...lastRowLayout.map(obj => obj.x + obj.w)) | ||
| : 0; | ||
|
|
||
| item.x = lastMaxX + item.w * 2 <= this.cols ? lastMaxX + item.w : 0; | ||
| item.y = lastMaxX + item.h * 2 <= this.cols ? lastMaxY : lastMaxY + item.h; | ||
| if (this.displaysService.addVertically$.value) { | ||
| stackVertical = true; | ||
| } else { | ||
| stackVertical = | ||
| layout.length !== 0 && rightBorder + item.w > this.cols; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| if (stackVertical) { | ||
| item.x = 0; | ||
| item.y = bottomBorder; | ||
| } else { | ||
| item.x = rightBorder; | ||
| item.y = lastItemY; | ||
| } | ||
|
|
||
| item.placed = true; | ||
|
|
||
|
|
@@ -294,8 +310,22 @@ export class ViewPaneComponent implements OnInit, OnDestroy, AfterViewInit { | |
| } | ||
| layoutById.set(id, item); | ||
| }); | ||
|
|
||
| return Array.from(layoutById, ([, value]) => value); | ||
| }, []), map(items => items.filter(item => item.visible))); | ||
| }, []), map(items => { | ||
| const visibleItems = items.filter(item => item.visible); | ||
| return this.packItems(visibleItems); | ||
| })); | ||
|
|
||
| private packItems(items: DeviceGridItem[]): DeviceGridItem[] { | ||
| const vertCompacted = ktdGridCompact(items, 'vertical', this.cols); | ||
| const bothCompacted = ktdGridCompact(vertCompacted, 'horizontal', this.cols); | ||
| const compactedMap = new Map(bothCompacted.map(item => [item.id, item])); | ||
| return items.map(item => { | ||
| const compacted = compactedMap.get(item.id); | ||
| return compacted ? { ...item, ...compacted } : item; | ||
| }); | ||
| } | ||
|
|
||
| forceShowDevice(deviceId: string) { | ||
| this.displaysService.onDeviceDisplayInfo({ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.