Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions js/viewer-main.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

1,671 changes: 797 additions & 874 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"@cypress/browserify-preprocessor": "^3.0.2",
"@nextcloud/babel-config": "^1.0.0",
"@nextcloud/browserslist-config": "^2.2.0",
"@nextcloud/eslint-config": "^6.1.2",
"@nextcloud/eslint-config": "^7.0.2",
"@nextcloud/stylelint-config": "^2.1.2",
"@nextcloud/webpack-vue-config": "^4.3.2",
"babel-loader-exclude-node-modules-except": "^1.2.1",
Expand Down
6 changes: 2 additions & 4 deletions src/components/Audios.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
<!-- Plyr currently replaces the parent. Wrapping to prevent this
https://github.com/redxtech/vue-plyr/issues/259 -->
<div v-if="davPath">
<VuePlyr
ref="plyr"
<VuePlyr ref="plyr"
:options="options">
<audio
ref="audio"
<audio ref="audio"
:autoplay="active"
:src="davPath"
preload="metadata"
Expand Down
7 changes: 3 additions & 4 deletions src/components/Images.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
-->

<template>
<img
:class="{
<img :class="{
dragging,
loaded,
zoomed: zoomRatio !== 1
Expand Down Expand Up @@ -112,7 +111,7 @@ export default {
/**
* Manually retrieve the path and return its base64
*
* @returns {String}
* @return {string}
*/
async getBase64FromImage() {
const file = await axios.get(this.davPath)
Expand All @@ -123,7 +122,7 @@ export default {
* Handle zooming
*
* @param {Event} event the scroll event
* @returns {null}
* @return {null}
*/
updateZoom(event) {
event.stopPropagation()
Expand Down
6 changes: 2 additions & 4 deletions src/components/Videos.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@
<!-- Plyr currently replaces the parent. Wrapping to prevent this
https://github.com/redxtech/vue-plyr/issues/259 -->
<div v-if="davPath">
<VuePlyr
ref="plyr"
<VuePlyr ref="plyr"
:options="options"
:style="{
height: height + 'px',
width: width + 'px'
}">
<video
ref="video"
<video ref="video"
:autoplay="active"
:playsinline="true"
:poster="livePhotoPath"
Expand Down
11 changes: 7 additions & 4 deletions src/mixins/PreviewUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export default {
computed: {
/**
* Link to the preview path if the file have a preview
* @returns {string}
*
* @return {string}
*/
previewpath() {
return this.getPreviewIfAny({
Expand All @@ -41,7 +42,8 @@ export default {

/**
* Absolute dav remote path of the file
* @returns {string}
*
* @return {string}
*/
davPath() {
return getDavPath({
Expand All @@ -56,11 +58,12 @@ export default {
* Return the preview url if the file have an existing
* preview or the absolute dav remote path if none.
*
* @param {Object} data destructuring object
* @param {object} data destructuring object
* @param {string} data.fileid the file id
* @param {boolean} data.hasPreview have the file an existing preview ?
* @param {string} data.davPath the absolute dav path
* @returns {String} the absolute url
* @param data.filename
* @return {string} the absolute url
*/
getPreviewIfAny({ fileid, filename, hasPreview, davPath }) {
const searchParams = `fileId=${fileid}`
Expand Down
5 changes: 5 additions & 0 deletions src/models/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
*/
import { getDavPath } from '../utils/fileUtils'

/**
* @param fileInfo
* @param mime
* @param component
*/
export default function(fileInfo, mime, component) {
const data = {
mime,
Expand Down
6 changes: 3 additions & 3 deletions src/services/FileInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import { genFileInfo } from '../utils/fileUtils'
/**
* Retrieve the files list
*
* @param {String} path the path relative to the user root
* @param {Object} [options] optional options for axios
* @returns {Array} the file list
* @param {string} path the path relative to the user root
* @param {object} [options] optional options for axios
* @return {Array} the file list
*/
export default async function(path, options) {
const response = await client.stat(path, Object.assign({
Expand Down
6 changes: 3 additions & 3 deletions src/services/FileList.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import { genFileInfo } from '../utils/fileUtils'
/**
* Retrieve the files list
*
* @param {String} path the path relative to the user root
* @param {Object} [options] optional options for axios
* @returns {Array} the file list
* @param {string} path the path relative to the user root
* @param {object} [options] optional options for axios
* @return {Array} the file list
*/
export default async function(path, options) {
// getDirectoryContents doesn't accept / for root
Expand Down
8 changes: 8 additions & 0 deletions src/services/FilesActionHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

import { encodePath } from '@nextcloud/paths'

/**
* @param name
* @param context
*/
export default function(name, context) {
// replace potential leading double slashes
const path = `${context.dir}/${name}`.replace(/^\/\//, '/')
Expand All @@ -36,6 +40,10 @@ export default function(name, context) {
OCA.Viewer.open({ path, onPrev: pushToHistory, onNext: pushToHistory, onClose })
}

/**
* @param root0
* @param root0.fileid
*/
function pushToHistory({ fileid }) {
const params = OC.Util.History.parseUrlQuery()
const dir = params.dir
Expand Down
22 changes: 11 additions & 11 deletions src/services/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class Viewer {
* Register a new handler
*
* @memberof Viewer
* @param {Object} handler a new unregistered handler
* @param {object} handler a new unregistered handler
*/
registerHandler(handler) {
this._state.handlers.push(handler)
Expand All @@ -74,7 +74,7 @@ export default class Viewer {
* Get the current opened file
*
* @memberof Viewer
* @returns {string} the currently opened file
* @return {string} the currently opened file
*/
get file() {
return this._state.file
Expand All @@ -84,7 +84,7 @@ export default class Viewer {
* Get the current files list
*
* @memberof Viewer
* @returns {Object[]} the currently opened file
* @return {object[]} the currently opened file
*/
get files() {
return this._state.files
Expand All @@ -94,7 +94,7 @@ export default class Viewer {
* Get the supported mimetypes that can be opened with the viewer
*
* @memberof Viewer
* @returns {array} list of mimetype strings that the viewer can open
* @return {Array} list of mimetype strings that the viewer can open
*/
get mimetypes() {
return this._mimetypes
Expand All @@ -104,7 +104,7 @@ export default class Viewer {
* Return the method provided to fetch more results
*
* @memberof Viewer
* @returns {Function}
* @return {Function}
*/
get loadMore() {
return this._state.loadMore
Expand All @@ -114,7 +114,7 @@ export default class Viewer {
* Get the method to run on previous navigation
*
* @memberof Viewer
* @returns {Function}
* @return {Function}
*/
get onPrev() {
return this._state.onPrev
Expand All @@ -124,7 +124,7 @@ export default class Viewer {
* Get the method to run on next navigation
*
* @memberof Viewer
* @returns {Function}
* @return {Function}
*/
get onNext() {
return this._state.onNext
Expand All @@ -134,7 +134,7 @@ export default class Viewer {
* Get the method to run on viewer close
*
* @memberof Viewer
* @returns {Function}
* @return {Function}
*/
get onClose() {
return this._state.onClose
Expand All @@ -144,7 +144,7 @@ export default class Viewer {
* Is looping over the provided list allowed?
*
* @memberof Viewer
* @returns {boolean}
* @return {boolean}
*/
get canLoop() {
return this._state.canLoop
Expand All @@ -154,9 +154,9 @@ export default class Viewer {
* Open the path into the viewer
*
* @memberof Viewer
* @param {Object} options Options for opening the viewer
* @param {object} options Options for opening the viewer
* @param {string} options.path path of the file to open
* @param {Object[]} [options.list] the list of files as objects (fileinfo) format
* @param {object[]} [options.list] the list of files as objects (fileinfo) format
* @param {Function} options.loadMore callback for loading more files
* @param {boolean} options.canLoop can the viewer loop over the array
* @param {Function} options.onPrev callback when navigating back to previous file
Expand Down
6 changes: 3 additions & 3 deletions src/utils/CancelableRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import axios from '@nextcloud/axios'
/**
* Creates a cancelable axios 'request object'.
*
* @param {function} request the axios promise request
* @returns {Object}
* @param {Function} request the axios promise request
* @return {object}
*/
const CancelableRequest = function(request) {
/**
Expand All @@ -40,7 +40,7 @@ const CancelableRequest = function(request) {
* Execute the request
*
* @param {string} url the url to send the request to
* @param {Object} [options] optional config for the request
* @param {object} [options] optional config for the request
*/
const fetch = async function(url, options) {
return request(
Expand Down
23 changes: 13 additions & 10 deletions src/utils/fileUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import { isNumber } from './numberUtil'
/**
* Get an url encoded path
*
* @param {String} path the full path
* @returns {string} url encoded file path
* @param {string} path the full path
* @return {string} url encoded file path
*/
const encodeFilePath = function(path) {
const pathSections = (path.startsWith('/') ? path : `/${path}`).split('/')
Expand All @@ -46,8 +46,8 @@ const encodeFilePath = function(path) {
/**
* Extract dir and name from file path
*
* @param {String} path the full path
* @returns {String[]} [dirPath, fileName]
* @param {string} path the full path
* @return {string[]} [dirPath, fileName]
*/
const extractFilePaths = function(path) {
const pathSections = path.split('/')
Expand All @@ -59,11 +59,11 @@ const extractFilePaths = function(path) {
/**
* Sorting comparison function
*
* @param {Object} fileInfo1 file 1 fileinfo
* @param {Object} fileInfo2 file 2 fileinfo
* @param {object} fileInfo1 file 1 fileinfo
* @param {object} fileInfo2 file 2 fileinfo
* @param {string} key key to sort with
* @param {boolean} [asc=true] sort ascending?
* @returns {number}
* @return {number}
*/
const sortCompare = function(fileInfo1, fileInfo2, key, asc = true) {

Expand Down Expand Up @@ -95,8 +95,8 @@ const sortCompare = function(fileInfo1, fileInfo2, key, asc = true) {
* Generate a fileinfo object based on the full dav properties
* It will flatten everything and put all keys to camelCase
*
* @param {Object} obj the object
* @returns {Object}
* @param {object} obj the object
* @return {object}
*/
const genFileInfo = function(obj) {
const fileInfo = {}
Expand Down Expand Up @@ -125,8 +125,11 @@ const genFileInfo = function(obj) {

/**
* Generate absolute dav remote path of the file
*
* @param {object} fileInfo The fileInfo
* @returns {string}
* @param fileInfo.filename
* @param fileInfo.basename
* @return {string}
*/
const getDavPath = function({ filename, basename }) {
// TODO: allow proper dav access without the need of basic auth
Expand Down
Loading