Skip to content

Commit

Permalink
Merge pull request #5052 from systeminit/zack/show-geo-in-debug
Browse files Browse the repository at this point in the history
chore: show views/geometry in debug panel
  • Loading branch information
zacharyhamm authored Dec 2, 2024
2 parents d281749 + 64cacdb commit 0a9b67c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/web/src/components/Debug/ComponentDebugDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
title="Parent Id?"
/>
</dl>
<dl class="border-l-2 p-xs flex flex-col gap-xs">
<DebugViewItem
v-for="[viewId, geometry] in Object.entries(debugData.geometry)"
:key="viewId"
:data="geometry"
:title="geometryTitle(viewId)"
/>
</dl>
</TreeNode>

<!-- Attributes -->
Expand Down Expand Up @@ -132,6 +140,8 @@ import {
} from "@si/vue-lib/design-system";
import { computed, onMounted, ref } from "vue";
import { useComponentsStore } from "@/store/components.store";
import { useViewsStore } from "@/store/views.store";
import { ViewId } from "@/api/sdf/dal/views";
import AttributeDebugView from "./AttributeDebugView.vue";
import SocketDebugView from "./SocketDebugView.vue";
import DebugViewItem from "./DebugViewItem.vue";
Expand All @@ -145,6 +155,13 @@ const debugParent = ref<InstanceType<typeof Element>>();
const searchString = ref("");
const viewStore = useViewsStore();
const geometryTitle = (viewId: ViewId) => {
const viewName = viewStore.viewsById[viewId]?.name ?? "unknown";
return `view: ${viewName}`;
};
function _findChildren(elm: Element) {
if (elm.tagName === "DD" || elm.tagName === "DT")
if (
Expand Down
11 changes: 11 additions & 0 deletions app/web/src/store/components.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ export interface ComponentDebugView {
inputSockets: SocketDebugView[];
outputSockets: SocketDebugView[];
parentId?: string | null;
geometry: {
[key: string]: {
id: string;
created_at: Date;
updated_at: Date;
x: number;
y: number;
width?: number;
height?: number;
};
};
}

export interface ComponentGeometry {
Expand Down
18 changes: 18 additions & 0 deletions lib/dal/src/component/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use thiserror::Error;
use crate::attribute::value::AttributeValueError;

use crate::attribute::value::debug::{AttributeDebugView, AttributeDebugViewError};
use crate::diagram::geometry::Geometry;
use crate::diagram::view::{View, ViewId};
use crate::diagram::DiagramError;
use crate::prop::PropError;
use crate::socket::debug::{SocketDebugView, SocketDebugViewError};
use crate::socket::input::InputSocketError;
Expand Down Expand Up @@ -34,6 +37,7 @@ pub struct ComponentDebugView {
pub input_sockets: Vec<SocketDebugView>,
pub output_sockets: Vec<SocketDebugView>,
pub parent_id: Option<ComponentId>,
pub geometry: HashMap<ViewId, Geometry>,
}
/// A generated view for an [`Component`](crate::Component) that contains metadata about each of
/// the components attributes. Used for constructing a debug view of the component and also for
Expand Down Expand Up @@ -62,6 +66,8 @@ pub enum ComponentDebugViewError {
Component(String),
#[error("component error: {0}")]
ComponentError(#[from] ComponentError),
#[error("diagram error: {0}")]
Diagram(#[from] DiagramError),
#[error("func error: {0}")]
Func(#[from] FuncError),
#[error("input socket error: {0}")]
Expand Down Expand Up @@ -138,13 +144,25 @@ impl ComponentDebugView {
output_sockets.push(avd);
}

let mut geometry = HashMap::new();
for view in View::list(ctx).await? {
let Some(geo) =
Geometry::try_get_by_component_and_view(ctx, component.id, view.id()).await?
else {
continue;
};

geometry.insert(view.id(), geo);
}

let debug_view = ComponentDebugView {
name: component_debug_data.name,
schema_variant_id: component_debug_data.schema_variant_id,
attributes,
input_sockets,
output_sockets,
parent_id: component_debug_data.parent_id,
geometry,
};

Ok(debug_view)
Expand Down

0 comments on commit 0a9b67c

Please sign in to comment.