Skip to content

Commit

Permalink
[Patch] File versions fix
Browse files Browse the repository at this point in the history
- Files can now be back rolled to a previous or further version
- The different versions of a file can be downloaded
  • Loading branch information
nadir committed Apr 13, 2016
1 parent 99fa1a5 commit fd3b57f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion apps/files_versions/download.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions apps/files_versions/js/versioncollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
});
Expand Down
7 changes: 4 additions & 3 deletions apps/files_versions/js/versionmodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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);
},
Expand All @@ -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);
}
Expand Down
12 changes: 7 additions & 5 deletions apps/files_versions/js/versionstabview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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*/);
},

/**
Expand Down

0 comments on commit fd3b57f

Please sign in to comment.