add tabs to dashboard

tab with recent redeems and counters
then tab with redeems info
recent redeems open by default
This commit is contained in:
Lili (Tlapka) 2022-11-09 14:35:45 +01:00
parent 73194a0fc8
commit f0b918aa2c
4 changed files with 156 additions and 80 deletions

View File

@ -1,6 +1,6 @@
REDEEMS={ REDEEMS={
"hydrate": {"price": 60, "type": "list"}, "hydrate": {"price": 60, "type": "list"},
"lurk": {"price": 1, "type": "counter"}, "lurk": {"price": 1, "type": "counter", "info": "Let everyone know you're going to lurk."},
"react": {"price": 200, "type": "note", "info": "Attach a link to a video for me to react to."}, "react": {"price": 200, "type": "note", "info": "Attach a link to a video for me to react to."},
"request": {"price": 100, "type": "note", "info": "Request a gamemode, level, skin, etc."} "request": {"price": 100, "type": "note", "info": "Request a gamemode, level, skin, etc."}
} }

View File

@ -0,0 +1,19 @@
function openTab(event, tabName) {
var i, tabcontent, tablinks;
// Get all elements with class="tabcontent" and hide them
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
// Get all elements with class="tablinks" and remove the class "active"
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
// Show the current tab, and add an "active" class to the button that opened the tab
document.getElementById(tabName).style.display = "block";
evt.currentTarget.className += " active";
}

View File

@ -101,4 +101,39 @@ pre{padding: 1em;}
} }
select { select {
width: auto; width: auto;
} }
.tab {
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
}
/* Style the buttons that are used to open the tab content */
.tab button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
}
/* Change background color of buttons on hover */
.tab button:hover {
background-color: #ddd;
}
/* Create an active/current tablink class */
.tab button.active {
background-color: #ccc;
}
/* Style the tab content */
.tabcontent {
display: none;
padding: 6px 12px;
border: 1px solid #ccc;
border-top: none;
}

View File

@ -4,86 +4,108 @@
<head> <head>
<title>Redeems Dashboard</title> <title>Redeems Dashboard</title>
</head> </head>
<body> <div id="script">
<h3>Redeems Dashboard</h3>
{% if (username and users ) %}
<table>
<thead>
<tr>
<th>Points balance:</th>
</tr>
</thead>
{% for user in users %}
<tbody>
<td> {{ user[0] }} </td>
<td> {{ user[1] }} </td>
</tbody>
{% endfor %}
</table>
{% endif %}
{% if counters %} <script src="/static/dashboard.js"></script>
<table>
<thead>
<tr>
<th>Counters</th>
</tr>
</thead>
{% for counter in counters %}
<tbody>
<td> {{ counter[0] }} </td>
<td> {{ counter[1] }} </td>
</tbody>
{% endfor %}
</table>
{% endif %}
{% if queue %} <div class="tab">
<table> <button class="tablinks" onclick="openTab(event, 'dashboard')", id="defaultOpen">Redeems Dashboard</button>
<thead> <button class="tablinks" onclick="openTab(event, 'redeems-list')">List of Redeems</button>
<tr> </div>
<th>time</th>
<th>redeem</th> <div id='dashboard' class="tabcontent">
<th>redeemer</th> <body>
<th>note</th> <h3>Redeems Dashboard</h3>
</tr> {% if (username and users ) %}
</thead> <table>
{% for row in queue %} <thead>
<tbody> <tr>
<td>{{ row[0].replace(tzinfo=utc_timezone).astimezone().strftime("%H:%M") }}</td> <th>Points balance:</th>
<td>{{ row[1] }}</td> </tr>
<td>{{ row[3] }}</td> </thead>
{% if row[2] %} {% for user in users %}
<td>{{ row[2] }}</td> <tbody>
<td> {{ user[0] }} </td>
<td> {{ user[1] }} </td>
</tbody>
{% endfor %}
</table>
{% endif %} {% endif %}
</tbody>
{% endfor %} {% if counters %}
</table> <table>
{% endif %} <thead>
</body> <tr>
<h3>Currently Active Redeems</h3> <th>Counters</th>
<body> </tr>
{% if redeems %} </thead>
<table> {% for counter in counters %}
<thead> <tbody>
<tr> <td> {{ counter[0] }} </td>
<th>redeem</th> <td> {{ counter[1] }} </td>
<th>price</th> </tbody>
<th>type</th> {% endfor %}
<th>description</th> </table>
</tr>
</thead>
{% for redeem, redeem_info in redeems.items() %}
<tbody>
<td>{{ redeem }}</td>
<td>{{ redeem_info["price"] }}</td>
<td>{{ redeem_info["type"] }}</td>
{% if redeem_info["info"] %}
<td>{{ redeem_info["info"] }}</td>
{% endif %} {% endif %}
</tbody>
{% endfor %} {% if queue %}
</table> <table>
{% endif %} <thead>
</body> <tr>
<th>Time</th>
<th>Redeem</th>
<th>Redeemer</th>
<th>Note</th>
</tr>
</thead>
{% for row in queue %}
<tbody>
<td>{{ row[0].replace(tzinfo=utc_timezone).astimezone().strftime("%H:%M") }}</td>
<td>{{ row[1] }}</td>
<td>{{ row[3] }}</td>
{% if row[2] %}
<td>{{ row[2] }}</td>
{% endif %}
</tbody>
{% endfor %}
</table>
{% endif %}
</body>
</div>
<div id='redeems-list' class="tabcontent">
<h3>Currently Active Redeems</h3>
<body>
{% if redeems %}
<table>
<thead>
<tr>
<th>Redeem</th>
<th>Price</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
{% for redeem, redeem_info in redeems.items() %}
<tbody>
<td>{{ redeem }}</td>
<td>{{ redeem_info["price"] }}</td>
<td>{{ redeem_info["type"] }}</td>
{% if redeem_info["info"] %}
<td>{{ redeem_info["info"] }}</td>
{% endif %}
</tbody>
{% endfor %}
</table>
{% endif %}
</body>
</div>
</div>
<script>
// Get the element with id="defaultOpen" and click on it
document.getElementById("defaultOpen").click();
</script>
</html> </html>