Skip to content

Commit

Permalink
get file through dav
Browse files Browse the repository at this point in the history
  • Loading branch information
tcitworld committed Sep 27, 2016
1 parent 47751d1 commit ea4122e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 75 deletions.
7 changes: 0 additions & 7 deletions appinfo/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@ public function __construct($params=[]) {

return new Controller\ProxyController($c->getAppName(), $request, $client);
});
$container->registerService('ImportController', function(IAppContainer $c) {
$request = $c->query('Request');
/** @var Folder $userFolder */
$rootFolder = $c->query('ServerContainer')->getRootFolder();

return new Controller\ImportController($c->getAppName(), $request, $rootFolder);
});
}

/**
Expand Down
55 changes: 0 additions & 55 deletions controller/importcontroller.php

This file was deleted.

24 changes: 11 additions & 13 deletions js/app/controllers/calcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
* Description: The fullcalendar controller.
*/

app.controller('CalController', ['$scope', 'Calendar', 'CalendarService', 'VEventService', 'SettingsService', 'TimezoneService', 'VEvent', 'is', 'fc', 'EventsEditorDialogService', 'PopoverPositioningUtility', '$http', '$rootScope', '$uibModal',
function ($scope, Calendar, CalendarService, VEventService, SettingsService, TimezoneService, VEvent, is, fc, EventsEditorDialogService, PopoverPositioningUtility, $http, $rootScope, $uibModal) {
app.controller('CalController', ['$scope', 'Calendar', 'CalendarService', 'VEventService', 'SettingsService', 'TimezoneService', 'VEvent', 'is', 'fc', 'EventsEditorDialogService', 'PopoverPositioningUtility', '$http', '$rootScope', '$uibModal', '$window',
function ($scope, Calendar, CalendarService, VEventService, SettingsService, TimezoneService, VEvent, is, fc, EventsEditorDialogService, PopoverPositioningUtility, $http, $rootScope, $uibModal, $window) {
'use strict';

is.loading = true;
Expand Down Expand Up @@ -133,14 +133,12 @@ app.controller('CalController', ['$scope', 'Calendar', 'CalendarService', 'VEven
$scope.$apply();
});

$scope.importFileById = function(id) {
return $http.get($rootScope.baseUrl + 'import', {
params: {
fileid: id
}
}).then(function(response) {
const fileName = response.data.name;
const fileBody = response.data.body;
$scope.importFileByPath = function(path) {
return $http.get(
OC.linkToRemoteBase('dav') + '/files/' + OC.getCurrentUser().displayName + '/' + decodeURI(path)
).then(function(response) {
const fileName = decodeURIComponent(path);
const fileBody = response.data;
let file = new File([fileBody], fileName, {type: 'text/calendar'});

$uibModal.open({
Expand All @@ -160,9 +158,9 @@ app.controller('CalController', ['$scope', 'Calendar', 'CalendarService', 'VEven
});
};

var hashParts = window.location.hash.substr(1).split('/');
if (!hashParts[0] && hashParts[1] === 'file' && hashParts[2]) {
$scope.importFileById(hashParts[2]);
var hashParts = $window.location.hash.substr(1).split('/');
if (!hashParts[0] && hashParts[1] === 'import' && hashParts[2]) {
$scope.importFileByPath(hashParts[2]);
}


Expand Down

0 comments on commit ea4122e

Please sign in to comment.