Browse Source

add cache and loader for big menu

develop
Simon Vieille 7 months ago
parent
commit
2653fbbfa7
Signed by: deblan GPG Key ID: 03383D15A1D31745
  1. 10
      css/sideMenu.css
  2. 17
      img/loader.svg
  3. 20
      lib/Controller/NavController.php
  4. 19
      src/SideMenuBig.vue

10
css/sideMenu.css

@ -175,6 +175,16 @@
color: var(--side-menu-text-color, #fff);
}
.side-menu-loader {
text-align: center;
}
.side-menu-loader svg {
width: 38px;
margin: auto;
stroke: var(--side-menu-text-color, #fff);
}
.side-menu-big .side-menu-app-icon {
vertical-align: middle;
margin-top: -2px;

17
img/loader.svg

@ -0,0 +1,17 @@
<!-- By Sam Herbert (@sherb), for everyone. More @ http://goo.gl/7AJzbL -->
<svg width="38" height="38" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg" stroke="#fff">
<g fill="none" fill-rule="evenodd">
<g transform="translate(1 1)" stroke-width="2">
<circle stroke-opacity=".5" cx="18" cy="18" r="18"/>
<path d="M36 18c0-9.94-8.06-18-18-18">
<animateTransform
attributeName="transform"
type="rotate"
from="0 18 18"
to="360 18 18"
dur="1s"
repeatCount="indefinite"/>
</path>
</g>
</g>
</svg>

20
lib/Controller/NavController.php

@ -21,10 +21,12 @@ namespace OCA\SideMenu\Controller;
use OC;
use OC\App\AppStore\Fetcher\CategoryFetcher;
use OC\URLGenerator;
use OCA\SideMenu\AppInfo\Application;
use OCA\SideMenu\Service\AppRepository;
use OCA\SideMenu\Service\ConfigProxy;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IUserSession;
@ -37,6 +39,11 @@ class NavController extends Controller
*/
protected $config;
/**
* @var IConfig
*/
protected $iConfig;
/**
* @var AppRepository
*/
@ -60,6 +67,7 @@ class NavController extends Controller
public function __construct(
string $appName,
IRequest $request,
IConfig $iConfig,
ConfigProxy $config,
AppRepository $appRepository,
CategoryFetcher $categoryFetcher,
@ -70,6 +78,7 @@ class NavController extends Controller
parent::__construct($appName, $request);
$this->config = $config;
$this->iConfig = $iConfig;
$this->appRepository = $appRepository;
$this->categoryFetcher = $categoryFetcher;
$this->l10nFactory = $l10nFactory;
@ -87,7 +96,6 @@ class NavController extends Controller
{
$apps = $this->appRepository->getVisibleApps();
$currentLanguage = substr($this->l10nFactory->findLanguage(), 0, 2);
$categoriesLabels = $this->categoryFetcher->get();
$externalSitesInTopMenu = $this->config->getAppValueBool('external-sites-in-top-menu', '0');
$user = OC::$server[IUserSession::class]->getUser();
$appsCategories = [];
@ -100,6 +108,14 @@ class NavController extends Controller
]);
}
$categoriesLabels = $this->config->getAppValueArray('cache-categories', '[]');
if (empty($categoriesLabels)) {
$categoriesLabels = $this->categoryFetcher->get();
$this->iConfig->setAppValue(Application::APP_ID, 'cache-categories', json_encode($categoriesLabels));
}
$topMenuApps = $this->config->getAppValueArray('top-menu-apps', '[]');
$userTopMenuApps = $this->config->getUserValueArray($user, 'top-menu-apps', '[]');
@ -135,7 +151,7 @@ class NavController extends Controller
foreach ($categories as $category) {
if (!isset($items[$category])) {
$items[$category] = [
'name' => $categoriesLabels[$category],
'name' => $categoriesLabels[$category] ?? $category,
'apps' => [],
];
}

19
src/SideMenuBig.vue

@ -23,6 +23,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<div class="side-menu-categories-wrapper">
<div class="side-menu-categories">
<div v-if="!items.length" class="side-menu-loader">
<svg width="38" height="38" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg">
<g fill="none" fill-rule="evenodd">
<g transform="translate(1 1)" stroke-width="2">
<circle stroke-opacity=".5" cx="18" cy="18" r="18"/>
<path d="M36 18c0-9.94-8.06-18-18-18">
<animateTransform
attributeName="transform"
type="rotate"
from="0 18 18"
to="360 18 18"
dur="1s"
repeatCount="indefinite"/>
</path>
</g>
</g>
</svg>
</div>
<div class="side-menu-category" v-for="category in items">
<h2 class="side-menu-category-title" v-if="category.name != ''" v-html="category.name"></h2>

Loading…
Cancel
Save