started implementing ajax file rollback
This commit is contained in:
parent
c693ee2adb
commit
18a024e251
|
@ -11,9 +11,16 @@ $source = strip_tags( $source );
|
||||||
if( OCA_Versions\Storage::isversioned( $source ) ) {
|
if( OCA_Versions\Storage::isversioned( $source ) ) {
|
||||||
|
|
||||||
$count=5; //show the newest revisions
|
$count=5; //show the newest revisions
|
||||||
$versions=OCA_Versions\Storage::getversions( $source, $count);
|
$versions = OCA_Versions\Storage::getversions( $source, $count);
|
||||||
|
$versionsFormatted = array();
|
||||||
|
|
||||||
|
foreach ( $versions AS $version ) {
|
||||||
|
|
||||||
|
$versionsFormatted[] = OC_Util::formatDate( $version );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$versionsSorted = array_reverse( $versions );
|
$versionsSorted = array_reverse( $versionsFormatted );
|
||||||
|
|
||||||
if ( !empty( $versionsSorted ) ) {
|
if ( !empty( $versionsSorted ) ) {
|
||||||
OC_JSON::encodedPrint($versionsSorted);
|
OC_JSON::encodedPrint($versionsSorted);
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once('../../../lib/base.php');
|
||||||
|
OC_JSON::checkAppEnabled('files_versions');
|
||||||
|
require_once('../versions.php');
|
||||||
|
|
||||||
|
$userDirectory = "/".OC_User::getUser()."/files";
|
||||||
|
|
||||||
|
$source = $_GET['source'];
|
||||||
|
|
||||||
|
$source = strip_tags( $source );
|
||||||
|
|
||||||
|
echo "\n\n$source\n\n";
|
||||||
|
|
||||||
|
$revision = strtotime( $source );
|
||||||
|
|
||||||
|
echo "\n\n$revision\n\n";
|
||||||
|
|
||||||
|
if( OCA_Versions\Storage::isversioned( $source ) ) {
|
||||||
|
|
||||||
|
|
||||||
|
#\OCA_Versions\Storage::rollback( $source, $revision );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -32,13 +32,18 @@ if ( isset( $_GET['path'] ) ) {
|
||||||
|
|
||||||
// roll back to old version if button clicked
|
// roll back to old version if button clicked
|
||||||
if( isset( $_GET['revert'] ) ) {
|
if( isset( $_GET['revert'] ) ) {
|
||||||
\OCA_Versions\Storage::rollback( $path, $_GET['revert'] );
|
|
||||||
|
if( \OCA_Versions\Storage::rollback( $path, $_GET['revert'] ) ) {
|
||||||
|
|
||||||
|
echo "<script>OC.dialogs.alert(response.data.message, t('contacts', 'Error'))</script>";
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// show the history only if there is something to show
|
// show the history only if there is something to show
|
||||||
if( OCA_Versions\Storage::isversioned( $path ) ) {
|
if( OCA_Versions\Storage::isversioned( $path ) ) {
|
||||||
|
|
||||||
$count=5; //show the newest revisions
|
$count=999; //show the newest revisions
|
||||||
$versions=OCA_Versions\Storage::getversions( $path, $count);
|
$versions=OCA_Versions\Storage::getversions( $path, $count);
|
||||||
|
|
||||||
$tmpl = new OC_Template( 'files_versions', 'history', 'user' );
|
$tmpl = new OC_Template( 'files_versions', 'history', 'user' );
|
||||||
|
|
|
@ -17,17 +17,7 @@ $(document).ready(function(){
|
||||||
async: false,
|
async: false,
|
||||||
success: function(versions) {
|
success: function(versions) {
|
||||||
if (versions) {
|
if (versions) {
|
||||||
|
|
||||||
// icon = OC.imagePath('core', 'actions/shared');
|
|
||||||
// $.each(users, function(index, row) {
|
|
||||||
// if (row.uid_shared_with == 'public') {
|
|
||||||
// icon = OC.imagePath('core', 'actions/public');
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// } else {
|
|
||||||
// icon = OC.imagePath('core', 'actions/share');
|
|
||||||
}
|
}
|
||||||
shared_status[file]= { timestamp: new Date().getTime(), icon: icon };
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -37,15 +27,15 @@ $(document).ready(function(){
|
||||||
|
|
||||||
function createVersionsDropdown(filename, files) {
|
function createVersionsDropdown(filename, files) {
|
||||||
var historyUrl = '../apps/files_versions/history.php?path='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename);
|
var historyUrl = '../apps/files_versions/history.php?path='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename);
|
||||||
//alert( historyUrl );
|
|
||||||
var html = '<div id="dropdown" class="drop" data-file="'+files+'">';
|
var html = '<div id="dropdown" class="drop" data-file="'+files+'">';
|
||||||
html += '<div id="private">';
|
html += '<div id="private">';
|
||||||
html += '<select data-placeholder="File Version" id="found_versions" class="chzen-select">';
|
html += '<select data-placeholder="File Version" id="found_versions" class="chzen-select">';
|
||||||
html += '<option value="">Select version</option>';
|
html += '<option value="">Select version</option>';
|
||||||
html += '</select>';
|
html += '</select>';
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
html += '<input type="button" name="makelink" id="makelink" value="Revert file" />';
|
html += '<input type="button" value="Revert file" onclick="revertFile()" />';
|
||||||
html += '<input type="button" onclick="window.location=\''+historyUrl+'\'" name="makelink" id="makelink" value="More..." />';
|
html += '<input type="button" value="More..." onclick="window.location=\''+historyUrl+'\'" name="makelink" id="makelink" />';
|
||||||
html += '<br />';
|
html += '<br />';
|
||||||
html += '<input id="link" style="display:none; width:90%;" />';
|
html += '<input id="link" style="display:none; width:90%;" />';
|
||||||
|
|
||||||
|
@ -76,6 +66,22 @@ function createVersionsDropdown(filename, files) {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function revertFile() {
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: OC.linkTo('files_versions', 'ajax/rollbackVersion.php'),
|
||||||
|
dataType: 'json',
|
||||||
|
data: {path: file, revision: 'revision'},
|
||||||
|
async: false,
|
||||||
|
success: function(versions) {
|
||||||
|
if (versions) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function addVersion( name ) {
|
function addVersion( name ) {
|
||||||
|
|
||||||
var version = '<option>'+name+'</option>';
|
var version = '<option>'+name+'</option>';
|
||||||
|
|
Loading…
Reference in New Issue