Add shared albums
parent
5927163b33
commit
038ba2eb87
|
@ -277,7 +277,14 @@ class ApiController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run actual query
|
// 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);
|
return new JSONResponse($list, Http::STATUS_OK);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,15 +30,24 @@ trait TimelineQueryAlbums
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get list of albums */
|
/** Get list of albums */
|
||||||
public function getAlbums(string $uid)
|
public function getAlbums(string $uid, $shared=false)
|
||||||
{
|
{
|
||||||
$query = $this->connection->getQueryBuilder();
|
$query = $this->connection->getQueryBuilder();
|
||||||
|
|
||||||
// SELECT everything from albums
|
// SELECT everything from albums
|
||||||
$count = $query->func()->count($query->createFunction('DISTINCT m.fileid'), 'count');
|
$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');
|
||||||
$query->expr()->eq('user', $query->createNamedParameter($uid)),
|
|
||||||
);
|
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
|
// WHERE these are items with this album
|
||||||
$query->leftJoin('pa', 'photos_albums_files', 'paf', $query->expr()->andX(
|
$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) {
|
} else if (this.$route.name === 'people' && !this.$route.params.name) {
|
||||||
data = await dav.getPeopleData();
|
data = await dav.getPeopleData();
|
||||||
} else if (this.$route.name === 'albums' && !this.$route.params.name) {
|
} else if (this.$route.name === 'albums' && !this.$route.params.name) {
|
||||||
data = await dav.getAlbumsData();
|
data = await dav.getAlbumsData('3');
|
||||||
} else {
|
} else {
|
||||||
// Try the cache
|
// Try the cache
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -9,7 +9,10 @@
|
||||||
@click.native="openTag(data)">
|
@click.native="openTag(data)">
|
||||||
|
|
||||||
<div class="bbl"> <NcCounterBubble> {{ data.count }} </NcCounterBubble> </div>
|
<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="previews fill-block" ref="previews">
|
||||||
<div class="img-outer" v-for="info of previews" :key="info.fileid">
|
<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 { IAlbum, IPhoto, ITag } from '../../types';
|
||||||
import { generateUrl } from '@nextcloud/router'
|
import { generateUrl } from '@nextcloud/router'
|
||||||
import { getPreviewUrl } from "../../services/FileUtils";
|
import { getPreviewUrl } from "../../services/FileUtils";
|
||||||
|
import { getCurrentUser } from '@nextcloud/auth';
|
||||||
|
|
||||||
import { NcCounterBubble } from '@nextcloud/vue'
|
import { NcCounterBubble } from '@nextcloud/vue'
|
||||||
|
|
||||||
|
@ -50,6 +54,9 @@ export default class Tag extends Mixins(GlobalMixin) {
|
||||||
// Error occured fetching thumbs
|
// Error occured fetching thumbs
|
||||||
private error = false;
|
private error = false;
|
||||||
|
|
||||||
|
// Smaller subtitle
|
||||||
|
private subtitle = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open tag event
|
* Open tag event
|
||||||
* Unless noNavigate is set, the tag will be opened
|
* Unless noNavigate is set, the tag will be opened
|
||||||
|
@ -84,6 +91,7 @@ export default class Tag extends Mixins(GlobalMixin) {
|
||||||
async refreshPreviews() {
|
async refreshPreviews() {
|
||||||
// Reset state
|
// Reset state
|
||||||
this.error = false;
|
this.error = false;
|
||||||
|
this.subtitle = '';
|
||||||
|
|
||||||
// Add dummy preview if face
|
// Add dummy preview if face
|
||||||
if (this.isFace) {
|
if (this.isFace) {
|
||||||
|
@ -97,6 +105,9 @@ export default class Tag extends Mixins(GlobalMixin) {
|
||||||
if (album.last_added_photo > 0) {
|
if (album.last_added_photo > 0) {
|
||||||
this.previews = [{ fileid: album.last_added_photo, etag: '', flag: 0 }];
|
this.previews = [{ fileid: album.last_added_photo, etag: '', flag: 0 }];
|
||||||
}
|
}
|
||||||
|
if (album.user !== getCurrentUser()?.uid) {
|
||||||
|
this.subtitle = `(${album.user})`;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,6 +171,12 @@ export default class Tag extends Mixins(GlobalMixin) {
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
line-height: 1em;
|
line-height: 1em;
|
||||||
|
|
||||||
|
> .subtitle {
|
||||||
|
font-size: 0.7em;
|
||||||
|
margin-top: 2px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
.isFace > & {
|
.isFace > & {
|
||||||
top: unset;
|
top: unset;
|
||||||
bottom: 10%;
|
bottom: 10%;
|
||||||
|
|
|
@ -107,7 +107,7 @@ export default class AlbumPicker extends Mixins(GlobalMixin) {
|
||||||
|
|
||||||
async loadAlbums() {
|
async loadAlbums() {
|
||||||
try {
|
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;
|
this.albums = res.data;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(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
|
* 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[] = [];
|
let data: IAlbum[] = [];
|
||||||
try {
|
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;
|
data = res.data;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw e;
|
throw e;
|
||||||
|
|
Loading…
Reference in New Issue