Boh
- fix notification - new menu system - possibility to remove patients
This commit is contained in:
@@ -205,7 +205,7 @@ namespace IdentityDemo.Controllers
|
|||||||
Username = username
|
Username = username
|
||||||
});
|
});
|
||||||
|
|
||||||
var a = _notification(doctor, InsertAsDoct + username);
|
var a = _notification(doctor, InsertAsDoct + username, "/user/" + username);
|
||||||
return Json(OkJson);
|
return Json(OkJson);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,23 @@ namespace SeniorAssistant.Controllers
|
|||||||
[Route("User/{User}")]
|
[Route("User/{User}")]
|
||||||
public IActionResult SingleUser(string user)
|
public IActionResult SingleUser(string user)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string rm = HttpContext.Request.Query["removePatient"];
|
||||||
|
string usr = HttpContext.Session.GetString(Username);
|
||||||
|
|
||||||
|
var pt = Db.Patients
|
||||||
|
.Where(p => p.Username.Equals(rm) && p.Doctor.Equals(usr))
|
||||||
|
.FirstOrDefault();
|
||||||
|
var mp = Db.MenuPatients
|
||||||
|
.Where(m => m.PatientUsername.Equals(rm) && m.Username.Equals(usr))
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
|
Db.Delete(pt);
|
||||||
|
Db.Delete(mp);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
return CheckAuthorized("User", GetUser(user));
|
return CheckAuthorized("User", GetUser(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Linq;
|
||||||
using System.Linq;
|
|
||||||
using LinqToDB;
|
using LinqToDB;
|
||||||
using LinqToDB.Data;
|
using LinqToDB.Data;
|
||||||
using LinqToDB.DataProvider;
|
using LinqToDB.DataProvider;
|
||||||
@@ -24,6 +23,7 @@ namespace SeniorAssistant.Data
|
|||||||
public ITable<Notification> Notifications => GetTable<Notification>();
|
public ITable<Notification> Notifications => GetTable<Notification>();
|
||||||
public ITable<Message> Messages => GetTable<Message>();
|
public ITable<Message> Messages => GetTable<Message>();
|
||||||
public ITable<Forgot> Forgot => GetTable<Forgot>();
|
public ITable<Forgot> Forgot => GetTable<Forgot>();
|
||||||
|
public ITable<MenuPatient> MenuPatients => GetTable<MenuPatient>();
|
||||||
|
|
||||||
public T[] GetLastMessages<T>(ITable<T> table, string receiver, ref int numNotSeen, int max = 10)
|
public T[] GetLastMessages<T>(ITable<T> table, string receiver, ref int numNotSeen, int max = 10)
|
||||||
where T : IHasMessage
|
where T : IHasMessage
|
||||||
|
|||||||
18
SeniorAssistant/Models/Users/MenuPatient.cs
Normal file
18
SeniorAssistant/Models/Users/MenuPatient.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using LinqToDB.Mapping;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace SeniorAssistant.Models.Users
|
||||||
|
{
|
||||||
|
public class MenuPatient : IHasUsername
|
||||||
|
{
|
||||||
|
[Column(IsPrimaryKey = true, CanBeNull = false)]
|
||||||
|
public string Username { get; set; }
|
||||||
|
|
||||||
|
[Column(IsPrimaryKey = true, CanBeNull = false)]
|
||||||
|
public string PatientUsername { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
[Association(ThisKey = nameof(PatientUsername), OtherKey = nameof(User.Username), CanBeNull = false)]
|
||||||
|
public User Usr { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -134,6 +134,7 @@ namespace SeniorAssistant
|
|||||||
db.CreateTableIfNotExists<Notification>();
|
db.CreateTableIfNotExists<Notification>();
|
||||||
db.CreateTableIfNotExists<Message>();
|
db.CreateTableIfNotExists<Message>();
|
||||||
db.CreateTableIfNotExists<Forgot>();
|
db.CreateTableIfNotExists<Forgot>();
|
||||||
|
db.CreateTableIfNotExists<MenuPatient>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ else
|
|||||||
</div>
|
</div>
|
||||||
@if (isDoc)
|
@if (isDoc)
|
||||||
{
|
{
|
||||||
|
<form action="" method="get" onsubmit="return confirm('Sicuro di voler rimuovere il paziente?');">
|
||||||
|
<button type="submit" name="removePatient" class="btn flat-btn" value="@Model.Username">Rimuovi paziente</button>
|
||||||
|
</form>
|
||||||
<div>
|
<div>
|
||||||
<textarea id="note-area" placeholder="Scrivi una nota..">@Model.Pat.Notes</textarea>
|
<textarea id="note-area" placeholder="Scrivi una nota..">@Model.Pat.Notes</textarea>
|
||||||
<button id="send-note" class="btn">Salva</button>
|
<button id="send-note" class="btn">Salva</button>
|
||||||
@@ -125,8 +128,7 @@ else
|
|||||||
$("#chart-data").html("Nessun dato");
|
$("#chart-data").html("Nessun dato");
|
||||||
else {
|
else {
|
||||||
$("#chart-data").html("");
|
$("#chart-data").html("");
|
||||||
console.log(heartbeat[0].time);
|
|
||||||
console.log("min = " +new Date(heartbeat[0].time).getTime());
|
|
||||||
var minDate = Math.min(
|
var minDate = Math.min(
|
||||||
new Date(heartbeat[0].time).getTime(),
|
new Date(heartbeat[0].time).getTime(),
|
||||||
new Date(steps[0].time).getTime(),
|
new Date(steps[0].time).getTime(),
|
||||||
|
|||||||
@@ -3,66 +3,74 @@
|
|||||||
|
|
||||||
@{
|
@{
|
||||||
var session = HttpContextAccessor.HttpContext.Session;
|
var session = HttpContextAccessor.HttpContext.Session;
|
||||||
string search = HttpContextAccessor.HttpContext.Request.Query["q"];
|
string add = HttpContextAccessor.HttpContext.Request.Query["add"];
|
||||||
|
string remove = HttpContextAccessor.HttpContext.Request.Query["remove"];
|
||||||
string username = session.GetString("username");
|
string username = session.GetString("username");
|
||||||
|
var db = dbFactory.Create();
|
||||||
|
|
||||||
|
|
||||||
if (username != null)
|
if (username != null)
|
||||||
{
|
{
|
||||||
var isDoc = session.GetString("role").Equals("doctor");
|
var isDoc = session.GetString("role").Equals("doctor");
|
||||||
var MaxPatients = 30;
|
|
||||||
var Menu = new List<IMenuItem>();
|
var Menu = new List<IMenuItem>();
|
||||||
Menu.Add(new MenuItem("Profilo", "/"));
|
Menu.Add(new MenuItem("Profilo", "/"));
|
||||||
Menu.Add(new MenuItem("Dati personali", "/user/" + username));
|
Menu.Add(new MenuItem("Dati personali", "/user/" + username));
|
||||||
if (isDoc)
|
|
||||||
{
|
|
||||||
var db = dbFactory.Create();
|
|
||||||
var patients = (from p in db.Patients
|
|
||||||
where p.Doctor.Equals(username)
|
|
||||||
join u in db.Users on p.Username equals u.Username
|
|
||||||
select new { Username = p.Username, Name = u.Name + " " + u.LastName }).ToArray();
|
|
||||||
|
|
||||||
if(search != null)
|
|
||||||
{
|
|
||||||
patients = (from p in patients
|
|
||||||
where p.Name.StartsWith(search)
|
|
||||||
select p).ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
patients.Take(MaxPatients);
|
|
||||||
|
|
||||||
var num = patients.Count();
|
|
||||||
var sub = new SubMenu() { Text = num + " pazienti link rapido", Items = new List<MenuItem>() };
|
|
||||||
foreach (var p in patients)
|
|
||||||
{
|
|
||||||
sub.Items.Add(new MenuItem(p.Name, "/user/" + p.Username));
|
|
||||||
}
|
|
||||||
Menu.Add(sub);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var db = dbFactory.Create();
|
|
||||||
var patient = (from p in db.Patients
|
|
||||||
where p.Username.Equals(username)
|
|
||||||
select p).FirstOrDefault();
|
|
||||||
if (patient != null)
|
|
||||||
{
|
|
||||||
Menu.Add(new MenuItem("Invia un messaggio al dottore", "/Message/" + patient.Doctor));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
<aside class="main-sidebar">
|
<aside class="main-sidebar">
|
||||||
<!-- sidebar: style can be found in sidebar.less -->
|
<!-- sidebar: style can be found in sidebar.less -->
|
||||||
<section class="sidebar">
|
<section class="sidebar">
|
||||||
@if (isDoc)
|
@if (isDoc)
|
||||||
{
|
{
|
||||||
|
if (add != null)
|
||||||
|
{
|
||||||
|
var user = db.Patients
|
||||||
|
.Where(p => p.Username.Equals(add) && p.Doctor.Equals(username))
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
db.Insert(new MenuPatient()
|
||||||
|
{
|
||||||
|
Username = username,
|
||||||
|
PatientUsername = user.Username
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
if(remove != null)
|
||||||
|
{
|
||||||
|
var menu = db.MenuPatients
|
||||||
|
.Where(p => p.Username.Equals(username) && p.PatientUsername.Equals(remove))
|
||||||
|
.FirstOrDefault();
|
||||||
|
if(menu != null)
|
||||||
|
{
|
||||||
|
db.Delete(menu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var patients = db.MenuPatients
|
||||||
|
.LoadWith(m => m.Usr)
|
||||||
|
.Where(m => m.Username.Equals(username))
|
||||||
|
.Select(m => m.Usr)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
var num = patients.Count();
|
||||||
|
var sub = new SubMenu() { Text = num + " pazienti link rapido", Items = new List<MenuItem>() };
|
||||||
|
foreach (var p in patients)
|
||||||
|
{
|
||||||
|
sub.Items.Add(new MenuItem(p.Name + " " + p.LastName, "/user/" + p.Username));
|
||||||
|
}
|
||||||
|
Menu.Add(sub);
|
||||||
|
|
||||||
<!-- Sidebar user panel (optional) -->
|
<!-- Sidebar user panel (optional) -->
|
||||||
<!-- search form (Optional) -->
|
<!-- search form (Optional) -->
|
||||||
<form action="#" method="get" class="sidebar-form">
|
<div class=" sidebar-menu text-muted">Aggiungi un utente ai link rapidi</div>
|
||||||
|
<form action="" method="get" class="sidebar-form">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" name="q" class="form-control" placeholder="Search..." , value="@search">
|
<input type="text" name="add" class="form-control" placeholder="Aggiungi..." , value="">
|
||||||
<span class="input-group-btn">
|
<span class="input-group-btn">
|
||||||
<button type="submit" name="search" id="search-btn" class="btn btn-flat">
|
<button type="submit" class="btn btn-flat">
|
||||||
<i class="fa fa-search"></i>
|
<i class="fa fa-plus"></i>
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -70,6 +78,16 @@
|
|||||||
<!-- /.search form -->
|
<!-- /.search form -->
|
||||||
<!-- Sidebar Menu -->
|
<!-- Sidebar Menu -->
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var patient = (from p in db.Patients
|
||||||
|
where p.Username.Equals(username)
|
||||||
|
select p).FirstOrDefault();
|
||||||
|
if (patient != null)
|
||||||
|
{
|
||||||
|
Menu.Add(new MenuItem("Invia un messaggio al dottore", "/Message/" + patient.Doctor));
|
||||||
|
}
|
||||||
|
}
|
||||||
<div>
|
<div>
|
||||||
<ul class="sidebar-menu" data-widget="tree">
|
<ul class="sidebar-menu" data-widget="tree">
|
||||||
@foreach (var menuItem in Menu)
|
@foreach (var menuItem in Menu)
|
||||||
@@ -82,28 +100,25 @@
|
|||||||
</li>
|
</li>
|
||||||
break;
|
break;
|
||||||
case SubMenu multi:
|
case SubMenu multi:
|
||||||
<li class="treeview @if(search != null) {<text>menu-open</text>}">
|
<li class="treeview">
|
||||||
<a href="#">
|
<a href="#">
|
||||||
<i class="fa fa-link"></i><span>@multi.Text</span>
|
<i class="fa fa-link"></i><span>@multi.Text</span>
|
||||||
<span class="pull-right-container">
|
<span class="pull-right-container">
|
||||||
<i class="fa fa-angle-left pull-right"></i>
|
<i class="fa fa-angle-left pull-right"></i>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<ul class="treeview-menu" @if (search != null) { <text> style="display: block;" </text> }>
|
<ul class="treeview-menu">
|
||||||
@foreach (MenuItem item in multi.Items)
|
@foreach (MenuItem item in multi.Items)
|
||||||
{
|
{
|
||||||
<li>
|
<li>
|
||||||
@{
|
<a href="@item.HRef">
|
||||||
var text = item.Text;
|
<span>@Html.Raw(item.Text)</span>
|
||||||
var bg = "";
|
<form class="pull-right-container" action="" method="get">
|
||||||
if (search != null && item.Text.StartsWith(search))
|
<input type="text" name="remove" class="hide" value="@System.IO.Path.GetFileName(item.HRef)">
|
||||||
{
|
<button class="no-border btn-flat" type="submit">
|
||||||
bg = "bg-aqua";
|
<i class="fa fa-minus pull-right"></i>
|
||||||
text = item.Text.Replace(search, "<em>" + search + "</em>");
|
</button>
|
||||||
}
|
</form>
|
||||||
}
|
|
||||||
<a href="@item.HRef" class="@bg">
|
|
||||||
@Html.Raw(text)
|
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
@@ -118,11 +133,5 @@
|
|||||||
</section>
|
</section>
|
||||||
<!-- /.sidebar -->
|
<!-- /.sidebar -->
|
||||||
</aside>
|
</aside>
|
||||||
@if (search != null)
|
|
||||||
{
|
|
||||||
<script>
|
|
||||||
$("body").removeClass("sidebar-collapse");
|
|
||||||
</script>
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,3 +5,4 @@
|
|||||||
@using Microsoft.AspNetCore.Mvc;
|
@using Microsoft.AspNetCore.Mvc;
|
||||||
@using Microsoft.AspNetCore.Http;
|
@using Microsoft.AspNetCore.Http;
|
||||||
@using System.Linq;
|
@using System.Linq;
|
||||||
|
@using LinqToDB;
|
||||||
Reference in New Issue
Block a user