diff --git a/UI/Scheduler/UIxCalFolderActions.m b/UI/Scheduler/UIxCalFolderActions.m
index f108961bd..f8ee346c0 100644
--- a/UI/Scheduler/UIxCalFolderActions.m
+++ b/UI/Scheduler/UIxCalFolderActions.m
@@ -72,18 +72,14 @@
rc = [NSMutableDictionary dictionary];
request = [context request];
folder = [self clientObject];
- data = [request formValueForKey: @"calendarFile"];
- if ([data respondsToSelector: @selector(isEqualToString:)])
- fileContent = (NSString *) data;
- else
- {
- fileContent = [[NSString alloc] initWithData: (NSData *) data
- encoding: NSUTF8StringEncoding];
- if (fileContent == nil)
- fileContent = [[NSString alloc] initWithData: (NSData *) data
- encoding: NSISOLatin1StringEncoding];
- [fileContent autorelease];
- }
+ data = [[[[[request httpRequest] body] parts] lastObject] body];
+
+ fileContent = [[NSString alloc] initWithData: (NSData *) data
+ encoding: NSUTF8StringEncoding];
+ if (fileContent == nil)
+ fileContent = [[NSString alloc] initWithData: (NSData *) data
+ encoding: NSISOLatin1StringEncoding];
+ [fileContent autorelease];
if (fileContent && [fileContent length]
&& [fileContent hasPrefix: @"BEGIN:"])
diff --git a/UI/Templates/SchedulerUI/UIxCalMainView.wox b/UI/Templates/SchedulerUI/UIxCalMainView.wox
index b4d843768..9a41c7ca6 100644
--- a/UI/Templates/SchedulerUI/UIxCalMainView.wox
+++ b/UI/Templates/SchedulerUI/UIxCalMainView.wox
@@ -8,7 +8,7 @@
xmlns:label="OGo:label"
className="UIxPageFrame"
title="title"
- const:jsFiles="Common.js, Preferences.services.js, Contacts.services.js, Mailer.services.js, Scheduler.js, Scheduler.services.js">
+ const:jsFiles="Common.js, Preferences.services.js, Contacts.services.js, Mailer.services.js, vendor/angular-file-upload.min.js, Scheduler.js, Scheduler.services.js">
+
+
+
+
diff --git a/UI/WebServerResources/js/Scheduler/CalendarsController.js b/UI/WebServerResources/js/Scheduler/CalendarsController.js
index 30350f160..5bc3dd27f 100644
--- a/UI/WebServerResources/js/Scheduler/CalendarsController.js
+++ b/UI/WebServerResources/js/Scheduler/CalendarsController.js
@@ -6,8 +6,8 @@
/**
* @ngInject
*/
- CalendarsController.$inject = ['$rootScope', '$scope', '$window', '$mdDialog', '$log', 'sgFocus', 'Dialog', 'sgSettings', 'Calendar', 'User', 'stateCalendars'];
- function CalendarsController($rootScope, $scope, $window, $mdDialog, $log, focus, Dialog, Settings, Calendar, User, stateCalendars) {
+ CalendarsController.$inject = ['$rootScope', '$scope', '$window', '$mdDialog', '$log', '$mdToast', 'FileUploader', 'sgFocus', 'Dialog', 'sgSettings', 'Calendar', 'User', 'stateCalendars'];
+ function CalendarsController($rootScope, $scope, $window, $mdDialog, $log, $mdToast, FileUploader, focus, Dialog, Settings, Calendar, User, stateCalendars) {
var vm = this;
vm.activeUser = Settings.activeUser;
@@ -19,6 +19,8 @@
vm.revertEditing = revertEditing;
vm.renameFolder = renameFolder;
vm.share = share;
+ vm.importCalendar = importCalendar;
+ vm.exportCalendar = exportCalendar;
vm.showLinks = showLinks;
vm.showProperties = showProperties;
vm.subscribeToFolder = subscribeToFolder;
@@ -97,6 +99,93 @@
}
}
+ function importCalendar($event, folder) {
+ $mdDialog.show({
+ parent: angular.element(document.body),
+ targetEvent: $event,
+ clickOutsideToClose: true,
+ escapeToClose: true,
+ templateUrl: 'UIxCalendarImportDialog',
+ controller: CalendarImportDialogController,
+ controllerAs: '$CalendarImportDialogController',
+ locals: {
+ folder: folder
+ }
+ });
+
+ /**
+ * @ngInject
+ */
+ CalendarImportDialogController.$inject = ['scope', '$mdDialog', 'folder'];
+ function CalendarImportDialogController(scope, $mdDialog, folder) {
+ var vm = this;
+
+ vm.uploader = new FileUploader({
+ url: ApplicationBaseURL + [folder.id, 'import'].join('/'),
+ autoUpload: true,
+ queueLimit: 1,
+ filters: [{ name: filterByExtension, fn: filterByExtension }],
+ onSuccessItem: function(item, response, status, headers) {
+ var msg;
+
+ $mdDialog.hide();
+
+ if (response.imported === 0)
+ msg = l('No event was imported.');
+ else {
+ msg = l('A total of %{0} events were imported in the calendar.', response.imported);
+ $rootScope.$emit('calendars:list');
+ }
+
+ $mdToast.show(
+ $mdToast.simple()
+ .content(msg)
+ .position('top right')
+ .hideDelay(3000));
+ },
+ onErrorItem: function(item, response, status, headers) {
+ $mdToast.show({
+ template: [
+ '',
+ ' error_outline',
+ ' ' + l('An error occurred while importing calendar.') + '',
+ ''
+ ].join(''),
+ position: 'top right',
+ hideDelay: 3000
+ });
+ }
+ });
+
+ vm.close = function() {
+ $mdDialog.hide();
+ };
+
+ function filterByExtension(item) {
+ var isTextFile = item.type.indexOf('text') === 0 ||
+ /\.(ics)$/.test(item.name);
+
+ if (!isTextFile)
+ $mdToast.show({
+ template: [
+ '',
+ ' error_outline',
+ ' ' + l('Select an iCalendar file (.ics).') + '',
+ ''
+ ].join(''),
+ position: 'top right',
+ hideDelay: 3000
+ });
+
+ return isTextFile;
+ }
+ }
+ }
+
+ function exportCalendar(calendar) {
+ window.location.href = ApplicationBaseURL + '/' + calendar.id + '.ics' + '/export';
+ }
+
function showLinks(calendar) {
$mdDialog.show({
parent: angular.element(document.body),
diff --git a/UI/WebServerResources/js/Scheduler/Scheduler.app.js b/UI/WebServerResources/js/Scheduler/Scheduler.app.js
index 6813f1dc8..2931f7f5e 100644
--- a/UI/WebServerResources/js/Scheduler/Scheduler.app.js
+++ b/UI/WebServerResources/js/Scheduler/Scheduler.app.js
@@ -4,7 +4,7 @@
(function() {
'use strict';
- angular.module('SOGo.SchedulerUI', ['ngSanitize', 'ui.router', 'SOGo.Common', 'SOGo.PreferencesUI', 'SOGo.ContactsUI', 'SOGo.MailerUI'])
+ angular.module('SOGo.SchedulerUI', ['ngSanitize', 'ui.router', 'angularFileUpload', 'SOGo.Common', 'SOGo.PreferencesUI', 'SOGo.ContactsUI', 'SOGo.MailerUI'])
.config(configure)
.run(runBlock);