Feature #35: Livestamp implemented

Humanized dates now update automatically when a page is left open for
some time.
This commit is contained in:
Gary Sharp
2014-02-11 16:50:03 +11:00
parent c4cc54d316
commit 7bdbeb6a82
40 changed files with 1395 additions and 1022 deletions
@@ -32,7 +32,7 @@
else
{ @da.Comments }}
</span><span class="author">@da.TechUser.ToString()</span>@if (canRemoveAnyAttachments || (canRemoveOwnAttachments && da.TechUserId == CurrentUser.Id))
{<text><span class="remove fa fa-times-circle"></span></text>}<span class="timestamp" title="@da.Timestamp.ToFullDateTime()">@da.Timestamp.FromNow()</span>
{<text><span class="remove fa fa-times-circle"></span></text>}<span class="timestamp" title="@da.Timestamp.ToFullDateTime()" data-livestamp="@da.Timestamp.ToUnixEpoc()">@da.Timestamp.ToFullDateTime()</span>
</a>
}
}
@@ -153,7 +153,7 @@
e.find('.icon img').attr('src', '@(Url.Action(MVC.API.Device.AttachmentThumbnail()))/' + a.Id);
e.find('.comments').text(a.Comments);
e.find('.author').text(a.Author);
e.find('.timestamp').text(a.TimestampFuzzy).attr('title', a.TimestampFull);
e.find('.timestamp').text(a.TimestampFull).attr('title', a.TimestampFull).livestamp(a.TimestampUnixEpoc);
if (canRemove)
e.find('.remove').click(removeAttachment);
if (!quick)
@@ -199,6 +199,7 @@
var $this = $(this);
if ($this.attr('data-mimetype').toLowerCase().indexOf('image/') == 0)
Shadowbox.removeCache(this);
$this.find('.timestamp').livestamp('destroy');
$this.remove();
});
} else {
@@ -29,6 +29,7 @@ namespace Disco.Web.Views.Device.DeviceParts
using Disco;
using Disco.BI.Extensions;
using Disco.Models.Repository;
using Disco.Services;
using Disco.Services.Authorization;
using Disco.Services.Web;
using Disco.Web;
@@ -276,11 +277,22 @@ WriteAttribute("title", Tuple.Create(" title=\"", 2144), Tuple.Create("\"", 2182
, 2152), false)
);
WriteLiteral(" data-livestamp=\"");
#line 35 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(da.Timestamp.ToUnixEpoc());
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(">");
#line 35 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(da.Timestamp.FromNow());
Write(da.Timestamp.ToFullDateTime());
#line default
@@ -584,7 +596,7 @@ WriteLiteral("/\' + a.Id);\r\n e.find(\'.icon img\').
WriteLiteral(@"/' + a.Id);
e.find('.comments').text(a.Comments);
e.find('.author').text(a.Author);
e.find('.timestamp').text(a.TimestampFuzzy).attr('title', a.TimestampFull);
e.find('.timestamp').text(a.TimestampFull).attr('title', a.TimestampFull).livestamp(a.TimestampUnixEpoc);
if (canRemove)
e.find('.remove').click(removeAttachment);
if (!quick)
@@ -654,25 +666,26 @@ WriteLiteral("\',\r\n dataType: \'json\',
"= $(this);\r\n if ($this.attr(\'" +
"data-mimetype\').toLowerCase().indexOf(\'image/\') == 0)\r\n " +
" Shadowbox.removeCache(this);\r\n " +
" $this.remove();\r\n " +
" });\r\n } else {\r\n " +
" alert(\'Unable to remove attachment:" +
" \' + d);\r\n }\r\n " +
" $dialogRemoveAttachment.dialog(\"close\");\r\n " +
" },\r\n error: functi" +
"on (jqXHR, textStatus, errorThrown) {\r\n " +
" alert(\'Unable to remove attachment: \' + textStatus);\r\n " +
" $dialogRemoveAttachment.dialog(\"close\");\r\n " +
" }\r\n });\r\n " +
" },\r\n \"Cancel\": function () {\r\n" +
" $dialogRemoveAttachment.dialog(\"close\");\r\n " +
" }\r\n });\r\n\r\n " +
" $dialogRemoveAttachment.dialog(\'open\');\r\n\r\n " +
" return false;\r\n }\r\n //#endr" +
"egion\r\n ");
" $this.find(\'.timestamp\').livestamp(\'destroy\');\r" +
"\n $this.remove();\r\n " +
" });\r\n " +
" } else {\r\n alert(\'Unable t" +
"o remove attachment: \' + d);\r\n }\r\n " +
" $dialogRemoveAttachment.dialog(\"close\")" +
";\r\n },\r\n " +
" error: function (jqXHR, textStatus, errorThrown) {\r\n " +
" alert(\'Unable to remove attachment: \' + textStatus);\r\n " +
" $dialogRemoveAttachment.dialog(\"close\")" +
";\r\n }\r\n " +
" });\r\n },\r\n \"Canc" +
"el\": function () {\r\n $dialogRemoveAttachment." +
"dialog(\"close\");\r\n }\r\n " +
" });\r\n\r\n $dialogRemoveAttachment.dialog(\'open\');\r\n\r\n " +
" return false;\r\n }\r\n " +
" //#endregion\r\n ");
#line 225 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 226 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
}
@@ -714,7 +727,7 @@ WriteLiteral("></i>&nbsp;Are you sure?\r\n </p>\r\n </div>\r\n <scr
"etailTab-ResourcesLink\">Attachments [");
#line 247 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 248 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Model.Device.DeviceAttachments == null ? 0 : Model.Device.DeviceAttachments.Count);
@@ -143,7 +143,13 @@
alert('Unable to retrieve latest network logon date:\n' + response);
$('<span>').addClass('smallMessage').text('[may not be current]').appendTo(span);
} else {
span.attr('title', response.Formatted).text(response.Friendly);
var spanClasses = '',
diff = moment().valueOf() - response.UnixEpoc;
if (diff > 2592000000) // 30 Days
spanClasses = 'error';
else if (diff > 604800000) // 7 Days
spanClasses = 'alert';
span.removeClass('alert error').addClass(spanClasses).attr('title', response.Formatted).text(response.Formatted).livestamp(response.UnixEpoc);
}
});
window.setTimeout(function () {
@@ -372,7 +378,7 @@
@foreach (var db in Model.DeviceBatches.OrderBy(i => i.Name))
{
<li>
<input type="radio" data-devicebatchid="@db.Id" name="DeviceBatch" id="DeviceBatch_@(db.Id)" /><label for="DeviceBatch_@(db.Id)" title="Purchased: @(db.PurchaseDate.FromNow())">@db.Name</label></li>
<input type="radio" data-devicebatchid="@db.Id" name="DeviceBatch" id="DeviceBatch_@(db.Id)" /><label for="DeviceBatch_@(db.Id)" title="Purchased: @(db.PurchaseDate.ToLongDateString())">@db.Name</label></li>
}
</ul>
</div>
File diff suppressed because it is too large Load Diff