Issue UI: fix config file resolution (#23832)
Some checks failed
Some checks failed
Co-authored-by: Michael Geers <michael@geers.tv>
This commit is contained in:
parent
0880f82c65
commit
4a4027c766
2 changed files with 15 additions and 7 deletions
|
|
@ -143,10 +143,10 @@
|
|||
<template #description>
|
||||
<p class="text-muted small">
|
||||
{{ $t("issue.additional.yamlConfigDescription") }}<br />
|
||||
<span v-if="configPath"
|
||||
>{{ $t("issue.additional.source") }}:
|
||||
<code>{{ configPath }}</code></span
|
||||
>
|
||||
<span>
|
||||
{{ $t("issue.additional.source") }}:
|
||||
<code>{{ configPath || "---" }}</code>
|
||||
</span>
|
||||
</p>
|
||||
</template>
|
||||
</IssueAdditionalItem>
|
||||
|
|
@ -427,13 +427,21 @@ export default defineComponent({
|
|||
try {
|
||||
const response = await api.get("config/evcc.yaml", {
|
||||
responseType: "text",
|
||||
validateStatus: (code) => [200, 404].includes(code),
|
||||
});
|
||||
|
||||
// Handle 404 silently when evcc.yaml doesn't exist
|
||||
if (response.status === 404) {
|
||||
this.sections.yamlConfig.content = "no yaml configuration";
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove empty lines from config
|
||||
this.sections.yamlConfig.content = response.data
|
||||
.split("\n")
|
||||
.filter((line: string) => line.trim() !== "")
|
||||
.join("\n");
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error("Failed to fetch config:", error);
|
||||
this.sections.yamlConfig.content = "Failed to load configuration";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ func runRoot(cmd *cobra.Command, args []string) {
|
|||
|
||||
// publish system infos
|
||||
valueChan <- util.Param{Key: keys.Version, Val: util.FormattedVersion()}
|
||||
valueChan <- util.Param{Key: keys.Config, Val: cfgFile}
|
||||
valueChan <- util.Param{Key: keys.Config, Val: viper.ConfigFileUsed()}
|
||||
valueChan <- util.Param{Key: keys.Database, Val: db.FilePath}
|
||||
|
||||
// run shutdown functions on stop
|
||||
|
|
@ -343,7 +343,7 @@ func runRoot(cmd *cobra.Command, args []string) {
|
|||
log.INFO.Println("evcc was stopped by user. OS should restart the service. Or restart manually.")
|
||||
err = errors.New("restart required") // https://gokrazy.org/development/process-interface/
|
||||
once.Do(func() { close(stopC) }) // signal loop to end
|
||||
}, cfgFile)
|
||||
}, viper.ConfigFileUsed())
|
||||
|
||||
// show and check version, reduce api load during development
|
||||
if util.Version != util.DevVersion {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue