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 3684be5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 80 deletions.
2 changes: 1 addition & 1 deletion appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
$app = new Application();
$app->registerNavigation();

// only load text editor if the user is logged in
// only load calendar action if the user is logged in
if (User::isLoggedIn()) {
$eventDispatcher = \OC::$server->getEventDispatcher();
$eventDispatcher->addListener('OCA\Files::loadAdditionalScripts', function() {
Expand Down
8 changes: 0 additions & 8 deletions appinfo/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

use OCP\AppFramework\App;
use OCP\AppFramework\IAppContainer;
use OCP\Files\Folder;

class Application extends App {

Expand Down Expand Up @@ -62,13 +61,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
3 changes: 0 additions & 3 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,5 @@

// WebCal
['name' => 'proxy#proxy', 'url' => '/v1/proxy', 'verb' => 'GET'],

// Import from Files
['name' => 'import#import', 'url' => '/v1/import', 'verb' => 'GET'],
]
];
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 3684be5

Please sign in to comment.