import { Entity } from "../../../core/entity/model/entity" ; import { DatabaseEntity } from "../../../core/entity/database-entity.decorator" ; import { DatabaseField } from "../../../core/entity/database-field.decorator" ; @ DatabaseEntity ( "ProgressDashboardConfig" ) export class ProgressDashboardConfig extends Entity { @ DatabaseField ( ) title : string = $localize `Progress Widget` ; @ DatabaseField ( ) parts : Array < ProgressDashboardPart > = [ ] ; getTotalPercentage ( ) { const currentTotal = this . parts . reduce ( ( acc , entry ) => acc + entry . currentValue , 0 ) ; const targetTotal = this . parts . reduce ( ( acc , entry ) => acc + entry . targetValue , 0 ) ; return currentTotal / targetTotal ; } } export interface ProgressDashboardPart { label : string ; currentValue : number ; targetValue : number ; }