Skip to content

Commit

Permalink
Log Viewer: Allow retrieving logs from ring buffer (evcc-io#13330)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Apr 14, 2024
1 parent 75179b0 commit 334ffc1
Show file tree
Hide file tree
Showing 40 changed files with 1,231 additions and 357 deletions.
52 changes: 49 additions & 3 deletions assets/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
--evcc-dark-yellow: #bbb400;
--evcc-orange: #ff9000;
--evcc-orange-rgb: 255, 144, 0;
--evcc-red: #fc440f;
--evcc-red-rgb: 252, 68, 15;
--bs-gray-deep: #010322;
--bs-gray-dark: #28293e;
--bs-gray-medium: #93949e;
Expand Down Expand Up @@ -63,12 +65,16 @@
--bs-warning: var(--evcc-orange);
--bs-warning-rgb: var(--evcc-orange-rgb);

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

--bs-body-font-size: 14px;
--bs-font-sans-serif: Montserrat, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
"Segoe UI Symbol", "Noto Color Emoji";
--bs-success: var(--evcc-primary);
--bs-success-rgb: var(--bs-primary-rgb);
--bs-code-color: var(--evcc-darkest-green);
}

:root.dark {
Expand All @@ -82,6 +88,8 @@
--evcc-accent3: var(--evcc-darker-green);
--bs-primary: var(--evcc-dark-green);
--bs-border-color-translucent: rgba(255, 255, 255, 0.175);
--bs-code-color: var(--evcc-dark-green);
color-scheme: dark;
}

html {
Expand Down Expand Up @@ -229,11 +237,20 @@ a:hover {
--bs-btn-line-height: 2;
}

.btn-outline-secondary {
--bs-btn-color: var(--evcc-default-text);
--bs-btn-border-color: var(--evcc-default-text);
--bs-btn-hover-bg: transparent;
--bs-btn-hover-color: var(--bs-gray-medium);
--bs-btn-hover-border-color: var(--bs-gray-medium);
}

.dark .btn-outline-secondary {
--bs-btn-color: var(--bs-gray-bright);
--bs-btn-border-color: var(--bs-gray-bright);
--bs-btn-hover-bg: var(--bs-gray-bright);
--bs-btn-hover-color: var(--bs-gray-dark);
--bs-btn-hover-bg: transparent;
--bs-btn-hover-color: var(--bs-gray-medium);
--bs-btn-hover-border-color: var(--bs-gray-medium);
}

.accordion {
Expand Down Expand Up @@ -298,6 +315,9 @@ a:hover {
.modal-xl {
--bs-modal-width: 850px;
}
.w-lg-auto {
width: auto !important;
}
}

.modal-backdrop.show {
Expand Down Expand Up @@ -376,6 +396,10 @@ small {
background-color: var(--bs-primary);
color: var(--bs-white);
}
.form-select {
overflow: hidden;
text-overflow: ellipsis;
}

.dark .dropdown-menu {
box-shadow: 0 0 8px var(--evcc-background);
Expand All @@ -398,6 +422,7 @@ small {
--bs-table-color: var(--evcc-default-text);
--bs-table-border-color: var(--evcc-gray);
}

.nav-tabs .nav-link {
color: var(--evcc-gray) !important;
}
Expand Down Expand Up @@ -438,13 +463,21 @@ input::-webkit-datetime-edit {
}

.form-control {
background-color: var(--evcc-box);
color: var(--evcc-default-text);
}
.form-control:disabled {
color: var(--bs-gray-dark);
}

.dark .form-control {
background-color: var(--evcc-box);
color: var(--evcc-default-text);
}

.dark .form-control::placeholder {
color: var(--bs-gray-medium);
}

input[type="time"]::-webkit-calendar-picker-indicator {
display: none;
}
Expand Down Expand Up @@ -515,3 +548,16 @@ html.app .modal-dialog {
.btn-neutral:hover {
outline: revert;
}

.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);
}
11 changes: 10 additions & 1 deletion assets/js/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Modal from "bootstrap/js/dist/modal";
const auth = reactive({
configured: true,
loggedIn: false,
nextUrl: null,
});

export async function updateAuthStatus() {
Expand All @@ -28,6 +29,7 @@ export async function logout() {
try {
await api.post("/auth/logout");
await updateAuthStatus();
auth.nextUrl = null;
} catch (e) {
console.log("unable to logout", e);
}
Expand All @@ -41,7 +43,14 @@ export function isConfigured() {
return auth.configured;
}

export function openLoginModal() {
export function getAndClearNextUrl() {
const nextUrl = auth.nextUrl;
auth.nextUrl = null;
return nextUrl;
}

export function openLoginModal(nextUrl = null) {
auth.nextUrl = nextUrl;
const modal = Modal.getOrCreateInstance(document.getElementById("loginModal"));
modal.show();
}
Expand Down
49 changes: 24 additions & 25 deletions assets/js/components/Config/GeneralConfig.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="group pt-4 px-4 pb-1">
<div class="group round-box pt-4 px-4 pb-1">
<dl class="row" data-testid="generalconfig-title">
<dt class="col-sm-4">Title</dt>
<dd class="col-sm-8">
Expand All @@ -14,7 +14,19 @@
<TitleModal ref="titleModal" @changed="load" />
</dd>
</dl>
<dl class="row">
<dl class="row" data-testid="generalconfig-password">
<dt class="col-sm-4">Password</dt>
<dd class="col-sm-8">
*******
<a
href="#"
class="ms-2 d-inline-block text-muted"
@click.prevent="openModal('passwordModal')"
>edit</a
>
</dd>
</dl>
<dl class="row" data-testid="generalconfig-telemetry">
<dt class="col-sm-4">Telemetry</dt>
<dd class="col-sm-8">
{{ telemetryEnabled ? "on" : "off" }}
Expand All @@ -27,17 +39,17 @@
</a>
</dd>
</dl>
<dl class="row wip" data-testid="generalconfig-password">
<dt class="col-sm-4">Password</dt>
<dl class="row" data-testid="generalconfig-experimental">
<dt class="col-sm-4">Experimental</dt>
<dd class="col-sm-8">
*******
<!-- TODO: update this once auth is released -->
{{ hiddenFeatures ? "on" : "off" }}
<a
href="#"
class="ms-2 d-inline-block text-muted"
@click.prevent="todo() /* openModal('passwordModal')*/"
>edit</a
@click.prevent="openModal('globalSettingsModal')"
>
change
</a>
</dd>
</dl>
<dl class="row wip">
Expand Down Expand Up @@ -93,6 +105,9 @@ export default {
telemetryEnabled() {
return settings.telemetry === true;
},
hiddenFeatures() {
return settings.hiddenFeatures === true;
},
},
methods: {
async changed() {
Expand Down Expand Up @@ -124,29 +139,13 @@ export default {

<style scoped>
.group {
border-radius: 1rem;
box-shadow: 0 0 0 0 var(--evcc-gray-50);
color: var(--evcc-default-text);
background: var(--evcc-box);
padding: 1rem;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
min-height: 10rem;
margin-bottom: 5rem;
border: 1px solid var(--evcc-gray-50);
transition: box-shadow var(--evcc-transition-fast) linear;
}
.group:hover {
border-color: var(--evcc-gray);
}
.group:focus-within {
box-shadow: 0 0 1rem 0 var(--evcc-gray-50);
}
.wip {
opacity: 0.2;
display: none !important;
}
dt {
margin-bottom: 0.5rem;
Expand Down
25 changes: 19 additions & 6 deletions assets/js/components/HelpModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class="d-block d-sm-flex justify-content-between align-items-stretch mb-4"
>
<a
href="https://docs.evcc.io/"
:href="docsUrl"
target="_blank"
class="btn btn-outline-primary w-100 w-sm-auto flex-grow-1 mb-3 mb-sm-0 me-sm-3"
type="button"
Expand All @@ -46,6 +46,16 @@
<p>
{{ $t("help.secondaryActions") }}
</p>
<div
class="d-block d-sm-flex justify-content-between align-items-baseline mb-3"
>
<p class="flex-sm-grow-1 opacity-50 me-sm-3">
{{ $t("help.logsDescription") }}
</p>
<router-link to="/log" class="btn btn-outline-primary text-nowrap">
{{ $t("help.logsButton") }}
</router-link>
</div>
<div
class="d-block d-sm-flex justify-content-between align-items-baseline mb-3"
>
Expand All @@ -56,11 +66,11 @@
href="https://github.com/evcc-io/evcc/issues"
target="_blank"
class="btn btn-outline-primary text-nowrap"
type="button"
>
{{ $t("help.issueButton") }}
</a>
</div>

<div
class="d-block d-sm-flex justify-content-between align-items-baseline mb-3"
>
Expand Down Expand Up @@ -128,11 +138,17 @@

<script>
import Modal from "bootstrap/js/dist/modal";
import { docsPrefix } from "../i18n";
import api from "../api";
export default {
name: "HelpModal",
props: {},
computed: {
docsUrl() {
return `${docsPrefix()}/`;
},
},
methods: {
openHelpModal() {
const modal = Modal.getOrCreateInstance(document.getElementById("helpModal"));
Expand All @@ -144,10 +160,7 @@ export default {
},
async restartConfirmed() {
try {
await api.post("shutdown");
alert(
"Server was stopped successfully. Waiting for the operating system to start evcc again."
);
await api.post("/system/shutdown");
} catch (e) {
alert("Unabled to restart server.");
}
Expand Down
Loading

0 comments on commit 334ffc1

Please sign in to comment.