Skip to content
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

fix #227 add module and service #244

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
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
648 changes: 504 additions & 144 deletions ui/package-lock.json

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions ui/src/modules/plans/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@

export * from './attribute'
export * from './operation/operation-info.models'
export * from './plan/plan-overivew.models'
export * from './plan/plan-node-control.models'
6 changes: 5 additions & 1 deletion ui/src/modules/plans/models/plan/plan-info.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import { NgModule } from '@angular/core'
import { CommonModule } from '@angular/common'
import { PlanInfoService } from './plan-info.service'
import { PlanNodeControlService } from './plan-node-control.service'
import { PlanOverviewService } from './plan-overview.service'


@NgModule({
Expand All @@ -25,7 +27,9 @@ import { PlanInfoService } from './plan-info.service'
CommonModule
],
providers: [
PlanInfoService
PlanInfoService,
PlanNodeControlService,
PlanOverviewService
]
})
export class PlanInfoModule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,50 @@
* limitations under the License.
*/

import { Injectable } from '@angular/core'
import { SgNodeControl } from 'spline-shared/graph'
import { ExecutionPlanLineageNode } from 'spline-api'
import { SgNode, SgNodeCircle, SgNodeDefault } from 'spline-common/graph'
import { SgNodeControl } from 'spline-shared/graph'

import { OperationInfo } from '../operation'

export namespace PlanNodeControl {

import NodeView = SgNodeControl.NodeView
@Injectable()
export class PlanNodeControlService {


export function extractNodeName(nodeSource: ExecutionPlanLineageNode): string {
extractNodeName(nodeSource: ExecutionPlanLineageNode): string {
return nodeSource.name
}

export function toSgNode(nodeSource: ExecutionPlanLineageNode,
nodeView: NodeView = NodeView.Detailed): SgNode {
toSgNode(nodeSource: ExecutionPlanLineageNode, nodeView: SgNodeControl.NodeView = SgNodeControl.NodeView.Detailed): SgNode {
const nodeStyles = OperationInfo.getNodeStyles(nodeSource?.type, nodeSource.name)

const defaultActions = [
...SgNodeControl.getNodeRelationsHighlightActions(),
]

switch (nodeView) {
case NodeView.Compact:
case SgNodeControl.NodeView.Compact:
return SgNodeCircle.toNode(
nodeSource.id,
{
tooltip: extractNodeName(nodeSource),
tooltip: this.extractNodeName(nodeSource),
...nodeStyles,
},
)
case NodeView.Detailed:
case SgNodeControl.NodeView.Detailed:
default:
return SgNodeDefault.toNode(
nodeSource.id,
{
label: extractNodeName(nodeSource),
label: this.extractNodeName(nodeSource),
...nodeStyles,
inlineActions: defaultActions,
},
)
}
}

}


Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,18 @@
* limitations under the License.
*/


import { Injectable } from '@angular/core'
import { ActivatedRoute } from '@angular/router'
import { RouterNavigation } from 'spline-utils'
import { QueryParamAlis } from './query-param-alis'
import { RouterState } from './router-state'


export namespace PlanOverview {

export enum QueryParamAlis {
ExecutionPlanId = 'planId',
ExecutionEventId = 'eventId',
SelectedNodeId = 'nodeId',
SelectedAttributeId = 'attributeId',
}
@Injectable()
export class PlanOverviewService {

export type RouterState = {
[QueryParamAlis.ExecutionPlanId]: string
[QueryParamAlis.ExecutionEventId]: string | null
[QueryParamAlis.SelectedNodeId]: string | null
[QueryParamAlis.SelectedAttributeId]: string | null
}

export function extractRouterState(activatedRoute: ActivatedRoute): RouterState {
extractRouterState(activatedRoute: ActivatedRoute): RouterState {
return {
[QueryParamAlis.ExecutionPlanId]: activatedRoute.snapshot.params[QueryParamAlis.ExecutionPlanId],
[QueryParamAlis.ExecutionEventId]: RouterNavigation.extractQueryParam(activatedRoute, QueryParamAlis.ExecutionEventId),
Expand All @@ -44,11 +34,11 @@ export namespace PlanOverview {
}
}

export function getSelectedNodeId(activatedRoute: ActivatedRoute): string {
getSelectedNodeId(activatedRoute: ActivatedRoute): string {
return RouterNavigation.extractQueryParam(activatedRoute, QueryParamAlis.SelectedNodeId)
}

export function getSelectedAttributeId(activatedRoute: ActivatedRoute): string {
getSelectedAttributeId(activatedRoute: ActivatedRoute): string {
return RouterNavigation.extractQueryParam(activatedRoute, QueryParamAlis.SelectedAttributeId)
}
}
22 changes: 22 additions & 0 deletions ui/src/modules/plans/models/plan/query-param-alis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2023 ABSA Group Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export enum QueryParamAlis {
ExecutionPlanId = 'planId',
ExecutionEventId = 'eventId',
SelectedNodeId = 'nodeId',
SelectedAttributeId = 'attributeId',
}
25 changes: 25 additions & 0 deletions ui/src/modules/plans/models/plan/router-state.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2023 ABSA Group Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { QueryParamAlis } from './query-param-alis'


export interface RouterState {
[QueryParamAlis.ExecutionPlanId]: string
[QueryParamAlis.ExecutionEventId]: string | null
[QueryParamAlis.SelectedNodeId]: string | null
[QueryParamAlis.SelectedAttributeId]: string | null
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ import { BaseComponent, RouterNavigation } from 'spline-utils'

import { AttributeLineageDialogComponent } from '../../components'
import { AttributeLineageDialog } from '../../components/attribute-lineage/attribute-lineage-dialog/attribute-lineage-dialog.models'
import { PlanOverview } from '../../models'
import { ExecutionPlanOverviewFactoryStore } from '../../store'
import QueryParamAlis = PlanOverview.QueryParamAlis
import { PlanOverviewService } from '../../models/plan/plan-overview.service'
import { QueryParamAlis } from '../../models/plan/query-param-alis'
// import { PlanOverview } from '../../models'


@Component({
Expand Down Expand Up @@ -60,7 +61,8 @@ export class PlanOverviewPageComponent extends BaseComponent implements OnInit {
constructor(private readonly activatedRoute: ActivatedRoute,
private readonly router: Router,
private readonly matDialog: MatDialog,
readonly store: ExecutionPlanOverviewFactoryStore
readonly store: ExecutionPlanOverviewFactoryStore,
private planOverviewService: PlanOverviewService
) {
super()

Expand Down Expand Up @@ -98,7 +100,7 @@ export class PlanOverviewPageComponent extends BaseComponent implements OnInit {

ngOnInit(): void {

const routerState = PlanOverview.extractRouterState(this.activatedRoute)
const routerState = this.planOverviewService.extractRouterState(this.activatedRoute)
this.eventId = routerState[QueryParamAlis.ExecutionEventId]

// init store state
Expand Down Expand Up @@ -180,13 +182,13 @@ export class PlanOverviewPageComponent extends BaseComponent implements OnInit {
skip(1),
map(selectedNode => selectedNode ? selectedNode.id : null),
filter(selectedNodeId => {
const nodeId = PlanOverview.getSelectedNodeId(this.activatedRoute)
const nodeId = this.planOverviewService.getSelectedNodeId(this.activatedRoute)
return selectedNodeId !== nodeId
}),
takeUntil(this.destroyed$)
)
.subscribe(selectedNodeId =>
this.updateQueryParams(PlanOverview.QueryParamAlis.SelectedNodeId, selectedNodeId)
this.updateQueryParams(QueryParamAlis.SelectedNodeId, selectedNodeId)
)

//
Expand All @@ -198,13 +200,13 @@ export class PlanOverviewPageComponent extends BaseComponent implements OnInit {
skip(1),
map(selectedAttribute => selectedAttribute ? selectedAttribute.id : null),
filter(selectedAttributeId => {
const attrId = PlanOverview.getSelectedAttributeId(this.activatedRoute)
const attrId = this.planOverviewService.getSelectedAttributeId(this.activatedRoute)
return selectedAttributeId !== attrId
}),
takeUntil(this.destroyed$)
)
.subscribe(attrId =>
this.updateQueryParams(PlanOverview.QueryParamAlis.SelectedAttributeId, attrId)
this.updateQueryParams(QueryParamAlis.SelectedAttributeId, attrId)
)
}

Expand All @@ -217,7 +219,7 @@ export class PlanOverviewPageComponent extends BaseComponent implements OnInit {
)
.subscribe(() => {

const routerState = PlanOverview.extractRouterState(this.activatedRoute)
const routerState = this.planOverviewService.extractRouterState(this.activatedRoute)
this.eventId = routerState[QueryParamAlis.ExecutionEventId]

// reinitialize store state in case of new ExecutionPlan ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ import {
import { SgData } from 'spline-common/graph'
import { SgNodeControl } from 'spline-shared/graph'
import { ProcessingStoreNs, SplineEntityStoreNs } from 'spline-utils'

import { PlanNodeControl } from '../../models'
import { PlanNodeControlService } from '../../models/plan/plan-node-control.service'


export namespace ExecutionPlanOverviewStoreNs {

const planNodeControlService = new PlanNodeControlService()
export type State = {
nodes: SplineEntityStoreNs.EntityState<ExecutionPlanLineageNode>
executionPlanId: string | null
Expand Down Expand Up @@ -87,7 +86,7 @@ export namespace ExecutionPlanOverviewStoreNs {
nodes: nodesList
// map node source data to the SgNode schema
.map(
nodeSource => PlanNodeControl.toSgNode(nodeSource, state.graphNodeView)
nodeSource => planNodeControlService.toSgNode(nodeSource, state.graphNodeView)
)
}
}
Expand Down