diff options
Diffstat (limited to 'apps/files_sharing/js')
-rw-r--r-- | apps/files_sharing/js/app.js | 409 | ||||
-rw-r--r-- | apps/files_sharing/js/files_drop.js | 172 | ||||
-rw-r--r-- | apps/files_sharing/js/public.js | 517 | ||||
-rw-r--r-- | apps/files_sharing/js/public_note.js | 31 | ||||
-rw-r--r-- | apps/files_sharing/js/sharedfilelist.js | 541 | ||||
-rw-r--r-- | apps/files_sharing/js/templates.js | 43 | ||||
-rw-r--r-- | apps/files_sharing/js/templates/files_drop.handlebars | 8 |
7 files changed, 0 insertions, 1721 deletions
diff --git a/apps/files_sharing/js/app.js b/apps/files_sharing/js/app.js deleted file mode 100644 index b9a60c73dab..00000000000 --- a/apps/files_sharing/js/app.js +++ /dev/null @@ -1,409 +0,0 @@ -/** - * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com> - * - * This file is licensed under the Affero General Public License version 3 - * or later. - * - * See the COPYING-README file. - * - */ - -if (!OCA.Sharing) { - /** - * @namespace OCA.Sharing - */ - OCA.Sharing = {} -} - -/** - * @namespace - */ -OCA.Sharing.App = { - - _inFileList: null, - _outFileList: null, - _overviewFileList: null, - _pendingFileList: null, - - initSharingIn($el) { - if (this._inFileList) { - return this._inFileList - } - - this._inFileList = new OCA.Sharing.FileList( - $el, - { - id: 'shares.self', - sharedWithUser: true, - fileActions: this._createFileActions(), - config: OCA.Files.App.getFilesConfig(), - // The file list is created when a "show" event is handled, so - // it should be marked as "shown" like it would have been done - // if handling the event with the file list already created. - shown: true, - } - ) - - this._extendFileList(this._inFileList) - this._inFileList.appName = t('files_sharing', 'Shared with you') - this._inFileList.$el.find('.emptyfilelist.emptycontent').html('<div class="icon-shared"></div>' - + '<h2>' + t('files_sharing', 'Nothing shared with you yet') + '</h2>' - + '<p>' + t('files_sharing', 'Files and folders others share with you will show up here') + '</p>') - return this._inFileList - }, - - initSharingOut($el) { - if (this._outFileList) { - return this._outFileList - } - this._outFileList = new OCA.Sharing.FileList( - $el, - { - id: 'shares.others', - sharedWithUser: false, - fileActions: this._createFileActions(), - config: OCA.Files.App.getFilesConfig(), - // The file list is created when a "show" event is handled, so - // it should be marked as "shown" like it would have been done - // if handling the event with the file list already created. - shown: true, - } - ) - - this._extendFileList(this._outFileList) - this._outFileList.appName = t('files_sharing', 'Shared with others') - this._outFileList.$el.find('.emptyfilelist.emptycontent').html('<div class="icon-shared"></div>' - + '<h2>' + t('files_sharing', 'Nothing shared yet') + '</h2>' - + '<p>' + t('files_sharing', 'Files and folders you share will show up here') + '</p>') - return this._outFileList - }, - - initSharingLinks($el) { - if (this._linkFileList) { - return this._linkFileList - } - this._linkFileList = new OCA.Sharing.FileList( - $el, - { - id: 'shares.link', - linksOnly: true, - fileActions: this._createFileActions(), - config: OCA.Files.App.getFilesConfig(), - // The file list is created when a "show" event is handled, so - // it should be marked as "shown" like it would have been done - // if handling the event with the file list already created. - shown: true, - } - ) - - this._extendFileList(this._linkFileList) - this._linkFileList.appName = t('files_sharing', 'Shared by link') - this._linkFileList.$el.find('.emptyfilelist.emptycontent').html('<div class="icon-public"></div>' - + '<h2>' + t('files_sharing', 'No shared links') + '</h2>' - + '<p>' + t('files_sharing', 'Files and folders you share by link will show up here') + '</p>') - return this._linkFileList - }, - - initSharingDeleted($el) { - if (this._deletedFileList) { - return this._deletedFileList - } - this._deletedFileList = new OCA.Sharing.FileList( - $el, - { - id: 'shares.deleted', - defaultFileActionsDisabled: true, - showDeleted: true, - sharedWithUser: true, - fileActions: this._restoreShareAction(), - config: OCA.Files.App.getFilesConfig(), - // The file list is created when a "show" event is handled, so - // it should be marked as "shown" like it would have been done - // if handling the event with the file list already created. - shown: true, - } - ) - - this._extendFileList(this._deletedFileList) - this._deletedFileList.appName = t('files_sharing', 'Deleted shares') - this._deletedFileList.$el.find('.emptyfilelist.emptycontent').html('<div class="icon-share"></div>' - + '<h2>' + t('files_sharing', 'No deleted shares') + '</h2>' - + '<p>' + t('files_sharing', 'Shares you deleted will show up here') + '</p>') - return this._deletedFileList - }, - - initSharingPening($el) { - if (this._pendingFileList) { - return this._pendingFileList - } - this._pendingFileList = new OCA.Sharing.FileList( - $el, - { - id: 'shares.pending', - showPending: true, - detailsViewEnabled: false, - defaultFileActionsDisabled: true, - sharedWithUser: true, - fileActions: this._acceptShareAction(), - config: OCA.Files.App.getFilesConfig(), - // The file list is created when a "show" event is handled, so - // it should be marked as "shown" like it would have been done - // if handling the event with the file list already created. - shown: true, - } - ) - - this._extendFileList(this._pendingFileList) - this._pendingFileList.appName = t('files_sharing', 'Pending shares') - this._pendingFileList.$el.find('.emptyfilelist.emptycontent').html('<div class="icon-share"></div>' - + '<h2>' + t('files_sharing', 'No pending shares') + '</h2>' - + '<p>' + t('files_sharing', 'Shares you have received but not confirmed will show up here') + '</p>') - return this._pendingFileList - }, - - initShareingOverview($el) { - if (this._overviewFileList) { - return this._overviewFileList - } - this._overviewFileList = new OCA.Sharing.FileList( - $el, - { - id: 'shares.overview', - fileActions: this._createFileActions(), - config: OCA.Files.App.getFilesConfig(), - isOverview: true, - // The file list is created when a "show" event is handled, so - // it should be marked as "shown" like it would have been done - // if handling the event with the file list already created. - shown: true, - } - ) - - this._extendFileList(this._overviewFileList) - this._overviewFileList.appName = t('files_sharing', 'Shares') - this._overviewFileList.$el.find('.emptyfilelist.emptycontent').html('<div class="icon-share"></div>' - + '<h2>' + t('files_sharing', 'No shares') + '</h2>' - + '<p>' + t('files_sharing', 'Shares will show up here') + '</p>') - return this._overviewFileList - }, - - removeSharingIn() { - if (this._inFileList) { - this._inFileList.$fileList.empty() - } - }, - - removeSharingOut() { - if (this._outFileList) { - this._outFileList.$fileList.empty() - } - }, - - removeSharingLinks() { - if (this._linkFileList) { - this._linkFileList.$fileList.empty() - } - }, - - removeSharingDeleted() { - if (this._deletedFileList) { - this._deletedFileList.$fileList.empty() - } - }, - - removeSharingPending() { - if (this._pendingFileList) { - this._pendingFileList.$fileList.empty() - } - }, - - removeSharingOverview() { - if (this._overviewFileList) { - this._overviewFileList.$fileList.empty() - } - }, - - /** - * Destroy the app - */ - destroy() { - OCA.Files.fileActions.off('setDefault.app-sharing', this._onActionsUpdated) - OCA.Files.fileActions.off('registerAction.app-sharing', this._onActionsUpdated) - this.removeSharingIn() - this.removeSharingOut() - this.removeSharingLinks() - this._inFileList = null - this._outFileList = null - this._linkFileList = null - this._overviewFileList = null - delete this._globalActionsInitialized - }, - - _createFileActions() { - // inherit file actions from the files app - const fileActions = new OCA.Files.FileActions() - // note: not merging the legacy actions because legacy apps are not - // compatible with the sharing overview and need to be adapted first - fileActions.registerDefaultActions() - fileActions.merge(OCA.Files.fileActions) - - if (!this._globalActionsInitialized) { - // in case actions are registered later - this._onActionsUpdated = _.bind(this._onActionsUpdated, this) - OCA.Files.fileActions.on('setDefault.app-sharing', this._onActionsUpdated) - OCA.Files.fileActions.on('registerAction.app-sharing', this._onActionsUpdated) - this._globalActionsInitialized = true - } - - // when the user clicks on a folder, redirect to the corresponding - // folder in the files app instead of opening it directly - fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function(filename, context) { - OCA.Files.App.setActiveView('files', { silent: true }) - OCA.Files.App.fileList.changeDirectory(OC.joinPaths(context.$file.attr('data-path'), filename), true, true) - }) - fileActions.setDefault('dir', 'Open') - return fileActions - }, - - _restoreShareAction() { - const fileActions = new OCA.Files.FileActions() - fileActions.registerAction({ - name: 'Restore', - displayName: t('files_sharing', 'Restore'), - altText: t('files_sharing', 'Restore share'), - mime: 'all', - permissions: OC.PERMISSION_ALL, - iconClass: 'icon-history', - type: OCA.Files.FileActions.TYPE_INLINE, - actionHandler(fileName, context) { - const shareId = context.$file.data('shareId') - $.post(OC.linkToOCS('apps/files_sharing/api/v1/deletedshares', 2) + shareId) - .success(function(result) { - context.fileList.remove(context.fileInfoModel.attributes.name) - }).fail(function() { - OC.Notification.showTemporary(t('files_sharing', 'Something happened. Unable to restore the share.')) - }) - }, - }) - return fileActions - }, - - _acceptShareAction() { - const fileActions = new OCA.Files.FileActions() - fileActions.registerAction({ - name: 'Accept share', - displayName: t('files_sharing', 'Accept share'), - mime: 'all', - permissions: OC.PERMISSION_ALL, - iconClass: 'icon-checkmark', - type: OCA.Files.FileActions.TYPE_INLINE, - actionHandler(fileName, context) { - const shareId = context.$file.data('shareId') - let shareBase = 'shares/pending' - if (context.$file.attr('data-remote-id')) { - shareBase = 'remote_shares/pending' - } - $.post(OC.linkToOCS('apps/files_sharing/api/v1/' + shareBase, 2) + shareId) - .success(function(result) { - context.fileList.remove(context.fileInfoModel.attributes.name) - }).fail(function() { - OC.Notification.showTemporary(t('files_sharing', 'Something happened. Unable to accept the share.')) - }) - }, - }) - fileActions.registerAction({ - name: 'Reject share', - displayName: t('files_sharing', 'Reject share'), - mime: 'all', - permissions: OC.PERMISSION_ALL, - iconClass: 'icon-close', - type: OCA.Files.FileActions.TYPE_INLINE, - shouldRender(context) { - // disable rejecting group shares from the pending list because they anyway - // land back into that same list - if (context.$file.attr('data-remote-id') && parseInt(context.$file.attr('data-share-type'), 10) === OC.Share.SHARE_TYPE_REMOTE_GROUP) { - return false - } - return true - }, - actionHandler(fileName, context) { - const shareId = context.$file.data('shareId') - let shareBase = 'shares' - if (context.$file.attr('data-remote-id')) { - shareBase = 'remote_shares' - } - - $.ajax({ - url: OC.linkToOCS('apps/files_sharing/api/v1/' + shareBase, 2) + shareId, - type: 'DELETE', - }).success(function(result) { - context.fileList.remove(context.fileInfoModel.attributes.name) - }).fail(function() { - OC.Notification.showTemporary(t('files_sharing', 'Something happened. Unable to reject the share.')) - }) - }, - }) - return fileActions - }, - - _onActionsUpdated(ev) { - _.each([this._inFileList, this._outFileList, this._linkFileList], function(list) { - if (!list) { - return - } - - if (ev.action) { - list.fileActions.registerAction(ev.action) - } else if (ev.defaultAction) { - list.fileActions.setDefault( - ev.defaultAction.mime, - ev.defaultAction.name - ) - } - }) - }, - - _extendFileList(fileList) { - // remove size column from summary - fileList.fileSummary.$el.find('.filesize').remove() - }, -} - -window.addEventListener('DOMContentLoaded', function() { - $('#app-content-sharingin').on('show', function(e) { - OCA.Sharing.App.initSharingIn($(e.target)) - }) - $('#app-content-sharingin').on('hide', function() { - OCA.Sharing.App.removeSharingIn() - }) - $('#app-content-sharingout').on('show', function(e) { - OCA.Sharing.App.initSharingOut($(e.target)) - }) - $('#app-content-sharingout').on('hide', function() { - OCA.Sharing.App.removeSharingOut() - }) - $('#app-content-sharinglinks').on('show', function(e) { - OCA.Sharing.App.initSharingLinks($(e.target)) - }) - $('#app-content-sharinglinks').on('hide', function() { - OCA.Sharing.App.removeSharingLinks() - }) - $('#app-content-deletedshares').on('show', function(e) { - OCA.Sharing.App.initSharingDeleted($(e.target)) - }) - $('#app-content-deletedshares').on('hide', function() { - OCA.Sharing.App.removeSharingDeleted() - }) - $('#app-content-pendingshares').on('show', function(e) { - OCA.Sharing.App.initSharingPening($(e.target)) - }) - $('#app-content-pendingshares').on('hide', function() { - OCA.Sharing.App.removeSharingPending() - }) - $('#app-content-shareoverview').on('show', function(e) { - OCA.Sharing.App.initShareingOverview($(e.target)) - }) - $('#app-content-shareoverview').on('hide', function() { - OCA.Sharing.App.removeSharingOverview() - }) -}) diff --git a/apps/files_sharing/js/files_drop.js b/apps/files_sharing/js/files_drop.js deleted file mode 100644 index ffbe8284433..00000000000 --- a/apps/files_sharing/js/files_drop.js +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> - * - * This file is licensed under the Affero General Public License version 3 - * or later. - * - * See the COPYING-README file. - * - */ - -(function ($) { - - var Drop = { - /** @type {Function} **/ - _template: undefined, - - /** @type {boolean} */ - _uploading: false, - - addFileToUpload: function(e, data) { - var errors = []; - var output = this.template(); - - var filesClient = new OC.Files.Client({ - host: OC.getHost(), - port: OC.getPort(), - userName: $('#sharingToken').val(), - // note: password not be required, the endpoint - // will recognize previous validation from the session - root: OC.getRootPath() + '/public.php/webdav', - useHTTPS: OC.getProtocol() === 'https' - }); - - // We only process one file at a time 🤷♀️ - var name = data.files[0].name; - // removing unwanted characters - name = name.replace(/["'#%`]/gm, ''); - - try { - // FIXME: not so elegant... need to refactor that method to return a value - Files.isFileNameValid(name); - } - catch (errorMessage) { - OC.Notification.show(errorMessage, {type: 'error'}); - return false; - } - var base = OC.getProtocol() + '://' + OC.getHost(); - data.url = base + OC.getRootPath() + '/public.php/webdav/' + encodeURI(name); - - data.multipart = false; - - if (!data.headers) { - data.headers = {}; - } - - var userName = filesClient.getUserName(); - var password = filesClient.getPassword(); - if (userName) { - // copy username/password from DAV client - data.headers['Authorization'] = - 'Basic ' + btoa(userName + ':' + (password || '')); - } - - $('#drop-upload-done-indicator').addClass('hidden'); - $('#drop-upload-progress-indicator').removeClass('hidden'); - - $('#drop-uploaded-files').append(output({isUploading: true, name: data.files[0].name})); - data.submit(); - - return true; - }, - - updateFileItem: function (fileName, fileItem) { - $('#drop-uploaded-files li[data-name="' + fileName + '"]').replaceWith(fileItem); - }, - - initialize: function () { - $(document).bind('drop dragover', function (e) { - // Prevent the default browser drop action: - e.preventDefault(); - }); - var output = this.template(); - var self = this; - $('#public-upload').fileupload({ - type: 'PUT', - dropZone: $('#public-upload'), - sequentialUploads: true, - start: function(e) { - self._uploading = true; - }, - stop: function(e) { - self._uploading = false; - }, - add: function(e, data) { - Drop.addFileToUpload(e, data); - $('#drop-upload-status').text(t('files_sharing', 'Waiting…')); - //we return true to keep trying to upload next file even - //if addFileToUpload did not like the previous one - return true; - }, - done: function(e, data) { - // Created - var mimeTypeUrl = OC.MimeType.getIconUrl(data.files[0].type); - var fileItem = output({isUploading: false, iconSrc: mimeTypeUrl, name: data.files[0].name}); - Drop.updateFileItem(data.files[0].name, fileItem); - }, - fail: function(e, data) { - OC.Notification.showTemporary(OC.L10N.translate( - 'files_sharing', - 'Could not upload "{filename}"', - {filename: data.files[0].name} - )); - $('#drop-upload-status').text(t('files_sharing', 'error')); - var errorIconSrc = OC.imagePath('core', 'actions/error.svg'); - var fileItem = output({isUploading: false, iconSrc: errorIconSrc, name: data.files[0].name}); - Drop.updateFileItem(data.files[0].name, fileItem); - }, - progressall: function (e, data) { - var progress = parseInt(data.loaded / data.total * 100, 10); - if(progress === 100) { - $('#drop-upload-done-indicator').removeClass('hidden'); - $('#drop-upload-progress-indicator').addClass('hidden'); - } else { - $('#drop-upload-done-indicator').addClass('hidden'); - $('#drop-upload-progress-indicator').removeClass('hidden'); - } - }, - progress: function (e, data) { - var progress = parseInt(data.loaded / data.total * 100, 10); - if(progress === 100) { - $('#drop-upload-progress-bar').val(100); - $('#drop-upload-status').text(t('files_sharing', 'finished')); - } else { - $('#drop-upload-progress-bar').val(progress); - $('#drop-upload-status').text(progress + '%'); - } - }, - }); - $('#public-upload .button.icon-upload').click(function(e) { - e.preventDefault(); - $('#public-upload .emptycontent input').focus().trigger('click'); - }); - window.onbeforeunload = function() { - return self.confirmBeforeUnload(); - } - }, - - /** - * @returns {Function} from Handlebars - * @private - */ - template: function () { - return OCA.Sharing.Templates['files_drop']; - }, - - confirmBeforeUnload: function() { - if (this._uploading) { - return t('files', 'This will stop your current uploads.') - } - }, - }; - - OCA.FilesSharingDrop = Drop; - - window.addEventListener('DOMContentLoaded', function() { - if($('#upload-only-interface').val() === "1") { - $('.avatardiv').avatar($('#sharingUserId').val(), 128, true); - } - - OCA.FilesSharingDrop.initialize(); - }); -})(jQuery); diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js deleted file mode 100644 index 128875ba6ab..00000000000 --- a/apps/files_sharing/js/public.js +++ /dev/null @@ -1,517 +0,0 @@ -/* - * Copyright (c) 2014 - * @copyright Copyright (c) 2016, Björn Schießle <bjoern@schiessle.org> - * - * This file is licensed under the Affero General Public License version 3 - * or later. - * - * See the COPYING-README file. - * - */ - -/* global FileActions, Files, FileList */ -/* global dragOptions, folderDropOptions */ -if (!OCA.Sharing) { - OCA.Sharing = {}; -} -if (!OCA.Files) { - OCA.Files = {}; -} -/** - * @namespace - */ -OCA.Sharing.PublicApp = { - _initialized: false, - - /** - * Initializes the public share app. - * - * @param $el container - */ - initialize: function ($el) { - var self = this; - var fileActions; - if (this._initialized) { - return; - } - fileActions = new OCA.Files.FileActions(); - // default actions - fileActions.registerDefaultActions(); - // regular actions - fileActions.merge(OCA.Files.fileActions); - - // in case apps would decide to register file actions later, - // replace the global object with this one - OCA.Files.fileActions = fileActions; - - this._initialized = true; - var urlParams = OC.Util.History.parseUrlQuery(); - this.initialDir = urlParams.path || '/'; - - var token = $('#sharingToken').val(); - var hideDownload = $('#hideDownload').val(); - - // Prevent all right-click options if hideDownload is enabled - if (hideDownload === 'true') { - window.oncontextmenu = function(event) { - event.preventDefault(); - event.stopPropagation(); - return false; - }; - } - - // file list mode ? - if ($el.find('.files-filestable').length) { - // Toggle for grid view - this.$showGridView = $('input#showgridview'); - this.$showGridView.on('change', _.bind(this._onGridviewChange, this)); - - var filesClient = new OC.Files.Client({ - host: OC.getHost(), - port: OC.getPort(), - userName: token, - // note: password not be required, the endpoint - // will recognize previous validation from the session - root: OC.getRootPath() + '/public.php/webdav', - useHTTPS: OC.getProtocol() === 'https' - }); - - this.fileList = new OCA.Files.FileList( - $el, - { - id: 'files.public', - dragOptions: dragOptions, - folderDropOptions: folderDropOptions, - fileActions: fileActions, - detailsViewEnabled: false, - filesClient: filesClient, - enableUpload: true, - multiSelectMenu: [ - { - name: 'copyMove', - displayName: t('files', 'Move or copy'), - iconClass: 'icon-external', - }, - { - name: 'download', - displayName: t('files', 'Download'), - iconClass: 'icon-download', - }, - { - name: 'delete', - displayName: t('files', 'Delete'), - iconClass: 'icon-delete', - } - ] - } - ); - if (hideDownload === 'true') { - this.fileList._allowSelection = false; - } - this.files = OCA.Files.Files; - this.files.initialize(); - // TODO: move to PublicFileList.initialize() once - // the code was split into a separate class - OC.Plugins.attach('OCA.Sharing.PublicFileList', this.fileList); - } - - var mimetype = $('#mimetype').val(); - var mimetypeIcon = $('#mimetypeIcon').val(); - mimetypeIcon = mimetypeIcon.substring(0, mimetypeIcon.length - 3); - mimetypeIcon = mimetypeIcon + 'svg'; - - var previewSupported = $('#previewSupported').val(); - - if (typeof FileActions !== 'undefined') { - // Show file preview if previewer is available, images are already handled by the template - if (mimetype.substr(0, mimetype.indexOf('/')) !== 'image' && $('.publicpreview').length === 0) { - // Trigger default action if not download TODO - var spec = FileActions.getDefaultFileAction(mimetype, 'file', OC.PERMISSION_READ); - if (spec && spec.action) { - spec.action($('#filename').val()); - } - } - } - - // dynamically load image previews - var bottomMargin = 350; - var previewWidth = $(window).width(); - var previewHeight = $(window).height() - bottomMargin; - previewHeight = Math.max(200, previewHeight); - var params = { - x: Math.ceil(previewWidth * window.devicePixelRatio), - y: Math.ceil(previewHeight * window.devicePixelRatio), - a: 'true', - file: encodeURIComponent(this.initialDir + $('#filename').val()), - scalingup: 0 - }; - - var imgcontainer = $('<img class="publicpreview" alt="">'); - if (hideDownload === 'false') { - imgcontainer = $('<a href="' + $('#previewURL').val() + '" target="_blank"></a>').append(imgcontainer); - } - var img = imgcontainer.hasClass('publicpreview')? imgcontainer: imgcontainer.find('.publicpreview'); - img.css({ - 'max-width': previewWidth, - 'max-height': previewHeight - }); - - if (OCA.Viewer && OCA.Viewer.mimetypes.includes(mimetype) - && (mimetype.startsWith('image/') || mimetype.startsWith('video/') || mimetype.startsWith('audio'))) { - OCA.Viewer.setRootElement('#imgframe') - OCA.Viewer.open({ path: '/' }) - } else if (mimetype.substr(0, mimetype.indexOf('/')) === 'text' && window.btoa) { - if (OC.appswebroots['files_texteditor'] !== undefined || - OC.appswebroots['text'] !== undefined) { - // the text editor handles the previewing - return; - } - // Undocumented Url to public WebDAV endpoint - var url = parent.location.protocol + '//' + location.host + OC.linkTo('', 'public.php/webdav'); - $.ajax({ - url: url, - headers: { - Authorization: 'Basic ' + btoa(token + ':'), - Range: 'bytes=0-10000' - } - }).then(function (data) { - self._showTextPreview(data, previewHeight); - }); - } else if ((previewSupported === 'true' && mimetype.substr(0, mimetype.indexOf('/')) !== 'video') || - mimetype.substr(0, mimetype.indexOf('/')) === 'image' && - mimetype !== 'image/svg+xml') { - img.attr('src', OC.generateUrl('/apps/files_sharing/publicpreview/' + token + '?' + OC.buildQueryString(params))); - imgcontainer.appendTo('#imgframe'); - } else if (mimetype.substr(0, mimetype.indexOf('/')) !== 'video') { - img.attr('src', mimetypeIcon); - img.attr('width', 128); - // "#imgframe" is either empty or it contains an audio preview that - // the icon should appear before, so the container should be - // prepended to the frame. - imgcontainer.prependTo('#imgframe'); - } else if (previewSupported === 'true') { - $('#imgframe > video').attr('poster', OC.generateUrl('/apps/files_sharing/publicpreview/' + token + '?' + OC.buildQueryString(params))); - } - - if (this.fileList) { - // TODO: move this to a separate PublicFileList class that extends OCA.Files.FileList (+ unit tests) - this.fileList.getDownloadUrl = function (filename, dir, isDir) { - var path = dir || this.getCurrentDirectory(); - if (_.isArray(filename)) { - filename = JSON.stringify(filename); - } - var params = { - path: path - }; - if (filename) { - params.files = filename; - } - return OC.generateUrl('/s/' + token + '/download') + '?' + OC.buildQueryString(params); - }; - - this.fileList._createRow = function(fileData) { - var $tr = OCA.Files.FileList.prototype._createRow.apply(this, arguments); - if (hideDownload === 'true') { - this.fileActions.currentFile = $tr.find('td'); - - // Remove the link. This means that files without a default action fail hard - $tr.find('a.name').attr('href', '#'); - - this.fileActions.actions.all = {}; - } - return $tr; - }; - - this.fileList.isSelectedDownloadable = function () { - return hideDownload !== 'true'; - }; - - this.fileList.getUploadUrl = function(fileName, dir) { - if (_.isUndefined(dir)) { - dir = this.getCurrentDirectory(); - } - - var pathSections = dir.split('/'); - if (!_.isUndefined(fileName)) { - pathSections.push(fileName); - } - var encodedPath = ''; - _.each(pathSections, function(section) { - if (section !== '') { - encodedPath += '/' + encodeURIComponent(section); - } - }); - var base = ''; - - if (!this._uploader.isXHRUpload()) { - // also add auth in URL due to POST workaround - base = OC.getProtocol() + '://' + token + '@' + OC.getHost() + (OC.getPort() ? ':' + OC.getPort() : ''); - } - return base + OC.getRootPath() + '/public.php/webdav' + encodedPath; - }; - - this.fileList.getAjaxUrl = function (action, params) { - params = params || {}; - params.t = token; - return OC.filePath('files_sharing', 'ajax', action + '.php') + '?' + OC.buildQueryString(params); - }; - - this.fileList.linkTo = function (dir) { - return OC.generateUrl('/s/' + token + '') + '?' + OC.buildQueryString({path: dir}); - }; - - this.fileList.generatePreviewUrl = function (urlSpec) { - urlSpec = urlSpec || {}; - if (!urlSpec.x) { - urlSpec.x = this.$table.data('preview-x') || 250; - } - if (!urlSpec.y) { - urlSpec.y = this.$table.data('preview-y') || 250; - } - urlSpec.x *= window.devicePixelRatio; - urlSpec.y *= window.devicePixelRatio; - urlSpec.x = Math.ceil(urlSpec.x); - urlSpec.y = Math.ceil(urlSpec.y); - var token = $('#dirToken').val(); - return OC.generateUrl('/apps/files_sharing/publicpreview/' + token + '?' + OC.buildQueryString(urlSpec)); - }; - - this.fileList.updateEmptyContent = function() { - this.$el.find('.emptycontent .uploadmessage').text( - t('files_sharing', 'You can upload into this folder') - ); - OCA.Files.FileList.prototype.updateEmptyContent.apply(this, arguments); - }; - - this.fileList._uploader.on('fileuploadadd', function(e, data) { - if (!data.headers) { - data.headers = {}; - } - - data.headers.Authorization = 'Basic ' + btoa(token + ':'); - }); - - // do not allow sharing from the public page - delete this.fileList.fileActions.actions.all.Share; - - this.fileList.changeDirectory(this.initialDir || '/', false, true); - - // URL history handling - this.fileList.$el.on('changeDirectory', _.bind(this._onDirectoryChanged, this)); - OC.Util.History.addOnPopStateHandler(_.bind(this._onUrlChanged, this)); - - $('#download').click(function (e) { - e.preventDefault(); - OC.redirect(FileList.getDownloadUrl()); - }); - - if (hideDownload === 'true') { - this.fileList.$el.find('.summary').find('td:first-child').remove(); - } - } - - $(document).on('click', '#directLink', function () { - $(this).focus(); - $(this).select(); - }); - - $('.save-form').submit(function (event) { - event.preventDefault(); - - var remote = $(this).find('#remote_address').val(); - var token = $('#sharingToken').val(); - var owner = $('#save-external-share').data('owner'); - var ownerDisplayName = $('#save-external-share').data('owner-display-name'); - var name = $('#save-external-share').data('name'); - var isProtected = $('#save-external-share').data('protected') ? 1 : 0; - OCA.Sharing.PublicApp._createFederatedShare(remote, token, owner, ownerDisplayName, name, isProtected); - }); - - $('#remote_address').on("keyup paste", function() { - if ($(this).val() === '' || $('#save-external-share > .icon.icon-loading-small').length > 0) { - $('#save-button-confirm').prop('disabled', true); - } else { - $('#save-button-confirm').prop('disabled', false); - } - }); - - self._bindShowTermsAction(); - - // legacy - window.FileList = this.fileList; - }, - - /** - * Binds the click action for the "terms of service" action. - * Shows an OC info dialog on click. - * - * @private - */ - _bindShowTermsAction: function() { - $('#show-terms-dialog').on('click', function() { - OC.dialogs.info($('#disclaimerText').val(), t('files_sharing', 'Terms of service')); - }); - }, - - _showTextPreview: function (data, previewHeight) { - var textDiv = $('<div></div>').addClass('text-preview'); - textDiv.text(data); - textDiv.appendTo('#imgframe'); - var divHeight = textDiv.height(); - if (data.length > 999) { - var ellipsis = $('<div></div>').addClass('ellipsis'); - ellipsis.html('(…)'); - ellipsis.appendTo('#imgframe'); - } - if (divHeight > previewHeight) { - textDiv.height(previewHeight); - } - }, - - /** - * Toggle showing gridview by default or not - * - * @returns {undefined} - */ - _onGridviewChange: function() { - const isGridView = this.$showGridView.is(':checked'); - this.$showGridView.next('#view-toggle') - .removeClass('icon-toggle-filelist icon-toggle-pictures') - .addClass(isGridView ? 'icon-toggle-filelist' : 'icon-toggle-pictures') - this.$showGridView.next('#view-toggle').attr( - 'title', - isGridView ? t('files', 'Show list view') : t('files', 'Show grid view'), - ) - - if (this.fileList) { - this.fileList.setGridView(isGridView); - } - }, - - _onDirectoryChanged: function (e) { - OC.Util.History.pushState({ - // arghhhh, why is this not called "dir" !? - path: e.dir - }); - }, - - _onUrlChanged: function (params) { - this.fileList.changeDirectory(params.path || params.dir, false, true); - }, - - - /** - * fall back to old behaviour where we redirect the user to his server to mount - * the public link instead of creating a dedicated federated share - * - * @param {any} remote - - * @param {any} token - - * @param {any} owner - - * @param {any} ownerDisplayName - - * @param {any} name - - * @param {any} isProtected - - * @private - */ - _legacyCreateFederatedShare: function (remote, token, owner, ownerDisplayName, name, isProtected) { - - var self = this; - var location = window.location.protocol + '//' + window.location.host + OC.getRootPath(); - - if(remote.substr(-1) !== '/') { - remote += '/' - } - - var url = remote + 'index.php/apps/files#' + 'remote=' + encodeURIComponent(location) // our location is the remote for the other server - + "&token=" + encodeURIComponent(token) + "&owner=" + encodeURIComponent(owner) +"&ownerDisplayName=" + encodeURIComponent(ownerDisplayName) + "&name=" + encodeURIComponent(name) + "&protected=" + isProtected; - - - if (remote.indexOf('://') > 0) { - OC.redirect(url); - } else { - // if no protocol is specified, we automatically detect it by testing https and http - // this check needs to happen on the server due to the Content Security Policy directive - $.get(OC.generateUrl('apps/files_sharing/testremote'), {remote: remote}).then(function (protocol) { - if (protocol !== 'http' && protocol !== 'https') { - self._toggleLoading(); - OC.dialogs.alert(t('files_sharing', 'No compatible server found at {remote}', {remote: remote}), - t('files_sharing', 'Invalid server URL')); - } else { - OC.redirect(protocol + '://' + url); - } - }); - } - }, - - _toggleLoading: function() { - var loading = $('#save-external-share > .icon.icon-loading-small').length === 0; - if (loading) { - $('#save-external-share > .icon-external') - .removeClass("icon-external") - .addClass("icon-loading-small"); - $('#save-external-share #save-button-confirm').prop("disabled", true); - - } else { - $('#save-external-share > .icon-loading-small') - .addClass("icon-external") - .removeClass("icon-loading-small"); - $('#save-external-share #save-button-confirm').prop("disabled", false); - - } - }, - - _createFederatedShare: function (remote, token, owner, ownerDisplayName, name, isProtected) { - var self = this; - - this._toggleLoading(); - - if (remote.indexOf('@') === -1) { - this._legacyCreateFederatedShare(remote, token, owner, ownerDisplayName, name, isProtected); - return; - } - - $.post( - OC.generateUrl('/apps/federatedfilesharing/createFederatedShare'), - { - 'shareWith': remote, - 'token': token - } - ).done( - function (data) { - var url = data.remoteUrl; - - if (url.indexOf('://') > 0) { - OC.redirect(url); - } else { - OC.redirect('http://' + url); - } - } - ).fail( - function (jqXHR) { - OC.dialogs.alert(JSON.parse(jqXHR.responseText).message, - t('files_sharing', 'Failed to add the public link to your Nextcloud')); - self._toggleLoading(); - } - ); - } -}; - -window.addEventListener('DOMContentLoaded', function () { - // FIXME: replace with OC.Plugins.register() - if (window.TESTING) { - return; - } - - var App = OCA.Sharing.PublicApp; - // defer app init, to give a chance to plugins to register file actions - _.defer(function () { - App.initialize($('#preview')); - }); - - if (window.Files) { - // HACK: for oc-dialogs previews that depends on Files: - Files.generatePreviewUrl = function (urlSpec) { - return App.fileList.generatePreviewUrl(urlSpec); - }; - } - -}); diff --git a/apps/files_sharing/js/public_note.js b/apps/files_sharing/js/public_note.js deleted file mode 100644 index 96646d63eb4..00000000000 --- a/apps/files_sharing/js/public_note.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv@protonmail.com) - * - * @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> - * - * @license AGPL-3.0-or-later - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - - window.addEventListener('DOMContentLoaded', function() { - var noteElmt = document.getElementById('notemenu') - if (noteElmt) { - var noteHtml = noteElmt.outerHTML - $(noteHtml).insertBefore('#header-primary-action'); - $('#notemenu').removeClass('hidden'); - OC.registerMenu($('#notemenu .menutoggle'), $('#notemenu .menu')) - } - })
\ No newline at end of file diff --git a/apps/files_sharing/js/sharedfilelist.js b/apps/files_sharing/js/sharedfilelist.js deleted file mode 100644 index 65eb1b78f5f..00000000000 --- a/apps/files_sharing/js/sharedfilelist.js +++ /dev/null @@ -1,541 +0,0 @@ -/* eslint-disable */ -/* - * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com> - * - * This file is licensed under the Affero General Public License version 3 - * or later. - * - * See the COPYING-README file. - * - */ -(function() { - - /** - * @class OCA.Sharing.FileList - * @augments OCA.Files.FileList - * - * @classdesc Sharing file list. - * Contains both "shared with others" and "shared with you" modes. - * - * @param $el container element with existing markup for the .files-controls - * and a table - * @param [options] map of options, see other parameters - * @param {boolean} [options.sharedWithUser] true to return files shared with - * the current user, false to return files that the user shared with others. - * Defaults to false. - * @param {boolean} [options.linksOnly] true to return only link shares - */ - var FileList = function($el, options) { - this.initialize($el, options) - } - FileList.prototype = _.extend({}, OCA.Files.FileList.prototype, - /** @lends OCA.Sharing.FileList.prototype */ { - appName: 'Shares', - - /** - * Whether the list shows the files shared with the user (true) or - * the files that the user shared with others (false). - */ - _sharedWithUser: false, - _linksOnly: false, - _showDeleted: false, - _showPending: false, - _clientSideSort: true, - _allowSelection: false, - _isOverview: false, - - /** - * @private - */ - initialize: function($el, options) { - OCA.Files.FileList.prototype.initialize.apply(this, arguments) - if (this.initialized) { - return - } - - // TODO: consolidate both options - if (options && options.sharedWithUser) { - this._sharedWithUser = true - } - if (options && options.linksOnly) { - this._linksOnly = true - } - if (options && options.showDeleted) { - this._showDeleted = true - } - if (options && options.showPending) { - this._showPending = true - } - if (options && options.isOverview) { - this._isOverview = true - } - }, - - _renderRow: function() { - // HACK: needed to call the overridden _renderRow - // this is because at the time this class is created - // the overriding hasn't been done yet... - return OCA.Files.FileList.prototype._renderRow.apply(this, arguments) - }, - - _createRow: function(fileData) { - // TODO: hook earlier and render the whole row here - var $tr = OCA.Files.FileList.prototype._createRow.apply(this, arguments) - $tr.find('.filesize').remove() - $tr.find('td.date').before($tr.children('td:first')) - $tr.find('td.filename input:checkbox').remove() - $tr.attr('data-share-id', _.pluck(fileData.shares, 'id').join(',')) - if (this._sharedWithUser) { - $tr.attr('data-share-owner', fileData.shareOwner) - $tr.attr('data-mounttype', 'shared-root') - var permission = parseInt($tr.attr('data-permissions')) | OC.PERMISSION_DELETE - $tr.attr('data-permissions', permission) - } - if (this._showDeleted || this._showPending) { - var permission = fileData.permissions - $tr.attr('data-share-permissions', permission) - } - - if (fileData.remoteId) { - $tr.attr('data-remote-id', fileData.remoteId) - } - - if (fileData.shareType) { - $tr.attr('data-share-type', fileData.shareType) - } - - // add row with expiration date for link only shares - influenced by _createRow of filelist - if (this._linksOnly) { - var expirationTimestamp = 0 - if (fileData.shares && fileData.shares[0].expiration !== null) { - expirationTimestamp = moment(fileData.shares[0].expiration).valueOf() - } - $tr.attr('data-expiration', expirationTimestamp) - - // date column (1000 milliseconds to seconds, 60 seconds, 60 minutes, 24 hours) - // difference in days multiplied by 5 - brightest shade for expiry dates in more than 32 days (160/5) - var modifiedColor = Math.round((expirationTimestamp - (new Date()).getTime()) / 1000 / 60 / 60 / 24 * 5) - // ensure that the brightest color is still readable - if (modifiedColor >= 160) { - modifiedColor = 160 - } - - var formatted - var text - if (expirationTimestamp > 0) { - formatted = OC.Util.formatDate(expirationTimestamp) - text = OC.Util.relativeModifiedDate(expirationTimestamp) - } else { - formatted = t('files_sharing', 'No expiration date set') - text = '' - modifiedColor = 160 - } - td = $('<td></td>').attr({ 'class': 'date' }) - td.append($('<span></span>').attr({ - 'class': 'modified', - 'title': formatted, - 'style': 'color:rgb(' + modifiedColor + ',' + modifiedColor + ',' + modifiedColor + ')' - }).text(text)) - - $tr.append(td) - } - return $tr - }, - - /** - * Set whether the list should contain outgoing shares - * or incoming shares. - * - * @param state true for incoming shares, false otherwise - */ - setSharedWithUser: function(state) { - this._sharedWithUser = !!state - }, - - updateEmptyContent: function() { - var dir = this.getCurrentDirectory() - if (dir === '/') { - // root has special permissions - this.$el.find('.emptyfilelist.emptycontent').toggleClass('hidden', !this.isEmpty) - this.$el.find('.files-filestable thead th').toggleClass('hidden', this.isEmpty) - - // hide expiration date header for non link only shares - if (!this._linksOnly) { - this.$el.find('th.column-expiration').addClass('hidden') - } - } else { - OCA.Files.FileList.prototype.updateEmptyContent.apply(this, arguments) - } - }, - - getDirectoryPermissions: function() { - return OC.PERMISSION_READ | OC.PERMISSION_DELETE - }, - - updateStorageStatistics: function() { - // no op because it doesn't have - // storage info like free space / used space - }, - - reload: function() { - this.showMask() - if (this._reloadCall?.abort) { - this._reloadCall.abort() - } - - // there is only root - this._setCurrentDir('/', false) - - var promises = [] - - var deletedShares = { - url: OC.linkToOCS('apps/files_sharing/api/v1', 2) + 'deletedshares', - /* jshint camelcase: false */ - data: { - format: 'json', - include_tags: true - }, - type: 'GET', - beforeSend: function(xhr) { - xhr.setRequestHeader('OCS-APIREQUEST', 'true') - } - } - - var pendingShares = { - url: OC.linkToOCS('apps/files_sharing/api/v1/shares', 2) + 'pending', - /* jshint camelcase: false */ - data: { - format: 'json' - }, - type: 'GET', - beforeSend: function(xhr) { - xhr.setRequestHeader('OCS-APIREQUEST', 'true') - } - } - - var pendingRemoteShares = { - url: OC.linkToOCS('apps/files_sharing/api/v1/remote_shares', 2) + 'pending', - /* jshint camelcase: false */ - data: { - format: 'json' - }, - type: 'GET', - beforeSend: function(xhr) { - xhr.setRequestHeader('OCS-APIREQUEST', 'true') - } - } - - var shares = { - url: OC.linkToOCS('apps/files_sharing/api/v1') + 'shares', - /* jshint camelcase: false */ - data: { - format: 'json', - shared_with_me: this._sharedWithUser !== false, - include_tags: true - }, - type: 'GET', - beforeSend: function(xhr) { - xhr.setRequestHeader('OCS-APIREQUEST', 'true') - } - } - - var remoteShares = { - url: OC.linkToOCS('apps/files_sharing/api/v1') + 'remote_shares', - /* jshint camelcase: false */ - data: { - format: 'json', - include_tags: true - }, - type: 'GET', - beforeSend: function(xhr) { - xhr.setRequestHeader('OCS-APIREQUEST', 'true') - } - } - - // Add the proper ajax requests to the list and run them - // and make sure we have 2 promises - if (this._showDeleted) { - promises.push($.ajax(deletedShares)) - } else if (this._showPending) { - promises.push($.ajax(pendingShares)) - promises.push($.ajax(pendingRemoteShares)) - } else { - promises.push($.ajax(shares)) - - if (this._sharedWithUser !== false || this._isOverview) { - promises.push($.ajax(remoteShares)) - } - if (this._isOverview) { - shares.data.shared_with_me = !shares.data.shared_with_me - promises.push($.ajax(shares)) - } - } - - this._reloadCall = $.when.apply($, promises) - var callBack = this.reloadCallback.bind(this) - return this._reloadCall.then(callBack, callBack) - }, - - reloadCallback: function(shares, remoteShares, additionalShares) { - delete this._reloadCall - this.hideMask() - - this.$el.find('#headerSharedWith').text( - t('files_sharing', this._sharedWithUser ? 'Shared by' : 'Shared with') - ) - - var files = [] - - // make sure to use the same format - if (shares[0] && shares[0].ocs) { - shares = shares[0] - } - if (remoteShares && remoteShares[0] && remoteShares[0].ocs) { - remoteShares = remoteShares[0] - } - if (additionalShares && additionalShares[0] && additionalShares[0].ocs) { - additionalShares = additionalShares[0] - } - - if (shares.ocs && shares.ocs.data) { - files = files.concat(this._makeFilesFromShares(shares.ocs.data, this._sharedWithUser)) - } - - if (remoteShares && remoteShares.ocs && remoteShares.ocs.data) { - files = files.concat(this._makeFilesFromRemoteShares(remoteShares.ocs.data)) - } - - if (additionalShares && additionalShares.ocs && additionalShares.ocs.data) { - if (this._showPending) { - // in this case the second callback is about pending remote shares - files = files.concat(this._makeFilesFromRemoteShares(additionalShares.ocs.data)) - } else { - files = files.concat(this._makeFilesFromShares(additionalShares.ocs.data, !this._sharedWithUser)) - } - } - - this.setFiles(files) - return true - }, - - _makeFilesFromRemoteShares: function(data) { - var files = data - - files = _.chain(files) - // convert share data to file data - .map(function(share) { - var file = { - shareOwner: share.owner + '@' + share.remote.replace(/.*?:\/\//g, ''), - name: OC.basename(share.mountpoint), - mtime: share.mtime * 1000, - mimetype: share.mimetype, - type: share.type, - // remote share types are different and need to be mapped - shareType: (parseInt(share.share_type, 10) === 1) ? OC.Share.SHARE_TYPE_REMOTE_GROUP : OC.Share.SHARE_TYPE_REMOTE, - id: share.file_id, - path: OC.dirname(share.mountpoint), - permissions: share.permissions, - tags: share.tags || [] - } - - if (share.remote_id) { - // remote share - if (share.accepted !== '1') { - file.name = OC.basename(share.name) - file.path = '/' - } - file.remoteId = share.remote_id - file.shareOwnerId = share.owner - } - - if (!file.mimetype) { - // pending shares usually have no type, so default to showing a directory icon - file.mimetype = 'dir-shared' - } - - file.shares = [{ - id: share.id, - type: OC.Share.SHARE_TYPE_REMOTE - }] - return file - }) - .value() - return files - }, - - /** - * Converts the OCS API share response data to a file info - * list - * @param {Array} data OCS API share array - * @param {boolean} sharedWithUser - * @returns {Array.<OCA.Sharing.SharedFileInfo>} array of shared file info - */ - _makeFilesFromShares: function(data, sharedWithUser) { - /* jshint camelcase: false */ - var files = data - - if (this._linksOnly) { - files = _.filter(data, function(share) { - return share.share_type === OC.Share.SHARE_TYPE_LINK - }) - } - - // OCS API uses non-camelcased names - files = _.chain(files) - // convert share data to file data - .map(function(share) { - // TODO: use OC.Files.FileInfo - var file = { - id: share.file_source, - icon: OC.MimeType.getIconUrl(share.mimetype), - mimetype: share.mimetype, - hasPreview: share.has_preview, - tags: share.tags || [] - } - if (share.item_type === 'folder') { - file.type = 'dir' - file.mimetype = 'httpd/unix-directory' - } else { - file.type = 'file' - } - file.share = { - id: share.id, - type: share.share_type, - target: share.share_with, - stime: share.stime * 1000, - expiration: share.expiration - } - if (sharedWithUser) { - file.shareOwner = share.displayname_owner - file.shareOwnerId = share.uid_owner - file.name = OC.basename(share.file_target) - file.path = OC.dirname(share.file_target) - file.permissions = share.permissions - if (file.path) { - file.extraData = share.file_target - } - } else { - if (share.share_type !== OC.Share.SHARE_TYPE_LINK) { - file.share.targetDisplayName = share.share_with_displayname - file.share.targetShareWithId = share.share_with - } - file.name = OC.basename(share.path) - file.path = OC.dirname(share.path) - file.permissions = OC.PERMISSION_ALL - if (file.path) { - file.extraData = share.path - } - } - return file - }) - // Group all files and have a "shares" array with - // the share info for each file. - // - // This uses a hash memo to cumulate share information - // inside the same file object (by file id). - .reduce(function(memo, file) { - var data = memo[file.id] - var recipient = file.share.targetDisplayName - var recipientId = file.share.targetShareWithId - if (!data) { - data = memo[file.id] = file - data.shares = [file.share] - // using a hash to make them unique, - // this is only a list to be displayed - data.recipients = {} - data.recipientData = {} - // share types - data.shareTypes = {} - // counter is cheaper than calling _.keys().length - data.recipientsCount = 0 - data.mtime = file.share.stime - } else { - // always take the most recent stime - if (file.share.stime > data.mtime) { - data.mtime = file.share.stime - } - data.shares.push(file.share) - } - - if (recipient) { - // limit counterparts for output - if (data.recipientsCount < 4) { - // only store the first ones, they will be the only ones - // displayed - data.recipients[recipient] = true - data.recipientData[data.recipientsCount] = { - 'shareWith': recipientId, - 'shareWithDisplayName': recipient - } - } - data.recipientsCount++ - } - - data.shareTypes[file.share.type] = true - - delete file.share - return memo - }, {}) - // Retrieve only the values of the returned hash - .values() - // Clean up - .each(function(data) { - // convert the recipients map to a flat - // array of sorted names - data.mountType = 'shared' - delete data.recipientsCount - if (sharedWithUser) { - // only for outgoing shares - delete data.shareTypes - } else { - data.shareTypes = _.keys(data.shareTypes) - } - }) - // Finish the chain by getting the result - .value() - - // Sort by expected sort comparator - return files.sort(this._sortComparator) - } - }) - - /** - * Share info attributes. - * - * @typedef {Object} OCA.Sharing.ShareInfo - * - * @property {number} id share ID - * @property {number} type share type - * @property {String} target share target, either user name or group name - * @property {number} stime share timestamp in milliseconds - * @property {String} [targetDisplayName] display name of the recipient - * (only when shared with others) - * @property {String} [targetShareWithId] id of the recipient - * - */ - - /** - * Recipient attributes - * - * @typedef {Object} OCA.Sharing.RecipientInfo - * @property {String} shareWith the id of the recipient - * @property {String} shareWithDisplayName the display name of the recipient - */ - - /** - * Shared file info attributes. - * - * @typedef {OCA.Files.FileInfo} OCA.Sharing.SharedFileInfo - * - * @property {Array.<OCA.Sharing.ShareInfo>} shares array of shares for - * this file - * @property {number} mtime most recent share time (if multiple shares) - * @property {String} shareOwner name of the share owner - * @property {Array.<String>} recipients name of the first 4 recipients - * (this is mostly for display purposes) - * @property {Object.<OCA.Sharing.RecipientInfo>} recipientData (as object for easier - * passing to HTML data attributes with jQuery) - */ - - OCA.Sharing.FileList = FileList -})() diff --git a/apps/files_sharing/js/templates.js b/apps/files_sharing/js/templates.js deleted file mode 100644 index 07fd6ad6c42..00000000000 --- a/apps/files_sharing/js/templates.js +++ /dev/null @@ -1,43 +0,0 @@ -(function() { - var template = Handlebars.template, templates = OCA.Sharing.Templates = OCA.Sharing.Templates || {}; -templates['files_drop'] = template({"1":function(container,depth0,helpers,partials,data) { - var helper, lookupProperty = container.lookupProperty || function(parent, propertyName) { - if (Object.prototype.hasOwnProperty.call(parent, propertyName)) { - return parent[propertyName]; - } - return undefined - }; - - return " <div id=\"drop-upload-name\">" - + container.escapeExpression(((helper = (helper = lookupProperty(helpers,"name") || (depth0 != null ? lookupProperty(depth0,"name") : depth0)) != null ? helper : container.hooks.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"name","hash":{},"data":data,"loc":{"start":{"line":3,"column":29},"end":{"line":3,"column":37}}}) : helper))) - + "</div><div id=\"drop-upload-status\"></div>\n <progress id=\"drop-upload-progress-bar\" value=\"0\" max=\"100\"></progress>\n"; -},"3":function(container,depth0,helpers,partials,data) { - var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, alias3="function", alias4=container.escapeExpression, lookupProperty = container.lookupProperty || function(parent, propertyName) { - if (Object.prototype.hasOwnProperty.call(parent, propertyName)) { - return parent[propertyName]; - } - return undefined - }; - - return " <img src=\"" - + alias4(((helper = (helper = lookupProperty(helpers,"iconSrc") || (depth0 != null ? lookupProperty(depth0,"iconSrc") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"iconSrc","hash":{},"data":data,"loc":{"start":{"line":6,"column":12},"end":{"line":6,"column":23}}}) : helper))) - + "\"/> " - + alias4(((helper = (helper = lookupProperty(helpers,"name") || (depth0 != null ? lookupProperty(depth0,"name") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data,"loc":{"start":{"line":6,"column":27},"end":{"line":6,"column":35}}}) : helper))) - + "\n"; -},"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) { - var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, alias3="function", alias4=container.escapeExpression, lookupProperty = container.lookupProperty || function(parent, propertyName) { - if (Object.prototype.hasOwnProperty.call(parent, propertyName)) { - return parent[propertyName]; - } - return undefined - }; - - return "<li title=\"" - + alias4(((helper = (helper = lookupProperty(helpers,"name") || (depth0 != null ? lookupProperty(depth0,"name") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":19}}}) : helper))) - + "\" data-name=\"" - + alias4(((helper = (helper = lookupProperty(helpers,"name") || (depth0 != null ? lookupProperty(depth0,"name") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data,"loc":{"start":{"line":1,"column":32},"end":{"line":1,"column":40}}}) : helper))) - + "\">\n" - + ((stack1 = lookupProperty(helpers,"if").call(alias1,(depth0 != null ? lookupProperty(depth0,"isUploading") : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(3, data, 0),"data":data,"loc":{"start":{"line":2,"column":1},"end":{"line":7,"column":8}}})) != null ? stack1 : "") - + "</li>\n"; -},"useData":true}); -})();
\ No newline at end of file diff --git a/apps/files_sharing/js/templates/files_drop.handlebars b/apps/files_sharing/js/templates/files_drop.handlebars deleted file mode 100644 index 4128c920cb9..00000000000 --- a/apps/files_sharing/js/templates/files_drop.handlebars +++ /dev/null @@ -1,8 +0,0 @@ -<li title="{{name}}" data-name="{{name}}"> - {{#if isUploading}} - <div id="drop-upload-name">{{name}}</div><div id="drop-upload-status"></div> - <progress id="drop-upload-progress-bar" value="0" max="100"></progress> - {{else}} - <img src="{{iconSrc}}"/> {{name}} - {{/if}} -</li> |