-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Julius Härtl <jus@bitgrid.net>
- Loading branch information
1 parent
324e242
commit 2abed44
Showing
11 changed files
with
727 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net> | ||
* | ||
* @author Julius Härtl <jus@bitgrid.net> | ||
* | ||
* @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/>. | ||
* | ||
*/ | ||
|
||
namespace OCA\Calendar\Dashboard; | ||
|
||
use OCA\Calendar\AppInfo\Application; | ||
use OCA\Calendar\Service\JSDataService; | ||
use OCP\Dashboard\IWidget; | ||
use OCP\IInitialStateService; | ||
use OCP\IL10N; | ||
|
||
class CalendarWidget implements IWidget { | ||
|
||
/** | ||
* @var IL10N | ||
*/ | ||
private $l10n; | ||
|
||
/** | ||
* @var IInitialStateService | ||
*/ | ||
private $initialStateService; | ||
|
||
/** | ||
* @var JSDataService | ||
*/ | ||
private $dataService; | ||
|
||
/** | ||
* CalendarWidget constructor. | ||
* @param IL10N $l10n | ||
* @param IInitialStateService $initialStateService | ||
* @param JSDataService $dataService | ||
*/ | ||
public function __construct(IL10N $l10n, | ||
IInitialStateService $initialStateService, | ||
JSDataService $dataService) { | ||
$this->l10n = $l10n; | ||
$this->initialStateService = $initialStateService; | ||
$this->dataService = $dataService; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getId(): string { | ||
return Application::APP_ID; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getTitle(): string { | ||
return $this->l10n->t('Upcoming events'); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getOrder(): int { | ||
return 2; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getIconClass(): string { | ||
return 'icon-calendar-dark'; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getUrl(): ?string { | ||
return null; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function load(): void { | ||
\OCP\Util::addScript('calendar', 'dashboard'); | ||
|
||
$this->initialStateService->provideLazyInitialState(Application::APP_ID, 'dashboard_data', function () { | ||
return $this->dataService; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* Calendar App | ||
* | ||
* @author Georg Ehrke | ||
* @copyright 2020 Georg Ehrke <oc.list@georgehrke.com> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or any later version. | ||
* | ||
* This library 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 library. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
namespace OCA\Calendar\Service; | ||
|
||
use OCA\Calendar\AppInfo\Application; | ||
use OCP\IConfig; | ||
use OCP\IUserSession; | ||
|
||
class JSDataService implements \JsonSerializable { | ||
|
||
/** @var IConfig */ | ||
private $config; | ||
|
||
/** @var IUserSession */ | ||
private $userSession; | ||
|
||
/** | ||
* JSDataService constructor. | ||
* | ||
* @param IConfig $config | ||
* @param IUserSession $userSession | ||
*/ | ||
public function __construct(IConfig $config, | ||
IUserSession $userSession) { | ||
$this->config = $config; | ||
$this->userSession = $userSession; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function jsonSerialize() { | ||
$user = $this->userSession->getUser(); | ||
|
||
if ($user === null) { | ||
return []; | ||
} | ||
|
||
$defaultTimezone = $this->config->getAppValue(Application::APP_ID, 'timezone', 'automatic'); | ||
$defaultShowTasks = $this->config->getAppValue(Application::APP_ID, 'showTasks', 'yes'); | ||
$timezone = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'timezone', $defaultTimezone); | ||
$showTasks = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'showTasks', $defaultShowTasks) === 'yes'; | ||
|
||
return [ | ||
'timezone' => $timezone, | ||
'show_tasks' => $showTasks, | ||
]; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net> | ||
* | ||
* @author Julius Härtl <jus@bitgrid.net> | ||
* | ||
* @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 Vue from 'vue' | ||
import { generateFilePath } from '@nextcloud/router' | ||
import { getRequestToken } from '@nextcloud/auth' | ||
import { translate, translatePlural } from '@nextcloud/l10n' | ||
import Dashboard from './views/Dashboard' | ||
import store from './store' | ||
|
||
// eslint-disable-next-line | ||
__webpack_nonce__ = btoa(getRequestToken()) | ||
|
||
// eslint-disable-next-line | ||
__webpack_public_path__ = generateFilePath('calendar', '', 'js/') | ||
|
||
Vue.prototype.t = translate | ||
Vue.prototype.n = translatePlural | ||
Vue.prototype.OC = OC | ||
Vue.prototype.OCA = OCA | ||
|
||
document.addEventListener('DOMContentLoaded', function() { | ||
OCA.Dashboard.register('calendar', (el) => { | ||
const View = Vue.extend(Dashboard) | ||
new View({ | ||
store, | ||
propsData: {}, | ||
}).$mount(el) | ||
}) | ||
|
||
}) |
Oops, something went wrong.