Add shared albums
parent
5927163b33
commit
038ba2eb87
|
@ -277,7 +277,14 @@ class ApiController extends Controller
|
|||
}
|
||||
|
||||
// Run actual query
|
||||
$list = $this->timelineQuery->getAlbums($user->getUID());
|
||||
$list = [];
|
||||
$t = intval($this->request->getParam('t'));
|
||||
if ($t & 1) { // personal
|
||||
$list = array_merge($list, $this->timelineQuery->getAlbums($user->getUID()));
|
||||
}
|
||||
if ($t & 2) { // shared
|
||||
$list = array_merge($list, $this->timelineQuery->getAlbums($user->getUID(), true));
|
||||
}
|
||||
|
||||
return new JSONResponse($list, Http::STATUS_OK);
|
||||
}
|
||||
|
|
|
@ -30,15 +30,24 @@ trait TimelineQueryAlbums
|
|||
}
|
||||
|
||||
/** Get list of albums */
|
||||
public function getAlbums(string $uid)
|
||||
public function getAlbums(string $uid, $shared=false)
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder();
|
||||
|
||||
// SELECT everything from albums
|
||||
$count = $query->func()->count($query->createFunction('DISTINCT m.fileid'), 'count');
|
||||
$query->select('pa.*', $count)->from('photos_albums', 'pa')->where(
|
||||
$query->select('pa.*', $count)->from('photos_albums', 'pa');
|
||||
|
||||
if ($shared) {
|
||||
$query->innerJoin('pa', 'photos_collaborators', 'pc', $query->expr()->andX(
|
||||
$query->expr()->eq('pa.album_id', 'pc.album_id'),
|
||||
$query->expr()->eq('pc.collaborator_id', $query->createNamedParameter($uid)),
|
||||
));
|
||||
} else {
|
||||
$query->where(
|
||||
$query->expr()->eq('user', $query->createNamedParameter($uid)),
|
||||
);
|
||||
}
|
||||
|
||||
// WHERE these are items with this album
|
||||
$query->leftJoin('pa', 'photos_albums_files', 'paf', $query->expr()->andX(
|
||||
|
|
|
@ -560,7 +560,7 @@ export default class Timeline extends Mixins(GlobalMixin, UserConfig) {
|
|||
} else if (this.$route.name === 'people' && !this.$route.params.name) {
|
||||
data = await dav.getPeopleData();
|
||||
} else if (this.$route.name === 'albums' && !this.$route.params.name) {
|
||||
data = await dav.getAlbumsData();
|
||||
data = await dav.getAlbumsData('3');
|
||||
} else {
|
||||
// Try the cache
|
||||
try {
|
||||
|
|
|
@ -9,7 +9,10 @@
|
|||
@click.native="openTag(data)">
|
||||
|
||||
<div class="bbl"> <NcCounterBubble> {{ data.count }} </NcCounterBubble> </div>
|
||||
<div class="name"> {{ data.name }} </div>
|
||||
<div class="name">
|
||||
{{ data.name }}
|
||||
<span class="subtitle" v-if="subtitle"> {{ subtitle }} </span>
|
||||
</div>
|
||||
|
||||
<div class="previews fill-block" ref="previews">
|
||||
<div class="img-outer" v-for="info of previews" :key="info.fileid">
|
||||
|
@ -29,6 +32,7 @@ import { Component, Prop, Watch, Mixins, Emit } from 'vue-property-decorator';
|
|||
import { IAlbum, IPhoto, ITag } from '../../types';
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
import { getPreviewUrl } from "../../services/FileUtils";
|
||||
import { getCurrentUser } from '@nextcloud/auth';
|
||||
|
||||
import { NcCounterBubble } from '@nextcloud/vue'
|
||||
|
||||
|
@ -50,6 +54,9 @@ export default class Tag extends Mixins(GlobalMixin) {
|
|||
// Error occured fetching thumbs
|
||||
private error = false;
|
||||
|
||||
// Smaller subtitle
|
||||
private subtitle = '';
|
||||
|
||||
/**
|
||||
* Open tag event
|
||||
* Unless noNavigate is set, the tag will be opened
|
||||
|
@ -84,6 +91,7 @@ export default class Tag extends Mixins(GlobalMixin) {
|
|||
async refreshPreviews() {
|
||||
// Reset state
|
||||
this.error = false;
|
||||
this.subtitle = '';
|
||||
|
||||
// Add dummy preview if face
|
||||
if (this.isFace) {
|
||||
|
@ -97,6 +105,9 @@ export default class Tag extends Mixins(GlobalMixin) {
|
|||
if (album.last_added_photo > 0) {
|
||||
this.previews = [{ fileid: album.last_added_photo, etag: '', flag: 0 }];
|
||||
}
|
||||
if (album.user !== getCurrentUser()?.uid) {
|
||||
this.subtitle = `(${album.user})`;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -160,6 +171,12 @@ export default class Tag extends Mixins(GlobalMixin) {
|
|||
text-overflow: ellipsis;
|
||||
line-height: 1em;
|
||||
|
||||
> .subtitle {
|
||||
font-size: 0.7em;
|
||||
margin-top: 2px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.isFace > & {
|
||||
top: unset;
|
||||
bottom: 10%;
|
||||
|
|
|
@ -107,7 +107,7 @@ export default class AlbumPicker extends Mixins(GlobalMixin) {
|
|||
|
||||
async loadAlbums() {
|
||||
try {
|
||||
const res = await axios.get<IAlbum[]>(generateUrl('/apps/memories/api/albums'));
|
||||
const res = await axios.get<IAlbum[]>(generateUrl('/apps/memories/api/albums?t=3'));
|
||||
this.albums = res.data;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
|
|
@ -558,11 +558,12 @@ export async function* removeFaceImages(user: string, name: string, fileIds: num
|
|||
|
||||
/**
|
||||
* Get list of albums and convert to Days response
|
||||
* @param type Type of albums to get; 1 = personal, 2 = shared, 3 = all
|
||||
*/
|
||||
export async function getAlbumsData(): Promise<IDay[]> {
|
||||
export async function getAlbumsData(type: '1' | '2' | '3'): Promise<IDay[]> {
|
||||
let data: IAlbum[] = [];
|
||||
try {
|
||||
const res = await axios.get<typeof data>(generateUrl('/apps/memories/api/albums'));
|
||||
const res = await axios.get<typeof data>(generateUrl(`/apps/memories/api/albums?t=${type}`));
|
||||
data = res.data;
|
||||
} catch (e) {
|
||||
throw e;
|
||||
|
|
Loading…
Reference in New Issue