Skip to content

Commit

Permalink
Config UI: add missing config sections / partial yaml inputs (BC) (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
naltatis committed Jun 8, 2024
1 parent 62a1e22 commit 554ce1d
Show file tree
Hide file tree
Showing 133 changed files with 4,399 additions and 1,566 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ __debug_bin*
!templates/**/*.yaml
!templates/**/*-schema.json
!util/templates/**/*.yaml
!assets/js/**/*.yaml
!package*.json
!evcc.dist.yaml
!tests/**/*.evcc.yaml
Expand Down
142 changes: 142 additions & 0 deletions api/globalconfig/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
package globalconfig

import (
"fmt"
"net"
"strconv"
"time"

"github.com/evcc-io/evcc/charger/eebus"
"github.com/evcc-io/evcc/provider/mqtt"
"github.com/evcc-io/evcc/push"
"github.com/evcc-io/evcc/util/config"
"github.com/evcc-io/evcc/util/modbus"
)

type All struct {
Network Network
Log string
SponsorToken string
Plant string // telemetry plant id
Telemetry bool
Metrics bool
Profile bool
Levels map[string]string
Interval time.Duration
Database DB
Mqtt Mqtt
ModbusProxy []ModbusProxy
Javascript []Javascript
Go []Go
Influx Influx
EEBus eebus.Config
HEMS config.Typed
Messaging Messaging
Meters []config.Named
Chargers []config.Named
Vehicles []config.Named
Tariffs Tariffs
Site map[string]interface{}
Loadpoints []map[string]interface{}
Circuits []config.Named
}

type Javascript struct {
VM string
Script string
}

type Go struct {
VM string
Script string
}

type ModbusProxy struct {
Port int
ReadOnly string
modbus.Settings `mapstructure:",squash"`
}

type Mqtt struct {
mqtt.Config `mapstructure:",squash"`
Topic string `json:"topic"`
}

// Redacted implements the redactor interface used by the tee publisher
func (m Mqtt) Redacted() any {
// TODO add masked password
return struct {
Broker string `json:"broker"`
Topic string `json:"topic"`
User string `json:"user"`
ClientID string `json:"clientID"`
Insecure bool `json:"insecure"`
}{
Broker: m.Broker,
Topic: m.Topic,
User: m.User,
ClientID: m.ClientID,
Insecure: m.Insecure,
}
}

// Influx is the influx db configuration
type Influx struct {
URL string `json:"url"`
Database string `json:"database"`
Token string `json:"token"`
Org string `json:"org"`
User string `json:"user"`
Password string `json:"password"`
}

// Redacted implements the redactor interface used by the tee publisher
func (c Influx) Redacted() any {
// TODO add masked password
return struct {
URL string `json:"url"`
Database string `json:"database"`
Org string `json:"org"`
User string `json:"user"`
}{
URL: c.URL,
Database: c.Database,
Org: c.Org,
User: c.User,
}
}

type DB struct {
Type string
Dsn string
}

type Messaging struct {
Events map[string]push.EventTemplateConfig
Services []config.Typed
}

type Tariffs struct {
Currency string
Grid config.Typed
FeedIn config.Typed
Co2 config.Typed
Planner config.Typed
}

type Network struct {
Schema string `json:"schema"`
Host string `json:"host"`
Port int `json:"port"`
}

func (c Network) HostPort() string {
if c.Schema == "http" && c.Port == 80 || c.Schema == "https" && c.Port == 443 {
return c.Host
}
return net.JoinHostPort(c.Host, strconv.Itoa(c.Port))
}

func (c Network) URI() string {
return fmt.Sprintf("%s://%s", c.Schema, c.HostPort())
}
61 changes: 49 additions & 12 deletions assets/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@
--evcc-red-rgb: 252, 68, 15;
--bs-gray-deep: #010322;
--bs-gray-dark: #28293e;
--bs-gray-darker: #151630;
--bs-gray-medium: #93949e;
--bs-gray-light: #b5b6c3;
--bs-gray-bright: #f3f3f7;
--bs-gray-brighter: #f9f9fb;

--evcc-grid: var(--bs-gray-dark);
--evcc-self: var(--evcc-dark-green);
Expand All @@ -46,6 +48,7 @@
--evcc-export: var(--evcc-yellow);
--evcc-background: var(--bs-gray-bright);
--evcc-box: var(--bs-white);
--evcc-box-border: var(--bs-gray-brighter);
--evcc-default-text: var(--bs-gray-dark);
--evcc-gray: var(--bs-gray-medium);
--evcc-gray-50: #93949e80;
Expand All @@ -65,6 +68,10 @@

--bs-warning: var(--evcc-orange);
--bs-warning-rgb: var(--evcc-orange-rgb);
--bs-danger-50: #dc354580;

--bs-danger: var(--evcc-red);
--bs-danger-rgb: var(--evcc-red-rgb);

--bs-danger: var(--evcc-red);
--bs-danger-rgb: var(--evcc-red-rgb);
Expand All @@ -76,12 +83,14 @@
--bs-success: var(--evcc-primary);
--bs-success-rgb: var(--bs-primary-rgb);
--bs-code-color: var(--evcc-darkest-green);
--evcc-backdrop: #93949eaa; /* --bs-gray-medium + transparent */
}

:root.dark {
--evcc-grid: var(--bs-gray-medium);
--evcc-background: var(--bs-gray-deep);
--evcc-box: var(--bs-gray-dark);
--evcc-box-border: var(--vs-gray-darker);
--evcc-default-text: var(--bs-white);
--evcc-gray: var(--bs-gray-light);
--evcc-accent1: var(--evcc-yellow);
Expand All @@ -90,15 +99,10 @@
--bs-primary: var(--evcc-dark-green);
--bs-border-color-translucent: rgba(255, 255, 255, 0.175);
--bs-code-color: var(--evcc-dark-green);
--evcc-backdrop: #000000aa; /* black + transparent */
color-scheme: dark;
}

html {
/* prevents content jump when scrollbar is activate */
width: 100vw;
overflow-x: hidden;
}

html.no-transitions * {
transition: none !important;
}
Expand Down Expand Up @@ -322,7 +326,19 @@ a:hover {
}

.modal-backdrop.show {
opacity: 0.8;
opacity: 1;
}

.modal-backdrop {
--bs-backdrop-bg: var(--evcc-backdrop);
-webkit-backdrop-filter: blur(8px);
backdrop-filter: blur(8px);
}

.modal-backdrop.fade {
transition-property: opacity, backdrop-filter, background-color;
transition-duration: var(--evcc-transition-fast);
transition-timing-function: linear;
}

.modal-header {
Expand All @@ -342,6 +358,13 @@ a:hover {
color: var(--evcc-default-text);
}

.modal-content h6 {
margin-top: 2rem;
margin-bottom: 1.5rem;
font-size: 1rem;
font-weight: bold;
}

/* breakpoint sm */
@media (min-width: 576px) {
.modal-content {
Expand All @@ -362,6 +385,10 @@ a:hover {
margin: 0;
}

html:has(.modal.show) {
overflow-y: hidden;
}

.cursor-pointer {
cursor: pointer;
}
Expand Down Expand Up @@ -514,6 +541,9 @@ input[type="time"]::-webkit-calendar-picker-indicator {
.w-sm-50 {
width: 50% !important;
}
.w-sm-25 {
width: 25% !important;
}
}

html.app .hide-in-app {
Expand Down Expand Up @@ -553,13 +583,20 @@ html.app .modal-dialog {

.round-box {
border-radius: 1rem;
box-shadow: 0 0 0 0 var(--evcc-gray-50);
color: var(--evcc-default-text);
background: var(--evcc-box);
padding: 1rem;
border: 1px solid var(--evcc-gray-50);
transition: box-shadow var(--evcc-transition-fast) linear;
}
.round-box:hover {
border-color: var(--evcc-gray);

.round-box--error {
box-shadow: 0 0 0.5rem var(--bs-danger);
border: 1px solid var(--bs-danger);
}

.round-box--error .tags * {
color: var(--bs-danger-text-emphasis) !important;
}

.alert-danger code {
color: var(--evcc-darkest-green);
}
26 changes: 26 additions & 0 deletions assets/js/components/Config/CircuitsModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
<YamlModal
id="circuitsModal"
:title="$t('config.circuits.title')"
:description="$t('config.circuits.description')"
docs="/docs/reference/configuration/circuits"
:defaultYaml="defaultYaml"
endpoint="/config/circuits"
size="md"
@changed="$emit('changed')"
/>
</template>

<script>
import YamlModal from "./YamlModal.vue";
import defaultYaml from "./defaultYaml/circuits.yaml?raw";
export default {
name: "CircuitsModal",
components: { YamlModal },
emits: ["changed"],
data() {
return { defaultYaml: defaultYaml.trim() };
},
};
</script>
Loading

0 comments on commit 554ce1d

Please sign in to comment.