fixes: U4-10233 Umbraco 7.7 beta - format user last login date
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function UserEditController($scope, $timeout, $location, $routeParams, formHelper, usersResource, contentEditingHelper, localizationService, notificationsService, mediaHelper, Upload, umbRequestHelper, usersHelper, authResource) {
|
||||
function UserEditController($scope, $timeout, $location, $routeParams, formHelper, usersResource, contentEditingHelper, localizationService, notificationsService, mediaHelper, Upload, umbRequestHelper, usersHelper, authResource, dateHelper) {
|
||||
|
||||
var vm = this;
|
||||
|
||||
@@ -66,6 +66,11 @@
|
||||
makeBreadcrumbs(vm.user);
|
||||
setUserDisplayState();
|
||||
|
||||
// format dates to local
|
||||
if(vm.user.lastLoginDate) {
|
||||
vm.user.formattedLastLogin = getLocalDate(vm.user.lastLoginDate, "MMMM Do YYYY, HH:mm");
|
||||
}
|
||||
|
||||
vm.emailIsUsername = user.email === user.username;
|
||||
|
||||
//go get the config for the membership provider and add it to the model
|
||||
@@ -81,6 +86,21 @@
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getLocalDate(date, format) {
|
||||
var dateVal;
|
||||
var serverOffset = Umbraco.Sys.ServerVariables.application.serverTimeOffset;
|
||||
var localOffset = new Date().getTimezoneOffset();
|
||||
var serverTimeNeedsOffsetting = (-serverOffset !== localOffset);
|
||||
|
||||
if(serverTimeNeedsOffsetting) {
|
||||
dateVal = dateHelper.convertToLocalMomentTime(date, serverOffset);
|
||||
} else {
|
||||
dateVal = moment(date, "YYYY-MM-DD HH:mm:ss");
|
||||
}
|
||||
|
||||
return dateVal.format(format);
|
||||
}
|
||||
|
||||
function toggleChangePassword() {
|
||||
vm.changePasswordModel.isChanging = !vm.changePasswordModel.isChanging;
|
||||
|
||||
@@ -225,9 +225,10 @@
|
||||
|
||||
<div class="umb-package-details__information-item">
|
||||
<div class="umb-package-details__information-item-label">
|
||||
<localize key="user_lastLogin">Last login</localize>:</div>
|
||||
<localize key="user_lastLogin">Last login</localize>:
|
||||
</div>
|
||||
<div class="umb-package-details__information-item-content">
|
||||
<span ng-if="vm.user.lastLoginDate">{{ vm.user.lastLoginDate }}</span>
|
||||
<span ng-if="vm.user.lastLoginDate">{{ vm.user.formattedLastLogin }}</span>
|
||||
<span ng-if="!vm.user.lastLoginDate">{{ vm.user.name }} <localize key="user_noLogin">has not logged in yet</localize></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function UsersController($scope, $timeout, $location, usersResource, userGroupsResource, localizationService, contentEditingHelper, usersHelper, formHelper, notificationsService) {
|
||||
function UsersController($scope, $timeout, $location, usersResource, userGroupsResource, localizationService, contentEditingHelper, usersHelper, formHelper, notificationsService, dateHelper) {
|
||||
|
||||
var vm = this;
|
||||
var localizeSaving = localizationService.localize("general_saving");
|
||||
@@ -539,7 +539,18 @@
|
||||
function formatDates(users) {
|
||||
angular.forEach(users, function (user) {
|
||||
if (user.lastLoginDate) {
|
||||
user.formattedLastLogin = moment(user.lastLoginDate).format("MMMM Do YYYY, HH:mm");
|
||||
var dateVal;
|
||||
var serverOffset = Umbraco.Sys.ServerVariables.application.serverTimeOffset;
|
||||
var localOffset = new Date().getTimezoneOffset();
|
||||
var serverTimeNeedsOffsetting = (-serverOffset !== localOffset);
|
||||
|
||||
if(serverTimeNeedsOffsetting) {
|
||||
dateVal = dateHelper.convertToLocalMomentTime(user.lastLoginDate, serverOffset);
|
||||
} else {
|
||||
dateVal = moment(user.lastLoginDate, "YYYY-MM-DD HH:mm:ss");
|
||||
}
|
||||
|
||||
user.formattedLastLogin = dateVal.format("MMMM Do YYYY, HH:mm");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user