Added various

- Added DOC
- Added Patient
- Added Notifications
- Added Messages
- Various Refactoring
This commit is contained in:
2019-01-04 15:52:13 +01:00
parent e98b0ee6ce
commit 3751680fd3
23 changed files with 831 additions and 265 deletions

View File

@@ -1,14 +1,21 @@
@inject IHttpContextAccessor HttpContextAccessor
@inject IDataContextFactory<SeniorDataContext> dbFactory
@model string
@{
ViewBag.Title = "Hello Razor";
var session = HttpContextAccessor.HttpContext.Session;
var username = session.GetString("username");
// Questa variabile serve a sapere se si e' autorizzati o meno.
// Per ora e' semplice ma magari si puo' peggiorare utilizzando il ruolo di Doc... etc
// (Utilizzare inject DbContext)
bool auth = session.GetString("username").Equals(Model);
bool auth = username.Equals(Model);
if (session.GetString("role").Equals("doctor"))
{
var db = dbFactory.Create();
var isDocPatient = (from p in db.Patients
where p.Username.Equals(Model) && p.Doctor.Equals(username)
select p).ToArray().FirstOrDefault() != null;
auth = auth || isDocPatient;
}
}
@if (!auth)
@@ -18,90 +25,100 @@
else
{
// Aggiungere un qualcosa per scegliere le ore da vedere (Max 48?)
<div id="chart"></div>
<input id="hours-data" type="text" placeholder="hours" value="24" />
<button id="refresh-hours" class="fc-button">Cambia ora</button>
<div id="chart-data"></div>
<script>
var base_url = "@Url.Content("~/api/")";
var end_url = "/@Model/last/48";
$("#hours-data").on("change keyup paste click", function () {
var t = $(this);
t.val(t.val().replace(/[^0-9]/g, '').substring(0, 2));
});
$("#refresh-hours").on("click", function () {
var hours = $("#hours-data").val();
var base_url = "@Url.Content("~/api/")";
var end_url = "/@Model/last/" + hours;
$.getJSON(base_url + "heartbeat" + end_url, function (heartbeat) {
$.getJSON(base_url + "step" + end_url, function (steps) {
$.getJSON(base_url + "sleep" + end_url, function (sleep) {
var sleepArr = [];
sleep.forEach( function (el) {
sleepArr.push({ "time": el.time, "value": 1 });
var base_time = new Date(el.time).getTime();
$.getJSON(base_url + "heartbeat" + end_url, function (heartbeat) {
$.getJSON(base_url + "step" + end_url, function (steps) {
$.getJSON(base_url + "sleep" + end_url, function (sleep) {
var sleepArr = [];
sleep.forEach( function (el) {
sleepArr.push({ "time": el.time, "value": 1 });
var base_time = new Date(el.time).getTime();
for (var i = 60000; i <= el.value; i += 60000) {
sleepArr.push({ "time": new Date(base_time + i), "value": 1 });
}
});
$("#chart").kendoChart({
title: { text: "Visualizzazione attivita' di @Model" },
legend: { position: "bottom" },
seriesDefaults: {
type: "line",
style: "smooth"
},
series: [{
name: "Battito",
field: "value",
color: "red",
axis: "Heartbeat",
categoryField: "time",
data: heartbeat,
tooltip: {
visible: true,
format: "{0}%",
template: "Media di: #= value # bpm"
for (var i = 60000; i <= el.value; i += 60000) {
sleepArr.push({ "time": new Date(base_time + i), "value": 1 });
}
}, {
name: "Passi",
field: "value",
color: "blue",
axis: "Steps",
categoryField: "time",
data: steps,
tooltip: {
visible: true,
format: "{0}%",
template: "#= series.name #: #= value #"
}
}, {
type: "area",
name: "Sonno",
field: "value",
color: "black",
axis: "Sleep",
categoryField: "time",
data: sleepArr
}],
categoryAxis: {
labels: {
rotation: +45,
dateFormats: {
hours: "HH:mm"
}
});
$("#chart-data").kendoChart({
title: { text: "Visualizzazione attivita' di @Model" },
legend: { position: "bottom" },
seriesDefaults: {
type: "line",
style: "smooth"
},
type: "Date",
baseUnit: "hours"
},
valueAxes: [{
name: "Heartbeat",
color: "red"
}, {
name: "Steps",
color: "blue"
}, {
name: "Sleep",
color: "gray",
visible: false,
max: 1,
min: 0
}]
series: [{
name: "Battito",
field: "value",
color: "red",
axis: "Heartbeat",
categoryField: "time",
data: heartbeat,
tooltip: {
visible: true,
format: "{0}%",
template: "Media di: #= value # bpm"
}
}, {
name: "Passi",
field: "value",
color: "blue",
axis: "Steps",
categoryField: "time",
data: steps,
tooltip: {
visible: true,
format: "{0}%",
template: "#= series.name #: #= value #"
}
}, {
type: "area",
name: "Sonno",
field: "value",
color: "black",
axis: "Sleep",
categoryField: "time",
data: sleepArr
}],
categoryAxis: {
labels: {
rotation: +45,
dateFormats: {
hours: "HH:mm"
}
},
type: "Date",
baseUnit: "hours"
},
valueAxes: [{
name: "Heartbeat",
color: "red"
}, {
name: "Steps",
color: "blue"
}, {
name: "Sleep",
color: "gray",
visible: false,
max: 1,
min: 0
}]
})
})
})
})
});
});
$("#refresh-hours").click();
</script>
}

View File

@@ -31,6 +31,6 @@ se non loggato deve tornare qua
}
else
{
await Html.RenderPartialAsync("Profile");
await Html.RenderPartialAsync("Profile"); // magari sostituire qui
}
</div>

View File

@@ -0,0 +1,30 @@
@model int
@inject IHttpContextAccessor HttpContextAccessor
@inject IDataContextFactory<SeniorDataContext> dbFactory
@using LinqToDB;
@{
ViewBag.Title = "Hello Razor";
string username = HttpContextAccessor.HttpContext.Session.GetString("username");
var db = dbFactory.Create();
var message = (from m in db.Messages
where m.Id.Equals(Model) && m.Reciver.Equals(username)
select m).ToArray().FirstOrDefault();
}
<div class="content">
@if (message == null)
{
<p class="text-red">Non hai il permesso</p>
}
else
{
message.Seen = true;
db.Update(message);
<p>Messaggio da @message.Username</p>
<p>Inviato il @message.Time</p>
<div class="info-box-text">
@message.Body
</div>
}
</div>

View File

@@ -8,19 +8,11 @@
<script>
$(document).ready(function () {
var baseUrl = "@Url.Content("~/api/user/")";
$("#grid").kendoGrid({
dataSource: {
transport: {
read: { url: baseUrl, type: "GET" }
/*
parameterMap: function (model, operation) {
if (operation !== "read" && model) {
return kendo.stringify(model);
}
}
*/
},
serverPaging: false,
serverSorting: false,
@@ -30,7 +22,8 @@
id: "username",
fields: {
username: { type: "string" },
name: { type: "string" }
name: { type: "string" },
lastName: { type: "string" }
}
}
}
@@ -40,9 +33,10 @@
filterable: true,
editable: false,
columns: [
{ field: "username", title: "Username" },
{ field: "name", title: "Name" },
{ field: "url", title: "",template:'<a href=/user/#=username#>Vedi Dati</a>'}/*,
{ field: "lastName", title: "Lastname" },
{ field: "url", title: "", template: '<a href=/user/#=username#>Vedi Dati</a>' }
/*,
{ field: "time", title: "Date/Time", format: "{dd/MM/yyyy HH}" },
{ field: "value", title: "Heartbeats" }
*/