aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_versions/src
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-09-25 18:19:42 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-10-01 17:16:09 +0200
commitb9bc2417e7a8dc81feb0abe20359bedaf864f790 (patch)
tree61b47fbf37c1d168da8625224debde9e6a985348 /apps/files_versions/src
parent7fb651235128dcbca8a6683b5cdafdf835f46300 (diff)
downloadnextcloud-server-b9bc2417e7a8dc81feb0abe20359bedaf864f790.tar.gz
nextcloud-server-b9bc2417e7a8dc81feb0abe20359bedaf864f790.zip
Comply to eslint
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_versions/src')
-rw-r--r--apps/files_versions/src/filesplugin.js13
-rw-r--r--apps/files_versions/src/versioncollection.js61
-rw-r--r--apps/files_versions/src/versionmodel.js56
-rw-r--r--apps/files_versions/src/versionstabview.js152
4 files changed, 140 insertions, 142 deletions
diff --git a/apps/files_versions/src/filesplugin.js b/apps/files_versions/src/filesplugin.js
index a9457c522d6..e47003d6611 100644
--- a/apps/files_versions/src/filesplugin.js
+++ b/apps/files_versions/src/filesplugin.js
@@ -9,7 +9,7 @@
*/
(function() {
- OCA.Versions = OCA.Versions || {};
+ OCA.Versions = OCA.Versions || {}
/**
* @namespace
@@ -22,13 +22,12 @@
*/
attach: function(fileList) {
if (fileList.id === 'trashbin' || fileList.id === 'files.public') {
- return;
+ return
}
- fileList.registerTabView(new OCA.Versions.VersionsTabView('versionsTabView', {order: -10}));
+ fileList.registerTabView(new OCA.Versions.VersionsTabView('versionsTabView', { order: -10 }))
}
- };
-})();
-
-OC.Plugins.register('OCA.Files.FileList', OCA.Versions.Util);
+ }
+})()
+OC.Plugins.register('OCA.Files.FileList', OCA.Versions.Util)
diff --git a/apps/files_versions/src/versioncollection.js b/apps/files_versions/src/versioncollection.js
index 2ee683b38ef..1f3356e43d3 100644
--- a/apps/files_versions/src/versioncollection.js
+++ b/apps/files_versions/src/versioncollection.js
@@ -8,7 +8,7 @@
*
*/
-(function () {
+(function() {
/**
* @memberof OCA.Versions
*/
@@ -25,24 +25,24 @@
_client: null,
- setFileInfo: function (fileInfo) {
- this._fileInfo = fileInfo;
+ setFileInfo: function(fileInfo) {
+ this._fileInfo = fileInfo
},
- getFileInfo: function () {
- return this._fileInfo;
+ getFileInfo: function() {
+ return this._fileInfo
},
setCurrentUser: function(user) {
- this._currentUser = user;
+ this._currentUser = user
},
getCurrentUser: function() {
- return this._currentUser || OC.getCurrentUser().uid;
+ return this._currentUser || OC.getCurrentUser().uid
},
setClient: function(client) {
- this._client = client;
+ this._client = client
},
getClient: function() {
@@ -50,35 +50,34 @@
host: OC.getHost(),
root: OC.linkToRemoteBase('dav') + '/versions/' + this.getCurrentUser(),
useHTTPS: OC.getProtocol() === 'https'
- });
+ })
},
- url: function () {
- return OC.linkToRemoteBase('dav') + '/versions/' + this.getCurrentUser() + '/versions/' + this._fileInfo.get('id');
+ url: function() {
+ return OC.linkToRemoteBase('dav') + '/versions/' + this.getCurrentUser() + '/versions/' + this._fileInfo.get('id')
},
parse: function(result) {
- var fullPath = this._fileInfo.getFullPath();
- var fileId = this._fileInfo.get('id');
- var name = this._fileInfo.get('name');
- var user = this.getCurrentUser();
- var client = this.getClient();
+ var fullPath = this._fileInfo.getFullPath()
+ var fileId = this._fileInfo.get('id')
+ var name = this._fileInfo.get('name')
+ var user = this.getCurrentUser()
+ var client = this.getClient()
return _.map(result, function(version) {
- version.fullPath = fullPath;
- version.fileId = fileId;
- version.name = name;
- version.timestamp = parseInt(moment(new Date(version.timestamp)).format('X'), 10);
- version.id = OC.basename(version.href);
- version.size = parseInt(version.size, 10);
- version.user = user;
- version.client = client;
- return version;
- });
+ version.fullPath = fullPath
+ version.fileId = fileId
+ version.name = name
+ version.timestamp = parseInt(moment(new Date(version.timestamp)).format('X'), 10)
+ version.id = OC.basename(version.href)
+ version.size = parseInt(version.size, 10)
+ version.user = user
+ version.client = client
+ return version
+ })
}
- });
+ })
- OCA.Versions = OCA.Versions || {};
-
- OCA.Versions.VersionCollection = VersionCollection;
-})();
+ OCA.Versions = OCA.Versions || {}
+ OCA.Versions.VersionCollection = VersionCollection
+})()
diff --git a/apps/files_versions/src/versionmodel.js b/apps/files_versions/src/versionmodel.js
index 9857bf950b4..e36e59ac046 100644
--- a/apps/files_versions/src/versionmodel.js
+++ b/apps/files_versions/src/versionmodel.js
@@ -8,9 +8,7 @@
*
*/
-/* global moment */
-
-(function () {
+(function() {
/**
* @memberof OCA.Versions
*/
@@ -20,53 +18,55 @@
davProperties: {
'size': '{DAV:}getcontentlength',
'mimetype': '{DAV:}getcontenttype',
- 'timestamp': '{DAV:}getlastmodified',
+ 'timestamp': '{DAV:}getlastmodified'
},
/**
* Restores the original file to this revision
+ *
+ * @param {Object} [options] options
+ * @returns {Promise}
*/
- revert: function (options) {
- options = options ? _.clone(options) : {};
- var model = this;
+ revert: function(options) {
+ options = options ? _.clone(options) : {}
+ var model = this
- var client = this.get('client');
+ var client = this.get('client')
return client.move('/versions/' + this.get('fileId') + '/' + this.get('id'), '/restore/target', true)
- .done(function () {
+ .done(function() {
if (options.success) {
- options.success.call(options.context, model, {}, options);
+ options.success.call(options.context, model, {}, options)
}
- model.trigger('revert', model, options);
+ model.trigger('revert', model, options)
})
- .fail(function () {
+ .fail(function() {
if (options.error) {
- options.error.call(options.context, model, {}, options);
+ options.error.call(options.context, model, {}, options)
}
- model.trigger('error', model, {}, options);
- });
+ model.trigger('error', model, {}, options)
+ })
},
- getFullPath: function () {
- return this.get('fullPath');
+ getFullPath: function() {
+ return this.get('fullPath')
},
- getPreviewUrl: function () {
- var url = OC.generateUrl('/apps/files_versions/preview');
+ getPreviewUrl: function() {
+ var url = OC.generateUrl('/apps/files_versions/preview')
var params = {
file: this.get('fullPath'),
version: this.get('id')
- };
- return url + '?' + OC.buildQueryString(params);
+ }
+ return url + '?' + OC.buildQueryString(params)
},
- getDownloadUrl: function () {
- return OC.linkToRemoteBase('dav') + '/versions/' + this.get('user') + '/versions/' + this.get('fileId') + '/' + this.get('id');
+ getDownloadUrl: function() {
+ return OC.linkToRemoteBase('dav') + '/versions/' + this.get('user') + '/versions/' + this.get('fileId') + '/' + this.get('id')
}
- });
-
- OCA.Versions = OCA.Versions || {};
+ })
- OCA.Versions.VersionModel = VersionModel;
-})();
+ OCA.Versions = OCA.Versions || {}
+ OCA.Versions.VersionModel = VersionModel
+})()
diff --git a/apps/files_versions/src/versionstabview.js b/apps/files_versions/src/versionstabview.js
index 8adfe549aa9..b85cb6b08f5 100644
--- a/apps/files_versions/src/versionstabview.js
+++ b/apps/files_versions/src/versionstabview.js
@@ -8,7 +8,7 @@
*
*/
-import ItemTemplate from './templates/item.handlebars';
+import ItemTemplate from './templates/item.handlebars'
import Template from './templates/template.handlebars';
(function() {
@@ -28,137 +28,137 @@ import Template from './templates/template.handlebars';
},
initialize: function() {
- OCA.Files.DetailTabView.prototype.initialize.apply(this, arguments);
- this.collection = new OCA.Versions.VersionCollection();
- this.collection.on('request', this._onRequest, this);
- this.collection.on('sync', this._onEndRequest, this);
- this.collection.on('update', this._onUpdate, this);
- this.collection.on('error', this._onError, this);
- this.collection.on('add', this._onAddModel, this);
+ OCA.Files.DetailTabView.prototype.initialize.apply(this, arguments)
+ this.collection = new OCA.Versions.VersionCollection()
+ this.collection.on('request', this._onRequest, this)
+ this.collection.on('sync', this._onEndRequest, this)
+ this.collection.on('update', this._onUpdate, this)
+ this.collection.on('error', this._onError, this)
+ this.collection.on('add', this._onAddModel, this)
},
getLabel: function() {
- return t('files_versions', 'Versions');
+ return t('files_versions', 'Versions')
},
getIcon: function() {
- return 'icon-history';
+ return 'icon-history'
},
nextPage: function() {
if (this._loading) {
- return;
+ return
}
if (this.collection.getFileInfo() && this.collection.getFileInfo().isDirectory()) {
- return;
+ return
}
- this.collection.fetch();
+ this.collection.fetch()
},
_onClickRevertVersion: function(ev) {
- var self = this;
- var $target = $(ev.target);
- var fileInfoModel = this.collection.getFileInfo();
- var revision;
+ var self = this
+ var $target = $(ev.target)
+ var fileInfoModel = this.collection.getFileInfo()
+ var revision
if (!$target.is('li')) {
- $target = $target.closest('li');
+ $target = $target.closest('li')
}
- ev.preventDefault();
- revision = $target.attr('data-revision');
+ ev.preventDefault()
+ revision = $target.attr('data-revision')
- var versionModel = this.collection.get(revision);
+ var versionModel = this.collection.get(revision)
versionModel.revert({
success: function() {
// reset and re-fetch the updated collection
- self.$versionsContainer.empty();
- self.collection.setFileInfo(fileInfoModel);
- self.collection.reset([], {silent: true});
- self.collection.fetch();
+ self.$versionsContainer.empty()
+ self.collection.setFileInfo(fileInfoModel)
+ self.collection.reset([], { silent: true })
+ self.collection.fetch()
- self.$el.find('.versions').removeClass('hidden');
+ self.$el.find('.versions').removeClass('hidden')
// update original model
- fileInfoModel.trigger('busy', fileInfoModel, false);
+ fileInfoModel.trigger('busy', fileInfoModel, false)
fileInfoModel.set({
size: versionModel.get('size'),
mtime: versionModel.get('timestamp') * 1000,
// temp dummy, until we can do a PROPFIND
etag: versionModel.get('id') + versionModel.get('timestamp')
- });
+ })
},
error: function() {
- fileInfoModel.trigger('busy', fileInfoModel, false);
- self.$el.find('.versions').removeClass('hidden');
- self._toggleLoading(false);
+ fileInfoModel.trigger('busy', fileInfoModel, false)
+ self.$el.find('.versions').removeClass('hidden')
+ self._toggleLoading(false)
OC.Notification.show(t('files_version', 'Failed to revert {file} to revision {timestamp}.',
{
file: versionModel.getFullPath(),
timestamp: OC.Util.formatDate(versionModel.get('timestamp') * 1000)
}),
- {
- type: 'error'
- }
- );
+ {
+ type: 'error'
+ }
+ )
}
- });
+ })
// spinner
- this._toggleLoading(true);
- fileInfoModel.trigger('busy', fileInfoModel, true);
+ this._toggleLoading(true)
+ fileInfoModel.trigger('busy', fileInfoModel, true)
},
_toggleLoading: function(state) {
- this._loading = state;
- this.$el.find('.loading').toggleClass('hidden', !state);
+ this._loading = state
+ this.$el.find('.loading').toggleClass('hidden', !state)
},
_onRequest: function() {
- this._toggleLoading(true);
+ this._toggleLoading(true)
},
_onEndRequest: function() {
- this._toggleLoading(false);
- this.$el.find('.empty').toggleClass('hidden', !!this.collection.length);
+ this._toggleLoading(false)
+ this.$el.find('.empty').toggleClass('hidden', !!this.collection.length)
},
_onAddModel: function(model) {
- var $el = $(this.itemTemplate(this._formatItem(model)));
- this.$versionsContainer.append($el);
- $el.find('.has-tooltip').tooltip();
+ var $el = $(this.itemTemplate(this._formatItem(model)))
+ this.$versionsContainer.append($el)
+ $el.find('.has-tooltip').tooltip()
},
template: function(data) {
- return Template(data);
+ return Template(data)
},
itemTemplate: function(data) {
- return ItemTemplate(data);
+ return ItemTemplate(data)
},
setFileInfo: function(fileInfo) {
if (fileInfo) {
- this.render();
- this.collection.setFileInfo(fileInfo);
- this.collection.reset([], {silent: true});
- this.nextPage();
+ this.render()
+ this.collection.setFileInfo(fileInfo)
+ this.collection.reset([], { silent: true })
+ this.nextPage()
} else {
- this.render();
- this.collection.reset();
+ this.render()
+ this.collection.reset()
}
},
_formatItem: function(version) {
- var timestamp = version.get('timestamp') * 1000;
- var size = version.has('size') ? version.get('size') : 0;
- var preview = OC.MimeType.getIconUrl(version.get('mimetype'));
- var img = new Image();
- img.onload = function () {
- $('li[data-revision=' + version.get('id') + '] .preview').attr('src', version.getPreviewUrl());
- };
- img.src = version.getPreviewUrl();
+ var timestamp = version.get('timestamp') * 1000
+ var size = version.has('size') ? version.get('size') : 0
+ var preview = OC.MimeType.getIconUrl(version.get('mimetype'))
+ var img = new Image()
+ img.onload = function() {
+ $('li[data-revision=' + version.get('id') + '] .preview').attr('src', version.getPreviewUrl())
+ }
+ img.src = version.getPreviewUrl()
return _.extend({
versionId: version.get('id'),
@@ -175,7 +175,7 @@ import Template from './templates/template.handlebars';
previewUrl: preview,
revertLabel: t('files_versions', 'Restore'),
canRevert: (this.collection.getFileInfo().get('permissions') & OC.PERMISSION_UPDATE) !== 0
- }, version.attributes);
+ }, version.attributes)
},
/**
@@ -183,27 +183,27 @@ import Template from './templates/template.handlebars';
*/
render: function() {
this.$el.html(this.template({
- emptyResultLabel: t('files_versions', 'No other versions available'),
- }));
- this.$el.find('.has-tooltip').tooltip();
- this.$versionsContainer = this.$el.find('ul.versions');
- this.delegateEvents();
+ emptyResultLabel: t('files_versions', 'No other versions available')
+ }))
+ this.$el.find('.has-tooltip').tooltip()
+ this.$versionsContainer = this.$el.find('ul.versions')
+ this.delegateEvents()
},
/**
* Returns true for files, false for folders.
- *
- * @return {bool} true for files, false for folders
+ * @param {FileInfo} fileInfo fileInfo
+ * @returns {bool} true for files, false for folders
*/
canDisplay: function(fileInfo) {
if (!fileInfo) {
- return false;
+ return false
}
- return !fileInfo.isDirectory();
+ return !fileInfo.isDirectory()
}
- });
+ })
- OCA.Versions = OCA.Versions || {};
+ OCA.Versions = OCA.Versions || {}
- OCA.Versions.VersionsTabView = VersionsTabView;
-})();
+ OCA.Versions.VersionsTabView = VersionsTabView
+})()