Add current date in top bar
parent
0241cacbf9
commit
516e5fd303
|
@ -99,6 +99,7 @@
|
|||
- (NSString *) cn;
|
||||
|
||||
- (SOGoDateFormatter *) dateFormatterInContext: (WOContext *) context;
|
||||
- (NSDictionary *) currentDay;
|
||||
|
||||
/* defaults */
|
||||
- (SOGoUserDefaults *) userDefaults;
|
||||
|
|
|
@ -394,6 +394,39 @@
|
|||
return dateFormatter;
|
||||
}
|
||||
|
||||
- (NSDictionary *) currentDay
|
||||
{
|
||||
NSCalendarDate *now;
|
||||
NSDictionary *description, *abbr;
|
||||
NSDictionary *locale;
|
||||
SOGoUserDefaults *ud;
|
||||
WOResourceManager *resMgr;
|
||||
NSUInteger seconds;
|
||||
|
||||
now = [NSCalendarDate calendarDate];
|
||||
ud = [self userDefaults];
|
||||
resMgr = [[WOApplication application] resourceManager];
|
||||
locale = [resMgr localeForLanguageNamed: [ud language]];
|
||||
|
||||
[now setTimeZone: [ud timeZone]];
|
||||
seconds = [now hourOfDay]*3600 + [now minuteOfHour]*60 + [now secondOfMinute];
|
||||
|
||||
abbr = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[now descriptionWithCalendarFormat: @"%a" locale: locale], @"weekday",
|
||||
[now descriptionWithCalendarFormat: @"%b" locale: locale], @"month",
|
||||
nil];
|
||||
description = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[now descriptionWithCalendarFormat: @"%A" locale: locale], @"weekday",
|
||||
[now descriptionWithCalendarFormat: @"%B" locale: locale], @"month",
|
||||
[now descriptionWithCalendarFormat: @"%d" locale: locale], @"day",
|
||||
[now descriptionWithCalendarFormat: @"%Y" locale: locale], @"year",
|
||||
abbr, @"abbr",
|
||||
[NSNumber numberWithInt: (24*3600 - seconds)], @"secondsBeforeTomorrow",
|
||||
nil];
|
||||
|
||||
return description;
|
||||
}
|
||||
|
||||
- (SOGoUserDefaults *) userDefaults
|
||||
{
|
||||
if (!_defaults)
|
||||
|
|
|
@ -602,6 +602,27 @@
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /so/:username/date Get current day
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName GetCurrentDate
|
||||
* @apiGroup Common
|
||||
* @apiExample {curl} Example usage:
|
||||
* curl -i http://localhost/SOGo/so/sogo1/date
|
||||
*
|
||||
* @apiSuccess (Success 200) {String} weekday Full weekday name according to user's locale
|
||||
* @apiSuccess (Success 200) {String} month Full month name according to user's locale
|
||||
* @apiSuccess (Success 200) {String} day Day of month as two digit decimal number (leading zero)
|
||||
* @apiSuccess (Success 200) {String} year Year as a decimal number with century
|
||||
* @apiSuccess (Success 200) {Object} abbr Abbreviations
|
||||
* @apiSuccess (Success 200) {String} abbr.weekday Abbreviated weekday name according to user's locale
|
||||
* @apiSuccess (Success 200) {String} abbr.month Abbreviated month name according to user's locale
|
||||
*/
|
||||
- (id <WOActionResults>) dateAction
|
||||
{
|
||||
return [self responseWithStatus: 200 andJSONRepresentation: [[context activeUser] currentDay]];
|
||||
}
|
||||
|
||||
- (id) recoverAction
|
||||
{
|
||||
return [self responseWithStatus: 200
|
||||
|
|
|
@ -211,6 +211,11 @@
|
|||
pageName = "SOGoUserHomePage";
|
||||
actionName = "foldersSearch";
|
||||
};
|
||||
date = {
|
||||
protectedBy = "View";
|
||||
pageName = "SOGoUserHomePage";
|
||||
actionName = "date";
|
||||
}
|
||||
};
|
||||
};
|
||||
// SOGoGroupsFolder = {
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#import <NGExtensions/NSURL+misc.h>
|
||||
|
||||
#import <SOGo/NSCalendarDate+SOGo.h>
|
||||
#import <SOGo/NSDictionary+Utilities.h>
|
||||
#import <SOGo/NSObject+Utilities.h>
|
||||
#import <SOGo/NSString+Utilities.h>
|
||||
#import <SOGo/SOGoBuild.h>
|
||||
|
@ -440,6 +441,11 @@ static SoProduct *commonProduct = nil;
|
|||
return _selectedDate;
|
||||
}
|
||||
|
||||
- (NSString *) currentDayDescription
|
||||
{
|
||||
return [[[context activeUser] currentDay] jsonRepresentation];
|
||||
}
|
||||
|
||||
- (NSString *) dateStringForDate: (NSCalendarDate *) _date
|
||||
{
|
||||
[_date setTimeZone: [userDefaults timeZone]];
|
||||
|
|
|
@ -211,12 +211,11 @@
|
|||
<span class="md-icon-menu"></span>
|
||||
</md-button>
|
||||
<div class="sg-date-group" layout="column" layout-align="space-between end">
|
||||
<p class="sg-day">monday</p>
|
||||
<p class="sg-month">january</p>
|
||||
<p class="sg-year">2015</p>
|
||||
<p class="sg-day" ng-bind="currentDay.weekday"><!-- weekday --></p>
|
||||
<p class="sg-month" ng-bind="currentDay.month"><!-- month --></p>
|
||||
<p class="sg-year" ng-bind="currentDay.year"><!-- year --></p>
|
||||
</div>
|
||||
|
||||
<p class="sg-md-display-3 sg-date-today">15</p>
|
||||
<p class="sg-md-display-3 sg-date-today" ng-bind="currentDay.day"><!-- day --></p>
|
||||
</div>
|
||||
<div class="sg-toolbar-group-2">
|
||||
<md-button class="iconButton" label:aria-label="Search">
|
||||
|
|
|
@ -310,12 +310,11 @@
|
|||
<span class="md-icon-menu"></span>
|
||||
</md-button>
|
||||
<div class="sg-date-group" layout="column" layout-align="space-between end">
|
||||
<p class="sg-day">monday</p>
|
||||
<p class="sg-month">january</p>
|
||||
<p class="sg-year">2015</p>
|
||||
<p class="sg-day" ng-bind="currentDay.weekday"><!-- weekday --></p>
|
||||
<p class="sg-month" ng-bind="currentDay.month"><!-- month --></p>
|
||||
<p class="sg-year" ng-bind="currentDay.year"><!-- year --></p>
|
||||
</div>
|
||||
|
||||
<p class="sg-md-display-3 sg-date-today">15</p>
|
||||
<p class="sg-md-display-3 sg-date-today" ng-bind="currentDay.day"><!-- day --></p>
|
||||
</div>
|
||||
<div class="sg-toolbar-group-2">
|
||||
<md-button class="iconButton" aria-label="Search">
|
||||
|
|
|
@ -201,6 +201,8 @@
|
|||
var UserIdentification = '<var:string value="userIdentification" const:escapeHTML="NO" />';
|
||||
var UserLanguage = '<var:string value="userLanguage" const:escapeHTML="NO" />';
|
||||
</var:if>
|
||||
// This is the equivalent of an AJAX call to /SOGo/so/_UserLogin_/date
|
||||
var currentDay = <var:string value="currentDayDescription" const:escapeHTML="NO"/>;
|
||||
<var:string value="commonLocalizableStrings" const:escapeHTML="NO" />
|
||||
<var:string value="productLocalizableStrings" const:escapeHTML="NO" />
|
||||
</script>
|
||||
|
|
|
@ -116,7 +116,17 @@
|
|||
return l;
|
||||
})
|
||||
|
||||
.controller('navController', ['$scope', '$timeout', '$mdSidenav', '$mdBottomSheet', '$mdMedia', '$log', 'sgConstant', function ($scope, $timeout, $mdSidenav, $mdBottomSheet, $mdMedia, $log, sgConstant) {
|
||||
.controller('navController', ['$scope', '$timeout', '$interval', '$http', '$mdSidenav', '$mdBottomSheet', '$mdMedia', '$log', 'sgConstant', function ($scope, $timeout, $interval, $http, $mdSidenav, $mdBottomSheet, $mdMedia, $log, sgConstant) {
|
||||
// Show current day in top bar
|
||||
$scope.currentDay = window.currentDay;
|
||||
$timeout(function() {
|
||||
// Update date when day ends
|
||||
$interval(function() {
|
||||
$http.get('../date').success(function(data) {
|
||||
$scope.currentDay = data;
|
||||
});
|
||||
}, 24 * 3600 * 1000);
|
||||
}, window.secondsBeforeTomorrow * 1000);
|
||||
|
||||
$scope.toggleLeft = function () {
|
||||
$mdSidenav('left').toggle()
|
||||
|
|
Loading…
Reference in New Issue