Maps navigation entry (#13)

Maps navigation entry
This commit is contained in:
John Molakvoæ 2019-12-05 12:38:50 +01:00 committed by GitHub
commit 502ffb413f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 2 deletions

View File

@ -33,6 +33,7 @@ use OCP\EventDispatcher\IEventDispatcher;
use OCP\IInitialStateService;
use OCP\IRequest;
use OCP\Util;
use OCP\IConfig;
class PageController extends Controller {
@ -47,12 +48,14 @@ class PageController extends Controller {
public function __construct($appName,
IRequest $request,
IEventDispatcher $eventDispatcher,
IConfig $config,
IInitialStateService $initialStateService) {
parent::__construct($appName, $request);
$this->appName = $appName;
$this->eventDispatcher = $eventDispatcher;
$this->initialStateService = $initialStateService;
$this->config = $config;
}
@ -68,6 +71,7 @@ class PageController extends Controller {
$this->eventDispatcher->dispatch(LoadViewer::class, new LoadViewer());
$this->initialStateService->provideInitialState($this->appName, 'mimes', Application::MIMES);
$this->initialStateService->provideInitialState($this->appName, 'maps', $this->config->getAppValue('maps', 'enabled', 'no') === 'yes');
Util::addScript($this->appName, 'photos');
Util::addStyle($this->appName, 'icons');
@ -75,5 +79,4 @@ class PageController extends Controller {
$response = new TemplateResponse($this->appName, 'main');
return $response;
}
}

View File

@ -27,9 +27,15 @@ import Vue from 'vue'
import Albums from '../views/Albums'
import Timeline from '../views/Timeline'
import Tags from '../views/Tags'
import isMapsInstalled from '../services/IsMapsInstalled'
Vue.use(Router)
let mapsPath = generateUrl('/apps/maps')
if (!isMapsInstalled) {
mapsPath = generateUrl('/settings/apps/integration/maps')
}
export default new Router({
mode: 'history',
// if index.php is in the url AND we got this far, then it's working:
@ -86,7 +92,10 @@ export default new Router({
{
path: '/maps',
name: 'maps',
redirect: '',
// router-link doesn't support external url, let's force the redirect
beforeEnter() {
location.href = mapsPath
},
},
],
})

View File

@ -0,0 +1,26 @@
/**
* @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import { loadState } from '@nextcloud/initial-state'
const maps = loadState('photos', 'maps')
export default maps