diff --git a/js/app/controllers/calcontroller.js b/js/app/controllers/calcontroller.js index f91ef74d3b..b44ed50054 100644 --- a/js/app/controllers/calcontroller.js +++ b/js/app/controllers/calcontroller.js @@ -26,8 +26,8 @@ * Description: The fullcalendar controller. */ -app.controller('CalController', ['$scope', 'Calendar', 'CalendarService', 'VEventService', 'SettingsService', 'TimezoneService', 'VEvent', 'is', 'fc', 'EventsEditorDialogService', 'PopoverPositioningUtility', '$window', 'isPublic', 'constants', 'settings', '$uibModal', - function ($scope, Calendar, CalendarService, VEventService, SettingsService, TimezoneService, VEvent, is, fc, EventsEditorDialogService, PopoverPositioningUtility, $window, isPublic, constants, settings) { +app.controller('CalController', ['$scope', 'Calendar', 'CalendarService', 'VEventService', 'SettingsService', 'TimezoneService', 'VEvent', 'is', 'fc', 'EventsEditorDialogService', 'PopoverPositioningUtility', '$window', 'isPublic', 'constants', 'settings', '$http', '$uibModal', + function ($scope, Calendar, CalendarService, VEventService, SettingsService, TimezoneService, VEvent, is, fc, EventsEditorDialogService, PopoverPositioningUtility, $window, isPublic, constants, settings, $http, $uibModal) { 'use strict'; is.loading = true; @@ -153,9 +153,9 @@ app.controller('CalController', ['$scope', 'Calendar', 'CalendarService', 'VEven $scope.importFileByPath = function(path) { return $http.get( - OC.linkToRemoteBase('dav') + '/files/' + OC.getCurrentUser().displayName + '/' + decodeURI(path) + OC.linkToRemoteBase('dav') + '/files/' + OC.getCurrentUser().uid + '/' + decodeURIComponent(path) ).then(function(response) { - const fileName = decodeURIComponent(path); + const fileName = decodeURIComponent(decodeURI(path)).split('/').pop(); const fileBody = response.data; let file = new File([fileBody], fileName, {type: 'text/calendar'}); @@ -173,6 +173,8 @@ app.controller('CalController', ['$scope', 'Calendar', 'CalendarService', 'VEven }, scope: $scope }); + }).catch(function() { + OC.Notification.showTemporary(t('calendar', 'There was an issue while importing your calendar')); }); }; diff --git a/js/utility/registerUtility.js b/js/utility/registerUtility.js index e86a5963c1..cc093ad67b 100644 --- a/js/utility/registerUtility.js +++ b/js/utility/registerUtility.js @@ -30,7 +30,7 @@ let register = (function () { actionHandler: function(filename, context) { let path = $('#fileList').find('[data-file="'+filename+'"]').data('path'); path = path.substring(1); - window.location = OC.generateUrl('apps/calendar/#/import/{filename}', {filename: encodeURI(path + '/' + filename)}); + window.location = OC.generateUrl('apps/calendar/#/import/{filename}', {filename: encodeURIComponent(path + '/' + filename)}); }, permissions: OC.PERMISSION_READ, icon: function () { diff --git a/templates/part.import.dialog.php b/templates/part.import.dialog.php index 22a0028498..e6d9eac8ac 100644 --- a/templates/part.import.dialog.php +++ b/templates/part.import.dialog.php @@ -29,7 +29,7 @@