-
Notifications
You must be signed in to change notification settings - Fork 0
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
Added support for Inlinedashboard page #79
Changes from 5 commits
9c78ec9
69e9345
57b95fe
7f3da68
60b490d
e2120dd
90d200a
319cbed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<div *ngFor="let kid of children"> | ||
<div *ngIf="kid.type === 'DateTime'" [formGroup]="rangeFormGroup"> | ||
<mat-form-field class="psdk-full-width"> | ||
<mat-label>{{kid.label}}</mat-label> | ||
<mat-date-range-input [rangePicker]="picker"> | ||
<input matStartDate placeholder="Start date" formControlName="start"> | ||
<input matEndDate placeholder="End date" formControlName="end" (dateChange)="dateRangeChangeHandler(kid)"> | ||
</mat-date-range-input> | ||
<mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle> | ||
<mat-date-range-picker #picker></mat-date-range-picker> | ||
</mat-form-field> | ||
</div> | ||
<div *ngIf="kid.c11nEnv"> | ||
<span (input)="updateTmpData({event: $event, field: kid})"> | ||
<component-mapper [name]="kid.c11nEnv.getPConnect().getComponentName()" [props]="{ | ||
pConn$: kid.c11nEnv.getPConnect(), | ||
formGroup$: formGroup$ | ||
}" | ||
errorMsg="Promoted filters wants component not yet available: {{ kid.c11nEnv.getPConnect().getComponentName() }}"> | ||
</component-mapper> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like formatting is missing here, are you using prettier to format the code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, might be not used prettier to format for this file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. formatted the file with prettier |
||
</span> | ||
</div> | ||
</div> | ||
<div> | ||
<button mat-button color="primary" (click)="clearFilters()">Clear All</button> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.psdk-full-width { | ||
width: 100%; | ||
} | ||
|
||
::ng-deep .mat-mdc-form-field-subscript-wrapper { | ||
height: 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
|
||
import { DashboardFilterComponent } from './dashboard-filter.component'; | ||
|
||
describe('DashboardFilterComponent', () => { | ||
let component: DashboardFilterComponent; | ||
let fixture: ComponentFixture<DashboardFilterComponent>; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ DashboardFilterComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(DashboardFilterComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { Component, OnInit, Input, forwardRef, SimpleChanges, OnChanges } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { FormGroup, FormControl, ReactiveFormsModule } from '@angular/forms'; | ||
import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have library imports at top and local imports at the bottom There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
import { MatNativeDateModule } from '@angular/material/core'; | ||
import { MatDatepickerModule } from '@angular/material/datepicker'; | ||
import { MatFormFieldModule } from '@angular/material/form-field'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { debounceTime } from 'rxjs/operators'; | ||
import { Subject } from 'rxjs'; | ||
import { getFilterExpression, getFormattedDate, createFilter, combineFilters } from '../../../_helpers/filterUtils'; | ||
|
||
|
||
@Component({ | ||
selector: 'app-dashboard-filter', | ||
templateUrl: './dashboard-filter.component.html', | ||
styleUrls: ['./dashboard-filter.component.scss'], | ||
standalone: true, | ||
imports: [CommonModule, MatFormFieldModule, ReactiveFormsModule, MatDatepickerModule, MatButtonModule, MatNativeDateModule, forwardRef(() => ComponentMapperComponent)] | ||
tumms2021389 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}) | ||
export class DashboardFilterComponent implements OnInit { | ||
@Input() pConn$: any; | ||
@Input() formGroup$: FormGroup; | ||
@Input() inlineProps; | ||
@Input() children; | ||
angularPConnectData: any = {}; | ||
configProps$: Object; | ||
arChildren$: Array<any>; | ||
PCore$: any; | ||
private filterChangeSubject = new Subject<string>(); | ||
rangeFormGroup = new FormGroup({ | ||
start: new FormControl(null), | ||
end: new FormControl(null) | ||
}); | ||
|
||
constructor() { | ||
this.filterChangeSubject.pipe( | ||
debounceTime(500) | ||
).subscribe((val) => this.fireFilterChange(val)); | ||
} | ||
|
||
ngOnInit() { | ||
if (!this.PCore$) { | ||
this.PCore$ = window.PCore; | ||
} | ||
} | ||
|
||
clearFilters() { | ||
this.formGroup$.reset(); | ||
this.rangeFormGroup.reset(); | ||
this.PCore$.getPubSubUtils().publish( | ||
this.PCore$.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CLEAR_ALL | ||
); | ||
} | ||
|
||
updateTmpData(filterData) { | ||
this.filterChangeSubject.next(filterData); | ||
} | ||
|
||
dateRangeChangeHandler(field) { | ||
const { filterId, name } = field; | ||
const start = this.rangeFormGroup.get('start').value; | ||
const end = this.rangeFormGroup.get('end').value; | ||
if (start && end) { | ||
let startDate = getFormattedDate(start); | ||
let endDate = getFormattedDate(end); | ||
|
||
if (startDate && endDate) { | ||
startDate = `${startDate}T00:00:00`; | ||
endDate = `${endDate}T00:00:00`; | ||
const startFilter = createFilter(startDate, name, 'GT'); | ||
const endFilter = createFilter(endDate, name, 'LT'); | ||
|
||
const filterData = { | ||
filterId, | ||
filterExpression: combineFilters([startFilter, endFilter], null) | ||
}; | ||
this.PCore$.getPubSubUtils().publish( | ||
this.PCore$.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CHANGE, | ||
filterData | ||
); | ||
} | ||
} | ||
} | ||
|
||
fireFilterChange(data: any) { | ||
const { event, field } = data; | ||
const filterData = { | ||
filterId: field.filterId, | ||
filterExpression: getFilterExpression(event.target.value, field.name, field.metadata) | ||
}; | ||
|
||
this.PCore$.getPubSubUtils().publish( | ||
this.PCore$.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CHANGE, | ||
filterData | ||
); | ||
}; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<app-inline-dashboard [inlineProps]="inlineProps" [children]="children" [formGroup$]="formGroup$"></app-inline-dashboard> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
|
||
import { InlineDashboardPageComponent } from './inline-dashboard-page.component'; | ||
|
||
describe('InlineDashboardPageComponent', () => { | ||
let component: InlineDashboardPageComponent; | ||
let fixture: ComponentFixture<InlineDashboardPageComponent>; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [InlineDashboardPageComponent] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(InlineDashboardPageComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Component, OnInit, Input, forwardRef, SimpleChanges, OnChanges } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { FormGroup, FormBuilder } from '@angular/forms'; | ||
import { RegionComponent } from '../../infra/region/region.component'; | ||
import { InlineDashboardComponent } from '../inline-dashboard/inline-dashboard.component'; | ||
import { buildFilterComponents } from '../../../_helpers/filterUtils'; | ||
tumms2021389 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@Component({ | ||
selector: 'app-inline-dashboard-page', | ||
templateUrl: './inline-dashboard-page.component.html', | ||
styleUrls: ['./inline-dashboard-page.component.scss'], | ||
standalone: true, | ||
imports: [CommonModule, InlineDashboardComponent, forwardRef(() => RegionComponent)] | ||
tumms2021389 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}) | ||
export class InlineDashboardPageComponent implements OnInit, OnChanges { | ||
@Input() pConn$: any; | ||
|
||
configProps$: Object; | ||
arChildren$: Array<any>; | ||
filterComponents: any; | ||
inlineProps: any; | ||
children: any = []; | ||
formGroup$: FormGroup; | ||
constructor(private fb: FormBuilder) { | ||
this.formGroup$ = this.fb.group({ hideRequired: false }); | ||
} | ||
|
||
ngOnInit() { | ||
this.updateSelf(); | ||
} | ||
|
||
ngOnChanges(changes: SimpleChanges): void { | ||
const { pConn$ } = changes; | ||
|
||
if (pConn$.previousValue && pConn$.previousValue !== pConn$.currentValue) { | ||
this.updateSelf(); | ||
} | ||
} | ||
|
||
updateSelf() { | ||
this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()); | ||
this.arChildren$ = this.pConn$.getChildren(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need of creating arChildren$ as class property instead you can create a local variable with "const"
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
const allFilters = this.pConn$.getRawMetadata().children[1]; | ||
this.filterComponents = buildFilterComponents(this.pConn$, allFilters); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same with filterComponents There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try to use JS local variables instead of class properties There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
this.inlineProps = this.configProps$; | ||
this.children[0] = this.arChildren$[0]; | ||
this.children[1] = this.filterComponents; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<div class="psdk-inline-dashboard"> | ||
<h4 class="psdk-inline-dashboard-title">{{inlineProps.title}}</h4> | ||
<div [ngClass]="{ | ||
'psdk-inline-style': inlineProps.filterPosition === 'inline-start' || inlineProps.filterPosition === 'inline-end', | ||
'psdk-inline-end': inlineProps.filterPosition === 'inline-end' | ||
}" *ngIf="children"> | ||
<div class="psdk-inline-filter"> | ||
<div> | ||
<app-dashboard-filter [children]="children[1]" [formGroup$]="formGroup$" [ngClass]="{ | ||
'psdk-block-style': inlineProps.filterPosition === 'block-start' | ||
}"></app-dashboard-filter> | ||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. formatting missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
</div> | ||
<div class="psdk-inline-list"> | ||
<app-region [pConn$]="children[0].getPConnect()"></app-region> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use component mapper to load Region component There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
</div> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.psdk-inline-dashboard { | ||
margin-left: 8px; | ||
margin-right: 8px; | ||
} | ||
|
||
.psdk-inline-dashboard-title { | ||
font-weight: 500; | ||
font-size: 1.25rem; | ||
} | ||
|
||
.psdk-block-style { | ||
display: grid; | ||
direction: column-reverse; | ||
gap: 1rem; | ||
grid-template-columns: repeat(7, 1fr); | ||
} | ||
|
||
.psdk-not-block-style { | ||
display: grid; | ||
grid-template-columns: 3fr 7fr; | ||
} | ||
|
||
.psdk-inline-style { | ||
display: flex; | ||
.psdk-inline-filter { | ||
width: 25%; | ||
padding: 0px 8px; | ||
margin-top: 1rem; | ||
} | ||
.psdk-inline-list { | ||
width: 75%; | ||
padding: 0px 8px; | ||
} | ||
} | ||
|
||
.psdk-inline-end { | ||
flex-direction: row-reverse; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
|
||
import { InlineDashboardComponent } from './inline-dashboard.component'; | ||
|
||
describe('InlineDashboardComponent', () => { | ||
let component: InlineDashboardComponent; | ||
let fixture: ComponentFixture<InlineDashboardComponent>; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [InlineDashboardComponent] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(InlineDashboardComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Component, OnInit, Input, forwardRef } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { FormGroup } from '@angular/forms'; | ||
import { RegionComponent } from '../../infra/region/region.component'; | ||
import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component'; | ||
import { DashboardFilterComponent } from '../../infra/dashboard-filter/dashboard-filter.component'; | ||
|
||
@Component({ | ||
selector: 'app-inline-dashboard', | ||
templateUrl: './inline-dashboard.component.html', | ||
styleUrls: ['./inline-dashboard.component.scss'], | ||
standalone: true, | ||
imports: [CommonModule, DashboardFilterComponent, forwardRef(() => RegionComponent), forwardRef(() => ComponentMapperComponent)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check whether forwardRef is really needed or not? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes needed in this case, getting error when trying to use componentMapper component without forwardRef. |
||
}) | ||
export class InlineDashboardComponent implements OnInit { | ||
@Input() pConn$: any; | ||
@Input() formGroup$: FormGroup; | ||
@Input() inlineProps; | ||
@Input() children; | ||
|
||
|
||
constructor() { } | ||
|
||
ngOnInit() { | ||
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you using two formGroups?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the rangeFormGroup and using the existing one.