summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files/appinfo/application.php3
-rw-r--r--apps/files/appinfo/routes.php6
-rw-r--r--apps/files/controller/apicontroller.php19
-rw-r--r--apps/files/controller/viewcontroller.php14
-rw-r--r--apps/files/js/app.js5
-rw-r--r--apps/files/js/filelist.js7
-rw-r--r--apps/files/templates/index.php1
7 files changed, 47 insertions, 8 deletions
diff --git a/apps/files/appinfo/application.php b/apps/files/appinfo/application.php
index 593e0533c80..2d2decf6288 100644
--- a/apps/files/appinfo/application.php
+++ b/apps/files/appinfo/application.php
@@ -43,7 +43,8 @@ class Application extends App {
$server->getUserSession(),
$c->query('TagService'),
$server->getPreviewManager(),
- $server->getShareManager()
+ $server->getShareManager(),
+ $server->getConfig()
);
});
diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php
index 731c671b60a..6ad938101a2 100644
--- a/apps/files/appinfo/routes.php
+++ b/apps/files/appinfo/routes.php
@@ -1,6 +1,7 @@
<?php
/**
* @author Bart Visscher <bartv@thisnet.nl>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Lukas Reschke <lukas@owncloud.com>
* @author Roeland Jago Douma <rullzer@owncloud.com>
* @author Tobias Kaminsky <tobias@kaminsky.me>
@@ -48,6 +49,11 @@ $application->registerRoutes(
'verb' => 'GET',
'requirements' => array('tagName' => '.+'),
),
+ array(
+ 'name' => 'API#updateFileSorting',
+ 'url' => '/api/v1/sorting',
+ 'verb' => 'POST'
+ ),
[
'name' => 'view#index',
'url' => '/',
diff --git a/apps/files/controller/apicontroller.php b/apps/files/controller/apicontroller.php
index ad286284386..82d3ebb58b7 100644
--- a/apps/files/controller/apicontroller.php
+++ b/apps/files/controller/apicontroller.php
@@ -1,6 +1,7 @@
<?php
/**
* @author Joas Schilling <nickvergessen@owncloud.com>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Lukas Reschke <lukas@owncloud.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <rullzer@owncloud.com>
@@ -29,13 +30,13 @@ namespace OCA\Files\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Controller;
+use OCP\IConfig;
use OCP\IRequest;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\DataDisplayResponse;
use OCA\Files\Service\TagService;
use OCP\IPreview;
use OCP\Share\IManager;
-use OCP\Files\FileInfo;
use OCP\Files\Node;
use OCP\IUserSession;
@@ -53,6 +54,8 @@ class ApiController extends Controller {
private $previewManager;
/** IUserSession */
private $userSession;
+ /** IConfig */
+ private $config;
/**
* @param string $appName
@@ -65,12 +68,14 @@ class ApiController extends Controller {
IUserSession $userSession,
TagService $tagService,
IPreview $previewManager,
- IManager $shareManager) {
+ IManager $shareManager,
+ IConfig $config) {
parent::__construct($appName, $request);
$this->userSession = $userSession;
$this->tagService = $tagService;
$this->previewManager = $previewManager;
$this->shareManager = $shareManager;
+ $this->config = $config;
}
/**
@@ -196,4 +201,14 @@ class ApiController extends Controller {
return $shareTypes;
}
+ public function updateFileSorting($mode, $direction) {
+ $allowedMode = ['name', 'size', 'mtime'];
+ $allowedDirection = ['asc', 'desc'];
+ if (!in_array($mode, $allowedMode) || !in_array($direction, $allowedDirection)) {
+ return $this->buildResponse(null)->setStatus(Http::STATUS_UNPROCESSABLE_ENTITY);
+ }
+ $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'file_sorting', $mode);
+ $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'file_sorting_direction', $direction);
+ }
+
}
diff --git a/apps/files/controller/viewcontroller.php b/apps/files/controller/viewcontroller.php
index b71c8e38a79..a3718729339 100644
--- a/apps/files/controller/viewcontroller.php
+++ b/apps/files/controller/viewcontroller.php
@@ -1,5 +1,6 @@
<?php
/**
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Lukas Reschke <lukas@owncloud.com>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
@@ -27,11 +28,12 @@ use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\IConfig;
use OCP\IL10N;
use OCP\INavigationManager;
use OCP\IRequest;
use OCP\IURLGenerator;
-use OCP\IConfig;
+use OCP\IUserSession;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
@@ -54,6 +56,8 @@ class ViewController extends Controller {
protected $config;
/** @var EventDispatcherInterface */
protected $eventDispatcher;
+ /** @var IUserSession */
+ protected $userSession;
/**
* @param string $appName
@@ -70,7 +74,8 @@ class ViewController extends Controller {
INavigationManager $navigationManager,
IL10N $l10n,
IConfig $config,
- EventDispatcherInterface $eventDispatcherInterface) {
+ EventDispatcherInterface $eventDispatcherInterface,
+ IUserSession $userSession) {
parent::__construct($appName, $request);
$this->appName = $appName;
$this->request = $request;
@@ -79,6 +84,7 @@ class ViewController extends Controller {
$this->l10n = $l10n;
$this->config = $config;
$this->eventDispatcher = $eventDispatcherInterface;
+ $this->userSession = $userSession;
}
/**
@@ -213,7 +219,9 @@ class ViewController extends Controller {
$params['mailNotificationEnabled'] = $this->config->getAppValue('core', 'shareapi_allow_mail_notification', 'no');
$params['mailPublicNotificationEnabled'] = $this->config->getAppValue('core', 'shareapi_allow_public_notification', 'no');
$params['allowShareWithLink'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes');
- $params['defaultFileSorting'] = $this->config->getAppValue('files', 'file_sorting', 'name');
+ $user = $this->userSession->getUser()->getUID();
+ $params['defaultFileSorting'] = $this->config->getUserValue($user, 'files', 'file_sorting', 'name');
+ $params['defaultFileSortingDirection'] = $this->config->getUserValue($user, 'files', 'file_sorting_direction', 'name');
$params['appNavigation'] = $nav;
$params['appContents'] = $contentItems;
$this->navigationManager->setActiveEntry('files_index');
diff --git a/apps/files/js/app.js b/apps/files/js/app.js
index 8662cd7c852..4ed805d2681 100644
--- a/apps/files/js/app.js
+++ b/apps/files/js/app.js
@@ -73,7 +73,10 @@
allowLegacyActions: true,
scrollTo: urlParams.scrollto,
filesClient: OC.Files.getClient(),
- sorting: $('#defaultFileSorting').val()
+ sorting: {
+ mode: $('#defaultFileSorting').val(),
+ direction: $('#defaultFileSortingDirection').val()
+ }
}
);
this.files.initialize();
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 322dfcaa66e..fef371b8479 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -240,7 +240,7 @@
this.fileSummary = this._createSummary();
if (options.sorting) {
- this.setSort(options.sorting, 'asc');
+ this.setSort(options.sorting.mode, options.sorting.direction);
} else {
this.setSort('name', 'asc');
}
@@ -1401,6 +1401,11 @@
this.reload();
}
}
+
+ $.post(OC.generateUrl('/apps/files/api/v1/sorting'), {
+ mode: sort,
+ direction: direction
+ });
},
/**
diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php
index c108c6f0613..db464ad2eca 100644
--- a/apps/files/templates/index.php
+++ b/apps/files/templates/index.php
@@ -19,4 +19,5 @@
<input type="hidden" name="mailPublicNotificationEnabled" id="mailPublicNotificationEnabled" value="<?php p($_['mailPublicNotificationEnabled']) ?>" />
<input type="hidden" name="allowShareWithLink" id="allowShareWithLink" value="<?php p($_['allowShareWithLink']) ?>" />
<input type="hidden" name="defaultFileSorting" id="defaultFileSorting" value="<?php p($_['defaultFileSorting']) ?>" />
+<input type="hidden" name="defaultFileSortingDirection" id="defaultFileSortingDirection" value="<?php p($_['defaultFileSortingDirection']) ?>" />
<?php endif;