Refactoring
* refactoring * fixes * messages * new interface
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
<!-- hidden-xs hides the username on small devices so only the image appears. -->
|
||||
<span id="user-name" class="hidden-xs">@Model</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<ul class="dropdown-menu" style="box-shadow: black 0px 0px 2px">
|
||||
<!-- The user image in the menu -->
|
||||
<li class="user-header">
|
||||
<img src="~/AdminLTE-2.4.3/dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">
|
||||
|
||||
@@ -4,51 +4,10 @@
|
||||
@{
|
||||
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++;
|
||||
}
|
||||
}
|
||||
var num = 0;
|
||||
var messages = db.GetLastMessages(db.Messages, Model, ref num, maxMessage);
|
||||
}
|
||||
|
||||
<!--
|
||||
<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)
|
||||
@@ -64,8 +23,8 @@
|
||||
</a>
|
||||
@if (messages.Length != 0)
|
||||
{
|
||||
<ul id="id-message-drop" class="dropdown-menu">
|
||||
<li class="header">You have @num unread message</li>
|
||||
<ul id="id-message-drop" class="dropdown-menu" style="box-shadow: black 0px 0px 2px">
|
||||
<li class="header">Hai @num messaggi non letti</li>
|
||||
<li>
|
||||
<!-- Inner Menu: contains the messages -->
|
||||
<ul class="menu">
|
||||
@@ -75,7 +34,7 @@
|
||||
{
|
||||
<li>
|
||||
<!-- start notification -->
|
||||
<a id="message-@message.Id" @if(message.Seen) {<text>class= "bg-gray"</text>} href="/Message/@message.Id">
|
||||
<a id="message-@message.Id" @if(message.Seen != default) {<text>class= "bg-gray"</text>} href="/Message/@message.Username">
|
||||
<i class="fa text-lime">@message.Time</i><br />
|
||||
@message.Body
|
||||
</a>
|
||||
|
||||
@@ -3,29 +3,10 @@
|
||||
|
||||
@{
|
||||
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;
|
||||
var num = 0;
|
||||
var notifications = db.GetLastMessages(db.Notifications, Model, ref num);
|
||||
}
|
||||
|
||||
<!--
|
||||
<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)
|
||||
@@ -33,50 +14,48 @@
|
||||
<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)
|
||||
<ul id="id-notification-drop" class="dropdown-menu" style="box-shadow: black 0px 0px 2px">
|
||||
<li class="header">Hai @num nuove notifiche</li>
|
||||
<li>
|
||||
<!-- Inner Menu: contains the notifications -->
|
||||
<ul class="menu">
|
||||
@foreach (var notification in notifications)
|
||||
{
|
||||
if (notification != null)
|
||||
{
|
||||
<li>
|
||||
<!-- start notification -->
|
||||
<a id="notification-@notification.Id" href="#">
|
||||
<a id="notification-@notification.Id" class="@if (notification.Seen != default) {<text>bg-gray</text>}" href="@notification.Url">
|
||||
<i class="fa fa-users text-aqua">@notification.Time</i><br />
|
||||
@notification.Message
|
||||
@notification.Body
|
||||
</a>
|
||||
</li>
|
||||
<!-- end notification -->
|
||||
}
|
||||
</ul>
|
||||
</li>
|
||||
<!-- <li class="footer"><a href="#">View all</a></li> -->
|
||||
</ul>
|
||||
}
|
||||
</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>
|
||||
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).addClass("bg-gray");
|
||||
var num = parseInt($("#id-notification-toggle span").html()) - 1;
|
||||
if (num == 0)
|
||||
$("#id-notification-toggle span").remove();
|
||||
else
|
||||
$("#id-notification-toggle span").html(num);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -30,37 +30,8 @@
|
||||
<p class="text-bold">Dottore: @doctor.Name @doctor.LastName</p>
|
||||
<p class="text-fuchsia">Dove mi puoi trovare? @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"></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>
|
||||
|
||||
<a class="" href="/Message/@doctor.Username">Invia un messaggio al tuo dottore</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
@inject IList<IMenuItem> Menu
|
||||
@inject IHttpContextAccessor HttpContextAccessor
|
||||
@inject IHttpContextAccessor HttpContextAccessor
|
||||
@inject IDataContextFactory<SeniorDataContext> dbFactory
|
||||
|
||||
@{
|
||||
var session = HttpContextAccessor.HttpContext.Session;
|
||||
string search = HttpContextAccessor.HttpContext.Request.Query["q"];
|
||||
string username = session.GetString("username");
|
||||
|
||||
if (username != null)
|
||||
{
|
||||
Menu = new List<IMenuItem>(Menu);
|
||||
Menu.RemoveAt(1);
|
||||
Menu.Insert(1, new MenuItem("Dati personali", "/user/" + username));
|
||||
if (session.GetString("role").Equals("doctor"))
|
||||
var isDoc = session.GetString("role").Equals("doctor");
|
||||
var Menu = new List<IMenuItem>();
|
||||
Menu.Add(new MenuItem("Profilo", "/"));
|
||||
Menu.Add(new MenuItem("Dati personali", "/user/" + username));
|
||||
if (isDoc)
|
||||
{
|
||||
var db = dbFactory.Create();
|
||||
var patients = (from p in db.Patients
|
||||
@@ -25,36 +26,87 @@
|
||||
}
|
||||
Menu.Add(sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
<ul class="sidebar-menu" data-widget="tree">
|
||||
@foreach (var menuItem in Menu)
|
||||
{
|
||||
switch (menuItem)
|
||||
else
|
||||
{
|
||||
case MenuItem single:
|
||||
<li>
|
||||
<a href="@single.HRef">@single.Text</a>
|
||||
</li>
|
||||
break;
|
||||
case SubMenu multi:
|
||||
<li class="treeview">
|
||||
<a href="#">
|
||||
<i class="fa fa-link"></i><span>@multi.Text</span>
|
||||
<span class="pull-right-container">
|
||||
<i class="fa fa-angle-left pull-right"></i>
|
||||
</span>
|
||||
</a>
|
||||
<ul class="treeview-menu">
|
||||
@foreach (MenuItem item in multi.Items)
|
||||
var db = dbFactory.Create();
|
||||
var patient = (from p in db.Patients
|
||||
where p.Username.Equals(username)
|
||||
select p).FirstOrDefault();
|
||||
Menu.Add(new MenuItem("Invia un messaggio al dottore", "/Message/" + patient.Doctor));
|
||||
}
|
||||
<aside class="main-sidebar">
|
||||
<!-- sidebar: style can be found in sidebar.less -->
|
||||
<section class="sidebar">
|
||||
@if (isDoc)
|
||||
{
|
||||
<!-- Sidebar user panel (optional) -->
|
||||
<!-- search form (Optional) -->
|
||||
<form action="#" method="get" class="sidebar-form">
|
||||
<div class="input-group">
|
||||
<input type="text" name="q" class="form-control" placeholder="Search..." , value="@search">
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" name="search" id="search-btn" class="btn btn-flat">
|
||||
<i class="fa fa-search"></i>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
<!-- /.search form -->
|
||||
<!-- Sidebar Menu -->
|
||||
}
|
||||
<div>
|
||||
<ul class="sidebar-menu" data-widget="tree">
|
||||
@foreach (var menuItem in Menu)
|
||||
{
|
||||
<li>
|
||||
<a href="@item.HRef">@item.Text</a>
|
||||
</li>
|
||||
switch (menuItem)
|
||||
{
|
||||
case MenuItem single:
|
||||
<li>
|
||||
<a href="@single.HRef">@single.Text</a>
|
||||
</li>
|
||||
break;
|
||||
case SubMenu multi:
|
||||
<li class="treeview @if(search != null) {<text>menu-open</text>}">
|
||||
<a href="#">
|
||||
<i class="fa fa-link"></i><span>@multi.Text</span>
|
||||
<span class="pull-right-container">
|
||||
<i class="fa fa-angle-left pull-right"></i>
|
||||
</span>
|
||||
</a>
|
||||
<ul class="treeview-menu" @if (search != null) { <text> style="display: block;" </text> }>
|
||||
@foreach (MenuItem item in multi.Items)
|
||||
{
|
||||
<li>
|
||||
@{
|
||||
var text = item.Text;
|
||||
var bg = "";
|
||||
if (search != null && item.Text.StartsWith(search))
|
||||
{
|
||||
bg = "bg-aqua";
|
||||
text = item.Text.Replace(search, "<em>" + search + "</em>");
|
||||
}
|
||||
}
|
||||
<a href="@item.HRef" class="@bg">
|
||||
@Html.Raw(text)
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</li>
|
||||
break;
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
</li>
|
||||
break;
|
||||
</div>
|
||||
<!-- /.sidebar-menu -->
|
||||
</section>
|
||||
<!-- /.sidebar -->
|
||||
</aside>
|
||||
@if (search != null)
|
||||
{
|
||||
<script>
|
||||
$("body").removeClass("sidebar-collapse");
|
||||
</script>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
@@ -2,10 +2,12 @@
|
||||
@using Microsoft.Extensions.Options
|
||||
@inject IOptions<SeniorAssistant.Configuration.Kendo> Kendo
|
||||
@inject IOptions<SeniorAssistant.Configuration.Theme> Theme
|
||||
@inject IHttpContextAccessor HttpContextAccessor
|
||||
|
||||
@{
|
||||
var kendo = Kendo.Value;
|
||||
var theme = Theme.Value;
|
||||
var logged = HttpContextAccessor.HttpContext.Session.GetString("username") != null;
|
||||
}
|
||||
|
||||
<!DOCTYPE html>
|
||||
@@ -46,27 +48,8 @@ scratch. This page gets rid of all links and provides the needed markup only.
|
||||
<script src="~/kendo/@(kendo.Version)/js/jquery.min.js"></script>
|
||||
<script src="~/kendo/@(kendo.Version)/js/kendo.all.min.js"></script>
|
||||
</head>
|
||||
<!--
|
||||
BODY TAG OPTIONS:
|
||||
=================
|
||||
Apply one or more of the following classes to get the
|
||||
desired effect
|
||||
|---------------------------------------------------------|
|
||||
| SKINS | skin-blue |
|
||||
| | skin-black |
|
||||
| | skin-purple |
|
||||
| | skin-yellow |
|
||||
| | skin-red |
|
||||
| | skin-green |
|
||||
|---------------------------------------------------------|
|
||||
|LAYOUT OPTIONS | fixed |
|
||||
| | layout-boxed |
|
||||
| | layout-top-nav |
|
||||
| | sidebar-collapse |
|
||||
| | sidebar-mini |
|
||||
|---------------------------------------------------------|
|
||||
-->
|
||||
<body class="hold-transition @(theme.Skin.GetDescription()) @(theme.Layout.GetDescription())">
|
||||
|
||||
<body class="hold-transition @(theme.Skin.GetDescription()) @(!logged?theme.Layout.GetDescription():"")">
|
||||
<div class="wrapper">
|
||||
<!-- Main Header -->
|
||||
<header class="main-header">
|
||||
@@ -80,9 +63,14 @@ desired effect
|
||||
<!-- Header Navbar -->
|
||||
<nav class="navbar navbar-static-top" role="navigation">
|
||||
<!-- Sidebar toggle button-->
|
||||
<a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
</a>
|
||||
@if (logged)
|
||||
{
|
||||
<text>
|
||||
<a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
</a>
|
||||
</text>
|
||||
}
|
||||
<!-- Navbar Right Menu -->
|
||||
<div>
|
||||
@{ await Html.RenderPartialAsync("NavbarRightMenu"); }
|
||||
@@ -90,30 +78,7 @@ desired effect
|
||||
</nav>
|
||||
</header>
|
||||
<!-- Left side column. contains the logo and sidebar -->
|
||||
<aside class="main-sidebar">
|
||||
<!-- sidebar: style can be found in sidebar.less -->
|
||||
<section class="sidebar">
|
||||
<!-- Sidebar user panel (optional) -->
|
||||
<!-- search form (Optional) -->
|
||||
<form action="#" method="get" class="sidebar-form">
|
||||
<div class="input-group">
|
||||
<input type="text" name="q" class="form-control" placeholder="Search...">
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" name="search" id="search-btn" class="btn btn-flat">
|
||||
<i class="fa fa-search"></i>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
<!-- /.search form -->
|
||||
<!-- Sidebar Menu -->
|
||||
<div>
|
||||
@{ await Html.RenderPartialAsync("SidebarMenu"); }
|
||||
</div>
|
||||
<!-- /.sidebar-menu -->
|
||||
</section>
|
||||
<!-- /.sidebar -->
|
||||
</aside>
|
||||
@{ await Html.RenderPartialAsync("SidebarMenu"); }
|
||||
<!-- Content Wrapper. Contains page content -->
|
||||
<div class="content-wrapper">
|
||||
<!-- Content Header (Page header) -->
|
||||
|
||||
Reference in New Issue
Block a user