From fd3b57ffc79525298dba93eca476c698f3fad718 Mon Sep 17 00:00:00 2001 From: nadir Date: Wed, 13 Apr 2016 14:07:26 +0200 Subject: [PATCH] [Patch] File versions fix - Files can now be back rolled to a previous or further version - The different versions of a file can be downloaded --- apps/files_versions/download.php | 2 +- apps/files_versions/js/versioncollection.js | 4 ++-- apps/files_versions/js/versionmodel.js | 7 ++++--- apps/files_versions/js/versionstabview.js | 12 +++++++----- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/apps/files_versions/download.php b/apps/files_versions/download.php index dc6d9e13a73e..16a9fc6fc8c9 100644 --- a/apps/files_versions/download.php +++ b/apps/files_versions/download.php @@ -27,7 +27,7 @@ OCP\JSON::checkLoggedIn(); $file = $_GET['file']; -$revision=(int)$_GET['revision']; +$revision=$_GET['revision']; list($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($file); diff --git a/apps/files_versions/js/versioncollection.js b/apps/files_versions/js/versioncollection.js index 176f8e7529c4..ab2805f5e20a 100644 --- a/apps/files_versions/js/versioncollection.js +++ b/apps/files_versions/js/versioncollection.js @@ -74,12 +74,12 @@ parse: function(result) { var results = _.map(result.data.versions, function(version) { - var revision = parseInt(version.version, 10); + var revision = version.version;//parseInt(version.version, 10); return { id: revision, name: version.name, fullPath: version.path, - timestamp: revision, + timestamp: parseInt(revision), size: version.size }; }); diff --git a/apps/files_versions/js/versionmodel.js b/apps/files_versions/js/versionmodel.js index dc610fc21449..9d8049620b9d 100644 --- a/apps/files_versions/js/versionmodel.js +++ b/apps/files_versions/js/versionmodel.js @@ -21,7 +21,8 @@ options = options ? _.clone(options) : {}; var model = this; var file = this.getFullPath(); - var revision = this.get('timestamp'); + //var revision = this.get('timestamp'); + var revision = this.get('id'); $.ajax({ type: 'GET', @@ -55,7 +56,7 @@ var url = OC.generateUrl('/apps/files_versions/preview'); var params = { file: this.get('fullPath'), - version: this.get('timestamp') + version: this.get('id') }; return url + '?' + OC.buildQueryString(params); }, @@ -64,7 +65,7 @@ var url = OC.generateUrl('/apps/files_versions/download.php'); var params = { file: this.get('fullPath'), - revision: this.get('timestamp') + revision: this.get('id') }; return url + '?' + OC.buildQueryString(params); } diff --git a/apps/files_versions/js/versionstabview.js b/apps/files_versions/js/versionstabview.js index 7447156d5feb..a0cc6cfdf42f 100644 --- a/apps/files_versions/js/versionstabview.js +++ b/apps/files_versions/js/versionstabview.js @@ -179,16 +179,18 @@ rev = rev[0]; var title = formatDate(rev*1000); // JS epoch is*/ - var timestamp = version.get('timestamp') * 1000; - return _.extend({ - formattedTimestamp: OC.Util.formatDate(timestamp), - relativeTimestamp: OC.Util.relativeModifiedDate(timestamp), + var numTimestamp = version.get('timestamp') * 1000; + //var timestamp = version.get('id'); + return /*_.extend*/({ + timestamp: version.get('id'), + formattedTimestamp: OC.Util.formatDate(numTimestamp), + relativeTimestamp: OC.Util.relativeModifiedDate(numTimestamp), downloadUrl: version.getDownloadUrl(), downloadIconUrl: OC.imagePath('core', 'actions/download'), revertIconUrl: OC.imagePath('core', 'actions/history'), previewUrl: version.getPreviewUrl(), revertLabel: t('files_versions', 'Restore'), - }, version.attributes); + }/*, version.attributes*/); }, /**