Skip to content

Commit

Permalink
Add with uploadProgressFunc and some prompts for upload and download …
Browse files Browse the repository at this point in the history
…in userMain
  • Loading branch information
hcyuser committed Apr 23, 2019
1 parent 58686dc commit 6d846c3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
7 changes: 7 additions & 0 deletions DocuWidgets/docusky.ui.manageDbListSimpleUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,13 @@ var ClsDocuskyManageDbListSimpleUI = function(param) { // constructor
if(error){
console.error(error);
alert(error);
if (typeof realfailFunc === "function") {
realfailFunc(error);
}
else if(typeof me.Error === "function"){
me.Error("Server Error");
}

}else{
console.error("Connection Error");
if (typeof realfailFunc === "function") {
Expand Down
40 changes: 31 additions & 9 deletions userMainPage/userMainPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $(document).ready( function () {
docuskyDbObj = docuskyManageDbListSimpleUI;
docuskyJson = docuskyManageDataFileListSimpleUI;
docuskyDbObj.loginSuccFunc = InitialAfterLogin;

docuskyDbObj.uploadProgressFunc = uploadProgressFunc;
$("#JsonManage").hide();
$("#DocToolBox").hide();
$("#JsonToolBox").hide();
Expand Down Expand Up @@ -47,6 +47,11 @@ function InitialAfterLogin(data){
GetJson();
}

function uploadProgressFunc(data){
$('#LoadingDialog .modal-dialog .modal-content .modal-body .text-center')
.html('<img src="https://docusky.org.tw/DocuSky/WebApi/images/loading-circle.gif"><br>'+$("#UploadDBName").val()+' '+data+'%');
}

function goToTop() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
Expand Down Expand Up @@ -337,7 +342,6 @@ var readFile = function(file){
};

function UploadXMLBTN(event){
$("#uploadXmlToBuildDbId").html("上傳中");
event.preventDefault(); // 2016-05-05: 非常重要,否則會出現 out of memory 的 uncaught exception
var url = 'https://docusky.org.tw/DocuSky/webApi/uploadXmlFilesToBuildDbJson.php';
formData = [];
Expand All @@ -347,11 +351,25 @@ function UploadXMLBTN(event){
let nameVal = "importedFiles[]";
formData.file = {value: tmp.fileData, filename: tmp.fileName, name:nameVal};
//console.log(formData);
docuskyDbObj.uploadMultipart(url, formData,function(data){
$("#uploadXmlToBuildDbId").html("開始上傳");
alert(data.message);
GetCorpus();
});
$('#LoadingDialog .modal-dialog .modal-content .modal-body .text-center')
.html('<img src="https://docusky.org.tw/DocuSky/WebApi/images/loading-circle.gif"><br>'+$("#UploadDBName").val()+' 建庫中,請稍後');
$('#LoadingDialog').modal({backdrop: 'static', keyboard: false});
$("#LoadingDialog").modal('show');
docuskyDbObj.uploadMultipart(url, formData,
function(data){
alert(data.message);
GetCorpus();
$('#LoadingDialog .modal-dialog .modal-content .modal-body .text-center')
.html('<img src="https://docusky.org.tw/DocuSky/WebApi/images/loading-circle.gif">');
$("#LoadingDialog").modal('hide');
},
function(data){
GetCorpus();
$('#LoadingDialog .modal-dialog .modal-content .modal-body .text-center')
.html('<img src="https://docusky.org.tw/DocuSky/WebApi/images/loading-circle.gif">');
$("#LoadingDialog").modal('hide');
}
);
}


Expand Down Expand Up @@ -523,11 +541,14 @@ var downloadDocuXml = function (dbname) {
for (let i in docuSkyObj.docList) {
documents[docuSkyObj.docList[i].number] = docuSkyObj.docList[i].docInfo
}

$('#LoadingDialog .modal-dialog .modal-content .modal-body .text-center')
.html('<img src="https://docusky.org.tw/DocuSky/WebApi/images/loading-circle.gif"><br>'+dbname+' '+param.page*param.pageSize + " / " + totalFound);
if (param.page * param.pageSize <= totalFound) {
param.page += 1;
docuSkyObj.getQueryResultDocuments(param, null, getDocList);
} else {
$('#LoadingDialog .modal-dialog .modal-content .modal-body .text-center')
.html('<img src="https://docusky.org.tw/DocuSky/WebApi/images/loading-circle.gif">');
$("#LoadingDialog").modal('hide');
let exporter = new DocuSkyExporter();
let xmlString = exporter.generateDocuXml(documents, param.db);
Expand All @@ -538,7 +559,8 @@ var downloadDocuXml = function (dbname) {
};

docuSkyObj.hideLoadingIcon(true);
alert("下載中,請稍候");
$('#LoadingDialog .modal-dialog .modal-content .modal-body .text-center')
.html('<img src="https://docusky.org.tw/DocuSky/WebApi/images/loading-circle.gif"><br>'+dbname+' 下載中,請稍候');
$('#LoadingDialog').modal({backdrop: 'static', keyboard: false});
$("#LoadingDialog").modal('show');
docuSkyObj.getQueryResultDocuments(param, null, getDocList);
Expand Down

0 comments on commit 6d846c3

Please sign in to comment.