|
@@ -9,9 +9,6 @@
|
|
<script type="text/javascript" src="../../script/ao_module.js"></script>
|
|
<script type="text/javascript" src="../../script/ao_module.js"></script>
|
|
<script type="text/javascript" src="../../script/applocale.js"></script>
|
|
<script type="text/javascript" src="../../script/applocale.js"></script>
|
|
<style>
|
|
<style>
|
|
- body{
|
|
|
|
- overflow:hidden;
|
|
|
|
- }
|
|
|
|
|
|
|
|
</style>
|
|
</style>
|
|
</head>
|
|
</head>
|
|
@@ -22,7 +19,12 @@
|
|
<span locale="title/title">File Version History</span>
|
|
<span locale="title/title">File Version History</span>
|
|
<div class="sub header" locale="title/desc">Any file versions that is more than 30 days old will be automatically removed from the system.</div>
|
|
<div class="sub header" locale="title/desc">Any file versions that is more than 30 days old will be automatically removed from the system.</div>
|
|
</h3>
|
|
</h3>
|
|
|
|
+ <button onclick="createSnapshot();" class="ui basic green button"><i class="ui add icon"></i> <span locale="button/newver">Create New Version</span></button>
|
|
|
|
+
|
|
<div class="ui divider"></div>
|
|
<div class="ui divider"></div>
|
|
|
|
+ <div id="succ" style="display:none;" class="ui green message">
|
|
|
|
+ <i class="ui checkmark icon"></i> <span id="msg">File Restore Succeed</span>
|
|
|
|
+ </div>
|
|
<div>
|
|
<div>
|
|
<table class="ui very basic fluid celled table unstackable">
|
|
<table class="ui very basic fluid celled table unstackable">
|
|
<tbody id="versions">
|
|
<tbody id="versions">
|
|
@@ -30,8 +32,8 @@
|
|
<td>
|
|
<td>
|
|
<h4 class="ui header">
|
|
<h4 class="ui header">
|
|
<div class="content">
|
|
<div class="content">
|
|
- <span>No File</span>
|
|
|
|
- <div class="sub header">Invalid usage</div>
|
|
|
|
|
|
+ <span locale="message/nofile/title">No File</span>
|
|
|
|
+ <div locale="message/nofile/desc" class="sub header">Invalid usage</div>
|
|
</div>
|
|
</div>
|
|
</h4>
|
|
</h4>
|
|
</td>
|
|
</td>
|
|
@@ -39,20 +41,49 @@
|
|
</tbody>
|
|
</tbody>
|
|
</table>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
+ <div class="ui divider"></div>
|
|
|
|
+ <button class="ui red button" onclick="deleteAllVersions();"><i class="ui trash icon"></i> <span locale="button/removeAll">Remove All Version Histories</span></button>
|
|
<br>
|
|
<br>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
<script>
|
|
var files = ao_module_loadInputFiles();
|
|
var files = ao_module_loadInputFiles();
|
|
var targetFile = "";
|
|
var targetFile = "";
|
|
|
|
+ var currentVersionList = [];
|
|
if (files.length >= 1){
|
|
if (files.length >= 1){
|
|
targetFile = files[0];
|
|
targetFile = files[0];
|
|
loadVersionHistory(targetFile);
|
|
loadVersionHistory(targetFile);
|
|
|
|
+
|
|
|
|
+ setInterval(function(){
|
|
|
|
+ checkHistoryListUpdate(targetFile);
|
|
|
|
+ }, 3000)
|
|
}else{
|
|
}else{
|
|
//No file selected
|
|
//No file selected
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ applocale.init("../../SystemAO/locale/file_versions.json", function(){
|
|
|
|
+ applocale.translate();
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ function checkHistoryListUpdate(vpath){
|
|
|
|
+ $.ajax({
|
|
|
|
+ url: "../../system/file_system/versionHistory",
|
|
|
|
+ data: {path: vpath},
|
|
|
|
+ method: "POST",
|
|
|
|
+ success: function(data){
|
|
|
|
+ if (data.error == undefined){
|
|
|
|
+ if (currentVersionList.length != data.Versions.length){
|
|
|
|
+ loadVersionHistory(vpath);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
function loadVersionHistory(vpath){
|
|
function loadVersionHistory(vpath){
|
|
|
|
+ $("#versions").html("Loading...");
|
|
$.ajax({
|
|
$.ajax({
|
|
url: "../../system/file_system/versionHistory",
|
|
url: "../../system/file_system/versionHistory",
|
|
data: {path: vpath},
|
|
data: {path: vpath},
|
|
@@ -62,6 +93,7 @@
|
|
alert(data.error);
|
|
alert(data.error);
|
|
}else{
|
|
}else{
|
|
$("#versions").html("");
|
|
$("#versions").html("");
|
|
|
|
+ currentVersionList = data.Versions;
|
|
data.Versions.forEach(fileVersionEntry => {
|
|
data.Versions.forEach(fileVersionEntry => {
|
|
var filesize = ao_module_utils.formatBytes(fileVersionEntry.Filesize, 1);
|
|
var filesize = ao_module_utils.formatBytes(fileVersionEntry.Filesize, 1);
|
|
$("#versions").append(`<tr>
|
|
$("#versions").append(`<tr>
|
|
@@ -74,14 +106,28 @@
|
|
</h4></td>
|
|
</h4></td>
|
|
<td>
|
|
<td>
|
|
<div class="ui icon mini buttons">
|
|
<div class="ui icon mini buttons">
|
|
- <button relpath="${fileVersionEntry.Relpath}" onclick="downloadVersion(this);" class="ui very basic icon button" title="Download Version"><i class="ui blue download icon"></i></button>
|
|
|
|
- <button verid="${fileVersionEntry.HistoryID}" class="ui very basic icon button" title="Restore This Version"><i class="ui green sync icon"></i></button>
|
|
|
|
- <button verid="${fileVersionEntry.HistoryID}" class="ui very basic icon button" title="Delete"><i class="ui red trash icon"></i></button>
|
|
|
|
|
|
+ <button relpath="${fileVersionEntry.Relpath}" onclick="downloadVersion(this);" class="ui very basic icon button" title="${applocale.getString("title/download", "Download Version")}"><i class="ui blue download icon"></i></button>
|
|
|
|
+ <button verid="${fileVersionEntry.HistoryID}" onclick="restoreVersion(this);" class="ui very basic icon button" title="${applocale.getString("title/restore", "Restore This Version")}"><i class="ui green history icon"></i></button>
|
|
|
|
+ <button verid="${fileVersionEntry.HistoryID}" onclick="deleteVersion(this);" class="ui very basic icon button" title="${applocale.getString("title/delete", "Delete")}"><i class="ui red trash icon"></i></button>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</td>
|
|
</td>
|
|
</tr>`);
|
|
</tr>`);
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ if (data.Versions.length == 0){
|
|
|
|
+ //This file has no version history
|
|
|
|
+ $("#versions").html(`<tr>
|
|
|
|
+ <td>
|
|
|
|
+ <h4 class="ui header">
|
|
|
|
+ <div class="content">
|
|
|
|
+ <i class="ui history icon"></i><span> ${applocale.getString("message/nohist/title", "No History")}</span>
|
|
|
|
+ <div class="sub header">${applocale.getString("message/nohist/desc", "This file has no previous version histories.")}</div>
|
|
|
|
+ </div>
|
|
|
|
+ </h4>
|
|
|
|
+ </td>
|
|
|
|
+ </tr>`);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -95,8 +141,80 @@
|
|
window.open("../../media?file=" + accessPath + "&download=true")
|
|
window.open("../../media?file=" + accessPath + "&download=true")
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function createSnapshot(){
|
|
|
|
+ //Create a snapshot of the current object
|
|
|
|
+ $.ajax({
|
|
|
|
+ url: "../../system/file_system/versionHistory",
|
|
|
|
+ data: {path: targetFile, opr: "new"},
|
|
|
|
+ method: "POST",
|
|
|
|
+ success: function(data){
|
|
|
|
+ if (data.error != undefined){
|
|
|
|
+ alert(data.error)
|
|
|
|
+ }else{
|
|
|
|
+ msgbox(applocale.getString("msgbox/created","New Version Created"));
|
|
|
|
+ loadVersionHistory(targetFile);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function restoreVersion(object){
|
|
|
|
+ var versionID = $(object).attr("verid");
|
|
|
|
+ if (confirm(applocale.getString("warning/restore", "Restoring this file will remove all newer version histories of this file. Confirm?"))){
|
|
|
|
+ $.ajax({
|
|
|
|
+ url: "../../system/file_system/versionHistory",
|
|
|
|
+ data: {path: targetFile, opr: "restore", histid: versionID},
|
|
|
|
+ method: "POST",
|
|
|
|
+ success: function(data){
|
|
|
|
+ if (data.error != undefined){
|
|
|
|
+ alert(data.error)
|
|
|
|
+ }else{
|
|
|
|
+ loadVersionHistory(targetFile);
|
|
|
|
+ msgbox(applocale.getString("msgbox/restored","Restore Succeed"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function msgbox(message){
|
|
|
|
+ $("#msg").text(message);
|
|
|
|
+ $("#succ").stop().finish().fadeIn("fast").delay(3000).fadeOut("fast");
|
|
|
|
+ }
|
|
|
|
+
|
|
function deleteVersion(object){
|
|
function deleteVersion(object){
|
|
var versionID = $(object).attr("verid");
|
|
var versionID = $(object).attr("verid");
|
|
|
|
+ $.ajax({
|
|
|
|
+ url: "../../system/file_system/versionHistory",
|
|
|
|
+ data: {path: targetFile, opr: "delete", histid: versionID},
|
|
|
|
+ method: "POST",
|
|
|
|
+ success: function(data){
|
|
|
|
+ if (data.error != undefined){
|
|
|
|
+ alert(data.error)
|
|
|
|
+ }else{
|
|
|
|
+ loadVersionHistory(targetFile);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function deleteAllVersions(object){
|
|
|
|
+ var versionID = $(object).attr("verid");
|
|
|
|
+ if (confirm(applocale.getString("warning/deleteall", "This operation will **PERMANENTLY DELETE ALL** version history of this file. Confirm?"))){
|
|
|
|
+ $.ajax({
|
|
|
|
+ url: "../../system/file_system/versionHistory",
|
|
|
|
+ data: {path: targetFile, opr: "deleteAll", histid: versionID},
|
|
|
|
+ method: "POST",
|
|
|
|
+ success: function(data){
|
|
|
|
+ if (data.error != undefined){
|
|
|
|
+ alert(data.error)
|
|
|
|
+ }else{
|
|
|
|
+ msgbox(applocale.getString("msgbox/deletedall","All version history deleted"));
|
|
|
|
+ loadVersionHistory(targetFile);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|