-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement first version of device configuration
- Loading branch information
Showing
6 changed files
with
121 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<template>¨ | ||
<v-form> | ||
<v-text-field label="Name" type="input" v-model="name"></v-text-field> | ||
<v-text-field label="Verbrauch" type="number" v-model="nominal_power"></v-text-field> | ||
<v-btn block color="primary" @click="submit"> | ||
{{ $t('settings.save') }} | ||
</v-btn> | ||
</v-form> | ||
<br/> | ||
<v-btn block @click="router.back()"> | ||
{{ $t('close') }} | ||
</v-btn> | ||
<br/> | ||
<p>Details: </p> | ||
<ul> | ||
<li v-for="(value, key) in config"> | ||
{{ key }}: {{ value }} | ||
</li> | ||
</ul> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { api, IConfig, ConfigValueType } from '@/api/energyAssistant.api'; | ||
import { watch, ref } from 'vue'; | ||
import { useRouter } from 'vue-router'; | ||
// global refs | ||
const router = useRouter(); | ||
const config = ref<IConfig>(); | ||
const name = ref<string>("") | ||
const nominal_power = ref<number>(0) | ||
// props | ||
const props = defineProps<{ | ||
deviceId?: string; | ||
}>(); | ||
// watchers | ||
watch( | ||
() => props.deviceId, | ||
async (val) => { | ||
if (val) { | ||
console.log("Edit Device: " + val) | ||
config.value = await api.getDeviceConfig(val); | ||
name.value = config.value["name"]; | ||
nominal_power.value = config.value["nominal_power"]; | ||
} | ||
}, | ||
{ immediate: true }, | ||
); | ||
// methods | ||
const submit = async function () { | ||
/* values['enabled'] = config.value!.enabled; | ||
values['name'] = config.value!.name || null; | ||
api.saveDeviceConfig(props.deviceId!, values);*/ | ||
const values = { | ||
"name": name.value, | ||
"nominal_power": nominal_power.value | ||
} | ||
await api.saveDeviceConfig(props.deviceId!, values); | ||
router.push({ name: 'devicessettings' }); | ||
}; | ||
</script> |