transfer-google-drive-folde.../webui.html

218 lines
27 KiB
HTML
Raw Normal View History

2021-11-28 19:58:00 +01:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; margin: 0; padding: 0;">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Google Apps Script</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.5.0/pure-min.css">
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.5.0/grids-responsive-old-ie-min.css">
<![endif]-->
<!--[if gt IE 8]><!-->
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.5.0/grids-responsive-min.css">
<!--<![endif]-->
<style>@media screen and (min-width:35.5em){.u-sm-1,.u-sm-1-1,.u-sm-1-12,.u-sm-1-2,.u-sm-1-24,.u-sm-1-3,.u-sm-1-4,.u-sm-1-5,.u-sm-1-6,.u-sm-1-8,.u-sm-10-24,.u-sm-11-12,.u-sm-11-24,.u-sm-12-24,.u-sm-13-24,.u-sm-14-24,.u-sm-15-24,.u-sm-16-24,.u-sm-17-24,.u-sm-18-24,.u-sm-19-24,.u-sm-2-24,.u-sm-2-3,.u-sm-2-5,.u-sm-20-24,.u-sm-21-24,.u-sm-22-24,.u-sm-23-24,.u-sm-24-24,.u-sm-3-24,.u-sm-3-4,.u-sm-3-5,.u-sm-3-8,.u-sm-4-24,.u-sm-4-5,.u-sm-5-12,.u-sm-5-24,.u-sm-5-5,.u-sm-5-6,.u-sm-5-8,.u-sm-6-24,.u-sm-7-12,.u-sm-7-24,.u-sm-7-8,.u-sm-8-24,.u-sm-9-24{display:inline-block;zoom:1;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.u-sm-1-24{width:4.1667%}.u-sm-1-12,.u-sm-2-24{width:8.3333%}.u-sm-1-8,.u-sm-3-24{width:12.5%}.u-sm-1-6,.u-sm-4-24{width:16.6667%}.u-sm-1-5{width:20%}.u-sm-5-24{width:20.8333%}.u-sm-1-4,.u-sm-6-24{width:25%}.u-sm-7-24{width:29.1667%}.u-sm-1-3,.u-sm-8-24{width:33.3333%}.u-sm-3-8,.u-sm-9-24{width:37.5%}.u-sm-2-5{width:40%}.u-sm-10-24,.u-sm-5-12{width:41.6667%}.u-sm-11-24{width:45.8333%}.u-sm-1-2,.u-sm-12-24{width:50%}.u-sm-13-24{width:54.1667%}.u-sm-14-24,.u-sm-7-12{width:58.3333%}.u-sm-3-5{width:60%}.u-sm-15-24,.u-sm-5-8{width:62.5%}.u-sm-16-24,.u-sm-2-3{width:66.6667%}.u-sm-17-24{width:70.8333%}.u-sm-18-24,.u-sm-3-4{width:75%}.u-sm-19-24{width:79.1667%}.u-sm-4-5{width:80%}.u-sm-20-24,.u-sm-5-6{width:83.3333%}.u-sm-21-24,.u-sm-7-8{width:87.5%}.u-sm-11-12,.u-sm-22-24{width:91.6667%}.u-sm-23-24{width:95.8333%}.u-sm-1,.u-sm-1-1,.u-sm-24-24,.u-sm-5-5{width:100%}}@media screen and (min-width:48em){.u-md-1,.u-md-1-1,.u-md-1-12,.u-md-1-2,.u-md-1-24,.u-md-1-3,.u-md-1-4,.u-md-1-5,.u-md-1-6,.u-md-1-8,.u-md-10-24,.u-md-11-12,.u-md-11-24,.u-md-12-24,.u-md-13-24,.u-md-14-24,.u-md-15-24,.u-md-16-24,.u-md-17-24,.u-md-18-24,.u-md-19-24,.u-md-2-24,.u-md-2-3,.u-md-2-5,.u-md-20-24,.u-md-21-24,.u-md-22-24,.u-md-23-24,.u-md-24-24,.u-md-3-24,.u-md-3-4,.u-md-3-5,.u-md-3-8,.u-md-4-24,.u-md-4-5,.u-md-5-12,.u-md-5-24,.u-md-5-5,.u-md-5-6,.u-md-5-8,.u-md-6-24,.u-md-7-12,.u-md-7-24,.u-md-7-8,.u-md-8-24,.u-md-9-24{display:inline-block;zoom:1;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.u-md-1-24{width:4.1667%}.u-md-1-12,.u-md-2-24{width:8.3333%}.u-md-1-8,.u-md-3-24{width:12.5%}.u-md-1-6,.u-md-4-24{width:16.6667%}.u-md-1-5{width:20%}.u-md-5-24{width:20.8333%}.u-md-1-4,.u-md-6-24{width:25%}.u-md-7-24{width:29.1667%}.u-md-1-3,.u-md-8-24{width:33.3333%}.u-md-3-8,.u-md-9-24{width:37.5%}.u-md-2-5{width:40%}.u-md-10-24,.u-md-5-12{width:41.6667%}.u-md-11-24{width:45.8333%}.u-md-1-2,.u-md-12-24{width:50%}.u-md-13-24{width:54.1667%}.u-md-14-24,.u-md-7-12{width:58.3333%}.u-md-3-5{width:60%}.u-md-15-24,.u-md-5-8{width:62.5%}.u-md-16-24,.u-md-2-3{width:66.6667%}.u-md-17-24{width:70.8333%}.u-md-18-24,.u-md-3-4{width:75%}.u-md-19-24{width:79.1667%}.u-md-4-5{width:80%}.u-md-20-24,.u-md-5-6{width:83.3333%}.u-md-21-24,.u-md-7-8{width:87.5%}.u-md-11-12,.u-md-22-24{width:91.6667%}.u-md-23-24{width:95.8333%}.u-md-1,.u-md-1-1,.u-md-24-24,.u-md-5-5{width:100%}}@media screen and (min-width:58em){.u-lg-1,.u-lg-1-1,.u-lg-1-12,.u-lg-1-2,.u-lg-1-24,.u-lg-1-3,.u-lg-1-4,.u-lg-1-5,.u-lg-1-6,.u-lg-1-8,.u-lg-10-24,.u-lg-11-12,.u-lg-11-24,.u-lg-12-24,.u-lg-13-24,.u-lg-14-24,.u-lg-15-24,.u-lg-16-24,.u-lg-17-24,.u-lg-18-24,.u-lg-19-24,.u-lg-2-24,.u-lg-2-3,.u-lg-2-5,.u-lg-20-24,.u-lg-21-24,.u-lg-22-24,.u-lg-23-24,.u-lg-24-24,.u-lg-3-24,.u-lg-3-4,.u-lg-3-5,.u-lg-3-8,.u-lg-4-24,.u-lg-4-5,.u-lg-5-12,.u-lg-5-24,.u-lg-5-5,.u-lg-5-6,.u-lg-5-8,.u-lg-6-24,.u-lg-7-12,.u-lg-7-24,.u-lg-7-8,.u-lg-8-24,.u-lg-9-24{display:inline-block;zoom:1;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.u-lg-1-24{width:4.1667%}.u-lg-1-12,.u-lg-2-24{width:8.3333%}.u-lg-1-8,.u-lg-3-24{width:12.5%}.u-lg-1-6,.u-lg-4-24{width:16.6667%}.u-lg-1-5{width:20%}.u-lg-5-24{width:20.8333%}.u-lg-1-4,.u-lg-6-24{width:25%}.u-lg-7-24{width:29.1667%}.u-lg-1-3,.u-lg-8-24{width:33.3333%}.u-lg-3-8,.u-lg-9-24{width:37.5%}.u-lg-2-5{width:40%}.u-lg-10-24,.u-lg-5-12{width:41.6667%}.u-lg-11-24{width:45.8333%}.u-lg-1-2,.u-lg-12-24
</head>
<!-- http://purecss.io/ -->
<body>
<style scoped>
.button-main
.button-success,
.button-warning
.button-error,
.button-main {background: rgb(115, 143, 254);} /* #738ffe = Blue 400 */
.button-success {background: rgb(43, 175, 43);} /* #2baf2b = Green 400 */
.button-warning {background: rgb(255, 179, 0);} /* #ffb300 = Amber 600 */
.button-error {background: rgb(255, 112, 67);} /* #ff7043 = Deep Orange 400 */
</style>
<div class="header">
<h1><?= GVAR.SCRIPT_NAME ?></h1>
<h2>Control Panel</h2>
</div>
<br>
<div class="content">
<form class="pure-form pure-form-aligned">
<fieldset>
<legend>Main controls</legend>
<div class="pure-control-group">
<label for="name">Scan dir to cache file</label>
<button type="submit" class="pure-button button-error" onclick="var runResult = google.script.run.withFailureHandler(setFailure('bA')).withSuccessHandler(setSuccess('bA')).setDirScanToCacheFile()">Run</button>
<button type="submit" class="pure-button pure-button-disabled" id="bA" disabled>...</button>
</div>
<div class="pure-control-group">
<label for="name">Transfer ownership</label>
<button type="submit" class="pure-button button-error" onclick="var runResult = google.script.run.withFailureHandler(setFailure('bG')).withSuccessHandler(setSuccess('bG')).setTransferOwnership()">Run</button>
<button type="submit" class="pure-button pure-button-disabled" id="bG" disabled>...</button>
</div>
<div class="pure-control-group">
<label for="name">Settle new file for:</label>
<select id="settle-new-file">
<option>dirScan</option>
<option>transResult</option>
</select>
<button type="submit" class="pure-button button-warning" onclick="var runResult = google.script.run.withFailureHandler(setFailure('bB')).withSuccessHandler(setSuccess('bB')).getCacheFileId('true',$('#settle-new-file').val())">Run</button>
<button type="submit" class="pure-button pure-button-disabled" id="bB" disabled>...</button>
</div>
<div class="pure-control-group">
<label for="name">Clean existing file for:</label>
<select id="clean-existing-file">
<option>dirScan</option>
<option>transResult</option>
</select>
<button type="submit" class="pure-button button-warning" onclick="var runResult = google.script.run.withFailureHandler(setFailure('bC')).withSuccessHandler(setSuccess('bC')).setCleanCacheFile($('#clean-existing-file').val())">Run</button>
<button type="submit" class="pure-button pure-button-disabled" id="bC" disabled>...</button>
</div>
<div class="pure-control-group">
<label for="name">Get active triggers</label>
<button type="submit" class="pure-button button-main" onclick="var runResult = google.script.run.withSuccessHandler(getTriggers).getScriptTriggersArray()">Run</button>
<button type="submit" class="pure-button pure-button-disabled" id="bI" disabled>...</button>
</div>
<ul id="triggers">
<li>Click 'Run' button to get triggers...</li>
</ul>
<div class="pure-control-group">
<label for="name">Delete triggers for:</label>
<select id="trigger-function-to-delete">
<option>setTransferOwnership</option>
<option>setDirScanToCacheFile</option>
</select>
<button type="submit" class="pure-button button-warning" onclick="var runResult = google.script.run.withFailureHandler(setFailure('bE')).withSuccessHandler(setSuccess('bE')).setDeleteAllTriggersOfHandlerFunction($('#trigger-function-to-delete').val())">Run</button>
<button type="submit" class="pure-button pure-button-disabled" id="bE" disabled>...</button>
</div>
<div class="pure-control-group">
<label for="name">Release user lock</label>
<button type="submit" class="pure-button button-success" onclick="var runResult = google.script.run.withFailureHandler(setFailure('bD')).withSuccessHandler(setSuccess('bD')).setReleaseUserLock()">Run</button>
<button type="submit" class="pure-button pure-button-disabled" id="bD" disabled>...</button>
</div>
<div class="pure-control-group">
<label for="name">File count e-mail for:</label>
<input id="user-email" type="email" placeholder="E-mail address">
<button type="submit" class="pure-button button-success" onclick="var runResult = google.script.run.withFailureHandler(setFailure('bF')).withSuccessHandler(setSuccess('bF')).getUserSharedFileCount($('#user-email').val())">Run</button>
<button type="submit" class="pure-button pure-button-disabled" id="bF" disabled>...</button>
</div>
<div class="pure-control-group">
<label for="name">Revoke access</label>
<a href=<?= "https://script.google.com/a/" + GVAR.DOMAIN_OF_GOOGLE_APPS + "/d/" + GVAR.SCRIPT_URL_ID + "/manage/uninstall" ?>>Open URL</a>
</div>
</fieldset>
</form>
<form class="pure-form pure-form-aligned">
<fieldset>
<legend>Global variables</legend>
<div class="pure-control-group">
<label for="name">Transfer ownership to:</label>
<input id="TRANSFER_OWNERSHIP_TO" type="text" placeholder=<?=GVAR.TRANSFER_OWNERSHIP_TO?>>
</div>
<div class="pure-control-group">
<label for="name">Domain of Google Apps:</label>
<input id="DOMAIN_OF_GOOGLE_APPS" type="text" placeholder=<?=GVAR.DOMAIN_OF_GOOGLE_APPS?>>
</div>
<div class="pure-control-group">
<label for="name">Dir scan cache file lifetime (hours):</label>
<input id="CACHE_FILE_LIFETIME" type="text" placeholder=<?=GVAR.CACHE_FILE_LIFETIME?>>
</div>
<div class="pure-control-group">
<label for="name">Root folder ID:</label>
<input id="ROOT_FOLDER_ID" type="text" placeholder=<?=GVAR.ROOT_FOLDER_ID?>>
</div>
<div class="pure-control-group">
<label for="name">Cache folder ID:</label>
<input id="CACHE_FOLDER_ID" type="text" placeholder=<?=GVAR.CACHE_FOLDER_ID?>>
</div>
<div class="pure-control-group">
<label for="name">Log file ID:</label>
<input id="LOG_FILE_ID" type="text" placeholder=<?=GVAR.LOG_FILE_ID?>>
</div>
<!--<div class="pure-control-group">
<label for="name">Set global variables</label>
<button type="submit" class="pure-button button-error" onclick="var runResult = google.script.run.withFailureHandler(setFailure('bX')).withSuccessHandler(setSuccess('bX')).setGlobalVariables($('#user-email').val())">Run</button>
<button type="submit" class="pure-button pure-button-disabled" id="bX" disabled>...</button>
</div>-->
</fieldset>
</form>
<form class="pure-form pure-form-aligned">
<fieldset>
<legend>Actual variables and outputs</legend>
<div class="pure-control-group">
<label for="name">Work folder ID</label>
<a href=<?= "https://drive.google.com/open?id=" + GVAR.CACHE_FOLDER_ID + "&authuser=0"?>><?=GVAR.CACHE_FOLDER_ID?></a>
</div>
<div class="pure-control-group">
<label for="name">Actual cache file ID</label>
<a href=<?= "https://drive.google.com/open?id=" + PropertiesService.getScriptProperties().getProperty("cacheFileId" + "_" + "dirScan") + "&authuser=0"?>><?=PropertiesService.getScriptProperties().getProperty("cacheFileId" + "_" + "dirScan")?></a>
</div>
<div class="pure-control-group">
<label for="name">Actual result file ID</label>
<a href=<?= "https://drive.google.com/open?id=" + PropertiesService.getScriptProperties().getProperty("cacheFileId" + "_" + "transResult") + "&authuser=0"?>><?=PropertiesService.getScriptProperties().getProperty("cacheFileId" + "_" + "transResult")?></a>
</div>
<!--<div class="pure-control-group">
<label for="name">Show user triggers</label>
<a href=<?= "https://script.google.com/a/macros/netmail.eu/triggers?id=" + GVAR.SCRIPT_PROJECT_KEY ?>>Open URL</a>
</div>-->
</fieldset>
</form>
<form class="pure-form pure-form-aligned">
<fieldset>
<div class="pure-control-group">
<label for="name">Get file log</label>
<!--<button type="submit" class="pure-button button-main" onclick="var runResult = google.script.run.withSuccessHandler(getLog).getScriptLogArray()">Run</button>-->
<button type="submit" class="pure-button button-main" onclick="var runResult = google.script.run.withSuccessHandler(getLog).getFlog()">Run</button>
<button type="submit" class="pure-button pure-button-disabled" id="bH" disabled>...</button>
</div>
<div class="pure-control-group">
<label for="name">Clean file log</label>
<button type="submit" class="pure-button button-warning" onclick="var runResult = google.script.run.withSuccessHandler(setSuccess('bJ')).Flog('','true')">Run</button>
<button type="submit" class="pure-button pure-button-disabled" id="bJ" disabled>...</button>
</div>
<ul id="log">
<li>Click 'Run' button to get file log...</li>
</ul>
</fieldset>
</form>
</div>
<script>
function setSuccess(elemId) {
var setTimer = setInterval(function () {revertClass(elemId)}, 5000);
var aElem = document.getElementById(elemId);
aElem.innerHTML = "Success.";
aElem.setAttribute("class", "pure-button pure-button-disabled button-success");
}
function setFailure(elemId) {
var setTimer = setInterval(function () {revertClass(elemId)}, 5000);
var aElem = document.getElementById(elemId);
aElem.innerHTML = "Failure!";
aElem.setAttribute("class", "pure-button pure-button-disabled button-error");
}
function revertClass(elemId) {
var aElem = document.getElementById(elemId);
aElem.innerHTML = "...";
aElem.setAttribute("class", "pure-button pure-button-disabled");
}
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
function getTriggers(items) {
var list = $("#triggers");
list.empty();
if (items.length === 0) {list.append("<li>" + "Trigger list is empty at the moment." + "</li>")};
for (var i = 0; i < items.length; i++) {
list.append("<li>" + items[i] + "</li>");
}
setSuccess("bI");
return true;
}
</script>
<script>
function getLog(items) {
var list = $("#log");
list.empty();
if (items.length === 0) {list.append("<li>" + "Log is empty at the moment." + "</li>")};
for (var i = 0; i < items.length; i++) {
list.append("<li>" + items[i] + "</li>");
}
setSuccess("bH");
return true;
}
</script>
</body>