-
-
Notifications
You must be signed in to change notification settings - Fork 62
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: Marcel Klehr <[email protected]> Signed-off-by: Louis Chemineau <[email protected]>
- Loading branch information
Showing
7 changed files
with
210 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace OCA\Photos\Dashboard; | ||
|
||
use OCA\Photos\AppInfo\Application; | ||
use OCP\AppFramework\Services\IInitialState; | ||
use OCP\Dashboard\IWidget; | ||
use OCP\IL10N; | ||
use OCP\IURLGenerator; | ||
use OCP\Util; | ||
|
||
class OnThisDay implements IWidget { | ||
public function __construct( | ||
private IL10N $l, | ||
private IURLGenerator $url, | ||
private IInitialState $initialState | ||
) { | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getId(): string { | ||
return 'photos.onthisday'; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getTitle(): string { | ||
return $this->l->t('On This Day'); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getOrder(): int { | ||
return 20; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getIconClass(): string { | ||
return 'icon-calendar-dark'; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getUrl(): ?string { | ||
return $this->url->linkToRoute('photos.page.indexthisday'); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function load(): void { | ||
Util::addScript('photos', 'photos-dashboard'); | ||
$this->initialState->provideInitialState('image-mimes', Application::IMAGE_MIMES); | ||
$this->initialState->provideInitialState('video-mimes', Application::VIDEO_MIMES); | ||
} | ||
} |
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,88 @@ | ||
<!-- | ||
- Copyright (c) 2020. The Nextcloud Bookmarks contributors. | ||
- | ||
- This file is licensed under the Affero General Public License version 3 or later. See the COPYING file. | ||
--> | ||
|
||
<template> | ||
<div class="on-this-day-dashboard"> | ||
<NcLoadingIcon v-if="loading" :size="48" /> | ||
<NcEmptyContent v-else-if="items.length === 0" | ||
:name="t('photos', 'No picture for this day')" | ||
:description="t('photos', 'Picture taken on this day will show up here.')"> | ||
<template #icon> | ||
<ImageIcon /> | ||
</template> | ||
</NcEmptyContent> | ||
<template v-else> | ||
<File class="on-this-day-dashboard__file" | ||
:file="items[0]" | ||
:allow-selection="false" /> | ||
<NcButton :href="moreUrl"> | ||
{{ t('photos', 'More photos from this day') }} | ||
</NcButton> | ||
</template> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import Image from 'vue-material-design-icons/Image.vue' | ||
|
||
import { generateUrl } from '@nextcloud/router' | ||
import { NcButton, NcLoadingIcon, NcEmptyContent } from '@nextcloud/vue' | ||
|
||
import getPhotos from '../../services/PhotoSearch.js' | ||
import { allMimes } from '../../services/AllowedMimes.js' | ||
import File from '../File.vue' | ||
import logger from '../../services/logger.js' | ||
|
||
export default { | ||
name: 'DashboardOnThisDay', | ||
components: { | ||
File, | ||
NcButton, | ||
NcLoadingIcon, | ||
NcEmptyContent, | ||
ImageIcon: Image, | ||
}, | ||
data() { | ||
return { | ||
loading: true, | ||
items: [], | ||
} | ||
}, | ||
computed: { | ||
moreUrl() { | ||
return generateUrl('/apps/photos/thisday') | ||
}, | ||
}, | ||
async created() { | ||
try { | ||
this.items = await getPhotos({ | ||
firstResult: 0, | ||
nbResults: 1, | ||
mimesType: allMimes, | ||
onThisDay: true, | ||
}) | ||
} catch (error) { | ||
logger.error('Failed to load on this day pictures', { error }) | ||
} finally { | ||
this.loading = false | ||
} | ||
}, | ||
} | ||
</script> | ||
<style lang="scss" scoped> | ||
.on-this-day-dashboard { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
height: 100%; | ||
gap: 16px; | ||
|
||
.file-container { | ||
flex-grow: 1; | ||
border: none; | ||
} | ||
} | ||
</style> |
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,53 @@ | ||
/** | ||
* @copyright Copyright (c) 2019 John Molakvoæ <[email protected]> | ||
* | ||
* @author John Molakvoæ <[email protected]> | ||
* | ||
* @license AGPL-3.0-or-later | ||
* | ||
* 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 { generateFilePath } from '@nextcloud/router' | ||
import { getRequestToken } from '@nextcloud/auth' | ||
import { translate, translatePlural } from '@nextcloud/l10n' | ||
import Vue from 'vue' | ||
|
||
import store from './store/index.js' | ||
import DashboardOnThisDay from './components/Dashboard/DashboardOnThisDay.vue' | ||
|
||
// CSP config for webpack dynamic chunk loading | ||
// eslint-disable-next-line | ||
__webpack_nonce__ = btoa(getRequestToken()) | ||
|
||
// Correct the root of the app for chunk loading | ||
// OC.linkTo matches the apps folders | ||
// OC.generateUrl ensure the index.php (or not) | ||
// We do not want the index.php since we're loading files | ||
// eslint-disable-next-line | ||
__webpack_public_path__ = generateFilePath('photos', '', 'js/') | ||
|
||
Vue.prototype.t = translate | ||
Vue.prototype.n = translatePlural | ||
|
||
window.addEventListener('DOMContentLoaded', () => { | ||
OCA.Dashboard.register('photos.onthisday', (el) => { | ||
global.PhotosOnThisDay = new Vue({ | ||
el, | ||
store, | ||
render: h => h(DashboardOnThisDay), | ||
}) | ||
}) | ||
}) |
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