Indigo2 claim option
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import {useContext, useEffect, useReducer} from "react";
|
import {useContext, useEffect, useReducer} from "react";
|
||||||
import RuntimeContext from "../contexts/RuntimeContext";
|
import RuntimeContext from "../contexts/RuntimeContext";
|
||||||
import {Values} from "../models/Shared";
|
|
||||||
import {WorkoutState} from "../models/Workouts";
|
import {WorkoutState} from "../models/Workouts";
|
||||||
|
|
||||||
interface UseKpmReducerState {
|
interface UseKpmReducerState {
|
||||||
@@ -28,7 +27,7 @@ export function useKpm() {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
lastStates: [...inRange, newState],
|
lastStates: [...inRange, newState],
|
||||||
kpm: inRange.length > 30
|
kpm: duration >= 30
|
||||||
? Math.round(((newState.calories || 0) - (first.calories || 0)) * 60 / duration)
|
? Math.round(((newState.calories || 0) - (first.calories || 0)) * 60 / duration)
|
||||||
: 0,
|
: 0,
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -26,6 +26,7 @@ class Indigo2(
|
|||||||
private val oidcTokenEndpoint: String,
|
private val oidcTokenEndpoint: String,
|
||||||
private val oidcClientId: String,
|
private val oidcClientId: String,
|
||||||
private val oidcClientSecret: String,
|
private val oidcClientSecret: String,
|
||||||
|
private val autoClaim: Boolean,
|
||||||
) : ExportTarget {
|
) : ExportTarget {
|
||||||
private val om = jacksonObjectMapper().apply {
|
private val om = jacksonObjectMapper().apply {
|
||||||
configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||||
@@ -67,7 +68,7 @@ class Indigo2(
|
|||||||
"kind" to "ExerciseBike",
|
"kind" to "ExerciseBike",
|
||||||
"measurements" to tm(chunks.first()),
|
"measurements" to tm(chunks.first()),
|
||||||
),
|
),
|
||||||
"claimed" to true,
|
"claimed" to autoClaim,
|
||||||
"date" to workout.date.toString(),
|
"date" to workout.date.toString(),
|
||||||
"tags" to listOfNotNull(
|
"tags" to listOfNotNull(
|
||||||
tag("ykonsole:Version", "2"),
|
tag("ykonsole:Version", "2"),
|
||||||
|
|||||||
@@ -111,12 +111,14 @@ private data class RepositorySet(
|
|||||||
val tokenEndpoint = strEnv("INDIGO2_OIDC_TOKEN_ENDPOINT")
|
val tokenEndpoint = strEnv("INDIGO2_OIDC_TOKEN_ENDPOINT")
|
||||||
val clientId = strEnv("INDIGO2_OIDC_CLIENT_ID")
|
val clientId = strEnv("INDIGO2_OIDC_CLIENT_ID")
|
||||||
val clientSecret = strEnv("INDIGO2_OIDC_CLIENT_SECRET")
|
val clientSecret = strEnv("INDIGO2_OIDC_CLIENT_SECRET")
|
||||||
|
val autoClaim = optStrEnv("INDIGO2_OIDC_AUTO_CLAIM").lowercase() in arrayOf("yes", "1", "true")
|
||||||
|
|
||||||
return Indigo2(
|
return Indigo2(
|
||||||
indigoHost = indigo2Endpoint,
|
indigoHost = indigo2Endpoint,
|
||||||
oidcTokenEndpoint = tokenEndpoint,
|
oidcTokenEndpoint = tokenEndpoint,
|
||||||
oidcClientId = clientId,
|
oidcClientId = clientId,
|
||||||
oidcClientSecret = clientSecret,
|
oidcClientSecret = clientSecret,
|
||||||
|
autoClaim = autoClaim,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user