Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ export const subscribeToClientEvents = (

messageBus.on('getSignalGraph', getSignalGraphCallback(messageBus));

messageBus.on('toggleWatchSignal', toggleWatchSignal(messageBus));

if (appIsAngularInDevMode() && appIsSupportedAngularVersion() && appIsAngularIvy()) {
inspector.ref = setupInspector(messageBus);

Expand Down Expand Up @@ -660,12 +662,18 @@ const getSignalGraphCallback = (messageBus: MessageBus<Events>) => (element: Ele
epoch: node.epoch,
preview: serializeValue(node.value),
debuggable: !!node.debuggableFn,
watched: node.watched ?? false,
};
});
messageBus.emit('latestSignalGraph', [{nodes, edges: graph.edges}]);
}
};

const toggleWatchSignal = (messageBus: MessageBus<Events>) => (id: string) => {
const ng = ngDebugClient();
ng.toggleWatchSignal?.(id);
};

// Route data needs to be serializable to be sent over the message bus.
export function sanitizeRouteData(route: Route): Route {
if (route.data) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@let node = this.node();
@let isSignalNode = this.isSignalNode(node);
@let isClusterNode = this.isClusterNode(node);
@let isWatchable = this.isWatchable(node);

<div class="header">
<div class="controls">
Expand Down Expand Up @@ -48,6 +49,19 @@
>
<ng-icon name="graph_upstream" />
</button>
@if (isWatchable) {
<button
ng-button
size="compact"
class="action-btn"
[class.watched]="node.watched"
[btnType]="node.watched ? 'primary' : 'secondary'"
(click)="toggleIsBeingWatched()"
[matTooltip]="node.watched ? 'Unwatch signal' : 'Watch signal'"
>
<mat-icon> {{ node.watched ? 'visibility_off' : 'visibility' }} </mat-icon>
</button>
}
</div>
<button
ng-button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* found in the LICENSE file at https://angular.dev/license
*/

import {Component, computed, input, output} from '@angular/core';
import {Component, computed, inject, input, output} from '@angular/core';
import {MatIcon} from '@angular/material/icon';

import {DebugSignalGraphNode, ElementPosition} from '../../../../../protocol';
import {DebugSignalGraphNode, ElementPosition, Events, MessageBus} from '../../../../../protocol';
import {SignalValueTreeComponent} from './signal-value-tree/signal-value-tree.component';
import {ButtonComponent} from '../button/button.component';
import {
Expand Down Expand Up @@ -64,12 +64,21 @@ export class SignalDetailsComponent {
}>();
protected readonly close = output<void>();

private readonly _messageBus = inject<MessageBus<Events>>(MessageBus);

protected readonly TYPE_CLASS_MAP = TYPE_CLASS_MAP;
protected readonly CLUSTER_TYPE_CLASS_MAP = CLUSTER_TYPE_CLASS_MAP;

protected readonly isSignalNode = isSignalNode;
protected readonly isClusterNode = isClusterNode;

protected isWatchable(node: DevtoolsSignalGraphNode): node is DevtoolsSignalNode {
return (
isSignalNode(node) &&
(node.kind === 'signal' || node.kind === 'computed' || node.kind === 'linkedSignal')
Comment thread
dgp1130 marked this conversation as resolved.
);
}

protected readonly cluster = computed(() => {
const node = this.node();
if (isSignalNode(node) && node.clusterId) {
Expand Down Expand Up @@ -113,6 +122,13 @@ export class SignalDetailsComponent {
return previewableNode;
});

protected toggleIsBeingWatched() {
const selectedNode = this.node();
if (!this.isWatchable(selectedNode)) return;
this._messageBus.emit('toggleWatchSignal', [selectedNode.id]);
selectedNode.watched = !selectedNode.watched;
}

private getCompoundNodeValueHof(node: DevtoolsClusterNode) {
const compoundNodes = (this.graph().nodes.filter(
(n) => isSignalNode(n) && n.clusterId === node.id,
Expand Down
Loading
Loading