Add videos tab

pull/37/head
Varun Patil 2022-09-13 00:55:32 -07:00
parent 7c52b4f1d5
commit 06ea3401fa
10 changed files with 45 additions and 8 deletions

View File

@ -12,6 +12,7 @@ return [
] ]
], ],
['name' => 'page#favorites', 'url' => '/favorites', 'verb' => 'GET'], ['name' => 'page#favorites', 'url' => '/favorites', 'verb' => 'GET'],
['name' => 'page#videos', 'url' => '/videos', 'verb' => 'GET'],
// API // API
['name' => 'api#days', 'url' => '/api/days', 'verb' => 'GET'], ['name' => 'api#days', 'url' => '/api/days', 'verb' => 'GET'],

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -74,6 +74,11 @@ class ApiController extends Controller {
$transforms[] = array($this->timelineQuery, 'transformFavoriteFilter'); $transforms[] = array($this->timelineQuery, 'transformFavoriteFilter');
} }
// Filter only videos
if ($this->request->getParam('vid')) {
$transforms[] = array($this->timelineQuery, 'videoFilter');
}
return $transforms; return $transforms;
} }
@ -100,6 +105,7 @@ class ApiController extends Controller {
/** /**
* @NoAdminRequired * @NoAdminRequired
* @NoCSRFRequired
* *
* @return JSONResponse * @return JSONResponse
*/ */

View File

@ -77,4 +77,12 @@ class PageController extends Controller {
public function favorites() { public function favorites() {
return $this->main(); return $this->main();
} }
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function videos() {
return $this->main();
}
} }

View File

@ -8,7 +8,7 @@ use OCP\IDBConnection;
class TimelineQuery { class TimelineQuery {
use TimelineQueryDays; use TimelineQueryDays;
use TimelineQueryDay; use TimelineQueryDay;
use TimelineQueryFavorites; use TimelineQueryFilters;
protected IDBConnection $connection; protected IDBConnection $connection;

View File

@ -6,7 +6,7 @@ namespace OCA\Memories\Db;
use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\ITags; use OCP\ITags;
trait TimelineQueryFavorites { trait TimelineQueryFilters {
public function transformFavoriteFilter(IQueryBuilder $query, string $userId) { public function transformFavoriteFilter(IQueryBuilder $query, string $userId) {
// Inner join will filter only the favorites // Inner join will filter only the favorites
$query->innerJoin('m', 'vcategory_to_object', 'fvco', $query->expr()->eq('fvco.objid', 'm.fileid')); $query->innerJoin('m', 'vcategory_to_object', 'fvco', $query->expr()->eq('fvco.objid', 'm.fileid'));
@ -32,4 +32,8 @@ trait TimelineQueryFavorites {
$query->expr()->eq('vc.category', $query->createNamedParameter(ITags::TAG_FAVORITE)), $query->expr()->eq('vc.category', $query->createNamedParameter(ITags::TAG_FAVORITE)),
)); ));
} }
public function videoFilter(IQueryBuilder $query, string $userId) {
$query->andWhere($query->expr()->eq('m.isvideo', $query->createNamedParameter('1')));
}
} }

View File

@ -15,6 +15,10 @@
:title="t('favorites', 'Favorites')" :title="t('favorites', 'Favorites')"
icon="icon-favorite"> icon="icon-favorite">
</NcAppNavigationItem> </NcAppNavigationItem>
<NcAppNavigationItem :to="{name: 'videos'}"
:title="t('videos', 'Videos')"
icon="icon-video">
</NcAppNavigationItem>
</template> </template>
<template #footer> <template #footer>
<NcAppNavigationSettings :title="t('memories', 'Settings')"> <NcAppNavigationSettings :title="t('memories', 'Settings')">

View File

@ -378,6 +378,11 @@ export default class Timeline extends Mixins(GlobalMixin) {
query.set('fav', '1'); query.set('fav', '1');
} }
// Videos
if (this.$route.name === 'videos') {
query.set('vid', '1');
}
// Create query string and append to URL // Create query string and append to URL
const queryStr = query.toString(); const queryStr = query.toString();
if (queryStr) { if (queryStr) {

View File

@ -51,7 +51,7 @@
component: Timeline, component: Timeline,
name: 'timeline', name: 'timeline',
props: route => ({ props: route => ({
rootTitle: t('timeline', 'Timeline'), rootTitle: t('memories', 'Timeline'),
}), }),
}, },
@ -60,7 +60,7 @@
component: Timeline, component: Timeline,
name: 'folders', name: 'folders',
props: route => ({ props: route => ({
rootTitle: t('folders', 'Folders'), rootTitle: t('memories', 'Folders'),
}), }),
}, },
@ -69,7 +69,16 @@
component: Timeline, component: Timeline,
name: 'favorites', name: 'favorites',
props: route => ({ props: route => ({
rootTitle: t('favorites', 'Favorites'), rootTitle: t('memories', 'Favorites'),
}),
},
{
path: '/videos',
component: Timeline,
name: 'videos',
props: route => ({
rootTitle: t('memories', 'Videos'),
}), }),
}, },
], ],