Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Photos.vue « src - github.com/nextcloud/photos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 66a55c94f93ffa1a7624dcfc07ee4f2242738ec6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<!--
 - @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
 -
 - @author John Molakvoæ <skjnldsv@protonmail.com>
 -
 - @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/>.
 -
 -->

<template>
	<NcContent app-name="photos">
		<NcAppNavigation>
			<template #list>
				<NcAppNavigationItem :to="{name: 'all_media'}"
					class="app-navigation__all_media"
					:title="t('photos', 'All media')"
					exact>
					<ImageIcon slot="icon" :size="20" />
				</NcAppNavigationItem>
				<NcAppNavigationItem to="/photos" :title="t('photos', 'Photos')">
					<Camera slot="icon" :size="20" />
				</NcAppNavigationItem>
				<NcAppNavigationItem to="/videos" :title="t('photos', 'Videos')">
					<VideoIcon slot="icon" :size="20" />
				</NcAppNavigationItem>
				<NcAppNavigationItem :to="{name: 'albums'}" :title="t('photos', 'Albums')">
					<FolderMultipleImage slot="icon" :size="20" />
				</NcAppNavigationItem>
				<NcAppNavigationItem :to="{name: 'sharedAlbums'}" :title="t('photos', 'Collaborative albums')">
					<AccountGroup slot="icon" :size="20" />
				</NcAppNavigationItem>
				<NcAppNavigationItem v-if="showPeopleMenuEntry" :to="{name: 'faces'}" :title="t('photos', 'People')">
					<template #icon>
						<AccountBoxMultipleOutline :size="20" />
					</template>
				</NcAppNavigationItem>
				<NcAppNavigationItem :to="{name: 'folders'}" :title="t('photos', 'Folders')">
					<Folder slot="icon" :size="20" />
				</NcAppNavigationItem>
				<NcAppNavigationItem to="/favorites" :title="t('photos', 'Favorites')">
					<Star slot="icon" :size="20" />
				</NcAppNavigationItem>
				<NcAppNavigationItem :to="{name: 'thisday'}" :title="t('photos', 'On this day')">
					<CalendarToday slot="icon" :size="20" />
				</NcAppNavigationItem>
				<NcAppNavigationItem :to="{name: 'shared'}" :title="t('photos', 'Shared with you')">
					<ShareVariant slot="icon" :size="20" />
				</NcAppNavigationItem>
				<NcAppNavigationItem v-if="areTagsInstalled"
					:to="{name: 'tags'}"
					:title="t('photos', 'Tags')">
					<Tag slot="icon" :size="20" />
				</NcAppNavigationItem>
				<NcAppNavigationItem :to="{name: 'locations'}" :title="t('photos', 'Locations')">
					<MapMarker slot="icon" :size="20" />
				</NcAppNavigationItem>
				<NcAppNavigationItem v-if="showLocationMenuEntry"
					:to="{name: 'maps'}"
					:title="t('photos', 'Maps')">
					<MapMarker slot="icon" :size="20" />
				</NcAppNavigationItem>
			</template>
			<template #footer>
				<NcAppNavigationItem :title="t('photos', 'Photos settings')" @click="showSettings">
					<Cog slot="icon" :size="20" />
				</NcAppNavigationItem>
			</template>
		</NcAppNavigation>
		<NcAppContent>
			<router-view />

			<!-- svg img loading placeholder (linked to the File component) -->
			<!-- eslint-disable-next-line vue/no-v-html (because it's an SVG file) -->
			<span class="hidden-visually" role="none" v-html="svgplaceholder" />
			<!-- eslint-disable-next-line vue/no-v-html (because it's an SVG file) -->
			<span class="hidden-visually" role="none" v-html="imgplaceholder" />
			<!-- eslint-disable-next-line vue/no-v-html (because it's an SVG file) -->
			<span class="hidden-visually" role="none" v-html="videoplaceholder" />
		</NcAppContent>

		<!-- Main settings Modal-->
		<SettingsDialog :open.sync="openedSettings" />
	</NcContent>
</template>

<script>
import { getCurrentUser } from '@nextcloud/auth'
import { generateUrl } from '@nextcloud/router'
import { loadState } from '@nextcloud/initial-state'

import Camera from 'vue-material-design-icons/Camera.vue'
import ImageIcon from 'vue-material-design-icons/Image.vue'
import VideoIcon from 'vue-material-design-icons/Video.vue'
import FolderMultipleImage from 'vue-material-design-icons/FolderMultipleImage.vue'
import Folder from 'vue-material-design-icons/Folder.vue'
import Star from 'vue-material-design-icons/Star.vue'
import CalendarToday from 'vue-material-design-icons/CalendarToday.vue'
import AccountGroup from 'vue-material-design-icons/AccountGroup.vue'
import Tag from 'vue-material-design-icons/Tag.vue'
import MapMarker from 'vue-material-design-icons/MapMarker.vue'
import ShareVariant from 'vue-material-design-icons/ShareVariant.vue'
import AccountBoxMultipleOutline from 'vue-material-design-icons/AccountBoxMultipleOutline.vue'
import Cog from 'vue-material-design-icons/Cog.vue'

import { NcContent, NcAppContent, NcAppNavigation, NcAppNavigationItem } from '@nextcloud/vue'

import SettingsDialog from './components/Settings/SettingsDialog.vue'

import svgplaceholder from './assets/file-placeholder.svg'
import imgplaceholder from './assets/image.svg'
import videoplaceholder from './assets/video.svg'
import areTagsInstalled from './services/AreTagsInstalled.js'
import isMapsInstalled from './services/IsMapsInstalled.js'
import isRecognizeInstalled from './services/IsRecognizeInstalled.js'
import logger from './services/logger.js'

export default {
	name: 'Photos',
	components: {
		AccountBoxMultipleOutline,
		Cog,
		CalendarToday,
		Camera,
		AccountGroup,
		Folder,
		FolderMultipleImage,
		ImageIcon,
		ShareVariant,
		Star,
		Tag,
		VideoIcon,
		MapMarker,
		NcAppContent,
		NcAppNavigation,
		NcAppNavigationItem,
		NcContent,
		SettingsDialog,
	},
	data() {
		return {
			svgplaceholder,
			imgplaceholder,
			videoplaceholder,
			areTagsInstalled,

			showLocationMenuEntry: getCurrentUser() === null
				? false
				: getCurrentUser().isAdmin || isMapsInstalled,
			showPeopleMenuEntry: getCurrentUser() === null
				? false
				: getCurrentUser().isAdmin || isRecognizeInstalled,

			openedSettings: false,
		}
	},

	async beforeMount() {
		// Register excluded paths
		const files = loadState('photos', 'nomedia-paths', [])
		this.$store.dispatch('setNomediaPaths', files)
		logger.debug('Known .nomedia and .noimage  paths', { files })

		if ('serviceWorker' in navigator) {
			// Use the window load event to keep the page load performant
			window.addEventListener('load', () => {
				navigator.serviceWorker.register(generateUrl('/apps/photos/service-worker.js', {}, {
					noRewrite: true,
				}), {
					scope: generateUrl('/apps/photos'),
				}).then(registration => {
					logger.debug('SW registered: ', { registration })
				}).catch(registrationError => {
					logger.error('SW registration failed: ', { registrationError })
				})

			})
		} else {
			logger.debug('Service Worker is not enabled on this browser.')
		}
	},

	beforeDestroy() {
		window.removeEventListener('load', () => {
			navigator.serviceWorker.register(generateUrl('/apps/photos/service-worker.js', {}, {
				noRewrite: true,
			}))
		})
	},

	methods: {
		showSettings() {
			this.openedSettings = true
		},
	},
}
</script>
<style lang="scss">
.app-content {
	display: flex;
	flex-grow: 1;
	flex-direction: column;
	align-content: space-between;
}

.app-navigation__photos:deep .app-navigation-entry-icon.icon-photos {
	background-size: 20px;
}
</style>