import { AbstractModifier } from "./abstract.modifier" ; import * as _ from "lodash" ; import { GearType } from "../models/gear/gear-type.enum" ; import { BikeGearModel } from "../models/gear/bike-gear.model" ; import { VacuumProcessor } from "../processors/vacuum-processor" ; export class ActivityBikeOdoModifier extends AbstractModifier { public vacuumProcessor : VacuumProcessor ; public athleteId : number ; constructor ( vacuumProcessor , athleteId ) { super ( ) ; this . vacuumProcessor = vacuumProcessor ; this . athleteId = athleteId ; } public modify ( ) { const activityBike = $ ( ".gear-name" ) . text ( ) . trim ( ) ; this . vacuumProcessor . getAthleteGear ( this . athleteId , GearType . BIKE ) . then ( ( bikes ) => { const bikeFound = _ . find ( bikes , { display_name : activityBike } ) ; if ( bikeFound ) { $ ( ".gear-name" ) . html ( activityBike + "<strong> / Odo: " + bikeFound . total_distance + " " + bikeFound . units + "</strong>" ) ; } } , err => { console . error ( err ) ; } ) ; } }