Skip to content

Commit d3ca710

Browse files
Merge branch 'develop' of https://github.com/AbsaOSS/spline-ui into fix/228-setTimeout-refactor
2 parents c73b4ca + 28f813f commit d3ca710

File tree

38 files changed

+645
-939
lines changed

38 files changed

+645
-939
lines changed

ui/cypress/e2e/main-tests-spec.cy.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,53 @@ describe('Main Tests', () => {
2020
cy.title().should('eq', 'Spline - Data Lineage Tacking & Visualization')
2121
})
2222

23+
describe('Issue: datepicker calendar should filter data in the table', () => {
24+
it('Datepicker panel should open after clicking on button with text `Everything`', () => {
25+
cy.visit('/')
26+
cy.get('ngx-daterangepicker-material').should('not.exist')
27+
cy.get('spline-date-filter button').click()
28+
cy.get('ngx-daterangepicker-material').should('exist')
29+
})
30+
31+
it('Choosen date in datepicker should replace text on button with text `Everything`', () => {
32+
cy.visit('/')
33+
cy.get('spline-date-filter button').click()
34+
cy.get('ngx-daterangepicker-material .ranges .ng-star-inserted:nth-child(5) button').click()
35+
cy.get('ngx-daterangepicker-material .buttons_input button.btn:nth-child(3)').click()
36+
cy.get('spline-date-filter button .spline-inline-filter__value').should('not.contain.text', 'Everything')
37+
cy.get('spline-date-filter button .spline-inline-filter__value').invoke('text') // check the innerHTML text
38+
.should('match', /\d\d\d\d-\d\d-\d\d - \d\d\d\d-\d\d-\d\d/)
39+
cy.get('body').click()
40+
cy.get('ngx-daterangepicker-material').should('not.exist')
41+
})
42+
43+
it('Choosen date should filter data in table', () => {
44+
cy.visit('/')
45+
cy.get('spline-date-filter button').click()
46+
cy.get('ngx-daterangepicker-material .ranges .ng-star-inserted:nth-child(5) button').click()
47+
cy.get('ngx-daterangepicker-material .buttons_input button.btn:nth-child(3)')
48+
.should('contain.text', 'Apply').click()
49+
cy.get('mat-table mat-row').should('have.length.lessThan', 10)
50+
cy.get('ngx-daterangepicker-material').should('exist')
51+
})
52+
53+
it('Choosen date should correctly apply after page reloading', () => {
54+
cy.visit('/')
55+
cy.get('spline-date-filter button').click()
56+
cy.get('ngx-daterangepicker-material .ranges .ng-star-inserted:nth-child(7) button').click()
57+
cy.get('ngx-daterangepicker-material .buttons_input button.btn:nth-child(3)')
58+
.should('contain.text', 'Apply').click()
59+
cy.get('ngx-daterangepicker-material').should('exist')
60+
cy.reload()
61+
cy.get('mat-table mat-row').should('have.length.at.least', 1)
62+
cy.get('spline-loader mat-spinner').should('not.exist')
63+
})
64+
})
65+
2366
describe('Issue: On event-overview page', () => {
2467
it('back button should restore the state of the previous page', () => {
2568
cy.visit('/')
26-
cy.get('mat-row:nth-child(8) .link').first().click()
69+
cy.get('mat-row:nth-child(9) .link').first().click()
2770
cy.get('sg-overview-control button').last().click()
2871
cy.wait(1000)
2972
cy.get('ngx-graph .node-group:nth-child(3)').click()

ui/package-lock.json

Lines changed: 286 additions & 261 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@
6262
"bootstrap": "^4.4.1",
6363
"d3-scale": "^4.0.2",
6464
"d3-shape": "^1.3.7",
65+
"dayjs": "^1.11.7",
6566
"lodash-es": "^4.17.21",
6667
"moment": "^2.29.4",
67-
"ngx-daterangepicker-material": "^4.0.1",
68+
"ngx-daterangepicker-material": "^6.0.4",
6869
"ngx-json-viewer": "~3.0.2",
6970
"ngx-translate-multi-http-loader": "^3.0.0",
7071
"rxjs": "^7.0.0",
@@ -86,8 +87,9 @@
8687
"@babel/helper-get-function-arity": "^7.16.7",
8788
"@babel/plugin-transform-runtime": "^7.14.5",
8889
"@babel/runtime": "^7.14.6",
89-
"@cypress/schematic": "^2.4.0",
90+
"@cypress/schematic": "~2.4.0",
9091
"@ngrx/store-devtools": "^12.3.0",
92+
"@schematics/angular": "^12.1.3",
9193
"@types/d3-shape": "^1.3.2",
9294
"@types/eslint": "^8.4.10",
9395
"@types/jest": "^27.5.2",
@@ -96,7 +98,7 @@
9698
"@typescript-eslint/eslint-plugin": "^4.28.2",
9799
"@typescript-eslint/parser": "^4.28.2",
98100
"codelyzer": "^6.0.0",
99-
"cypress": "^12.3.0",
101+
"cypress": "^12.5.1",
100102
"eslint": "^7.26.0",
101103
"eslint-plugin-cypress": "^2.12.1",
102104
"eslint-plugin-import": "^2.27.5",
@@ -108,6 +110,8 @@
108110
"lint-staged": "^10.1.3",
109111
"loader-utils": "^2.0.4",
110112
"lodash": "^4.17.21",
113+
"mockdate": "^3.0.5",
114+
"ng-mocks": "^14.6.0",
111115
"ng-packagr": "^12.1.2",
112116
"ngrx-store-freeze": "^0.2.4",
113117
"replace-in-file": "^6.1.0",

ui/projects/spline-api/src/lib/execution-event/models/entities/execution-event/execution-events-query.models.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export namespace ExecutionEventsQuery {
5454
return {
5555
...(queryParams?.filter ? toQueryFilterDto(queryParams.filter) : {}),
5656
...(queryParams?.pager ? toQueryPagerDto(queryParams.pager) : {}),
57-
...(queryParams?.sortBy?.length ? toSortingDto(queryParams.sortBy) : {}),
57+
...(queryParams?.sortBy?.length ? toSortingDto(queryParams.sortBy) : {})
5858
}
5959
}
6060

@@ -74,25 +74,39 @@ export namespace ExecutionEventsQuery {
7474
}
7575

7676
export function toQueryParams(
77-
searchParams: SearchQuery.SearchParams<QueryFilter, ExecutionEventField>,
77+
searchParams: SearchQuery.SearchParams<QueryFilter, ExecutionEventField>
7878
): QueryParams {
7979
const queryFilter = {
8080
...searchParams.filter,
8181
...searchParams.alwaysOnFilter,
82-
searchTerm: searchParams.searchTerm,
82+
searchTerm: searchParams.searchTerm
8383
}
8484
return {
8585
filter: queryFilter,
8686
pager: searchParams.pager,
87-
sortBy: searchParams.sortBy,
87+
sortBy: searchParams.sortBy
8888
}
8989
}
9090

91+
function parseDate(value = undefined) {
92+
if (typeof value === 'number') {
93+
return value
94+
}
95+
if (typeof value === 'string') {
96+
return (Date.parse(value))
97+
}
98+
if (value instanceof Date) {
99+
return value.getTime()
100+
}
101+
102+
return undefined
103+
}
91104

92105
function toQueryFilterDto(queryFilter: QueryFilter): Partial<QueryParamsDto> {
106+
93107
return {
94-
timestampStart: queryFilter?.executedAtFrom ? queryFilter?.executedAtFrom.getTime() : undefined,
95-
timestampEnd: queryFilter?.executedAtTo ? queryFilter?.executedAtTo.getTime() : undefined,
108+
timestampStart: parseDate(queryFilter.executedAtFrom),
109+
timestampEnd: parseDate(queryFilter.executedAtTo),
96110
searchTerm: queryFilter?.searchTerm?.length ? queryFilter?.searchTerm : undefined,
97111
dataSourceUri: queryFilter?.dataSourceUri,
98112
asAtTime: queryFilter?.asAtTime,
@@ -117,14 +131,14 @@ export namespace ExecutionEventsQuery {
117131
const offset = queryPager?.offset ?? 0
118132
return {
119133
pageSize: limit,
120-
pageNum: offset / limit + 1,
134+
pageNum: offset / limit + 1
121135
}
122136
}
123137

124138
function toSortingDto(sortBy: QuerySorter.FieldSorter<ExecutionEventField>[]): Partial<QueryParamsDto> {
125139
return {
126140
sortField: sortBy[0].field,
127-
sortOrder: sortBy[0].dir.toLowerCase(),
141+
sortOrder: sortBy[0]?.dir?.toLowerCase()
128142
}
129143
}
130144
}

ui/projects/spline-common/dynamic-filter/filter-controls/src/date-range/df-control-date-range.component.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,24 @@
1515
*/
1616

1717
import { Component, Input } from '@angular/core'
18-
import { SplineDateRangeFilter } from 'spline-common'
1918
import { BaseDynamicFilterControlComponent } from 'spline-common/dynamic-filter'
19+
import { SplineDateRangeValue } from 'spline-utils'
2020

2121
import { DfControlDateRange } from './df-control-date-range.models'
2222

23+
2324
@Component({
25+
// eslint-disable-next-line @angular-eslint/component-selector
2426
selector: 'df-control-date-range',
25-
templateUrl: './df-control-date-range.component.html',
27+
templateUrl: './df-control-date-range.component.html'
2628
})
2729
export class DfControlDateRangeComponent<TId extends keyof any = any>
2830
extends BaseDynamicFilterControlComponent<DfControlDateRange.Value, DfControlDateRange.Options, TId> {
2931

30-
readonly defaultIcon = 'schedule'
31-
3232
@Input() model: DfControlDateRange.Model<TId>
33-
34-
onDateFilterChanged(value: SplineDateRangeFilter.Value): void {
33+
readonly defaultIcon = 'schedule'
34+
35+
onDateFilterChanged(value: SplineDateRangeValue): void {
3536
this.model.patchValue(
3637
value
3738
)

ui/projects/spline-common/dynamic-filter/filter-controls/src/date-range/df-control-date-range.models.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,17 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { SplineDateRangeFilter } from 'spline-common'
1817
import { BaseDynamicFilterControlModel, DynamicFilterControlSchema } from 'spline-common/dynamic-filter'
19-
import { SplineDateRangeValue } from 'spline-utils'
18+
import { SplineDateRangeValue, SplineRecord } from 'spline-utils'
2019

2120

2221
export namespace DfControlDateRange {
2322

2423
export const TYPE = 'DfControlDateRange'
2524

26-
export type Value = SplineDateRangeFilter.Value
25+
export type Value = SplineDateRangeValue
2726

28-
export type Options = {}
27+
export type Options = SplineRecord
2928

3029
export type Schema<TId extends keyof any = any> =
3130
& DynamicFilterControlSchema<Value, Options, TId>
@@ -35,20 +34,6 @@ export namespace DfControlDateRange {
3534
label?: string
3635
bounds?: SplineDateRangeValue | null
3736
}
38-
39-
export function getSchema<TId extends keyof any = any>(
40-
label?: string,
41-
icon?: string,
42-
bounds?: SplineDateRangeValue | null): Partial<Schema> {
43-
44-
return {
45-
type: TYPE,
46-
label,
47-
icon,
48-
bounds
49-
}
50-
}
51-
5237
export type Config = Omit<Schema, 'id' | 'type'>
5338

5439
export class Model<TId extends keyof any = any> extends BaseDynamicFilterControlModel<Value, Options, TId> {

ui/projects/spline-common/dynamic-table/src/core/dynamic-table.module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { MatIconModule } from '@angular/material/icon'
2121
import { MatSortModule } from '@angular/material/sort'
2222
import { MatTableModule } from '@angular/material/table'
2323
import { RouterModule } from '@angular/router'
24-
import { SplineLongTextModule, SplineSortHeaderModule, SplineVirtualScrollModule } from 'spline-common'
24+
import { SplineLongTextModule, SplineSortHeaderModule } from 'spline-common'
2525
import { SplineUtilsCommonModule } from 'spline-utils'
2626
import { SplineTranslateModule } from 'spline-utils/translate'
2727

@@ -41,7 +41,6 @@ import * as fromServices from './services'
4141
SplineLongTextModule,
4242
SplineTranslateModule.forChild({}),
4343
SplineSortHeaderModule,
44-
SplineVirtualScrollModule,
4544
],
4645
declarations: [
4746
...dynamicTableComponents,

ui/projects/spline-common/graph/src/components/graph/spline-graph.component.ts

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,20 @@ import { BaseComponent } from 'spline-utils'
3535

3636
import { SgControlPanelSectionDirective } from '../../directives/control-panel-action/sg-control-panel-section.directive'
3737
import {
38+
SG_DEFAULT_LAYOUT_SETTINGS,
3839
SgData,
3940
SgLayoutSettings,
4041
SgNativeNode,
4142
SgNodeControlEvent,
4243
SgNodeEvent,
4344
SgNodeSchema,
44-
SG_DEFAULT_LAYOUT_SETTINGS,
45-
toSgNativeNode,
45+
toSgNativeNode
4646
} from '../../models'
4747

4848

4949
@Component({
5050
selector: 'spline-graph',
51-
templateUrl: './spline-graph.component.html',
51+
templateUrl: './spline-graph.component.html'
5252
})
5353
export class SplineGraphComponent extends BaseComponent implements OnChanges, OnDestroy {
5454

@@ -59,35 +59,15 @@ export class SplineGraphComponent extends BaseComponent implements OnChanges, On
5959
@Input() curve: fromD3Shape.CurveFactoryLineOnly | fromD3Shape.CurveFactory = fromD3Shape.curveBasis
6060
@Input() layoutSettings: SgLayoutSettings = SG_DEFAULT_LAYOUT_SETTINGS
6161
@Input() focusNode$: Observable<string>
62-
63-
@Input() set selectedNodeId(nodeId: string) {
64-
if (nodeId !== this._selectedNodeId) {
65-
this._selectedNodeId = nodeId
66-
}
67-
}
68-
69-
@Input() set targetNodeId(nodeId: string) {
70-
if (nodeId !== this._targetNodeId) {
71-
this._targetNodeId = nodeId
72-
}
73-
}
74-
7562
@Output() substrateClick$ = new EventEmitter<{ mouseEvent: MouseEvent }>()
7663
@Output() nodeClick$ = new EventEmitter<{ nodeSchema: SgNodeSchema; mouseEvent: MouseEvent }>()
7764
@Output() nodeDoubleClick$ = new EventEmitter<{ nodeSchema: SgNodeSchema; mouseEvent: MouseEvent }>()
7865
@Output() nodeEvent$ = new EventEmitter<SgNodeEvent>()
7966
@Output() nodeSelectionChange$ = new EventEmitter<{ nodeSchema: SgNodeSchema | null }>()
80-
81-
82-
_selectedNodeId: string
8367
_focusedNodeId: string
84-
_targetNodeId: string
85-
8668
readonly defaultNodeWidth = 350
8769
readonly defaultNodeHeight = 50
88-
8970
readonly nativeGraphData$ = new BehaviorSubject<{ nodes: SgNativeNode[]; links: Edge[] }>(null)
90-
9171
private focusedNodeTimer: any
9272
private nodeClicksStream$ = new Subject<{ node: SgNativeNode; mouseEvent: MouseEvent }>()
9373

@@ -96,6 +76,22 @@ export class SplineGraphComponent extends BaseComponent implements OnChanges, On
9676
this.initNodeClicksEvents()
9777
}
9878

79+
_selectedNodeId: string
80+
81+
@Input() set selectedNodeId(nodeId: string) {
82+
if (nodeId !== this._selectedNodeId) {
83+
this._selectedNodeId = nodeId
84+
}
85+
}
86+
87+
_targetNodeId: string
88+
89+
@Input() set targetNodeId(nodeId: string) {
90+
if (nodeId !== this._targetNodeId) {
91+
this._targetNodeId = nodeId
92+
}
93+
}
94+
9995
ngOnChanges(changes: SimpleChanges): void {
10096
if (changes?.graphData && changes.graphData.currentValue) {
10197
const currentGraphData: SgData = changes.graphData.currentValue
@@ -107,7 +103,7 @@ export class SplineGraphComponent extends BaseComponent implements OnChanges, On
107103
if (changes?.focusNode$ && changes.focusNode$.currentValue) {
108104
changes.focusNode$.currentValue
109105
.pipe(
110-
takeUntil(this.destroyed$),
106+
takeUntil(this.destroyed$)
111107
)
112108
.subscribe((nodeId) => this.onFocusNode(nodeId))
113109
}
@@ -122,7 +118,7 @@ export class SplineGraphComponent extends BaseComponent implements OnChanges, On
122118
onNodeEvent(node: SgNativeNode, event: SgNodeControlEvent<any>): void {
123119
this.nodeEvent$.emit({
124120
nodeSchema: node,
125-
event,
121+
event
126122
})
127123
}
128124

@@ -131,7 +127,7 @@ export class SplineGraphComponent extends BaseComponent implements OnChanges, On
131127

132128
this.nodeClicksStream$.next({
133129
node,
134-
mouseEvent,
130+
mouseEvent
135131
})
136132
}
137133

@@ -142,17 +138,17 @@ export class SplineGraphComponent extends BaseComponent implements OnChanges, On
142138
private initNodeClicksEvents(): void {
143139
const doubleClickDelayInMs = 150
144140
const buff$ = this.nodeClicksStream$.pipe(
145-
debounceTime(doubleClickDelayInMs),
141+
debounceTime(doubleClickDelayInMs)
146142
)
147143

148144
this.nodeClicksStream$
149145
.pipe(
150-
buffer(buff$),
146+
buffer(buff$)
151147
)
152148
.subscribe((bufferValue: Array<{ node: SgNativeNode; mouseEvent: MouseEvent }>) => {
153149

154-
const refNode = bufferValue[0].node
155-
const refMouseEvent = bufferValue[0].mouseEvent
150+
const refNode = bufferValue[0]?.node
151+
const refMouseEvent = bufferValue[0]?.mouseEvent
156152

157153
if (bufferValue.length === 1) {
158154
this.nodeClick$.emit({ nodeSchema: refNode.schema, mouseEvent: refMouseEvent })
@@ -208,7 +204,7 @@ export class SplineGraphComponent extends BaseComponent implements OnChanges, On
208204
this.focusedNodeTimer = null
209205
}
210206
},
211-
removeClassAfterTimeInMs,
207+
removeClassAfterTimeInMs
212208
)
213209
}
214210
}

0 commit comments

Comments
 (0)