Skip to content

Commit

Permalink
Implement Authority confidence indicator component
Browse files Browse the repository at this point in the history
  • Loading branch information
toniprieto committed Dec 12, 2023
1 parent 9ccc5ee commit 04d0850
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<i class="fa-fw m-1 p-1" [ngClass]="getConfidenceTypeCSSClass()"
[ngbTooltip]="'helptext.confidence.indicator.' + getConfidenceTypeName() | translate"></i>

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ConfidenceIconComponent } from './confidence-icon.component';
import { TranslateModule } from '@ngx-translate/core';
import { MetadataValue } from '../../../core/shared/metadata.models';
import { ConfidenceType } from '../../../core/shared/confidence-type';

describe('ConfidenceIconComponent', () => {
let component: ConfidenceIconComponent;
let fixture: ComponentFixture<ConfidenceIconComponent>;
let metadataValue: MetadataValue;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ConfidenceIconComponent ],
imports: [TranslateModule.forRoot()]
})
.compileComponents();

metadataValue = Object.assign(new MetadataValue(), {
value: 'Regular Name',
language: 'en',
place: 0,
authority: 'Authority value',
confidence: ConfidenceType.CF_ACCEPTED
});

fixture = TestBed.createComponent(ConfidenceIconComponent);
component = fixture.componentInstance;
component.mdValue = metadataValue;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Component, Input } from '@angular/core';
import { ConfidenceType } from 'src/app/core/shared/confidence-type';
import { MetadataValue } from '../../../core/shared/metadata.models';

@Component({
selector: 'ds-confidence-icon',
templateUrl: './confidence-icon.component.html',
styleUrls: ['./confidence-icon.component.scss']
})
/**
* Component displaying a icon indicator confidence of an authority value
*/
export class ConfidenceIconComponent {

@Input() mdValue: MetadataValue;

getConfidenceTypeCSSClass() {
switch (this.mdValue.confidence) {
case ConfidenceType.CF_ACCEPTED: return 'far fa-circle-check';
case ConfidenceType.CF_UNCERTAIN: return 'fa fa-gear';
case ConfidenceType.CF_AMBIGUOUS: return 'far fa-circle-question';
case ConfidenceType.CF_NOTFOUND: return 'far fa-thumbs-down';
case ConfidenceType.CF_FAILED: return 'fa fa-triangle-exclamation';
case ConfidenceType.CF_REJECTED: return 'fas fa-turn-down';
case ConfidenceType.CF_NOVALUE: return 'fas fa-ban';
case ConfidenceType.CF_UNSET: return 'fa fa-xmark';
}
return 'fa fa-xmark';
}

getConfidenceTypeName() {
switch (this.mdValue.confidence) {
case ConfidenceType.CF_ACCEPTED: return 'accepted';
case ConfidenceType.CF_UNCERTAIN: return 'uncertain';
case ConfidenceType.CF_AMBIGUOUS: return 'ambigous';
case ConfidenceType.CF_NOTFOUND: return 'notfound';
case ConfidenceType.CF_FAILED: return 'failed';
case ConfidenceType.CF_REJECTED: return 'rejected';
case ConfidenceType.CF_NOVALUE: return 'novalue';
case ConfidenceType.CF_UNSET: return 'unset';
}
return 'unset';
}
}

0 comments on commit 04d0850

Please sign in to comment.