diff --git a/js/quota-files-sidebar.js b/js/quota-files-sidebar.js new file mode 100644 index 00000000..5f0b2e93 --- /dev/null +++ b/js/quota-files-sidebar.js @@ -0,0 +1,19 @@ +$(document).ready(function () { + + var $p = $('

'), + $quotaLink = $('#external_quota_link'), + $quotaName = $('#external_quota_name'); + $p.text($quotaName.val()); + $('li#quota').on('click', function() { + OC.redirect($quotaLink.val()); + }); + $('li#quota div.quota-container').after($p); + $('li.nav-trashbin').attr('style', 'margin-bottom: 36px !important'); + + if ($('li.nav-trashbin').exists()) { + $('#app-navigation > ul li:nth-last-child(2)').attr('style', 'margin-bottom: 124px !important'); + } else { + $('#app-navigation > ul li:nth-last-child(1)').attr('style', 'margin-bottom: 80px !important'); + + } +}); diff --git a/js/quota.js b/js/quota-personal.js similarity index 100% rename from js/quota.js rename to js/quota-personal.js diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 8d68a614..fdf4a8da 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -25,6 +25,7 @@ use OCA\External\SitesManager; use OCP\AppFramework\App; use OCP\IServerContainer; +use Symfony\Component\EventDispatcher\GenericEvent; class Application extends App { @@ -42,7 +43,7 @@ public function register() { $sites = $sitesManager->getSitesToDisplay(); $this->registerNavigationEntries($server, $sites); - $this->registerPersonalPage($sites); + $this->registerPersonalPage($server, $sites); } /** @@ -76,12 +77,23 @@ public function registerNavigationEntries(IServerContainer $server, array $sites } /** + * @param IServerContainer $server * @param array[] $sites */ - public function registerPersonalPage(array $sites) { + public function registerPersonalPage(IServerContainer $server, array $sites) { foreach ($sites as $site) { if ($site['type'] === SitesManager::TYPE_QUOTA) { \OCP\App::registerPersonal('external', 'personal'); + \OC::$server->getEventDispatcher()->addListener('OCA\Files::loadAdditionalScripts', function(GenericEvent $event) use ($server, $site) { + $url = $server->getURLGenerator(); + + $hiddenFields = $event->getArgument('hiddenFields'); + $hiddenFields['external_quota_link'] = $url->linkToRoute('external.site.showPage', ['id'=> $site['id']]); + $hiddenFields['external_quota_name'] = $site['name']; + $event->setArgument('hiddenFields', $hiddenFields); + + \OCP\Util::addScript('external', 'quota-files-sidebar'); + }); return; } } diff --git a/lib/Controller/SiteController.php b/lib/Controller/SiteController.php index 43ea2e98..5539fbfc 100644 --- a/lib/Controller/SiteController.php +++ b/lib/Controller/SiteController.php @@ -102,18 +102,17 @@ public function showPage($id) { public function renderQuotaLink() { $sites = $this->sitesManager->getSitesToDisplay(); - $quotaLinks = []; + $quotaLink = []; foreach ($sites as $site) { if ($site['type'] === SitesManager::TYPE_QUOTA) { - $quotaLinks[] = [ - 'link' => $this->url->linkToRoute('external.site.showPage', ['id'=> $site['id']]), - 'name' => $site['name'], - ]; + $quotaLink = $site; + break; } } return new TemplateResponse('external', 'quota', [ - 'sites' => $quotaLinks, + 'quotaLink' => $this->url->linkToRoute('external.site.showPage', ['id'=> $quotaLink['id']]), + 'quotaName' => $quotaLink['name'], ], ''); } } diff --git a/templates/quota.php b/templates/quota.php index 24f0c3b0..c2f9d826 100644 --- a/templates/quota.php +++ b/templates/quota.php @@ -19,10 +19,8 @@ * */ -script('external', 'quota'); +script('external', 'quota-personal'); ?>