Skip to content

Commit

Permalink
Add initial cut of templating
Browse files Browse the repository at this point in the history
  • Loading branch information
iainfogg committed Sep 22, 2024
1 parent dc23355 commit 53e044a
Show file tree
Hide file tree
Showing 9 changed files with 330 additions and 98 deletions.
13 changes: 13 additions & 0 deletions apps/predbat/templates/apps.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends "layout.html" %}

{% block title %}Home{% endblock %}

{% block content %}
<h2>Predbat Apps.yaml</h2>

<div id="apps">
{% autoescape false %}
{{ apps_html }}
{% endautoescape %}
</div>
{% endblock %}
19 changes: 19 additions & 0 deletions apps/predbat/templates/charts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends "layout.html" %}

{% block title %}Home{% endblock %}

{% block content %}
<h2>{{ chart_title }} Chart</h2>
- <a href="./charts?chart=Battery">Battery</a>
<a href="./charts?chart=Power">Power</a>
<a href="./charts?chart=Cost">Cost</a>
<a href="./charts?chart=Rates">Rates</a>
<a href="./charts?chart=InDay">InDay</a>
<a href="./charts?chart=PV">PV</a>
<a href="./charts?chart=PV7">PV7</a>
<div id="chart">
{% autoescape false %}
{{ chart_html }}
{% endautoescape %}
</div>
{% endblock %}
13 changes: 13 additions & 0 deletions apps/predbat/templates/config.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends "layout.html" %}

{% block title %}Home{% endblock %}

{% block content %}
<h2>Predbat Config</h2>

<div id="apps">
{% autoescape false %}
{{ config_html }}
{% endautoescape %}
</div>
{% endblock %}
10 changes: 10 additions & 0 deletions apps/predbat/templates/dash.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% extends "layout.html" %}

{% block title %}Home{% endblock %}


{% block content %}
{% autoescape false %}
{{ dash_html }}
{% endautoescape %}
{% endblock %}
9 changes: 9 additions & 0 deletions apps/predbat/templates/docs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends "layout.html" %}

{% block title %}Home{% endblock %}

{% block content %}
<div class="iframe-container">
<iframe src="https://springfall2008.github.io/batpred/" class="main-frame" name="main_frame"></iframe>
</div>
{% endblock %}
89 changes: 89 additions & 0 deletions apps/predbat/templates/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!doctype html>
<html>
<head>
<title>Predbat Web Interface</title>
<link href="https://cdn.jsdelivr.net/npm/@mdi/[email protected]/css/materialdesignicons.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
<style>
body, html {
margin: 0;
padding: 0;
height: 100%;
}
.iframe-container {
display: flex;
flex-direction: column;
height: 90vh;
}
/* Style for the top menu iframe */
.menu-frame {
height: 80px; /* Adjust the height of the menu bar */
width: 100%;
border: none;
overflow: hidden;
}
/* Style for the full height iframe */
.main-frame {
flex-grow: 1;
width: 100%;
border: none;
}
body {
font-family: Arial, sans-serif;
text-align: left;
margin: 5px;
background-color: #ffffff;
color: #333;
}
h1 {
color: #4CAF50;
}
h2 {
color: #4CAF50;
display: inline
}
table {
border-collapse: collapse;
padding: 1px;
border: 1px solid blue;
}
th,
td {
text-align: left;
padding: 5px;
vertical-align: top;
}
th {
background-color: #4CAF50;
color: white;
}
.default {
background-color: #FFFFFF;
}
.modified {
background-color: #FFCCCC;
}
</style>
{% if refresh is defined %}
<meta http-equiv="refresh" content="{{ refresh }}" >
{% endif %}

</head>
<body>
<div>
<table>
<tr>
<td><h2>Predbat</h2></td><td><img src="https://github-production-user-asset-6210df.s3.amazonaws.com/48591903/249456079-e98a0720-d2cf-4b71-94ab-97fe09b3cee1.png" width="50" height="50"></td>
<td><a href="./">Dash</a></td>
<td><a href="./plan">Plan</a></td>
<td><a href="./charts">Charts</a></td>
<td><a href="./config">Config</a></td>
<td><a href="./apps">apps.yaml</a></td>
<td><a href="./log?warnings">Log</a></td>
<td><a href="./docs">Docs</a></td>
</tr>
</table>
</div>
{% block content %}{% endblock %}
</body>
</html>
16 changes: 16 additions & 0 deletions apps/predbat/templates/logs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% extends "layout.html" %}

{% block title %}Home{% endblock %}


{% block content %}
<h2>Logfile ({% if errors %}Errors{% elif warnings %}Warnings{% else %}All{% endif %})</h2>
- <a href="./log">All</a> <a href="./log?warnings">Warnings</a> <a href="./log?errors">Errors</a><br>
<table width=100%>
{% for line in lines %}
<tr><td>{{ line.line_no}}</td><td nowrap><font color="#{% if "error" in line.rest_line.lower() %}ff3333{% elif not errors and "warn" in line.rest_line.lower()%}ffA500{% else %}33cc33{% endif %}">{{ line.start_line }}</font> {{ line.rest_line }}</td></tr>

This comment has been minimized.

Copy link
@springfall2008

springfall2008 Sep 23, 2024

Owner

How do you filter out lines I don't see that bit (just the auto color)?

{% endfor %}
</table>
{% autoescape false %}
{% endautoescape %}
{% endblock %}
11 changes: 11 additions & 0 deletions apps/predbat/templates/plan.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends "layout.html" %}

{% block title %}Home{% endblock %}


{% block content %}
Plan
{% autoescape false %}
{{ plan_html }}
{% endautoescape %}
{% endblock %}
Loading

0 comments on commit 53e044a

Please sign in to comment.