-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50d0724
commit c059c2d
Showing
6 changed files
with
209 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace RuokalistaServer.Models | ||
{ | ||
public class ProsenttiTulos | ||
{ | ||
public Ruokalista ruokalista { get; set; } | ||
public ViikonProsentit prosentit { get; set; } | ||
} | ||
|
||
public class ViikonProsentit | ||
{ | ||
public double maanantai { get; set; } | ||
public double tiistai { get; set; } | ||
public double keskiviikko { get; set; } | ||
public double torstai { get; set; } | ||
public double perjantai { get; set; } | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,73 @@ | ||
@using Newtonsoft.Json | ||
@using RuokalistaServer.Models; | ||
@model TulostauluModel | ||
@{ | ||
Layout = "_Layout"; | ||
ViewData["Title"] = "Tulostaulu"; | ||
} | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.1/chart.min.js" integrity="sha512-L0Shl7nXXzIlBSUUPpxrokqq4ojqgZFQczTYlGjzONGTDAcLremjwaWv5A+EDLnxhQzY5xUZPWLOLqYRkY0Cbw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> | ||
|
||
<h1>Tulostaulu</h1> | ||
|
||
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script> | ||
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script> | ||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script> | ||
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" /> | ||
|
||
<link rel="stylesheet" href="/css/aanestys.css"> | ||
<script src="/js/aanestys.js"></script> | ||
<link rel="stylesheet" href="/css/tulostaulu.css"> | ||
<script src="/js/tulostaulu.js"></script> | ||
|
||
|
||
<div> | ||
<canvas id="myChart"></canvas> | ||
|
||
</div> | ||
<div class="date-container"> | ||
<div class="title"> | ||
<h1>Tulostaulu</h1> | ||
|
||
</div> | ||
<div class="input-container"> | ||
<div>Aikaväli</div> | ||
<input type="text" name="datetimes" /> | ||
</div> | ||
</div> | ||
|
||
<br /> | ||
|
||
<div id="contentBody"> | ||
|
||
</div> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script> | ||
<script type="text/javascript"> | ||
<script> | ||
const ctx = document.getElementById('myChart'); | ||
var contentBody = document.getElementById('contentBody'); | ||
new Chart(ctx, { | ||
type: 'bar', | ||
data: { | ||
datasets: [{ | ||
data: @Html.Raw(Model?.data) | ||
}] | ||
$('input[name="datetimes"]').daterangepicker({ | ||
"showDropdowns": true, | ||
"minYear": 2022, | ||
"showWeekNumbers": true, | ||
ranges: { | ||
'Viimeiset 7 päivää': [moment().subtract(6, 'days'), moment()], | ||
'Viimeiset 30 päivää': [moment().subtract(29, 'days'), moment()], | ||
'Tämä kuukausi': [moment().startOf('month'), moment().endOf('month')], | ||
'Viime kuukausi': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] | ||
}, | ||
options: { | ||
indexAxis: 'y', | ||
elements: { | ||
bar: { | ||
borderWidth: 2, | ||
} | ||
}, | ||
responsive: true, | ||
plugins: { | ||
legend: { | ||
display: false | ||
}, | ||
title: { | ||
display: true, | ||
text: 'Ruokien äänestystulokset' | ||
} | ||
} | ||
} | ||
"alwaysShowCalendars": true, | ||
"startDate": "02/25/2024", | ||
"endDate": "03/02/2024", | ||
"opens": "left" | ||
}, function (start, end, label) { | ||
create_tulostaulu(contentBody, start, end) | ||
}); | ||
</script> | ||
const today = new Date(); | ||
const dayOfWeek = today.getDay(); | ||
const diffMonday = today.getDate() - dayOfWeek + (dayOfWeek === 0 ? -6 : 1); // Adjust for Sunday | ||
const diffFriday = diffMonday + 4; | ||
const friday = new Date(today.setDate(diffFriday)); | ||
const monday = new Date(today.setDate(diffMonday)); | ||
create_tulostaulu(contentBody, monday, friday) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.date-container { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
padding: 20px; | ||
box-sizing: border-box; | ||
} | ||
|
||
.input-container { | ||
text-align: left; | ||
margin-right: 20px; | ||
} | ||
|
||
.title { | ||
flex: 1; | ||
margin-right: 20px; | ||
} | ||
|
||
input { | ||
width: 100%; | ||
box-sizing: border-box; | ||
padding: 10px; | ||
background-color: #262626; | ||
color: #ffffff; | ||
border-radius: 5px | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
function create_tulostaulu(contentBody, startTime, endTime) { | ||
//muista että teet sellasen josta voi valita aikavälin (custom, tämäviikko, viimeviikko, tämä kuukausi, viime kuukausi, viimeiset kolme kuukautta, tämä vuosi, viime vuosi, koko aika ja custom) | ||
//aikavälin keskiarvo | ||
//toinen valinta että näyttää vaan tietyt päivät | ||
//ruokien arvostelujen kehitys ajan funktiona | ||
var startDate = new Date(startTime) | ||
var endDate = new Date(endTime) | ||
console.log("reguested for " + startDate.toISOString() + " - " + endDate.toISOString()) | ||
|
||
const formattedStartDate = formatDateForURL(startDate); | ||
const formattedEndDate = formatDateForURL(endDate); | ||
|
||
const url = `/api/v1/Aanestys/ProsenttiTuloksetTietyllaAikavalilla?start=${formattedStartDate}&end=${formattedEndDate}`; | ||
|
||
//get all of the votes in procentage form | ||
|
||
fetch(url) | ||
.then(response => { | ||
if (!response.ok) { | ||
throw new Error('Network response was not ok'); | ||
} | ||
return response.json(); | ||
}) | ||
.then(data => { | ||
console.log('Data:', data); | ||
// You can do something with the data here | ||
}) | ||
.catch(error => { | ||
console.error('Error:', error); | ||
}); | ||
|
||
} | ||
|
||
|
||
function formatDateForURL(date) { | ||
const options = { year: 'numeric', month: '2-digit', day: '2-digit' }; | ||
const formattedDate = date.toLocaleDateString('fi-FI', options); | ||
return formattedDate.replace(/\//g, '-'); | ||
} |