-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added getFlowState functionality #46
- Loading branch information
1 parent
9aa5717
commit c5841fd
Showing
27 changed files
with
438 additions
and
8 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
...rc/domain/get-flow-state/get-flow-state-connections/get-flow-state-connections-request.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,3 @@ | ||
export class GetFlowStateConnectionsRequest { | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
.../domain/get-flow-state/get-flow-state-connections/get-flow-state-connections.execution.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,28 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { GetFlowStateConnectionsRequest } from './get-flow-state-connections-request'; | ||
import { FExecutionRegister, IExecution } from '@foblex/mediator'; | ||
import { FComponentsStore } from '../../../f-storage'; | ||
import { IFFlowStateConnection } from '../i-f-flow-state-connection'; | ||
|
||
@Injectable() | ||
@FExecutionRegister(GetFlowStateConnectionsRequest) | ||
export class GetFlowStateConnectionsExecution implements IExecution<GetFlowStateConnectionsRequest, IFFlowStateConnection[]> { | ||
|
||
constructor( | ||
private fComponentsStore: FComponentsStore, | ||
) { | ||
} | ||
|
||
public handle(request: GetFlowStateConnectionsRequest): IFFlowStateConnection[] { | ||
return this.fComponentsStore.fConnections.map((x) => { | ||
return { | ||
id: x.fId, | ||
fOutputId: x.fOutputId, | ||
fInputId: x.fInputId, | ||
fType: x.fType, | ||
fBehavior: x.fBehavior, | ||
isSelected: x.isSelected() | ||
} | ||
}); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
projects/f-flow/src/domain/get-flow-state/get-flow-state-connections/index.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,3 @@ | ||
export * from './get-flow-state-connections.execution'; | ||
|
||
export * from './get-flow-state-connections-request'; |
9 changes: 9 additions & 0 deletions
9
...cts/f-flow/src/domain/get-flow-state/get-flow-state-nodes/get-flow-state-nodes-request.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,9 @@ | ||
import { Type } from '@angular/core'; | ||
|
||
export class GetFlowStateNodesRequest { | ||
|
||
constructor( | ||
public type: Type<any> | ||
) { | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...s/f-flow/src/domain/get-flow-state/get-flow-state-nodes/get-flow-state-nodes.execution.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,48 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { GetFlowStateNodesRequest } from './get-flow-state-nodes-request'; | ||
import { FExecutionRegister, IExecution } from '@foblex/mediator'; | ||
import { IFFlowStateNode } from '../i-f-flow-state-node'; | ||
import { FComponentsStore } from '../../../f-storage'; | ||
import { IFFlowStateConnector } from '../i-f-flow-state-connector'; | ||
|
||
@Injectable() | ||
@FExecutionRegister(GetFlowStateNodesRequest) | ||
export class GetFlowStateNodesExecution implements IExecution<GetFlowStateNodesRequest, IFFlowStateNode[]> { | ||
|
||
constructor( | ||
private fComponentsStore: FComponentsStore, | ||
) { | ||
} | ||
|
||
public handle(request: GetFlowStateNodesRequest): IFFlowStateNode[] { | ||
return this.fComponentsStore.fNodes.filter((x) => x instanceof request.type).map((x) => { | ||
return { | ||
id: x.fId, | ||
parent: x.fParentId, | ||
position: x.position, | ||
size: x.size, | ||
fOutputs: this.getOutputs(x.hostElement), | ||
fInputs: this.getInputs(x.hostElement), | ||
isSelected: x.isSelected() | ||
}; | ||
}); | ||
} | ||
|
||
private getOutputs(hostElement: HTMLElement): IFFlowStateConnector[] { | ||
return this.fComponentsStore.fOutputs.filter((x) => hostElement.contains(x.hostElement)).map((x) => { | ||
return { | ||
id: x.id, | ||
fConnectableSide: x.fConnectableSide | ||
} | ||
}); | ||
} | ||
|
||
private getInputs(hostElement: HTMLElement): IFFlowStateConnector[] { | ||
return this.fComponentsStore.fInputs.filter((x) => hostElement.contains(x.hostElement)).map((x) => { | ||
return { | ||
id: x.id, | ||
fConnectableSide: x.fConnectableSide | ||
} | ||
}); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
projects/f-flow/src/domain/get-flow-state/get-flow-state-nodes/index.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,3 @@ | ||
export * from './get-flow-state-nodes.execution'; | ||
|
||
export * from './get-flow-state-nodes-request'; |
37 changes: 37 additions & 0 deletions
37
projects/f-flow/src/domain/get-flow-state/get-flow-state.execution.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,37 @@ | ||
import { GetFlowStateRequest } from './get-flow-state.request'; | ||
import { Injectable } from '@angular/core'; | ||
import { FExecutionRegister, FMediator, IExecution } from '@foblex/mediator'; | ||
import { IFFlowState } from './i-f-flow-state'; | ||
import { FComponentsStore } from '../../f-storage'; | ||
import { FGroupDirective, FNodeDirective } from '../../f-node'; | ||
import { IPoint, ITransformModel, PointExtensions } from '@foblex/2d'; | ||
import { GetFlowStateNodesRequest } from './get-flow-state-nodes'; | ||
import { GetFlowStateConnectionsRequest } from './get-flow-state-connections'; | ||
|
||
@Injectable() | ||
@FExecutionRegister(GetFlowStateRequest) | ||
export class GetFlowStateExecution implements IExecution<GetFlowStateRequest, IFFlowState> { | ||
|
||
constructor( | ||
private fComponentsStore: FComponentsStore, | ||
private fMediator: FMediator | ||
) { | ||
} | ||
|
||
public handle(payload: GetFlowStateRequest): IFFlowState { | ||
return { | ||
position: this.getCanvasPosition(this.fComponentsStore.fCanvas!.transform), | ||
scale: this.fComponentsStore.fCanvas!.transform.scale, | ||
nodes: this.fMediator.send(new GetFlowStateNodesRequest(FNodeDirective)), | ||
groups: this.fMediator.send(new GetFlowStateNodesRequest(FGroupDirective)), | ||
connections: this.fMediator.send(new GetFlowStateConnectionsRequest()) | ||
} | ||
} | ||
|
||
private getCanvasPosition(transform: ITransformModel): IPoint { | ||
return PointExtensions.sum(transform.position, transform.scaledPosition); | ||
} | ||
} | ||
|
||
|
||
|
2 changes: 2 additions & 0 deletions
2
projects/f-flow/src/domain/get-flow-state/get-flow-state.request.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,2 @@ | ||
export class GetFlowStateRequest { | ||
} |
16 changes: 16 additions & 0 deletions
16
projects/f-flow/src/domain/get-flow-state/i-f-flow-state-connection.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,16 @@ | ||
import { EFConnectionBehavior, EFConnectionType } from '../../f-connection'; | ||
|
||
export interface IFFlowStateConnection { | ||
|
||
id: string; | ||
|
||
fOutputId: string; | ||
|
||
fInputId: string; | ||
|
||
fType: EFConnectionType; | ||
|
||
fBehavior: EFConnectionBehavior; | ||
|
||
isSelected: boolean; | ||
} |
8 changes: 8 additions & 0 deletions
8
projects/f-flow/src/domain/get-flow-state/i-f-flow-state-connector.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,8 @@ | ||
import { EFConnectableSide } from '../../f-connectors'; | ||
|
||
export interface IFFlowStateConnector { | ||
|
||
id: string; | ||
|
||
fConnectableSide: EFConnectableSide; | ||
} |
19 changes: 19 additions & 0 deletions
19
projects/f-flow/src/domain/get-flow-state/i-f-flow-state-node.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,19 @@ | ||
import { IPoint, ISize } from '@foblex/2d'; | ||
import { IFFlowStateConnector } from './i-f-flow-state-connector'; | ||
|
||
export interface IFFlowStateNode { | ||
|
||
id: string; | ||
|
||
parentId?: string; | ||
|
||
position: IPoint; | ||
|
||
size: ISize; | ||
|
||
fInputs: IFFlowStateConnector[]; | ||
|
||
fOutputs: IFFlowStateConnector[]; | ||
|
||
isSelected: boolean; | ||
} |
16 changes: 16 additions & 0 deletions
16
projects/f-flow/src/domain/get-flow-state/i-f-flow-state.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,16 @@ | ||
import { IFFlowStateNode } from './i-f-flow-state-node'; | ||
import { IFFlowStateConnection } from './i-f-flow-state-connection'; | ||
import { IPoint } from '@foblex/2d'; | ||
|
||
export interface IFFlowState { | ||
|
||
position: IPoint; | ||
|
||
scale: number; | ||
|
||
nodes: IFFlowStateNode[]; | ||
|
||
groups: IFFlowStateNode[]; | ||
|
||
connections: IFFlowStateConnection[]; | ||
} |
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,17 @@ | ||
export * from './get-flow-state-connections'; | ||
|
||
export * from './get-flow-state-nodes'; | ||
|
||
export * from './get-flow-state.execution'; | ||
|
||
export * from './get-flow-state.request'; | ||
|
||
export * from './i-f-flow-state'; | ||
|
||
export * from './i-f-flow-state-connection'; | ||
|
||
export * from './i-f-flow-state-connector'; | ||
|
||
export * from './i-f-flow-state-node'; | ||
|
||
export * from './providers'; |
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,12 @@ | ||
import { GetFlowStateExecution } from './get-flow-state.execution'; | ||
import { GetFlowStateNodesExecution } from './get-flow-state-nodes'; | ||
import { GetFlowStateConnectionsExecution } from './get-flow-state-connections'; | ||
|
||
export const GET_FLOW_STATE_PROVIDERS = [ | ||
|
||
GetFlowStateExecution, | ||
|
||
GetFlowStateNodesExecution, | ||
|
||
GetFlowStateConnectionsExecution | ||
]; |
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
18 changes: 18 additions & 0 deletions
18
projects/f-flow/src/f-connection/f-snap-connection/f-snap-connection.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,18 @@ | ||
<svg xmlns="http://www.w3.org/2000/svg"> | ||
<defs #defs></defs> | ||
<g class="f-connection-group"> | ||
<linearGradient fConnectionGradient></linearGradient> | ||
<path fConnectionSelection [attr.d]="path"></path> | ||
<g> | ||
<path f-connection-path | ||
[attr.d]="path"> | ||
</path> | ||
<circle f-connection-drag-handle r="8"></circle> | ||
</g> | ||
<text f-connection-text></text> | ||
</g> | ||
<ng-content></ng-content> | ||
</svg> | ||
<div #fConnectionCenter class="f-connection-center" *ngIf="fConnectionCenters.length"> | ||
<ng-content select="[fConnectionCenter]"></ng-content> | ||
</div> |
12 changes: 12 additions & 0 deletions
12
projects/f-flow/src/f-connection/f-snap-connection/f-snap-connection.component.scss
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,12 @@ | ||
:host { | ||
pointer-events: none; | ||
position: absolute; | ||
|
||
svg { | ||
overflow: visible; | ||
|
||
.f-connection-group { | ||
pointer-events: all; | ||
} | ||
} | ||
} |
Oops, something went wrong.