Skip to content

Commit

Permalink
#627 integration fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
arawinters committed Jun 18, 2024
1 parent 1b77ca9 commit 7aab987
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 78 deletions.
10 changes: 5 additions & 5 deletions examples/data-table/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<!--<div style="text-align:left; text-decoration: italic; font-size: 0.8em; margin: 2px 0 10px 0;">
An example Angular app showing usage of the sz-search, and sz-data-table
</div>-->
<div class="loading" *ngIf="isLoading">Loading!!!</div>
<!-- start data table results -->
<div class="component-example">
<sz-cross-source-statistics
showTableLoadingSpinner="false"
(loading)="onLoading($event)"
(cellClick)="onCellClick($event)">
<svg class="spinner" width="96" height="96" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><style>.spinner_ajPY{transform-origin:center;animation:spinner_AtaB .75s infinite linear}@keyframes spinner_AtaB{100%{transform:rotate(360deg)}}</style><path d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z" opacity=".25"/><path d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z" class="spinner_ajPY"/></svg>
showTableLoadingSpinner="true"
(cellClick)="onCellClick($event)"
(entityIdClick)="onEntityIdClick($event)">
<div class="lds-ring spinner"><div></div><div></div><div></div><div></div></div>
<!--<svg class="spinner" width="96" height="96" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><style>.spinner_ajPY{transform-origin:center;animation:spinner_AtaB .75s infinite linear}@keyframes spinner_AtaB{100%{transform:rotate(360deg)}}</style><path d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z" opacity=".25"/><path d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z" class="spinner_ajPY"/></svg>-->
</sz-cross-source-statistics>
</div>
<!-- end data table results -->
Expand Down
56 changes: 40 additions & 16 deletions examples/data-table/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, AfterViewInit, ViewChild, ElementRef, ViewContainerRef, TemplateRef, Input, OnDestroy } from '@angular/core';
import { Component, AfterViewInit, ViewChild, ElementRef, ViewContainerRef, TemplateRef, Input, OnDestroy, Inject } from '@angular/core';
import {
SzAlertMessageDialog,
SzDataMartService,
Expand All @@ -11,11 +11,13 @@ import {
SzEntitiesPage
} from '@senzing/sdk-components-ng';

import { tap, filter, take } from 'rxjs/operators';
import { tap, filter, take, takeUntil } from 'rxjs/operators';
import { Overlay, OverlayRef } from '@angular/cdk/overlay';
import { TemplatePortal } from '@angular/cdk/portal';
import { Subject, Subscription, fromEvent } from 'rxjs';
import { MatDialog } from '@angular/material/dialog';
import { LOCAL_STORAGE, StorageService } from 'ngx-webstorage-service';
import { SzSdkPrefsModel } from 'src/lib/services/sz-prefs.service';

@Component({
selector: 'app-root',
Expand All @@ -31,6 +33,12 @@ export class AppComponent implements AfterViewInit, OnDestroy {
public showEntityDetail = false;
public sampleStatType;
private _isLoading = false;
/** localstorage key to store pref data in */
public STORAGE_KEY = 'senzing-web-app-example-data-table';
/** original json value when app was loaded */
private _localStorageOriginalValue: SzSdkPrefsModel = this.storage.get(this.STORAGE_KEY);
/** local cached json model of prefs */
private _prefsJSON: SzSdkPrefsModel;

public get isLoading(): boolean {
return this._isLoading;
Expand All @@ -45,6 +53,7 @@ export class AppComponent implements AfterViewInit, OnDestroy {
public searchService: SzSearchService,
public overlay: Overlay,
public prefs: SzPrefsService,
@Inject(LOCAL_STORAGE) private storage: StorageService,
public dataMart: SzDataMartService,
public dialog: MatDialog,
public viewContainerRef: ViewContainerRef){}
Expand All @@ -61,6 +70,12 @@ export class AppComponent implements AfterViewInit, OnDestroy {
console.log(`new sample set data ready... `);
this.showSampleTable = true;
})*/
this.prefs.prefsChanged.pipe(
takeUntil(this.unsubscribe$)
).subscribe( (srprefs) => {
this._prefsJSON = srprefs;
this.savePrefsToLocalStorage();
});
}

/**
Expand All @@ -75,23 +90,32 @@ export class AppComponent implements AfterViewInit, OnDestroy {
onCellClick(data: any) {
console.log(`onCellClick`, data);
if(!data.value){ return; }
if(data.key === 'entityId' || data.key === 'relatedEntityId') {
this.dialog.open(SzAlertMessageDialog, {
panelClass: 'alert-dialog-panel',
width: '350px',
height: '200px',
data: {
title: `Opening Entity #${data.value} Detail`,
text: 'This would normally be a redirect to the entity detail page.',
showOkButton: false,
buttonText: 'Close'
}
});
}

onEntityIdClick(entityId: SzEntityIdentifier) {
console.log(`APP onEntityIdClick(${entityId})`);
if(entityId) {
this.openEntity(entityId);
}
}

onLoading(value: boolean) {
this._isLoading = value;
openEntity(entityId: SzEntityIdentifier) {
this.dialog.open(SzAlertMessageDialog, {
panelClass: 'alert-dialog-panel',
width: '350px',
height: '200px',
data: {
title: `Opening Entity #${entityId} Detail`,
text: 'This would normally be a redirect to the entity detail page.',
showOkButton: false,
buttonText: 'Close'
}
});
}

/** save value of _prefsJSON to local storage */
savePrefsToLocalStorage() {
this.storage.set(this.STORAGE_KEY, this._prefsJSON);
}

}
49 changes: 47 additions & 2 deletions examples/data-table/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
/* You can add global styles to this file, and also import other style files */

body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
/*font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;*/
font-family: "Open-Sans", "Helvetica Neue", Arial, sans-serif;
--sz-font-family: "Open-Sans", "Helvetica Neue", Arial, sans-serif;
}

.detail-wrapper {
Expand Down Expand Up @@ -68,4 +70,47 @@ sz-data-table tbody td.sz-dt-cell {
max-height: 30px;
overflow: hidden;
text-overflow: ellipsis;
}
}

/* spinner */

.lds-ring,
.lds-ring div {
box-sizing: border-box;
}
.lds-ring {
display: inline-block;
position: relative;
width: 80px;
height: 80px;
}
.lds-ring div {
box-sizing: border-box;
display: block;
position: absolute;
width: 64px;
height: 64px;
margin: 8px;
border: 8px solid currentColor;
border-radius: 50%;
animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
border-color: currentColor transparent transparent transparent;
}
.lds-ring div:nth-child(1) {
animation-delay: -0.45s;
}
.lds-ring div:nth-child(2) {
animation-delay: -0.3s;
}
.lds-ring div:nth-child(3) {
animation-delay: -0.15s;
}
@keyframes lds-ring {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { take, takeUntil, tap } from 'rxjs/operators';
import { Observable, Subject } from 'rxjs';
import { camelToKebabCase, underscoresToDashes, getMapKeyByValue, parseBool } from '../../common/utils';
import { SzDataMartService } from '../../services/sz-datamart.service';
import { SzCrossSourceSummaryCategoryType, SzCrossSourceSummarySelectionEvent, SzCrossSourceSummarySelectionClickEvent, SzStatsSampleTableLoadingEvent } from '../../models/stats';
import { SzCrossSourceSummaryCategoryType, SzCrossSourceSummarySelectionEvent, SzCrossSourceSummarySelectionClickEvent, SzStatsSampleTableLoadingEvent, SzCrossSourceSummaryCategoryTypeToMatchLevel } from '../../models/stats';
import { SzEntitiesPage, SzEntityData, SzEntityIdentifier, SzSourceSummary } from '@senzing/rest-api-client-ng';
import { SzDataTableCellEvent } from '../../models/stats';

Expand Down Expand Up @@ -34,14 +34,11 @@ export class SzCrossSourceStatistics implements OnInit, AfterViewInit, OnDestroy
/** subscription to notify subscribers to unbind */
public unsubscribe$ = new Subject<void>();

private _showTable = false;
public get showTable() {
return this._showTable;
}

private _disableClickingOnZeroResults = true;
private _isLoading = false;
private _showTable = false;
private _showTableLoadingSpinner = true;
private _disableClickingOnZeroResults = true;
private _title: string;

@HostBinding("class.loading") get isLoading() {
return this._isLoading;
Expand Down Expand Up @@ -84,23 +81,21 @@ export class SzCrossSourceStatistics implements OnInit, AfterViewInit, OnDestroy
private _loading: Subject<boolean> = new Subject();
@Output() loading: Observable<boolean> = this._loading.asObservable();

public toggleExpanded() {
this.prefs.dataMart.showDiagramHeader = !this.prefs.dataMart.showDiagramHeader;
public get defaultFromDataSource() {
return this.prefs.dataMart.defaultDataSource2;
}
public get defaultToDataSource() {
return this.prefs.dataMart.defaultDataSource1;
}

public get showAllColumns() {
return this.prefs.dataMart.showAllColumns;
}

public set showAllColumns(value: boolean) {
this.prefs.dataMart.showAllColumns = value;
}

public get defaultToDataSource() {
return this.prefs.dataMart.defaultDataSource1;
}
public get defaultFromDataSource() {
return this.prefs.dataMart.defaultDataSource2;
public get showTable() {
return this._showTable;
}

public get resolutionMode() {
Expand All @@ -117,46 +112,13 @@ export class SzCrossSourceStatistics implements OnInit, AfterViewInit, OnDestroy
}
}

private _title: string;

get title() {
/** the title of the collapseable header */
public get title() {
return this._title;
let retVal = '';
let isSingle = true;
if(this.dataMartService.sampleDataSource1 && this.dataMartService.sampleDataSource2 && this.dataMartService.sampleDataSource1 !== this.dataMartService.sampleDataSource2) {
isSingle = false;
} else if(this.dataMartService.sampleDataSource1 || this.dataMartService.sampleDataSource2) {
isSingle = true;
}
if(this.dataMartService.sampleStatType) {
switch(this.dataMartService.sampleStatType) {
case 'MATCHES':
retVal = isSingle ? 'Duplicates' : 'Matches';
break;
case 'AMBIGUOUS_MATCHES':
retVal = 'Ambiguous Matches';
break;
case 'POSSIBLE_MATCHES':
retVal = isSingle ? 'Possible Duplicates' : 'Possible Matches';
break;
case 'POSSIBLE_RELATIONS':
retVal = isSingle ? 'Possible Relationships' : 'Possibly Related';
break;
case 'DISCLOSED_RELATIONS':
retVal = 'Disclosed Relationships';
break;
};

if(this.dataMartService.sampleDataSource1 && this.dataMartService.sampleDataSource2 && this.dataMartService.sampleDataSource1 !== this.dataMartService.sampleDataSource2) {
retVal += `: ${this.dataMartService.sampleDataSource1} to ${this.dataMartService.sampleDataSource2}`;
} else if(this.dataMartService.sampleDataSource1) {
retVal += `: ${this.dataMartService.sampleDataSource1}`;
} else if(this.dataMartService.sampleDataSource2) {
retVal += `: ${this.dataMartService.sampleDataSource2}`;
}
}

return retVal;
}
/** set the title of the collapseable widget */
public set title(value: string) {
this._title = value;
}

private _getTitleFromEvent(event: SzCrossSourceSummarySelectionEvent) {
Expand Down Expand Up @@ -394,6 +356,10 @@ export class SzCrossSourceStatistics implements OnInit, AfterViewInit, OnDestroy
this.entityIdClick.emit(entityId);
}

public toggleExpanded() {
this.prefs.dataMart.showDiagramHeader = !this.prefs.dataMart.showDiagramHeader;
}

private getNewSampleSet(parameters: SzCrossSourceSummarySelectionEvent) {
// set loading emitter(s)
this._onNewSampleSetRequested.next(true);
Expand All @@ -414,4 +380,13 @@ export class SzCrossSourceStatistics implements OnInit, AfterViewInit, OnDestroy
})
)
}
public updateTitle(datasource1, datasource2, statType) {
let _evt: SzCrossSourceSummarySelectionEvent = {
dataSource1: datasource1,
dataSource2: datasource2,
statType: statType,
matchLevel: SzCrossSourceSummaryCategoryTypeToMatchLevel[statType]
}
this._title = this._getTitleFromEvent(_evt);
}
}
9 changes: 9 additions & 0 deletions src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ export { AdminStreamConnProperties, AdminStreamAnalysisConfig, AdminStreamLoadCo
export { SzDataSourceRecordAnalysis, SzDataSourceComposite } from './lib/models/data-sources';
export { SzGraphTooltipEntityModel, SzGraphTooltipLinkModel, SzGraphNodeFilterPair, SzMatchKeyComposite, SzMatchKeyTokenComposite, SzEntityNetworkMatchKeyTokens, SzNetworkGraphInputs, SzMatchKeyTokenFilterScope } from './lib/models/graph';
export { SzDataSourceRecordsSelection, SzDataSourceRecordSelection, SzWhySelectionModeBehavior, SzWhySelectionMode } from './lib/models/data-source-record-selection';
export {
SzCrossSourceSummaryCategoryType,
SzCrossSourceSummaryCategoryTypeToMatchLevel,
SzCrossSourceSummarySelectionEvent,
SzCrossSourceSummarySelectionClickEvent,
sampleDataSourceChangeEvent,
SzStatSampleSetParameters,
SzStatSampleSetPageChangeEvent
} from './lib/models/stats';
export * from './lib/models/data-how';
/** pipes */
export { SzShortNumberPipe } from './lib/pipes/shortnumber.pipe'
Expand Down

0 comments on commit 7aab987

Please sign in to comment.