show number of dictionaries per ruleset

This commit is contained in:
Timo 2021-01-20 10:44:06 +02:00
parent 21c6e17f09
commit 69d6589faf
3 changed files with 26 additions and 5 deletions

View File

@ -106,12 +106,12 @@
<div class="small-label stats-subtitle">
<div>
<mat-icon svgIcon="red:dictionary"></mat-icon>
{{ 'project-templates-listing.dictionaries' | translate: { length: 3 } }}
</div>
<div>
<mat-icon svgIcon="red:entries"></mat-icon>
{{ 'project-templates-listing.entries' | translate: { length: 300 } }}
{{ 'project-templates-listing.dictionaries' | translate: { length: ruleSet.dictionariesCount } }}
</div>
<!-- <div>-->
<!-- <mat-icon svgIcon="red:entries"></mat-icon>-->
<!-- {{ 'project-templates-listing.entries' | translate: { length: ruleSet.totalDictionaryEntries } }}-->
<!-- </div>-->
</div>
</div>

View File

@ -6,6 +6,8 @@ import { PermissionsService } from '../../../common/service/permissions.service'
import { FormBuilder, FormGroup } from '@angular/forms';
import { debounce } from '../../../utils/debounce';
import { RuleSetModel } from '@redaction/red-ui-http';
import { tap } from 'rxjs/operators';
import { forkJoin } from 'rxjs';
@Component({
selector: 'redaction-rule-sets-listing-screen',
@ -45,6 +47,21 @@ export class RuleSetsListingScreenComponent implements OnInit {
this._appStateService.reset();
this.ruleSets = this._appStateService.ruleSets;
this.displayedRuleSets = [...this.ruleSets];
this._loadRuleSetStats();
}
private _loadRuleSetStats() {
this.ruleSets.forEach((rs) => {
const dictionaries = this._appStateService.dictionaryData[rs.ruleSetId];
if (dictionaries) {
rs.dictionariesCount = Object.keys(dictionaries)
.map((key) => dictionaries[key])
.filter((d) => !d.virtual || d.type === 'false_positive').length;
} else {
rs.dictionariesCount = 0;
rs.totalDictionaryEntries = 0;
}
});
}
public get sortingOption(): SortingOption {

View File

@ -47,4 +47,8 @@ export interface RuleSetModel {
* Validity of end this ruleSet.
*/
validTo?: string;
// UI only virtual
dictionariesCount?: number;
totalDictionaryEntries?: number;
}