diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php
index 8ef17d5a25c..1d107c1bda0 100644
--- a/apps/files_versions/ajax/getVersions.php
+++ b/apps/files_versions/ajax/getVersions.php
@@ -1,7 +1,4 @@
array( "revision" => $revision, "file" => $file )));
+ }else{
+ OCP\JSON::error(array("data" => array( "message" => "Could not revert:" . $file )));
+ }
}
-
-?>
\ No newline at end of file
diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js
index eadf7a51039..61090f956f0 100644
--- a/apps/files_versions/js/versions.js
+++ b/apps/files_versions/js/versions.js
@@ -34,7 +34,7 @@ function createVersionsDropdown(filename, files) {
html += '';
html += '';
//html += '';
- html += '';
+ html += '';
html += '
';
html += '';
@@ -47,7 +47,7 @@ function createVersionsDropdown(filename, files) {
$.ajax({
type: 'GET',
- url: OC.linkTo('files_versions', 'ajax/getVersions.php'),
+ url: OC.filePath('files_versions', 'ajax', 'getVersions.php'),
dataType: 'json',
data: { source: files },
async: false,
@@ -58,34 +58,39 @@ function createVersionsDropdown(filename, files) {
if (versions) {
$.each( versions, function(index, row ) {
-
- addVersion( row );
+ addVersion( row );
});
}
-
+ $('#found_versions').change(function(){
+ var revision=parseInt($(this).val());
+ revertFile(files,revision);
+ })
}
});
- function revertFile() {
+ function revertFile(file, revision) {
$.ajax({
type: 'GET',
url: OC.linkTo('files_versions', 'ajax/rollbackVersion.php'),
dataType: 'json',
- data: {path: file, revision: 'revision'},
+ data: {file: file, revision: revision},
async: false,
- success: function(versions) {
- if (versions) {
+ success: function(response) {
+ if (response.status=='error') {
+ OC.dialogs.alert('Failed to revert '+file+' to revision '+formatDate(revision*1000)+'.','Failed to revert');
}
}
});
}
- function addVersion( name ) {
-
- var version = '';
+ function addVersion(revision ) {
+ name=formatDate(revision*1000);
+ var version=$('');
+ version.attr('value',revision);
+ version.text(name);
// } else {
// var checked = ((permissions > 0) ? 'checked="checked"' : 'style="display:none;"');
@@ -98,7 +103,7 @@ function createVersionsDropdown(filename, files) {
// user += '';
// }
- $(version).appendTo('#found_versions');
+ version.appendTo('#found_versions');
}
$('#dropdown').show('blind');