Added various
- Added DOC - Added Patient - Added Notifications - Added Messages - Various Refactoring
This commit is contained in:
90
SeniorAssistant/Views/Shared/Messages.cshtml
Normal file
90
SeniorAssistant/Views/Shared/Messages.cshtml
Normal file
@@ -0,0 +1,90 @@
|
||||
@model string
|
||||
@inject IDataContextFactory<SeniorDataContext> dbFactory
|
||||
|
||||
@{
|
||||
var db = dbFactory.Create();
|
||||
var maxMessage = 10;
|
||||
var notSeen = (from n in db.Messages
|
||||
where n.Reciver.Equals(Model) && n.Seen == false
|
||||
orderby n.Time descending
|
||||
select n).Take(maxMessage).ToArray();
|
||||
|
||||
var messages = new Message[maxMessage];
|
||||
var num = notSeen.Length;
|
||||
|
||||
int i;
|
||||
for (i=0; i<num; i++)
|
||||
{
|
||||
messages[i] = notSeen[i];
|
||||
}
|
||||
|
||||
if (num < maxMessage)
|
||||
{
|
||||
var messSeen = (from n in db.Messages
|
||||
where n.Reciver.Equals(Model) && n.Seen == true
|
||||
orderby n.Time descending
|
||||
select n).Take(maxMessage-num).ToArray();
|
||||
|
||||
foreach(var m in messSeen)
|
||||
{
|
||||
messages[i] = m;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<!--
|
||||
<script>
|
||||
$(document).ready(
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
url: "/Account/_message",
|
||||
data: { Username: "@Model", Message: "stronzo" },
|
||||
success: function (data) {
|
||||
console.log(data);
|
||||
}
|
||||
})
|
||||
);
|
||||
</script>
|
||||
-->
|
||||
|
||||
<a id="id-message-toggle" href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-envelope-o"></i>
|
||||
@if (num != 0)
|
||||
{
|
||||
<span class="label label-danger">
|
||||
@num
|
||||
@if(num > maxMessage)
|
||||
{
|
||||
@:+
|
||||
}
|
||||
</span>
|
||||
}
|
||||
</a>
|
||||
@if (messages.Length != 0)
|
||||
{
|
||||
<ul id="id-message-drop" class="dropdown-menu">
|
||||
<li class="header">You have @num unread message</li>
|
||||
<li>
|
||||
<!-- Inner Menu: contains the messages -->
|
||||
<ul class="menu">
|
||||
@foreach (var message in messages)
|
||||
{
|
||||
if(message != null)
|
||||
{
|
||||
<li>
|
||||
<!-- start notification -->
|
||||
<a id="message-@message.Id" @if(message.Seen) {<text>class= "bg-gray"</text>} href="/Message/@message.Id">
|
||||
<i class="fa text-lime">@message.Time</i><br />
|
||||
@message.Body
|
||||
</a>
|
||||
</li>
|
||||
<!-- end message -->
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
</li>
|
||||
<!-- <li class="footer"><a href="#">View all</a></li> -->
|
||||
</ul>
|
||||
}
|
||||
@@ -6,116 +6,49 @@
|
||||
|
||||
<div class="navbar-custom-menu">
|
||||
<ul class="nav navbar-nav">
|
||||
<!-- Messages: style can be found in dropdown.less-->
|
||||
<li class="dropdown messages-menu">
|
||||
<!-- Menu toggle button -->
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-envelope-o"></i>
|
||||
<span class="label label-success">4</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="header">You have 4 messages</li>
|
||||
<li>
|
||||
<!-- inner menu: contains the messages -->
|
||||
<ul class="menu">
|
||||
<li>
|
||||
<!-- start message -->
|
||||
@if (session != null)
|
||||
{
|
||||
<!--
|
||||
Scheletro di una roba sopra per le notifiche e messaggi e robe in piu...
|
||||
<li class="dropdown ??-menu">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-??-o"></i>
|
||||
<span class="label label-??">??</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="header">??</li>
|
||||
<li>
|
||||
<ul class="menu">
|
||||
<li>Elements Here</li>
|
||||
<a href="#">
|
||||
<div class="pull-left">
|
||||
<!-- User Image -->
|
||||
<img src="~/AdminLTE-2.4.3/dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">
|
||||
</div>
|
||||
<!-- Message title and timestamp -->
|
||||
<h4>
|
||||
Support Team
|
||||
<small><i class="fa fa-clock-o"></i> 5 mins</small>
|
||||
</h4>
|
||||
<!-- The message -->
|
||||
<p>Why not buy a new awesome theme?</p>
|
||||
</a>
|
||||
</li>
|
||||
<!-- end message -->
|
||||
</ul>
|
||||
<!-- /.menu -->
|
||||
</li>
|
||||
<li class="footer"><a href="#">See All Messages</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<!-- /.messages-menu -->
|
||||
<!-- Notifications Menu -->
|
||||
<li class="dropdown notifications-menu">
|
||||
<!-- Menu toggle button -->
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-bell-o"></i>
|
||||
<span class="label label-warning">10</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="header">You have 10 notifications</li>
|
||||
<li>
|
||||
<!-- Inner Menu: contains the notifications -->
|
||||
<ul class="menu">
|
||||
<li>
|
||||
<!-- start notification -->
|
||||
<a href="#">
|
||||
<i class="fa fa-users text-aqua"></i> 5 new members joined today
|
||||
</a>
|
||||
</li>
|
||||
<!-- end notification -->
|
||||
</ul>
|
||||
</li>
|
||||
<li class="footer"><a href="#">View all</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<!-- Tasks Menu -->
|
||||
<li class="dropdown tasks-menu">
|
||||
<!-- Menu Toggle Button -->
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-flag-o"></i>
|
||||
<span class="label label-danger">9</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="header">You have 9 tasks</li>
|
||||
<li>
|
||||
<!-- Inner menu: contains the tasks -->
|
||||
<ul class="menu">
|
||||
<li>
|
||||
<!-- Task item -->
|
||||
<a href="#">
|
||||
<!-- Task title and progress text -->
|
||||
<h3>
|
||||
Design some buttons
|
||||
<small class="pull-right">20%</small>
|
||||
</h3>
|
||||
<!-- The progress bar -->
|
||||
<div class="progress xs">
|
||||
<!-- Change the css width attribute to simulate progress -->
|
||||
<div class="progress-bar progress-bar-aqua" style="width: 20%" role="progressbar"
|
||||
aria-valuenow="20" aria-valuemin="0" aria-valuemax="100">
|
||||
<span class="sr-only">20% Complete</span>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<!-- end task item -->
|
||||
</ul>
|
||||
</li>
|
||||
<li class="footer">
|
||||
<a href="#">View all tasks</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<!-- User Account Menu -->
|
||||
<li id="user-menu" class="dropdown user user-menu">
|
||||
<!-- Menu Toggle Button -->
|
||||
@if(session != null)
|
||||
{
|
||||
await Html.RenderPartialAsync("Logout", session);
|
||||
}
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
-->
|
||||
<li class="dropdown messages-menu">
|
||||
@{ await Html.RenderPartialAsync("Messages", session); }
|
||||
</li>
|
||||
<li class="dropdown notifications-menu">
|
||||
@{ await Html.RenderPartialAsync("Notifications", session); }
|
||||
</li>
|
||||
<li id="user-menu" class="dropdown user user-menu">
|
||||
@{ await Html.RenderPartialAsync("Logout", session); }
|
||||
</li>
|
||||
|
||||
</li>
|
||||
<!-- Control Sidebar Toggle Button -->
|
||||
<li>
|
||||
<a href="#" data-toggle="control-sidebar"><i class="fa fa-gears"></i></a>
|
||||
</li>
|
||||
<!-- Control Sidebar Toggle Button -->
|
||||
<li>
|
||||
<a href="#" data-toggle="control-sidebar"><i class="fa fa-gears"></i></a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
82
SeniorAssistant/Views/Shared/Notifications.cshtml
Normal file
82
SeniorAssistant/Views/Shared/Notifications.cshtml
Normal file
@@ -0,0 +1,82 @@
|
||||
@model string
|
||||
@inject IDataContextFactory<SeniorDataContext> dbFactory
|
||||
|
||||
@{
|
||||
var db = dbFactory.Create();
|
||||
var notifications = (from n in db.Notifications
|
||||
where n.Username.Equals(Model) && n.Seen == false
|
||||
orderby n.Time
|
||||
select n).ToArray();
|
||||
var num = notifications.Length;
|
||||
}
|
||||
|
||||
<!--
|
||||
<script>
|
||||
$(document).ready(
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
url: "/Account/_notification",
|
||||
data: { Username: "@Model", Message: "stronzo" },
|
||||
success: function (data) {
|
||||
console.log(data);
|
||||
}
|
||||
})
|
||||
);
|
||||
</script>
|
||||
-->
|
||||
|
||||
<a id="id-notification-toggle" href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-bell-o"></i>
|
||||
@if (num != 0)
|
||||
{
|
||||
<span class="label label-warning">@num</span>
|
||||
}
|
||||
</a>
|
||||
@if (num != 0)
|
||||
{
|
||||
<ul id="id-notification-drop" class="dropdown-menu">
|
||||
<li class="header">You have @num notifications</li>
|
||||
<li>
|
||||
<!-- Inner Menu: contains the notifications -->
|
||||
<ul class="menu">
|
||||
@foreach (var notification in notifications)
|
||||
{
|
||||
<li>
|
||||
<!-- start notification -->
|
||||
<a id="notification-@notification.Id" href="#">
|
||||
<i class="fa fa-users text-aqua">@notification.Time</i><br />
|
||||
@notification.Message
|
||||
</a>
|
||||
</li>
|
||||
<!-- end notification -->
|
||||
}
|
||||
</ul>
|
||||
</li>
|
||||
<!-- <li class="footer"><a href="#">View all</a></li> -->
|
||||
</ul>
|
||||
|
||||
<script>
|
||||
var user = "@Model";
|
||||
$("[id^='notification-']").on("click", function () {
|
||||
var id = this.id.replace(/notification-/g, '');
|
||||
var allId = this.id;
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
dataType: "json",
|
||||
url: "/Account/_notification",
|
||||
data: { id: id },
|
||||
success: function () {
|
||||
$("#" + allId).remove();
|
||||
var num = parseInt($("#id-notification-toggle span").html()) - 1;
|
||||
if (num == 0) {
|
||||
$("#id-notification-toggle span").remove();
|
||||
$("#id-notification-drop").remove();
|
||||
}
|
||||
else
|
||||
$("#id-notification-toggle span").html(num);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
@@ -1,15 +1,162 @@
|
||||
@inject IHttpContextAccessor HttpContextAccessor
|
||||
@inject IDataContextFactory<SeniorDataContext> dbFactory
|
||||
|
||||
@{
|
||||
var session = HttpContextAccessor.HttpContext.Session;
|
||||
var db = dbFactory.Create();
|
||||
var username = session.GetString("username");
|
||||
var patientData = db.Patients.Where(p => p.Username.Equals(username)).ToArray().FirstOrDefault();
|
||||
var hasDoc = patientData != null;
|
||||
}
|
||||
|
||||
<div class="content">
|
||||
<h2 class="alert-success" style="text-align:center">
|
||||
Welcome @session.GetString("username")
|
||||
<div class="pull-left" , style="width: 50%">
|
||||
<h2 class="alert-success" style="text-align:center">
|
||||
Welcome @username
|
||||
</h2>
|
||||
name: @session.GetString("name")<br />
|
||||
lastname: @session.GetString("lastname")<br />
|
||||
email: @session.GetString("email")<br />
|
||||
</div>
|
||||
|
||||
</h2>
|
||||
name: @session.GetString("name")<br />
|
||||
lastname: @session.GetString("lastname")<br />
|
||||
email: @session.GetString("email")
|
||||
<div class="box pull-right" , style="width: 45%">
|
||||
@if (hasDoc) // is patient and has doc, must show doc data
|
||||
{
|
||||
var doctor = (from u in db.Users
|
||||
join d in db.Doctors on u.Username equals d.Username
|
||||
where d.Username.Equals(patientData.Doctor)
|
||||
select new { u.Username, u.Name, u.LastName, d.Location }).ToArray().First();
|
||||
|
||||
<p class="text-bold">@doctor.Name @doctor.LastName</p>
|
||||
<p class="text-fuchsia">@doctor.Location</p>
|
||||
<textarea class="progress-text" placeholder="Nessuna nuova nota" readonly>@patientData.Notes</textarea>
|
||||
|
||||
<div id="send-doc-message">
|
||||
<p>Invia un messaggio al tuo dottore</p>
|
||||
<textarea id="doc-message" class="progress-text" placeholder="scrivi qui">@patientData.Notes</textarea>
|
||||
<button id="btn-send-message">Invia</button>
|
||||
<p id="message-error" class="text-red"></p>
|
||||
|
||||
<script>
|
||||
$("#btn-send-message").on("click", function () {
|
||||
var body = $("#doc-message").val().trim();
|
||||
var endMessage = $("#message-error");
|
||||
if (body.length < 20) {
|
||||
endMessage.html("Messaggio non valido (minimo 20 caratteri)");
|
||||
return false;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "Account/_sendMessage",
|
||||
type: "POST",
|
||||
data: {
|
||||
Reciver: "@doctor.Username",
|
||||
Body: body
|
||||
},
|
||||
success: function () {
|
||||
$("#doc-message").val("");
|
||||
endMessage.html("Messaggio inviato");
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
dynamic[] data;
|
||||
Type type = null;
|
||||
string title = null;
|
||||
var docData = db.Doctors.Where(d => d.Username.Equals(username)).ToArray().FirstOrDefault();
|
||||
|
||||
if (docData != null) // is DOC
|
||||
{
|
||||
// see all the patient of the doc
|
||||
title = "Lista dei pazienti";
|
||||
var patients = (from u in db.Users
|
||||
join p in db.Patients on u.Username equals p.Username
|
||||
where p.Doctor.Equals(docData.Username)
|
||||
select new { u.Username, u.Name, u.LastName, p.Notes, Profile = "<a href=\\\"/user/" + u.Username + "\\\">Profile</a>" }).ToArray();
|
||||
data = patients;
|
||||
type = patients.FirstOrDefault().GetType();
|
||||
}
|
||||
else // is a patient and need to choose a doctor
|
||||
{
|
||||
// choose which doc you want
|
||||
title = "Scegli un Doc";
|
||||
var docs = (from u in db.Users
|
||||
join d in db.Doctors on u.Username equals d.Username
|
||||
select new { u.Username, u.Name, u.LastName, d.Location, Choose = "<a id=\\\"choose-" + u.Username + "\\\" href=#>Scegli</a>" }).ToArray();
|
||||
data = docs;
|
||||
type = docs.FirstOrDefault().GetType();
|
||||
}
|
||||
|
||||
var fields = new List<string>();
|
||||
foreach (var field in type.GetProperties())
|
||||
{
|
||||
fields.Add(field.Name);
|
||||
}
|
||||
|
||||
<p>@title</p>
|
||||
<div id="var-table"></div>
|
||||
<script>
|
||||
var datas = [
|
||||
@foreach (var el in data)
|
||||
{
|
||||
@:{
|
||||
@foreach (var field in fields)
|
||||
{
|
||||
@field@:: "@Html.Raw(type.GetProperty(field).GetValue(el, null))",
|
||||
}
|
||||
@:},
|
||||
}
|
||||
];
|
||||
|
||||
$(document).ready(function () {
|
||||
$("#var-table").kendoGrid({
|
||||
dataSource: {
|
||||
data: datas,
|
||||
schema: {
|
||||
model: {
|
||||
fields: {
|
||||
@foreach (var field in fields)
|
||||
{
|
||||
@field@: : { type: "@field.GetType().Name" },
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
scrollable: true,
|
||||
sortable: true,
|
||||
filterable: true,
|
||||
columns: [
|
||||
@foreach (var field in fields)
|
||||
{
|
||||
@:{ field: "@field", title: "@field", template: "#=@field#" },
|
||||
}
|
||||
]
|
||||
});
|
||||
@if(docData == null) // choose a doc
|
||||
{
|
||||
<text>
|
||||
$('[id^="choose-"]').on("click", function () {
|
||||
var id = this.id.replace("choose-", '');
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Account/_addDoc",
|
||||
data: { doctor: id },
|
||||
success: function (data) {
|
||||
if (data.success) {
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
</text>
|
||||
}
|
||||
});
|
||||
</script>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user