Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions js/quota-files-sidebar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$(document).ready(function () {

var $p = $('<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');

}
});
File renamed without changes.
16 changes: 14 additions & 2 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use OCA\External\SitesManager;
use OCP\AppFramework\App;
use OCP\IServerContainer;
use Symfony\Component\EventDispatcher\GenericEvent;

class Application extends App {

Expand All @@ -42,7 +43,7 @@ public function register() {
$sites = $sitesManager->getSitesToDisplay();

$this->registerNavigationEntries($server, $sites);
$this->registerPersonalPage($sites);
$this->registerPersonalPage($server, $sites);
}

/**
Expand Down Expand Up @@ -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;
}
}
Expand Down
11 changes: 5 additions & 6 deletions lib/Controller/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
], '');
}
}
6 changes: 2 additions & 4 deletions templates/quota.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
*
*/

script('external', 'quota');
script('external', 'quota-personal');
?>
<div id="quota_link" class="section hidden">
<?php foreach ($_['sites'] as $site) { ?>
<a class="button" href="<?php p($site['link']); ?>"><?php p($site['name']); ?></a>
<?php } ?>
<a class="button" href="<?php p($_['quotaLink']); ?>"><?php p($_['quotaName']); ?></a>
</div>