-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(chrome-devtools): add a panel to see the current value of all av…
…ailable facts
- Loading branch information
Showing
23 changed files
with
288 additions
and
99 deletions.
There are no files selected for viewing
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
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
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
61 changes: 61 additions & 0 deletions
61
.../@o3r/rules-engine/src/components/rules-engine/facts-snapshot/facts-snapshot.component.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,61 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
computed, | ||
input, | ||
signal, | ||
ViewEncapsulation, | ||
} from '@angular/core'; | ||
import { | ||
FormsModule, | ||
ReactiveFormsModule, | ||
} from '@angular/forms'; | ||
import type { | ||
Facts, | ||
} from '../../../engine'; | ||
import { | ||
O3rJsonOrStringPipe, | ||
} from '../shared/index'; | ||
|
||
@Component({ | ||
selector: 'o3r-facts-snapshot', | ||
styleUrls: ['./facts-snapshot.style.scss'], | ||
templateUrl: './facts-snapshot.template.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [ | ||
O3rJsonOrStringPipe, | ||
FormsModule, | ||
ReactiveFormsModule | ||
], | ||
encapsulation: ViewEncapsulation.None | ||
}) | ||
export class FactsSnapshotComponent { | ||
/** | ||
* Full list of available facts with their current value | ||
*/ | ||
public facts = input<{ factName: string; value: Facts }[]>([]); | ||
|
||
/** | ||
* Search terms | ||
*/ | ||
public search = signal(''); | ||
|
||
/** | ||
* Filtered list of facts using search terms | ||
*/ | ||
public filteredFacts = computed(() => { | ||
const search = this.search(); | ||
if (search) { | ||
const matchString = new RegExp(search.replace(/[\s#$()*+,.?[\\\]^{|}-]/g, '\\$&'), 'i'); | ||
return this.facts().filter(({ factName, value }) => | ||
matchString.test(factName) | ||
|| (typeof value === 'object' | ||
? matchString.test(JSON.stringify(value)) | ||
: matchString.test(String(value))) | ||
); | ||
} else { | ||
return this.facts(); | ||
} | ||
}); | ||
} |
15 changes: 15 additions & 0 deletions
15
...es/@o3r/rules-engine/src/components/rules-engine/facts-snapshot/facts-snapshot.style.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,15 @@ | ||
@import '../styling/shared-mixin'; | ||
|
||
o3r-facts-snapshot { | ||
.fact-name { | ||
color: $ruleset-variable-key-color; | ||
} | ||
|
||
.fact-value { | ||
color: $ruleset-variable-value-color; | ||
} | ||
|
||
.fact-name, .fact-value { | ||
font-family: monospace; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...@o3r/rules-engine/src/components/rules-engine/facts-snapshot/facts-snapshot.template.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,26 @@ | ||
<section> | ||
@if (facts().length < 1) { | ||
<div class="alert alert-danger m-2" role="alert"> | ||
No facts are registered. | ||
</div> | ||
} @else { | ||
<div class="input-group"> | ||
<label class="input-group-text" for="search-fact"> | ||
<span class="mx-1 fa-search" aria-label="Search"></span> | ||
</label> | ||
<input class="form-control" [(ngModel)]="search" type="text" id="search-fact" placeholder="Search for fact name or value" /> | ||
</div> | ||
<div class="mt-3"> | ||
List of <b>{{facts().length}}</b> registered facts | ||
@if (facts().length > filteredFacts().length) { (<b>{{filteredFacts().length}}</b> matching the search) } | ||
</div> | ||
<ul> | ||
@for (fact of filteredFacts(); track fact.factName) { | ||
<li> | ||
<span class="fact-name">{{fact.factName}}: </span> | ||
<span class="fact-value">{{fact.value | o3rJsonOrString}}</span> | ||
</li> | ||
} | ||
</ul> | ||
} | ||
</section> |
1 change: 1 addition & 0 deletions
1
packages/@o3r/rules-engine/src/components/rules-engine/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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './facts-snapshot/facts-snapshot.component'; | ||
export * from './ruleset-history/ruleset-history-pres.component'; | ||
export * from './ruleset-history/ruleset-history-pres.module'; | ||
export * from './shared/index'; |
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
Oops, something went wrong.