Add Rule Title in UserEntry for Automation (as note)
This commit is contained in:
parent
206bac6da8
commit
1f4b75a30d
|
@ -203,6 +203,7 @@ class AutomationPlugin @Inject constructor(
|
|||
if (event.systemAction || userEventsEnabled) {
|
||||
val actions = event.actions
|
||||
for (action in actions) {
|
||||
action.title = event.title
|
||||
if (action.isValid())
|
||||
action.doAction(object : Callback() {
|
||||
override fun run() {
|
||||
|
|
|
@ -23,6 +23,8 @@ abstract class Action(val injector: HasAndroidInjector) {
|
|||
abstract fun isValid(): Boolean
|
||||
@DrawableRes abstract fun icon(): Int
|
||||
|
||||
var title = ""
|
||||
|
||||
init {
|
||||
injector.androidInjector().inject(this)
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class ActionLoopDisable(injector: HasAndroidInjector) : Action(injector) {
|
|||
if ((loopPlugin as PluginBase).isEnabled()) {
|
||||
(loopPlugin as PluginBase).setPluginEnabled(PluginType.LOOP, false)
|
||||
configBuilderPlugin.storeSettings("ActionLoopDisable")
|
||||
uel.log(UserEntry.Action.LOOP_DISABLED, Sources.Automation)
|
||||
uel.log(UserEntry.Action.LOOP_DISABLED, Sources.Automation, title)
|
||||
commandQueue.cancelTempBasal(true, object : Callback() {
|
||||
override fun run() {
|
||||
rxBus.send(EventRefreshOverview("ActionLoopDisable"))
|
||||
|
|
|
@ -34,7 +34,7 @@ class ActionLoopEnable(injector: HasAndroidInjector) : Action(injector) {
|
|||
(loopPlugin as PluginBase).setPluginEnabled(PluginType.LOOP, true)
|
||||
configBuilderPlugin.storeSettings("ActionLoopEnable")
|
||||
rxBus.send(EventRefreshOverview("ActionLoopEnable"))
|
||||
uel.log(UserEntry.Action.LOOP_ENABLED, Sources.Automation)
|
||||
uel.log(UserEntry.Action.LOOP_ENABLED, Sources.Automation, title)
|
||||
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
||||
} else {
|
||||
callback.result(PumpEnactResult(injector).success(true).comment(R.string.alreadyenabled))?.run()
|
||||
|
|
|
@ -32,7 +32,7 @@ class ActionLoopResume(injector: HasAndroidInjector) : Action(injector) {
|
|||
configBuilderPlugin.storeSettings("ActionLoopResume")
|
||||
loopPlugin.createOfflineEvent(0)
|
||||
rxBus.send(EventRefreshOverview("ActionLoopResume"))
|
||||
uel.log(UserEntry.Action.RESUME, Sources.Automation)
|
||||
uel.log(UserEntry.Action.RESUME, Sources.Automation, title)
|
||||
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
||||
} else {
|
||||
callback.result(PumpEnactResult(injector).success(true).comment(R.string.notsuspended))?.run()
|
||||
|
|
|
@ -37,7 +37,7 @@ class ActionLoopSuspend(injector: HasAndroidInjector) : Action(injector) {
|
|||
if (!loopPlugin.isSuspended) {
|
||||
loopPlugin.suspendLoop(minutes.getMinutes())
|
||||
rxBus.send(EventRefreshOverview("ActionLoopSuspend"))
|
||||
uel.log(UserEntry.Action.SUSPEND, Sources.Automation,
|
||||
uel.log(UserEntry.Action.SUSPEND, Sources.Automation, title,
|
||||
XXXValueWithUnit.StringResource(R.string.suspendloopforXmin, listOf(XXXValueWithUnit.Minute(minutes.getMinutes()))))
|
||||
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
||||
} else {
|
||||
|
|
|
@ -58,7 +58,7 @@ class ActionProfileSwitch(injector: HasAndroidInjector) : Action(injector) {
|
|||
callback.result(PumpEnactResult(injector).success(false).comment(R.string.notexists))?.run()
|
||||
return
|
||||
}
|
||||
uel.log(UserEntry.Action.PROFILE_SWITCH, Sources.Automation,
|
||||
uel.log(UserEntry.Action.PROFILE_SWITCH, Sources.Automation, title,
|
||||
XXXValueWithUnit.SimpleString(inputProfileName.value),
|
||||
XXXValueWithUnit.Percent(100))
|
||||
activePlugin.activeTreatments.doProfileSwitch(profileStore, inputProfileName.value, 0, 100, 0, DateUtil.now())
|
||||
|
|
|
@ -42,7 +42,7 @@ class ActionProfileSwitchPercent(injector: HasAndroidInjector) : Action(injector
|
|||
}
|
||||
|
||||
override fun doAction(callback: Callback) {
|
||||
uel.log(UserEntry.Action.PROFILE_SWITCH, Sources.Automation,
|
||||
uel.log(UserEntry.Action.PROFILE_SWITCH, Sources.Automation, title,
|
||||
if (duration.value == 0) XXXValueWithUnit.StringResource( R.string.startprofileforever, listOf(XXXValueWithUnit.Percent(pct.value.toInt())))
|
||||
else XXXValueWithUnit.StringResource( R.string.startprofile, listOf(XXXValueWithUnit.Percent(pct.value.toInt()), XXXValueWithUnit.Minute(duration.value))))
|
||||
activePlugin.activeTreatments.doProfileSwitch(duration.value, pct.value.toInt(), 0)
|
||||
|
|
|
@ -61,7 +61,7 @@ class ActionStartTempTarget(injector: HasAndroidInjector) : Action(injector) {
|
|||
.subscribe({ result ->
|
||||
result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") }
|
||||
result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") }
|
||||
uel.log(UserEntry.Action.TT, Sources.Automation,
|
||||
uel.log(UserEntry.Action.TT, Sources.Automation, title,
|
||||
XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.AUTOMATION),
|
||||
XXXValueWithUnit.fromGlucoseUnit(tt().lowTarget, Constants.MGDL),
|
||||
XXXValueWithUnit.fromGlucoseUnit(tt().highTarget, Constants.MGDL).takeIf { tt().lowTarget != tt().highTarget },
|
||||
|
|
|
@ -32,7 +32,7 @@ class ActionStopTempTarget(injector: HasAndroidInjector) : Action(injector) {
|
|||
override fun doAction(callback: Callback) {
|
||||
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(dateUtil._now()))
|
||||
.subscribe({ result ->
|
||||
uel.log(UserEntry.Action.CANCEL_TT, Sources.Automation)
|
||||
uel.log(UserEntry.Action.CANCEL_TT, Sources.Automation, title)
|
||||
result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") }
|
||||
}, {
|
||||
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it)
|
||||
|
|
Loading…
Reference in a new issue