Index

src/app/utils/style-utils.ts

addAlphaToHexColor
addAlphaToHexColor(color, opacity)
Parameters :
Name Optional
color No
opacity No
getHue
getHue(r: number, g: number, b: number)

Source ://gist.github.com/mjackson/5311256https

Parameters :
Name Type Optional
r number No
g number No
b number No

src/app/core/entity/database-field.decorator.ts

addPropertySchema
addPropertySchema(target, propertyName: string, propertySchema: EntitySchemaField)
Parameters :
Name Type Optional
target No
propertyName string No
propertySchema EntitySchemaField No
DatabaseField
DatabaseField(propertySchema: EntitySchemaField)

Decorator (Annotation @DatabaseField()) to mark a property of an Entity that should be persisted in the database.

also see

Parameters :
Name Type Optional Default value Description
propertySchema EntitySchemaField No {}

(optional) SchemaField definition that configures additional options regarding this field

getEntitySchema
getEntitySchema(ctor)

Returns the schema map of this entity (not the superclass). Creates and assigns a new one if it doesn't exist yet.

Parameters :
Name Optional
ctor No
Returns : EntitySchema

src/app/utils/utils.ts

addToGroup
addToGroup(allGroups, currentValue, currentElement)
Parameters :
Name Optional
allGroups No
currentValue No
currentElement No
calculateAge
calculateAge(dateOfBirth: Date)
Parameters :
Name Type Optional
dateOfBirth Date No
Returns : number
compareEnums
compareEnums(a: ConfigurableEnumValue, b: ConfigurableEnumValue)
Parameters :
Name Type Optional
a ConfigurableEnumValue No
b ConfigurableEnumValue No
Returns : boolean
dateToString
dateToString(value: Date)
Parameters :
Name Type Optional
value Date No
equals
equals(a, b)

Comparing two values for equality that might be different than just object equality

Parameters :
Name Optional
a No
b No
Returns : boolean
getParentUrl
getParentUrl(router: Router)
Parameters :
Name Type Optional
router Router No
Returns : string
getUrlWithoutParams
getUrlWithoutParams(router: Router)
Parameters :
Name Type Optional
router Router No
Returns : string
groupBy
groupBy(array, propertyToGroupBy: P)

Group an array by the given property.

Parameters :
Name Type Optional Description
array No

A simple array to be grouped.

propertyToGroupBy P No

The key of the property in the elements by whose value the result is grouped. If this is an array, grouped by individual elements.

Returns : []

an array where the first entry is the value of this group and the second all entries that have this value.

isValidDate
isValidDate(date: any)
Parameters :
Name Type Optional
date any No
Returns : boolean
readFile
readFile(file: Blob)
Parameters :
Name Type Optional
file Blob No
Returns : Promise<string>
serviceProvider
serviceProvider(service, factory)

This is a simple shorthand function to create factories for services. The use case is, when multiple services extend the same class and one of these services will be provided.

Parameters :
Name Optional Description
service No

the token for which a service is provided

factory No

factory which returns a subtype of class

Returns : FactoryProvider
sortByAttribute
sortByAttribute(attribute, order)
Parameters :
Name Optional Default value
attribute No
order No "asc"
Returns : number

src/app/features/skill/link-external-profile/link-external-profile-dialog/link-external-profile-dialog.component.ts

addTooltip
addTooltip(profile: ExternalProfile)
Parameters :
Name Type Optional
profile ExternalProfile No

src/app/core/common-components/entity-select/entity-select.component.ts

applyTextToCreatedEntity
applyTextToCreatedEntity(entity: Entity, input: string)

Update the given entity by applying the text entered by a user to the most likely appropriate entity field, inferred from the toString representation.

Parameters :
Name Type Optional
entity Entity No
input string No
isMulti
isMulti(cmp: EntitySelectComponent)
Parameters :
Name Type Optional
cmp EntitySelectComponent No

src/app/core/entity/model/entity-update.ts

applyUpdate
applyUpdate(entities, next: UpdatedEntity, addIfMissing: boolean)

Updates a list of entities given an updated version of the entity. This updated version can either be a new entity (that should be inserted into the list), or an existing entity that should be updated or deleted. The given array will not be mutated but will be returned when the given new entity or type is illegal

Parameters :
Name Type Optional Default value Description
entities No

The entities to update, must be defined

next UpdatedEntity No

An entity that should be updated as well as the type of update. This, as well as the entity may be undefined or null. In this event, the entities-array is returned as is.

addIfMissing boolean No true

(Optional) whether to add an entity that comes through an update event but is not part of the array yet, default is to add, disable this if you do special filtering or calculations on the data

Returns : T[]

An array of the given entities with the update applied

src/app/utils/asArray.ts

asArray
asArray(x)

Convert wrap a value in an array if it is not already an array.

Parameters :
Name Optional
x No
Returns : T[]

src/main.ts

bootstrap
bootstrap()

src/app/core/common-components/entity-form/dynamic-form-validators/readonly-after-set.validator.ts

buildReadonlyValidator
buildReadonlyValidator(entity: Entity)

Validator to ensure a field becomes readonly after it has been saved once.

Parameters :
Name Type Optional
entity Entity No
Returns : literal type

src/app/child-dev-project/attendance/model/calculate-average-event-attendance.ts

calculateAverageAttendance
calculateAverageAttendance(event: Note)
Parameters :
Name Type Optional
event Note No

src/app/core/basic-datatypes/date/date-range-filter/date-range-filter-panel/date-range-utils.ts

calculateDateRange
calculateDateRange(dateRangeOption: DateRangeFilterConfigOption)
Parameters :
Name Type Optional
dateRangeOption DateRangeFilterConfigOption No
Returns : DateRange<Date>

src/app/features/notification/close-only-submenu.ts

closeOnlySubmenu
closeOnlySubmenu(menu: MatMenuTrigger, event: MouseEvent)

Close the mat-menu of the given menu trigger and stop propagation of the event to avoid closing parent menus as well.

Parameters :
Name Type Optional
menu MatMenuTrigger No
event MouseEvent No

src/app/core/common-components/entities-table/table-sort/table-sort.ts

compareValues
compareValues(a, b)
Parameters :
Name Optional
a No
b No
getComparableValue
getComparableValue(obj: OBJECT, key: PROPERTY)
Parameters :
Name Type Optional
obj OBJECT No
key PROPERTY No
Returns : number | string | Symbol
tableSort
tableSort(data, __namedParameters: {direction: "asc" | "desc" | string, active: PROPERTY | string})

Custom sort implementation for a MatTableDataSource<TableRow>

Parameters :
Name Type Optional Description
data No

The data of the data source

direction "asc" | "desc" | string No

direction "asc", "desc" or "" meaning none

active PROPERTY | string No

the property of T for which it should be sorted

Returns : TableRow[]

the sorted table rows

src/app/core/demo-data/create-entity-of-type.ts

createEntityOfType
createEntityOfType(type: string, id: string)

"Simulate" a custom entity type that saves all fields without transformations through a mocked EntitySchema.

This is a utility function to help demo data creation because the dynamically migrated config is not ready at the time of demo data generation yet.

Parameters :
Name Type Optional Default value
type string No
id string No uuid()

src/app/features/skill/skill-api/skill-api-mock.ts

createSkillApiDummyData
createSkillApiDummyData(externalId: string)
Parameters :
Name Type Optional
externalId string No
Returns : ExternalProfile

src/app/core/config/testing-config-service.ts

createTestingConfigService
createTestingConfigService(configsObject: any)
Parameters :
Name Type Optional Default value
configsObject any No defaultJsonConfig
Returns : ConfigService

src/app/core/basic-datatypes/configurable-enum/configurable-enum-testing.ts

createTestingConfigurableEnumService
createTestingConfigurableEnumService()

src/app/core/entity/database-entity.decorator.ts

DatabaseEntity
DatabaseEntity(entityType: string)

Decorator (Annotation @DatabaseEntity()) to set the string ENTITY_TYPE to an Entity Type. The entity should also be added to the databaseEntities array of the surrounding module.

also see

Parameters :
Name Type Optional Description
entityType string No

The string key for this Entity Type, used as id prefix.

src/app/features/config-setup/config-import-parser.service.ts

deleteEmptyProperties
deleteEmptyProperties(data: Object)

Delete properties on an object which are "empty", to clean up redundant details.

Parameters :
Name Type Optional
data Object No
extendArray
extendArray(array: any, newSize: number)

Pad an array with additional empty arrays up to the given new size.

Parameters :
Name Type Optional
array any No
newSize number No

src/app/core/logging/logging.service.ts

enhanceSentryBreadcrumb
enhanceSentryBreadcrumb(breadcrumb, hint: SentryBreadcrumbHint)

Add more human-readable descriptions to Sentry breadcrumbs for debugging.

see https://docs.sentry.io/platforms/javascript/enriching-events/breadcrumbs/

Parameters :
Name Type Optional
breadcrumb No
hint SentryBreadcrumbHint No

src/app/core/filter/filter-generator/filter-predicate.ts

entityFilterPredicate
entityFilterPredicate(data: Entity, filter: string)
Parameters :
Name Type Optional
data Entity No
filter string No
Returns : boolean

src/app/utils/test-utils/observable-utils.ts

expectObservable
expectObservable(observable: Observable)
Parameters :
Name Type Optional
observable Observable No

src/app/features/dashboard-widgets/entity-count-dashboard-widget/entity-count-dashboard/entity-count-dashboard.component.ts

extractHumanReadableLabel
extractHumanReadableLabel(value)

Get a human-readable string from the given value as a label.

Parameters :
Name Optional
value No
Returns : string

src/app/core/entity/entity-mapper/entity-relations.service.ts

fieldsIncludingId
fieldsIncludingId(entity: Entity, refId: string, relevantFields)

Return the fields of entity that contain the given refId. If there is no such referenced ID, the array will be empty.

Parameters :
Name Type Optional Description
entity Entity No
refId string No
relevantFields No

The entity fields to check for the refId

Returns : FormFieldConfig[]

src/app/features/public-form/public-form.component.ts

findFieldInFieldGroups
findFieldInFieldGroups(formConfig: PublicFormConfig, id: string)
Parameters :
Name Type Optional
formConfig PublicFormConfig No
id string No
Returns : FormFieldConfig
migratePublicFormConfig
migratePublicFormConfig(formConfig: PublicFormConfig)
Parameters :
Name Type Optional
formConfig PublicFormConfig No
Returns : PublicFormConfig

src/app/features/notification/notification-settings/notification-settings.component.ts

generateDefaultNotificationConfig
generateDefaultNotificationConfig(userId: string, userEntity: string)
Parameters :
Name Type Optional
userId string No
userEntity string No

src/app/child-dev-project/attendance/model/activity-attendance.ts

generateEventWithAttendance
generateEventWithAttendance(participating, date, activity?: RecurringActivity)

Generate a event with children for the given AttendanceStatus array.

This is particularly useful to generate simple data for demo or test purposes.

Parameters :
Name Type Optional Default value Description
participating No

Object where keys are string childId and values are its attendance status

date No new Date()

(Optional) date of the event; if not given today's date is used

activity RecurringActivity Yes

(Optional) reference to the connected activity entity

Returns : EventNote

src/app/core/entity/default-datatype/edit-component-story-utils.ts

generateFormFieldStory
generateFormFieldStory(editComponent, defaultValue, withTooltip, additionalSchema: object, additionalProviders: [])
Parameters :
Name Type Optional Default value Description
editComponent No
defaultValue No
withTooltip No true

set to false to disable tooltip (?) button

additionalSchema object No {}

an object that is applied to the schema field and allows to overwrite or add schema properties

additionalProviders [] No []

Angular service providers that should be initialized in addition to defaults

Returns : literal type

src/app/utils/generate-id-from-label/generate-id-from-label.ts

generateIdFromLabel
generateIdFromLabel(label: string)

Create a simplified id string from the given text. This generates a camelCase string and replacing special characters with underscores.

Parameters :
Name Type Optional Description
label string No

The input string to be transformed

Returns : string | undefined

src/app/features/todos/recurring-interval/time-interval.ts

generateLabelFromInterval
generateLabelFromInterval(interval: TimeInterval)
Parameters :
Name Type Optional
interval TimeInterval No

src/app/core/default-values/default-value-strategy.interface.ts

getConfigsByMode
getConfigsByMode(fieldConfigs, mode)

Get the default value configs filtered for the given mode.

Parameters :
Name Optional
fieldConfigs No
mode No

src/app/features/reporting/report-row.ts

getGroupingInformationString
getGroupingInformationString(groupedBy)
Parameters :
Name Optional
groupedBy No
Returns : string
getValueDescription
getValueDescription(value: any, property: string)
Parameters :
Name Type Optional
value any No
property string No
Returns : string

src/app/features/location/map-utils.ts

getHueForEntity
getHueForEntity(entity: Entity, offset: number)

Translates the color of an entity to the necessary hue-rotate filter

Parameters :
Name Type Optional Default value Description
entity Entity No

to get color from

offset number No 145

hue offset which should be added on top. default 145 (rough guess of the default leaflet marker icon)

Returns : string
getKmDistance
getKmDistance(x: Coordinates, y: Coordinates)

Calculate distance between two points Source ://henry-rossiter.medium.com/calculating-distance-between-geographic-coordinates-with-javascript-5f3097b61898https

Parameters :
Name Type Optional
x Coordinates No
y Coordinates No
getLocationProperties
getLocationProperties(entity: EntityConstructor)

Get all properties of an entity that represent a geographic location

Parameters :
Name Type Optional
entity EntityConstructor No

src/app/core/common-components/entities-table/value-accessor/value-accessor.ts

getReadableValue
getReadableValue(value: any)

An enhanced sortingDataAccessor function that can be set for a MatTableDataSource in order to support sorting by ConfigurableEnum columns and other Entity specific values.

Parameters :
Name Type Optional Description
value any No

the object for which a readable string should be returned

Returns : any
isConfigurableEnum
isConfigurableEnum(value: any)
Parameters :
Name Type Optional
value any No
isGeoLocation
isGeoLocation(value: any)
Parameters :
Name Type Optional
value any No
Returns : GeoLocation
transformToReadableFormat
transformToReadableFormat(obj: any)

Transform a whole object into a readable format. This also transforms date objects to YYYY-MM-DD format.

Parameters :
Name Type Optional
obj any No

src/app/child-dev-project/warning-level.ts

getWarningLevelColor
getWarningLevelColor(warningLevel: WarningLevel)
Parameters :
Name Type Optional
warningLevel WarningLevel No

src/app/core/basic-datatypes/configurable-enum/configurable-enum-ordering.ts

hasOrdinalValue
hasOrdinalValue(value: any)
Parameters :
Name Type Optional
value any No
Returns : HasOrdinal
imposeTotalOrdering
imposeTotalOrdering(values: Array)

Extends an array of configurable enum values with an ordinal value so that the ordinal value of each enum value matches the position of the element in the array.

Note that this should be used 'early' in the pipeline, i.e. when the ConfigurableEnumConfig is just created. It is technically not incorrect to use this function on any array that contains configurable enum values, but it doesn't make sense to apply this function to 'scrambled' arrays, i.e. arrays where the ordering of values is not the natural order of these values.

Parameters :
Name Type Optional Description
values Array No

The values to impose a total ordering on

src/bootstrap-environment.ts

initEnvironmentConfig
initEnvironmentConfig()

Overwrite environment settings with the settings from the config.json if present. If no file is found, the environment settings are kept.

initFirebaseConfigToEnvironment
initFirebaseConfigToEnvironment()

Load Push Notifications config for Firebase. Please add assets/firebase-config.json with your own Firebase config

src/bootstrap-i18n.ts

initLanguage
initLanguage(locale?: string)

Load translation files and apply them to angular localize system.

Parameters :
Name Type Optional Description
locale string Yes

(Optional) overwrite the locale to use (otherwise loaded from local storage)

Returns : Promise<void>

src/app/utils/test-utils/custom-matcher-utils.ts

makeCustomMatcher
makeCustomMatcher(condition, compareMessage, negativeCompareMessage)

Create a custom matcher that checks a condition and displays a message when that condition fails, resp. a message when the inverse of that condition fails
This is a utility function to create a custom matcher from three functions

Parameters :
Name Optional Description
condition No

The condition to check

compareMessage No

The message displayed when the condition fails

negativeCompareMessage No

The message displayed when not condition failed, i.e. the message displayed when using expect(x).not.toBeEmpty()

Returns : jasmine.CustomMatcher

src/app/core/basic-datatypes/date-only/date-only.datatype.ts

migrateIsoDatesToInferredDateOnly
migrateIsoDatesToInferredDateOnly(value: string)
Parameters :
Name Type Optional
value string No
Returns : string

src/app/core/entity/entity-mapper/mock-entity-mapper-service.ts

mockEntityMapper
mockEntityMapper(withData)
Parameters :
Name Optional Default value
withData No []

src/app/core/basic-datatypes/entity/entity.datatype.ts

normalizeValue
normalizeValue(val: any)

Normalizes a value for comparison, converting it to a standardized string format. Ensures both numbers and strings are treated consistently.

Parameters :
Name Type Optional Description
val any No

The value to normalize.

Returns : string

The normalized value as a string.

src/app/core/session/session-utils.ts

parseJwt
parseJwt(token)

Parses and returns the payload of a JWT into a JSON object. For me info see ://jwt.iohttps.

Parameters :
Name Optional Description
token No

a valid JWT

Returns : ParsedJWT

src/app/core/common-components/entity-form/dynamic-form-validators/dynamic-validators.service.ts

patternWithMessage
patternWithMessage(pattern, message: string)

creates a pattern validator that also carries a predefined message

Parameters :
Name Type Optional Description
pattern No

The pattern to check

message string No

The custom message to display when the pattern fails

Returns : ValidatorFn

src/app/utils/performance-analysis-logging.ts

PerformanceAnalysisLogging
PerformanceAnalysisLogging(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor)

Extend any class method to measure the duration it takes to finish and log it to the console.

Parameters :
Name Type Optional
target Object No
propertyKey string No
descriptor TypedPropertyDescriptor No

src/app/utils/retry-on-server-error.rxjs-pipe.ts

random
random(min: number, max: number)
Parameters :
Name Type Optional
min number No
max number No
retryOnServerError
retryOnServerError(maxRetries: number)

Retry a request on server error (status code 5xx). Use this in pipe(retryOnServerError(2)).

Retries are done with exponential backoff delays that are randomized (in case there are many parallel requests to be spread out).

Parameters :
Name Type Optional
maxRetries number No
Returns : MonoTypeOperatorFunction<T>

src/app/features/file/file-utils.ts

resizeImage
resizeImage(file: File, maxSize: number)
Parameters :
Name Type Optional Default value
file File No
maxSize number No 360
Returns : Promise<HTMLCanvasElement>

src/app/core/import/additional-actions/import-additional/import-additional-actions.component.ts

sortExportOnlyLast
sortExportOnlyLast(a: AdditionalImportAction, b: AdditionalImportAction)
Parameters :
Name Type Optional
a AdditionalImportAction No
b AdditionalImportAction No

src/app/child-dev-project/notes/dashboard-widgets/notes-dashboard/notes-dashboard.component.ts

statsToEntityWithRecentNoteInfo
statsToEntityWithRecentNoteInfo(stat, queryRange: number)

Map a result entry from getDaysSinceLastNoteOfEachEntity to the EntityWithRecentNoteInfo interface

Parameters :
Name Type Optional Description
stat No

Array of [entityId, daysSinceLastNote]

queryRange number No

The query range (the maximum of days that exactly calculated)

src/app/core/common-components/entity-form/FormConfig.ts

toFormFieldConfig
toFormFieldConfig(column: ColumnConfig)
Parameters :
Name Type Optional
column ColumnConfig No
Returns : FormFieldConfig

src/app/core/language/TranslatableMatPaginator.ts

TranslatableMatPaginator
TranslatableMatPaginator()

src/app/core/common-components/entity-form/unique-id-validator/unique-id-validator.ts

uniqueIdValidator
uniqueIdValidator(existingIds)
Parameters :
Name Optional
existingIds No

src/app/core/session/session-states/session-utils.ts

waitForChangeTo
waitForChangeTo(state: State)

Waits until the state of a source observable is equal to the given state, then emit that state. All other states are discarded.
After the state has changed to the desired state, subsequent states are let through. if this desire is not intended, use the filter function

Parameters :
Name Type Optional Description
state State No

The state to wait on otherwise continues to emit values from the source observable

Returns : MonoTypeOperatorFunction<State>

results matching ""

    No results matching ""