Init
This commit is contained in:
75
src/templates/index.ejs
Normal file
75
src/templates/index.ejs
Normal file
@@ -0,0 +1,75 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>BerichtExporter</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-size: 16px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.selector {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.selector select {
|
||||
height: 30px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.selector button {
|
||||
font-size: 16px;
|
||||
height: 30px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
#export-textarea {
|
||||
font-size: 16px;
|
||||
width: 90%;
|
||||
resize: none;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>BerichtExporter</h1>
|
||||
<div class="selector">
|
||||
<select id="week-list">
|
||||
<% options.forEach((element, index) => { %>
|
||||
<option value="<%= index %>"><%= element %></option>
|
||||
<% }); %>
|
||||
</select>
|
||||
<button id="export-button" onclick="exportReport()">Export</button>
|
||||
</div>
|
||||
<textarea id="export-textarea" readonly></textarea>
|
||||
|
||||
<script>
|
||||
const exportTextarea = document.getElementById('export-textarea');
|
||||
const weekList = document.getElementById('week-list');
|
||||
|
||||
function exportReport() {
|
||||
const week = weekList.value;
|
||||
|
||||
fetch('/getreport?week=' + week)
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.text();
|
||||
} else {
|
||||
exportTextarea.value = 'Error while fetching report';
|
||||
throw new Error('Error while fetching report');
|
||||
}
|
||||
}).then(text => {
|
||||
exportTextarea.value = text;
|
||||
exportTextarea.style.height = exportTextarea.scrollHeight + "px";
|
||||
}).catch(error => {
|
||||
exportTextarea.value = 'Error while fetching report';
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user