switch from sync.js to DownloadScript.tmpl
This commit is contained in:
@@ -4,6 +4,40 @@ var minisrv_service_file = true;
|
|||||||
headers = `200 OK
|
headers = `200 OK
|
||||||
Content-Type: text/html
|
Content-Type: text/html
|
||||||
wtv-expire: wtv-disk:/content/DownloadScreen.tmpl`
|
wtv-expire: wtv-disk:/content/DownloadScreen.tmpl`
|
||||||
|
var content_dir = "content/"
|
||||||
|
var diskmap_dir = content_dir + "diskmaps/";
|
||||||
|
var diskmap = request_headers.query[wtvshared.getCaseInsensitiveKey("DiskMap", request_headers.query)];
|
||||||
|
var diskmap_json_file = null;
|
||||||
|
Object.keys(service_vaults).forEach(function (g) {
|
||||||
|
if (diskmap_json_file != null) return;
|
||||||
|
diskmap_json_file = service_vaults[g] + "/" + service_name + "/" + diskmap_dir + diskmap + ".json";
|
||||||
|
if (!fs.existsSync(diskmap_json_file)) diskmap_json_file = null;
|
||||||
|
});
|
||||||
|
var diskmap_data = JSON.parse(fs.readFileSync(diskmap_json_file).toString());
|
||||||
|
if (!diskmap_data[request_headers.query.group]) {
|
||||||
|
throw ("Invalid diskmap data (group does not match)");
|
||||||
|
}
|
||||||
|
diskmap_data = diskmap_data[request_headers.query.group];
|
||||||
|
var message = request_headers.query.message || diskmap_data.message || "Retrieving files...";
|
||||||
|
var main_message = request_headers.query.main_message || diskmap_data.main_message || "Your receiver is downloading files.";
|
||||||
|
var success_url = request_headers.query.success_url || diskmap_data.success_url || null;
|
||||||
|
var fail_url = request_headers.query.fail_url || diskmap_data.fail_url || null;
|
||||||
|
|
||||||
|
if (success_url === null) success_url = new clientShowAlert({
|
||||||
|
'image': this.minisrv_config.config.service_logo,
|
||||||
|
'message': "Download successful!",
|
||||||
|
'buttonlabel1': "Okay",
|
||||||
|
'buttonaction1': "client:goback",
|
||||||
|
'noback': true,
|
||||||
|
}).getURL();
|
||||||
|
|
||||||
|
if (fail_url === null) fail_url = new clientShowAlert({
|
||||||
|
'image': this.minisrv_config.config.service_logo,
|
||||||
|
'message': "Download failed...",
|
||||||
|
'buttonlabel1': "Okay",
|
||||||
|
'buttonaction1': "client:goback",
|
||||||
|
'noback': true,
|
||||||
|
}).getURL();
|
||||||
|
|
||||||
data = `<html>
|
data = `<html>
|
||||||
<head>
|
<head>
|
||||||
@@ -16,7 +50,7 @@ if (!request_headers.query.group) data += `&root=file://Disk/Browser/`;
|
|||||||
else data += `&group=${request_headers.query.group}`;
|
else data += `&group=${request_headers.query.group}`;
|
||||||
data += `&message=Retrieving Files..."
|
data += `&message=Retrieving Files..."
|
||||||
>
|
>
|
||||||
<display downloadsuccess=client:goback downloadfail=client:goback>
|
<display downloadsuccess="${success_url}" downloadfail="${fail_url}">
|
||||||
<title>Retrieving Files</title>
|
<title>Retrieving Files</title>
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor=#0 text=#42CC55 fontsize=large hspace=0 vspace=0>
|
<body bgcolor=#0 text=#42CC55 fontsize=large hspace=0 vspace=0>
|
||||||
|
|||||||
@@ -321,7 +321,6 @@ if (request_headers['wtv-request-type'] == 'download') {
|
|||||||
Object.keys(service_vaults).forEach(function (g) {
|
Object.keys(service_vaults).forEach(function (g) {
|
||||||
if (diskmap_json_file != null) return;
|
if (diskmap_json_file != null) return;
|
||||||
diskmap_json_file = service_vaults[g] + "/" + service_name + "/" + diskmap_dir + diskmap + ".json";
|
diskmap_json_file = service_vaults[g] + "/" + service_name + "/" + diskmap_dir + diskmap + ".json";
|
||||||
console.log("Checking diskmap file: " + diskmap_json_file);
|
|
||||||
if (!fs.existsSync(diskmap_json_file)) diskmap_json_file = null;
|
if (!fs.existsSync(diskmap_json_file)) diskmap_json_file = null;
|
||||||
});
|
});
|
||||||
var diskmap_data = JSON.parse(fs.readFileSync(diskmap_json_file).toString());
|
var diskmap_data = JSON.parse(fs.readFileSync(diskmap_json_file).toString());
|
||||||
|
|||||||
@@ -254,104 +254,6 @@ class WTVDownloadList {
|
|||||||
this.deleteGroup(group + "-UPDATE");
|
this.deleteGroup(group + "-UPDATE");
|
||||||
this.delete(path + ".GROUP-UPDATE/");
|
this.delete(path + ".GROUP-UPDATE/");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates the Download page
|
|
||||||
* @param {object} minisrv_config minisrv config object
|
|
||||||
* @param {string} title Page title
|
|
||||||
* @param {string} group
|
|
||||||
* @param {string|null} diskmap
|
|
||||||
* @param {string|null} main_message Message displayed in the center of the page
|
|
||||||
* @param {string|null} message Initial progress bar message
|
|
||||||
* @param {boolean|null} force_update Force this update even if the client reports the files are synced
|
|
||||||
* @param {string|null} success_url Where the client goes when the process succeeds
|
|
||||||
* @param {string|null} fail_url Where the client goes when the process fails.
|
|
||||||
* @param {string|null} url Use your own URL for client:fetch?source= instead of our generated one
|
|
||||||
* @returns {string} HTML Download Page
|
|
||||||
*/
|
|
||||||
getSyncPage(title, group, diskmap = null, main_message = null, message = null, force_update = null, dont_delete_files = null, success_url = null, fail_url = null, url = null) {
|
|
||||||
// Begin Set defaults
|
|
||||||
if (main_message === null) main_message = "Your receiver is downloading files.";
|
|
||||||
|
|
||||||
if (message === null) message = "Retrieving files";
|
|
||||||
|
|
||||||
if (force_update === null) force_update = false;
|
|
||||||
|
|
||||||
if (url === null) url = this.service_name + ":/sync?diskmap=" + escape(diskmap);
|
|
||||||
|
|
||||||
if (force_update) url += "&force=" + force_update;
|
|
||||||
if (dont_delete_files) url += "&dont_delete_files=" + dont_delete_files;
|
|
||||||
|
|
||||||
if (success_url === null) success_url = new this.clientShowAlert({
|
|
||||||
'image': this.minisrv_config.config.service_logo,
|
|
||||||
'message': "Download successful!",
|
|
||||||
'buttonlabel1': "Okay",
|
|
||||||
'buttonaction1': "client:goback",
|
|
||||||
'noback': true,
|
|
||||||
}).getURL();
|
|
||||||
|
|
||||||
if (fail_url === null) fail_url = new this.clientShowAlert({
|
|
||||||
'image': this.minisrv_config.config.service_logo,
|
|
||||||
'message': "Download failed...",
|
|
||||||
'buttonlabel1': "Okay",
|
|
||||||
'buttonaction1': "client:goback",
|
|
||||||
'noback': true,
|
|
||||||
}).getURL();
|
|
||||||
// End set defaults
|
|
||||||
return `<html>
|
|
||||||
<head>
|
|
||||||
<meta
|
|
||||||
http-equiv=refresh
|
|
||||||
content="0;url=client:Fetch?group=${encodeURIComponent(group)}&source=${encodeURIComponent(url)}&message=${encodeURIComponent(message)}"
|
|
||||||
>
|
|
||||||
<display downloadsuccess="${success_url}" downloadfail="${fail_url}">
|
|
||||||
<title>${title}</title>
|
|
||||||
</head>
|
|
||||||
<body bgcolor=#0 text=#42CC55 fontsize=large hspace=0 vspace=0>
|
|
||||||
<table cellspacing=0 cellpadding=0>
|
|
||||||
<tr>
|
|
||||||
<td width=104 height=74 valign=middle align=center bgcolor=3B3A4D>
|
|
||||||
<img src="${this.minisrv_config.config.service_logo}" width=86 height=64>
|
|
||||||
<td width=20 valign=top align=left bgcolor=3B3A4D>
|
|
||||||
<spacer>
|
|
||||||
<td colspan=2 width=436 valign=middle align=left bgcolor=3B3A4D>
|
|
||||||
<font color=D6DFD0 size=+2><blackface><shadow>
|
|
||||||
<spacer type=block width=1 height=4>
|
|
||||||
<br>
|
|
||||||
${message}
|
|
||||||
</shadow>
|
|
||||||
</blackface>
|
|
||||||
</font>
|
|
||||||
<tr>
|
|
||||||
<td width=104 height=20>
|
|
||||||
<td width=20>
|
|
||||||
<td width=416>
|
|
||||||
<td width=20>
|
|
||||||
<tr>
|
|
||||||
<td colspan=2>
|
|
||||||
<td>
|
|
||||||
<font size=+1>
|
|
||||||
${main_message}
|
|
||||||
<p>This may take a while.
|
|
||||||
</font>
|
|
||||||
<tr>
|
|
||||||
<td colspan=2>
|
|
||||||
<td>
|
|
||||||
<br><br>
|
|
||||||
<font color=white>
|
|
||||||
<progressindicator name="downloadprogress"
|
|
||||||
message="Preparing..."
|
|
||||||
height=40 width=250>
|
|
||||||
</font>
|
|
||||||
|
|
||||||
<br>
|
|
||||||
</table>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
`
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = WTVDownloadList;
|
module.exports = WTVDownloadList;
|
||||||
Reference in New Issue
Block a user