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

Albums.vue « views « src - github.com/nextcloud/photos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 535ce4c3e267d6d4fcf7c5c75cffffdae3295c0f (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
<!--
 - @copyright Copyright (c) 2022 Louis Chemineau <louis@chmn.me>
 -
 - @author Louis Chemineau <louis@chmn.me>
 -
 - @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>
	<!-- Errors handlers-->
	<NcEmptyContent v-if="errorFetchingAlbums">
		{{ t('photos', 'An error occurred') }}
	</NcEmptyContent>

	<!-- Album list -->
	<div v-else class="albums">
		<HeaderNavigation key="navigation"
			:loading="loadingAlbums"
			:title="t('photos', 'Albums')"
			:root-title="t('photos', 'Albums')"
			@refresh="onRefresh">
			<NcButton type="primary"
				:aria-label="t('photos', 'Create a new album.')"
				@click="showAlbumCreationForm = true">
				<template #icon>
					<Plus />
				</template>
				{{ t('photos', 'New album') }}
			</NcButton>
		</HeaderNavigation>

		<!-- No albums -->
		<div v-if="noAlbums && !loadingAlbums" class="albums__empty">
			<NcEmptyContent>
				<template #icon>
					<FolderMultipleImage />
				</template>
				<template #desc>
					{{ t('photos', "There is no album yet!") }}
				</template>
			</NcEmptyContent>

			<NcButton class="albums__empty__button"
				type="primary"
				:aria-label="t('photos', 'Create a new album')"
				@click="showAlbumCreationForm = true">
				<template #icon>
					<Plus />
				</template>
				{{ t('photos', "Add") }}
			</NcButton>
		</div>

		<div v-else-if="!noAlbums" class="albums__list">
			<AlbumCover v-for="album in albums"
				:key="album.basename"
				class="album"
				:base-name="album.basename" />
		</div>

		<NcModal v-if="showAlbumCreationForm"
			:title="t('photos', 'New album')"
			@close="showAlbumCreationForm = false">
			<AlbumForm @done="handleAlbumCreated" />
		</NcModal>
	</div>
</template>

<script>
import { NcButton, NcModal, NcEmptyContent } from '@nextcloud/vue'

import Plus from 'vue-material-design-icons/Plus'
import FolderMultipleImage from 'vue-material-design-icons/FolderMultipleImage'

import FetchAlbumsMixin from '../mixins/FetchAlbumsMixin.js'
import AlbumCover from '../components/AlbumCover.vue'
import AlbumForm from '../components/AlbumForm.vue'
import HeaderNavigation from '../components/HeaderNavigation.vue'

export default {
	name: 'Albums',
	components: {
		AlbumCover,
		AlbumForm,
		FolderMultipleImage,
		HeaderNavigation,
		NcButton,
		NcEmptyContent,
		NcModal,
		Plus,
	},

	mixins: [
		FetchAlbumsMixin,
	],

	data() {
		return {
			showAlbumCreationForm: false,
		}
	},

	computed: {
		/**
		 * @return {boolean} Whether the list of album is empty or not.
		 */
		noAlbums() {
			return Object.keys(this.albums).length === 0
		},
	},

	methods: {
		handleAlbumCreated({ album }) {
			this.showAlbumCreationForm = false
			this.$router.push({
				name: 'albums',
				params: {
					path: album.basename,
				},
			})
		},

		onRefresh() {
			this.fetchAlbums()
		},
	},
}
</script>
<style lang="scss" scoped>
.albums {
	display: flex;
	flex-direction: column;
	height: 100%;

	&__list {
		padding: 32px 48px;
		flex-grow: 1;
		display: flex;
		flex-wrap: wrap;
		gap: 16px;
		align-items: flex-start;
		height: calc(100% - 60px);
		overflow-x: scroll;

		@media only screen and (max-width: 1200px) {
			padding: 32px 12px;
			justify-content: center;
		}

	}

	&__empty {
		display: flex;
		flex-direction: column;
		align-items: center;

		&__button {
			margin-top: 32px;
		}
	}
}

.empty-content-with-illustration ::v-deep .empty-content__icon {
	width: 200px;
	height: 200px;

	svg {
		width: 200px;
		height: 200px;
	}
}
</style>