Skip to content

Commit

Permalink
Merge pull request #477 from nextcloud/feature/implement-video-tab
Browse files Browse the repository at this point in the history
Implement "your videos" tab
  • Loading branch information
Mikescops authored Oct 14, 2020
2 parents f84e43a + 3f7ea97 commit 862110c
Show file tree
Hide file tree
Showing 25 changed files with 252 additions and 218 deletions.
1 change: 1 addition & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
return [
'routes' => [
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
['name' => 'page#index', 'url' => '/videos', 'verb' => 'GET', 'postfix' => 'videos'],
['name' => 'page#index', 'url' => '/favorites', 'verb' => 'GET', 'postfix' => 'favorites'],
['name' => 'page#index', 'url' => '/albums/{path}', 'verb' => 'GET', 'postfix' => 'albums',
'requirements' => [
Expand Down
12 changes: 6 additions & 6 deletions js/photos-0.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-0.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions js/photos-1.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-1.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-2.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-2.js.map

Large diffs are not rendered by default.

276 changes: 138 additions & 138 deletions js/photos-4.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-4.js.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions js/photos-5.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-5.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions js/photos-6.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-6.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions js/photos-7.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-7.js.map

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions js/photos-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-main.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@
class Application extends App implements IBootstrap {
public const APP_ID = 'photos';

public const MIMES = [
public const IMAGE_MIMES = [
'image/png',
'image/jpeg',
'image/heic',
// 'image/gif', // too rarely used for photos
// 'image/x-xbitmap', // too rarely used for photos
// 'image/bmp', // too rarely used for photos
// 'image/svg+xml', // too rarely used for photos
];

public const VIDEO_MIMES = [
// 'video/mpeg', // too rarely used for photos
// 'video/ogg', // too rarely used for photos
// 'video/webm', // too rarely used for photos
Expand Down
3 changes: 2 additions & 1 deletion lib/Controller/AlbumsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ private function scanCurrentFolder(Folder $folder, bool $shared): iterable {
}

private function validFile(File $file, bool $shared): bool {
if (in_array($file->getMimeType(), Application::MIMES) && $this->isShared($file) === $shared) {
$allowed_mimes = array_merge(Application::IMAGE_MIMES, Application::VIDEO_MIMES);
if (in_array($file->getMimeType(), $allowed_mimes) && $this->isShared($file) === $shared) {
return true;
}

Expand Down
3 changes: 2 additions & 1 deletion lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public function index(): TemplateResponse {
$this->eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar());
$this->eventDispatcher->dispatch(LoadViewer::class, new LoadViewer());

$this->initialStateService->provideInitialState($this->appName, 'mimes', Application::MIMES);
$this->initialStateService->provideInitialState($this->appName, 'image-mimes', Application::IMAGE_MIMES);
$this->initialStateService->provideInitialState($this->appName, 'video-mimes', Application::VIDEO_MIMES);
$this->initialStateService->provideInitialState($this->appName, 'maps', $this->appManager->isEnabledForUser('maps') === true);

Util::addScript($this->appName, 'photos-main');
Expand Down
1 change: 1 addition & 0 deletions src/Photos.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
:title="t('photos', 'Your photos')"
icon="icon-yourphotos"
exact />
<AppNavigationItem to="/videos" :title="t('photos', 'Your videos')" icon="icon-video" />
<AppNavigationItem to="/favorites" :title="t('photos', 'Favorites')" icon="icon-favorite" />
<AppNavigationItem :to="{name: 'albums'}" :title="t('photos', 'Your albums')" icon="icon-files-dark" />
<AppNavigationItem :to="{name: 'shared'}" :title="t('photos', 'Shared albums')" icon="icon-share" />
Expand Down
10 changes: 10 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import Router from 'vue-router'
import Vue from 'vue'

import isMapsInstalled from '../services/IsMapsInstalled'
import { videoMimes } from '../services/AllowedMimes'

const Albums = () => import('../views/Albums')
const Tags = () => import('../views/Tags')
Expand Down Expand Up @@ -77,6 +78,15 @@ export default new Router({
showShared: true,
}),
},
{
path: '/videos',
component: Timeline,
name: 'videos',
props: route => ({
rootTitle: t('photos', 'Your videos'),
mimesType: videoMimes,
}),
},
{
path: '/favorites',
component: Timeline,
Expand Down
7 changes: 5 additions & 2 deletions src/services/AllowedMimes.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@

import { loadState } from '@nextcloud/initial-state'

const mimes = loadState('photos', 'mimes')
export default mimes
const imageMimes = loadState('photos', 'image-mimes')
const videoMimes = loadState('photos', 'video-mimes')
const allMimes = [...imageMimes, ...videoMimes]

export { allMimes as default, allMimes, imageMimes, videoMimes }
6 changes: 4 additions & 2 deletions src/services/PhotoSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import { genFileInfo } from '../utils/fileUtils'
import { getCurrentUser } from '@nextcloud/auth'
import allowedMimes from './AllowedMimes'
import { allMimes } from './AllowedMimes'
import client from './DavClient'
import { props } from './DavRequest'
import { sizes } from '../assets/grid-sizes'
Expand All @@ -38,17 +38,19 @@ import { sizes } from '../assets/grid-sizes'
* @returns {Array} the file list
*/
export default async function(onlyFavorites = false, options = {}) {

// default function options
options = Object.assign({}, {
page: 0, // start at the first page
perPage: sizes.max.count * 10, // ten rows of the max width
mimesType: allMimes, // all mimes types
}, options)

const prefixPath = `/files/${getCurrentUser().uid}`

// generating the search or condition
// based on the allowed mimetypes
const orMime = allowedMimes.reduce((str, mime) => `${str}
const orMime = options.mimesType.reduce((str, mime) => `${str}
<d:eq>
<d:prop>
<d:getcontenttype/>
Expand Down
12 changes: 12 additions & 0 deletions src/views/Timeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import Loader from '../components/Loader'

import cancelableRequest from '../utils/CancelableRequest'
import GridConfigMixin from '../mixins/GridConfig'
import { allMimes } from '../services/AllowedMimes'

export default {
name: 'Timeline',
Expand All @@ -89,6 +90,10 @@ export default {
type: Boolean,
default: false,
},
mimesType: {
type: Array,
default: () => allMimes,
},
rootTitle: {
type: String,
required: true,
Expand Down Expand Up @@ -180,6 +185,11 @@ export default {
this.resetState()
this.getContent()
},
async mimesType() {
// reset component
this.resetState()
this.getContent()
},
},

beforeMount() {
Expand Down Expand Up @@ -224,6 +234,7 @@ export default {
const files = await request(this.onlyFavorites, {
page: this.page,
perPage: numberOfImagesPerBatch,
mimesType: this.mimesType,
})

// If we get less files than requested that means we got to the end
Expand Down Expand Up @@ -271,6 +282,7 @@ export default {
this.done = false
this.error = null
this.page = 0
this.lastSection = ''
this.$emit('update:loading', true)
this.$refs.virtualgrid.resetGrid()
},
Expand Down

0 comments on commit 862110c

Please sign in to comment.