From 02837c54b51526e798d06325f96c8cf39ef56d2a Mon Sep 17 00:00:00 2001 From: fnuesse Date: Sat, 21 Jul 2018 00:40:33 +0200 Subject: [PATCH 01/10] Added helperfunction to cut down size of quota in filesapp to sensible values --- apps/files/lib/Controller/ViewController.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 0a13af3233156..fee117218cfa4 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -214,7 +214,7 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal if ($storageInfo['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED) { $totalSpace = $this->l10n->t('Unlimited'); } else { - $totalSpace = \OC_Helper::humanFileSize($storageInfo['total']); + $totalSpace = $this->reduceStorageSizeBySensibleBoundaries($storageInfo['total']); } $nav->assign('total_space', $totalSpace); $nav->assign('quota', $storageInfo['quota']); @@ -312,4 +312,20 @@ private function showFile($fileId) { } throw new \OCP\Files\NotFoundException(); } + + /** + * Cuts of an int containing the amount of bytes of a given size, to a sensible way. It converts the bytecount to a human readable size, and then cuts it down under a certain threshhold. + * + * @param int $storage storagevalue to be cut off + * @return int human readable filesize which is reduced to a sensible value. + */ + private function reduceStorageSizeBySensibleBoundaries($storage) { + $reducedStorageSize = \OC_Helper::humanFileSize($storage); + if ($storage > 104857600 && $storage < 1073741824) { //Over 100MB under 1GB + $reducedStorageSize = round($reducedStorageSize); + } else if ($storage > 107374182400 && $storage < 1099511531399) { //Over 100GB under 1TB + $reducedStorageSize = round($reducedStorageSize); + } + return $reducedStorageSize; + } } From 40d184d065e966c831ae1374d35ec3d618625933 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Sat, 21 Jul 2018 00:42:30 +0200 Subject: [PATCH 02/10] Changed quotasize-reduction in filesapp to more sensible values --- apps/files/lib/Controller/ViewController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index fee117218cfa4..cd1e4601c0d05 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -321,9 +321,9 @@ private function showFile($fileId) { */ private function reduceStorageSizeBySensibleBoundaries($storage) { $reducedStorageSize = \OC_Helper::humanFileSize($storage); - if ($storage > 104857600 && $storage < 1073741824) { //Over 100MB under 1GB + if ($storage > 10485760 && $storage < 1073741824) { //Over 10MB under 1GB $reducedStorageSize = round($reducedStorageSize); - } else if ($storage > 107374182400 && $storage < 1099511531399) { //Over 100GB under 1TB + } else if ($storage > 10737418240 && $storage < 1099511531399) { //Over 10GB under 1TB $reducedStorageSize = round($reducedStorageSize); } return $reducedStorageSize; From 8b5a1573b783d9614c73a1a34b3dc66903979ad9 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Sat, 21 Jul 2018 00:56:50 +0200 Subject: [PATCH 03/10] Fixed missing filesizeindicator for quotasize-reduction in filesapp --- apps/files/lib/Controller/ViewController.php | 115 ++++++++++--------- 1 file changed, 61 insertions(+), 54 deletions(-) diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index cd1e4601c0d05..773e6e095574c 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -73,27 +73,27 @@ class ViewController extends Controller { protected $activityHelper; public function __construct(string $appName, - IRequest $request, - IURLGenerator $urlGenerator, - IL10N $l10n, - IConfig $config, - EventDispatcherInterface $eventDispatcherInterface, - IUserSession $userSession, - IAppManager $appManager, - IRootFolder $rootFolder, - Helper $activityHelper + IRequest $request, + IURLGenerator $urlGenerator, + IL10N $l10n, + IConfig $config, + EventDispatcherInterface $eventDispatcherInterface, + IUserSession $userSession, + IAppManager $appManager, + IRootFolder $rootFolder, + Helper $activityHelper ) { parent::__construct($appName, $request); - $this->appName = $appName; - $this->request = $request; - $this->urlGenerator = $urlGenerator; - $this->l10n = $l10n; - $this->config = $config; + $this->appName = $appName; + $this->request = $request; + $this->urlGenerator = $urlGenerator; + $this->l10n = $l10n; + $this->config = $config; $this->eventDispatcher = $eventDispatcherInterface; - $this->userSession = $userSession; - $this->appManager = $appManager; - $this->rootFolder = $rootFolder; - $this->activityHelper = $activityHelper; + $this->userSession = $userSession; + $this->appManager = $appManager; + $this->rootFolder = $rootFolder; + $this->activityHelper = $activityHelper; } /** @@ -102,8 +102,8 @@ public function __construct(string $appName, * @return string */ protected function renderScript($appName, $scriptName) { - $content = ''; - $appPath = \OC_App::getAppPath($appName); + $content = ''; + $appPath = \OC_App::getAppPath($appName); $scriptPath = $appPath . '/' . $scriptName; if (file_exists($scriptPath)) { // TODO: sanitize path / script name ? @@ -173,21 +173,21 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $favoritesSublistArray = Array(); $navBarPositionPosition = 6; - $currentCount = 0; + $currentCount = 0; foreach ($favElements['folders'] as $dir) { - $id = substr($dir, strrpos($dir, '/') + 1, strlen($dir)); - $link = $this->urlGenerator->linkToRoute('files.view.index', ['dir' => $dir, 'view' => 'files']); + $id = substr($dir, strrpos($dir, '/') + 1, strlen($dir)); + $link = $this->urlGenerator->linkToRoute('files.view.index', ['dir' => $dir, 'view' => 'files']); $sortingValue = ++$currentCount; - $element = [ - 'id' => str_replace('/', '-', $dir), - 'view' => 'files', - 'href' => $link, - 'dir' => $dir, - 'order' => $navBarPositionPosition, - 'folderPosition' => $sortingValue, - 'name' => $id, - 'icon' => 'files', + $element = [ + 'id' => str_replace('/', '-', $dir), + 'view' => 'files', + 'href' => $link, + 'dir' => $dir, + 'order' => $navBarPositionPosition, + 'folderPosition' => $sortingValue, + 'name' => $id, + 'icon' => 'files', 'quickaccesselement' => 'true' ]; @@ -210,7 +210,8 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $nav->assign('navigationItems', $navItems); - $nav->assign('usage', \OC_Helper::humanFileSize($storageInfo['used'])); + //$nav->assign('usage', \OC_Helper::humanFileSize($storageInfo['used'])); + $nav->assign('usage', $this->reduceStorageSizeBySensibleBoundaries($storageInfo['used'])); if ($storageInfo['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED) { $totalSpace = $this->l10n->t('Unlimited'); } else { @@ -236,13 +237,13 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $subcontent = $this->renderScript($subitem['appname'], $subitem['script']); } $contentItems[$subitem['id']] = [ - 'id' => $subitem['id'], + 'id' => $subitem['id'], 'content' => $subcontent ]; } } $contentItems[$item['id']] = [ - 'id' => $item['id'], + 'id' => $item['id'], 'content' => $content ]; } @@ -250,20 +251,20 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $event = new GenericEvent(null, ['hiddenFields' => []]); $this->eventDispatcher->dispatch('OCA\Files::loadAdditionalScripts', $event); - $params = []; - $params['usedSpacePercent'] = (int) $storageInfo['relative']; - $params['owner'] = $storageInfo['owner']; - $params['ownerDisplayName'] = $storageInfo['ownerDisplayName']; - $params['isPublic'] = false; - $params['allowShareWithLink'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes'); - $params['defaultFileSorting'] = $this->config->getUserValue($user, 'files', 'file_sorting', 'name'); + $params = []; + $params['usedSpacePercent'] = (int)$storageInfo['relative']; + $params['owner'] = $storageInfo['owner']; + $params['ownerDisplayName'] = $storageInfo['ownerDisplayName']; + $params['isPublic'] = false; + $params['allowShareWithLink'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes'); + $params['defaultFileSorting'] = $this->config->getUserValue($user, 'files', 'file_sorting', 'name'); $params['defaultFileSortingDirection'] = $this->config->getUserValue($user, 'files', 'file_sorting_direction', 'asc'); - $showHidden = (bool) $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', false); - $params['showHiddenFiles'] = $showHidden ? 1 : 0; - $params['fileNotFound'] = $fileNotFound ? 1 : 0; - $params['appNavigation'] = $nav; - $params['appContents'] = $contentItems; - $params['hiddenFields'] = $event->getArgument('hiddenFields'); + $showHidden = (bool)$this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', false); + $params['showHiddenFiles'] = $showHidden ? 1 : 0; + $params['fileNotFound'] = $fileNotFound ? 1 : 0; + $params['appNavigation'] = $nav; + $params['appContents'] = $contentItems; + $params['hiddenFields'] = $event->getArgument('hiddenFields'); $response = new TemplateResponse( $this->appName, @@ -285,14 +286,14 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal * @throws \OCP\Files\NotFoundException */ private function showFile($fileId) { - $uid = $this->userSession->getUser()->getUID(); + $uid = $this->userSession->getUser()->getUID(); $baseFolder = $this->rootFolder->getUserFolder($uid); - $files = $baseFolder->getById($fileId); - $params = []; + $files = $baseFolder->getById($fileId); + $params = []; if (empty($files) && $this->appManager->isEnabledForUser('files_trashbin')) { - $baseFolder = $this->rootFolder->get($uid . '/files_trashbin/files/'); - $files = $baseFolder->getById($fileId); + $baseFolder = $this->rootFolder->get($uid . '/files_trashbin/files/'); + $files = $baseFolder->getById($fileId); $params['view'] = 'trashbin'; } @@ -321,11 +322,17 @@ private function showFile($fileId) { */ private function reduceStorageSizeBySensibleBoundaries($storage) { $reducedStorageSize = \OC_Helper::humanFileSize($storage); + $ending = substr($reducedStorageSize, (strrpos($reducedStorageSize, "B") - 1), strlen($reducedStorageSize)); + $ending = trim($ending); + if ($storage > 10485760 && $storage < 1073741824) { //Over 10MB under 1GB $reducedStorageSize = round($reducedStorageSize); } else if ($storage > 10737418240 && $storage < 1099511531399) { //Over 10GB under 1TB $reducedStorageSize = round($reducedStorageSize); + } else { + return $reducedStorageSize; } - return $reducedStorageSize; + + return $reducedStorageSize . " " . $ending; } } From eaa247e7568db5a4895d70fbb2d4b17ad11de0e6 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Sat, 21 Jul 2018 01:00:43 +0200 Subject: [PATCH 04/10] Undid autoformatting in filesapp-ViewController --- apps/files/lib/Controller/ViewController.php | 105 +++++++++---------- 1 file changed, 52 insertions(+), 53 deletions(-) diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 773e6e095574c..d943fa0c07e40 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -73,27 +73,27 @@ class ViewController extends Controller { protected $activityHelper; public function __construct(string $appName, - IRequest $request, - IURLGenerator $urlGenerator, - IL10N $l10n, - IConfig $config, - EventDispatcherInterface $eventDispatcherInterface, - IUserSession $userSession, - IAppManager $appManager, - IRootFolder $rootFolder, - Helper $activityHelper + IRequest $request, + IURLGenerator $urlGenerator, + IL10N $l10n, + IConfig $config, + EventDispatcherInterface $eventDispatcherInterface, + IUserSession $userSession, + IAppManager $appManager, + IRootFolder $rootFolder, + Helper $activityHelper ) { parent::__construct($appName, $request); - $this->appName = $appName; - $this->request = $request; - $this->urlGenerator = $urlGenerator; - $this->l10n = $l10n; - $this->config = $config; + $this->appName = $appName; + $this->request = $request; + $this->urlGenerator = $urlGenerator; + $this->l10n = $l10n; + $this->config = $config; $this->eventDispatcher = $eventDispatcherInterface; - $this->userSession = $userSession; - $this->appManager = $appManager; - $this->rootFolder = $rootFolder; - $this->activityHelper = $activityHelper; + $this->userSession = $userSession; + $this->appManager = $appManager; + $this->rootFolder = $rootFolder; + $this->activityHelper = $activityHelper; } /** @@ -102,8 +102,8 @@ public function __construct(string $appName, * @return string */ protected function renderScript($appName, $scriptName) { - $content = ''; - $appPath = \OC_App::getAppPath($appName); + $content = ''; + $appPath = \OC_App::getAppPath($appName); $scriptPath = $appPath . '/' . $scriptName; if (file_exists($scriptPath)) { // TODO: sanitize path / script name ? @@ -173,21 +173,21 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $favoritesSublistArray = Array(); $navBarPositionPosition = 6; - $currentCount = 0; + $currentCount = 0; foreach ($favElements['folders'] as $dir) { - $id = substr($dir, strrpos($dir, '/') + 1, strlen($dir)); - $link = $this->urlGenerator->linkToRoute('files.view.index', ['dir' => $dir, 'view' => 'files']); + $id = substr($dir, strrpos($dir, '/') + 1, strlen($dir)); + $link = $this->urlGenerator->linkToRoute('files.view.index', ['dir' => $dir, 'view' => 'files']); $sortingValue = ++$currentCount; - $element = [ - 'id' => str_replace('/', '-', $dir), - 'view' => 'files', - 'href' => $link, - 'dir' => $dir, - 'order' => $navBarPositionPosition, - 'folderPosition' => $sortingValue, - 'name' => $id, - 'icon' => 'files', + $element = [ + 'id' => str_replace('/', '-', $dir), + 'view' => 'files', + 'href' => $link, + 'dir' => $dir, + 'order' => $navBarPositionPosition, + 'folderPosition' => $sortingValue, + 'name' => $id, + 'icon' => 'files', 'quickaccesselement' => 'true' ]; @@ -210,7 +210,6 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $nav->assign('navigationItems', $navItems); - //$nav->assign('usage', \OC_Helper::humanFileSize($storageInfo['used'])); $nav->assign('usage', $this->reduceStorageSizeBySensibleBoundaries($storageInfo['used'])); if ($storageInfo['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED) { $totalSpace = $this->l10n->t('Unlimited'); @@ -237,13 +236,13 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $subcontent = $this->renderScript($subitem['appname'], $subitem['script']); } $contentItems[$subitem['id']] = [ - 'id' => $subitem['id'], + 'id' => $subitem['id'], 'content' => $subcontent ]; } } $contentItems[$item['id']] = [ - 'id' => $item['id'], + 'id' => $item['id'], 'content' => $content ]; } @@ -251,20 +250,20 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $event = new GenericEvent(null, ['hiddenFields' => []]); $this->eventDispatcher->dispatch('OCA\Files::loadAdditionalScripts', $event); - $params = []; - $params['usedSpacePercent'] = (int)$storageInfo['relative']; - $params['owner'] = $storageInfo['owner']; - $params['ownerDisplayName'] = $storageInfo['ownerDisplayName']; - $params['isPublic'] = false; - $params['allowShareWithLink'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes'); - $params['defaultFileSorting'] = $this->config->getUserValue($user, 'files', 'file_sorting', 'name'); + $params = []; + $params['usedSpacePercent'] = (int) $storageInfo['relative']; + $params['owner'] = $storageInfo['owner']; + $params['ownerDisplayName'] = $storageInfo['ownerDisplayName']; + $params['isPublic'] = false; + $params['allowShareWithLink'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes'); + $params['defaultFileSorting'] = $this->config->getUserValue($user, 'files', 'file_sorting', 'name'); $params['defaultFileSortingDirection'] = $this->config->getUserValue($user, 'files', 'file_sorting_direction', 'asc'); - $showHidden = (bool)$this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', false); - $params['showHiddenFiles'] = $showHidden ? 1 : 0; - $params['fileNotFound'] = $fileNotFound ? 1 : 0; - $params['appNavigation'] = $nav; - $params['appContents'] = $contentItems; - $params['hiddenFields'] = $event->getArgument('hiddenFields'); + $showHidden = (bool) $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', false); + $params['showHiddenFiles'] = $showHidden ? 1 : 0; + $params['fileNotFound'] = $fileNotFound ? 1 : 0; + $params['appNavigation'] = $nav; + $params['appContents'] = $contentItems; + $params['hiddenFields'] = $event->getArgument('hiddenFields'); $response = new TemplateResponse( $this->appName, @@ -286,14 +285,14 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal * @throws \OCP\Files\NotFoundException */ private function showFile($fileId) { - $uid = $this->userSession->getUser()->getUID(); + $uid = $this->userSession->getUser()->getUID(); $baseFolder = $this->rootFolder->getUserFolder($uid); - $files = $baseFolder->getById($fileId); - $params = []; + $files = $baseFolder->getById($fileId); + $params = []; if (empty($files) && $this->appManager->isEnabledForUser('files_trashbin')) { - $baseFolder = $this->rootFolder->get($uid . '/files_trashbin/files/'); - $files = $baseFolder->getById($fileId); + $baseFolder = $this->rootFolder->get($uid . '/files_trashbin/files/'); + $files = $baseFolder->getById($fileId); $params['view'] = 'trashbin'; } From dadef82b0f7f938748393767a5c7550cc8571f4a Mon Sep 17 00:00:00 2001 From: fnuesse Date: Tue, 24 Jul 2018 19:00:05 +0200 Subject: [PATCH 05/10] Removed doubled-newline Signed-off-by: fnuesse --- apps/files/lib/Controller/ApiController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index fd63d54515179..2ac77289787a2 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -430,5 +430,4 @@ public function getNodeType($folderpath) { return $node->getType(); } - } From 7e33d3d72b619b57609cf278f7cfce79b5491dad Mon Sep 17 00:00:00 2001 From: fnuesse Date: Tue, 24 Jul 2018 19:00:05 +0200 Subject: [PATCH 06/10] Removed doubled-newline Signed-off-by: fnuesse --- apps/files/lib/Controller/ApiController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index fd63d54515179..2ac77289787a2 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -430,5 +430,4 @@ public function getNodeType($folderpath) { return $node->getType(); } - } From 9d936809ba3437d61e32f933dddda261a8180a2c Mon Sep 17 00:00:00 2001 From: fnuesse Date: Tue, 14 Aug 2018 17:53:19 +0200 Subject: [PATCH 07/10] Added smart storagesize-calculation --- apps/files/lib/Controller/ViewController.php | 169 +++++++++++++------ settings/css/settings.scss | 36 ++++ settings/src/views/Users.vue | 84 ++++++++- 3 files changed, 231 insertions(+), 58 deletions(-) diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index d943fa0c07e40..25a237c918723 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -73,27 +73,27 @@ class ViewController extends Controller { protected $activityHelper; public function __construct(string $appName, - IRequest $request, - IURLGenerator $urlGenerator, - IL10N $l10n, - IConfig $config, - EventDispatcherInterface $eventDispatcherInterface, - IUserSession $userSession, - IAppManager $appManager, - IRootFolder $rootFolder, - Helper $activityHelper + IRequest $request, + IURLGenerator $urlGenerator, + IL10N $l10n, + IConfig $config, + EventDispatcherInterface $eventDispatcherInterface, + IUserSession $userSession, + IAppManager $appManager, + IRootFolder $rootFolder, + Helper $activityHelper ) { parent::__construct($appName, $request); - $this->appName = $appName; - $this->request = $request; - $this->urlGenerator = $urlGenerator; - $this->l10n = $l10n; - $this->config = $config; + $this->appName = $appName; + $this->request = $request; + $this->urlGenerator = $urlGenerator; + $this->l10n = $l10n; + $this->config = $config; $this->eventDispatcher = $eventDispatcherInterface; - $this->userSession = $userSession; - $this->appManager = $appManager; - $this->rootFolder = $rootFolder; - $this->activityHelper = $activityHelper; + $this->userSession = $userSession; + $this->appManager = $appManager; + $this->rootFolder = $rootFolder; + $this->activityHelper = $activityHelper; } /** @@ -102,8 +102,8 @@ public function __construct(string $appName, * @return string */ protected function renderScript($appName, $scriptName) { - $content = ''; - $appPath = \OC_App::getAppPath($appName); + $content = ''; + $appPath = \OC_App::getAppPath($appName); $scriptPath = $appPath . '/' . $scriptName; if (file_exists($scriptPath)) { // TODO: sanitize path / script name ? @@ -173,21 +173,21 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $favoritesSublistArray = Array(); $navBarPositionPosition = 6; - $currentCount = 0; + $currentCount = 0; foreach ($favElements['folders'] as $dir) { - $id = substr($dir, strrpos($dir, '/') + 1, strlen($dir)); - $link = $this->urlGenerator->linkToRoute('files.view.index', ['dir' => $dir, 'view' => 'files']); + $id = substr($dir, strrpos($dir, '/') + 1, strlen($dir)); + $link = $this->urlGenerator->linkToRoute('files.view.index', ['dir' => $dir, 'view' => 'files']); $sortingValue = ++$currentCount; - $element = [ - 'id' => str_replace('/', '-', $dir), - 'view' => 'files', - 'href' => $link, - 'dir' => $dir, - 'order' => $navBarPositionPosition, - 'folderPosition' => $sortingValue, - 'name' => $id, - 'icon' => 'files', + $element = [ + 'id' => str_replace('/', '-', $dir), + 'view' => 'files', + 'href' => $link, + 'dir' => $dir, + 'order' => $navBarPositionPosition, + 'folderPosition' => $sortingValue, + 'name' => $id, + 'icon' => 'files', 'quickaccesselement' => 'true' ]; @@ -210,9 +210,10 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $nav->assign('navigationItems', $navItems); - $nav->assign('usage', $this->reduceStorageSizeBySensibleBoundaries($storageInfo['used'])); + $nav->assign('usage', $this->showAsPartsOfUnit($storageInfo['used'], $this->getEnding($storageInfo['total']))); if ($storageInfo['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED) { $totalSpace = $this->l10n->t('Unlimited'); + $nav->assign('usage', $this->reduceStorageSizeBySensibleBoundaries($storageInfo['used'])); } else { $totalSpace = $this->reduceStorageSizeBySensibleBoundaries($storageInfo['total']); } @@ -236,13 +237,13 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $subcontent = $this->renderScript($subitem['appname'], $subitem['script']); } $contentItems[$subitem['id']] = [ - 'id' => $subitem['id'], + 'id' => $subitem['id'], 'content' => $subcontent ]; } } $contentItems[$item['id']] = [ - 'id' => $item['id'], + 'id' => $item['id'], 'content' => $content ]; } @@ -250,20 +251,20 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $event = new GenericEvent(null, ['hiddenFields' => []]); $this->eventDispatcher->dispatch('OCA\Files::loadAdditionalScripts', $event); - $params = []; - $params['usedSpacePercent'] = (int) $storageInfo['relative']; - $params['owner'] = $storageInfo['owner']; - $params['ownerDisplayName'] = $storageInfo['ownerDisplayName']; - $params['isPublic'] = false; - $params['allowShareWithLink'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes'); - $params['defaultFileSorting'] = $this->config->getUserValue($user, 'files', 'file_sorting', 'name'); + $params = []; + $params['usedSpacePercent'] = (int)$storageInfo['relative']; + $params['owner'] = $storageInfo['owner']; + $params['ownerDisplayName'] = $storageInfo['ownerDisplayName']; + $params['isPublic'] = false; + $params['allowShareWithLink'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes'); + $params['defaultFileSorting'] = $this->config->getUserValue($user, 'files', 'file_sorting', 'name'); $params['defaultFileSortingDirection'] = $this->config->getUserValue($user, 'files', 'file_sorting_direction', 'asc'); - $showHidden = (bool) $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', false); - $params['showHiddenFiles'] = $showHidden ? 1 : 0; - $params['fileNotFound'] = $fileNotFound ? 1 : 0; - $params['appNavigation'] = $nav; - $params['appContents'] = $contentItems; - $params['hiddenFields'] = $event->getArgument('hiddenFields'); + $showHidden = (bool)$this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', false); + $params['showHiddenFiles'] = $showHidden ? 1 : 0; + $params['fileNotFound'] = $fileNotFound ? 1 : 0; + $params['appNavigation'] = $nav; + $params['appContents'] = $contentItems; + $params['hiddenFields'] = $event->getArgument('hiddenFields'); $response = new TemplateResponse( $this->appName, @@ -285,14 +286,14 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal * @throws \OCP\Files\NotFoundException */ private function showFile($fileId) { - $uid = $this->userSession->getUser()->getUID(); + $uid = $this->userSession->getUser()->getUID(); $baseFolder = $this->rootFolder->getUserFolder($uid); - $files = $baseFolder->getById($fileId); - $params = []; + $files = $baseFolder->getById($fileId); + $params = []; if (empty($files) && $this->appManager->isEnabledForUser('files_trashbin')) { - $baseFolder = $this->rootFolder->get($uid . '/files_trashbin/files/'); - $files = $baseFolder->getById($fileId); + $baseFolder = $this->rootFolder->get($uid . '/files_trashbin/files/'); + $files = $baseFolder->getById($fileId); $params['view'] = 'trashbin'; } @@ -321,8 +322,7 @@ private function showFile($fileId) { */ private function reduceStorageSizeBySensibleBoundaries($storage) { $reducedStorageSize = \OC_Helper::humanFileSize($storage); - $ending = substr($reducedStorageSize, (strrpos($reducedStorageSize, "B") - 1), strlen($reducedStorageSize)); - $ending = trim($ending); + $ending = $this->getEnding($storage); if ($storage > 10485760 && $storage < 1073741824) { //Over 10MB under 1GB $reducedStorageSize = round($reducedStorageSize); @@ -334,4 +334,63 @@ private function reduceStorageSizeBySensibleBoundaries($storage) { return $reducedStorageSize . " " . $ending; } + + /** + * Returns either '<0.1' or a readable Size, depending on the unit. If the given size is smaller than 10% of the given unit, '<0.1' is returned. + * + * @param $bytes bytes of the used space + * @param $unit unit of the total assigned space + * @return String Size + */ + private function showAsPartsOfUnit($bytes,$unit) { + + if ($unit == "KB") { + if ($bytes < 102) { + return "<0.1"; + } + } + + if ($unit == "MB") { + if ($bytes < 104857) { + return "<0.1"; + } + } + + if ($unit == "GB") { + if ($bytes < 107374182) { + return "<0.1"; + } + } + + if ($unit == "TB") { + if ($bytes < 109951162777) { + return "<0.1"; + } + } + + return $this->stripEnding($bytes); + } + + /** + * Returns the humanFileSize, but without the unit. + * + * @param $bytes bytes + * @return String Size + */ + private function stripEnding($bytes) { + $sizeHuman = \OC_Helper::humanFileSize($bytes); + return trim(substr($sizeHuman, 0, (strrpos($sizeHuman, "B") - 1))); + } + + /** + * Returns the unit of humanFileSize + * + * @param $bytes bytes + * @return String Unit + */ + private function getEnding($bytes) { + $sizeHuman = \OC_Helper::humanFileSize($bytes); + return trim(substr($sizeHuman, (strrpos($sizeHuman, "B") - 1), strlen($sizeHuman))); + } + } diff --git a/settings/css/settings.scss b/settings/css/settings.scss index 4bba5afa7888f..cb26376891547 100644 --- a/settings/css/settings.scss +++ b/settings/css/settings.scss @@ -272,6 +272,42 @@ select { font-weight: normal; white-space: nowrap; } + +} +#progress { + height: 5px; + + .progress-states { + display: inline-block; + vertical-align: top; + height: 5px; + border-radius: $border-radius; + position: relative; + } + .progress-used { + @extend .progress-states; + z-index: 3; + background-color: $color-primary; + } + .progress-unused { + @extend .progress-states; + z-index: 1; + background-color: #e6e6e6; + } + .progress-blocked { + @extend .progress-states; + z-index: 2; + $color-stripe-light: #b8b8b8; + $color-stripe-dark: #767676; + background-image: linear-gradient( + 121deg, + $color-stripe-dark 32.65%, + $color-stripe-light 32.65%, + $color-stripe-light 60%, + $color-stripe-dark 60% + ); + background-size: 23px 30px; + } } diff --git a/settings/src/views/Users.vue b/settings/src/views/Users.vue index 9e577160bb2f9..c1b3fbde82f59 100644 --- a/settings/src/views/Users.vue +++ b/settings/src/views/Users.vue @@ -21,8 +21,22 @@ -->