mirror of https://github.com/perkeep/perkeep.git
UI: checkbox to optionally use rolling checksum boundaries
This commit is contained in:
parent
4bef24be00
commit
6a74ef1e80
|
@ -233,7 +233,16 @@ func (ui *UIHandler) serveUploadHelper(rw http.ResponseWriter, req *http.Request
|
|||
http.Error(rw, "Multipart error: "+err.String(), 500)
|
||||
break
|
||||
}
|
||||
br, err := schema.WriteFileFromReader(ui.Storage, part.FileName(), part)
|
||||
fileName := part.FileName()
|
||||
if fileName == "" {
|
||||
continue
|
||||
}
|
||||
get, _ := http.ParseQuery(req.URL.RawQuery)
|
||||
writeFn := schema.WriteFileFromReader
|
||||
if len(get["rollsum"]) == 1 && get["rollsum"][0] == "1" {
|
||||
writeFn = schema.WriteFileFromReaderRolling
|
||||
}
|
||||
br, err := writeFn(ui.Storage, fileName, part)
|
||||
|
||||
fmt.Fprintf(&buf, "filename=%q, formname=%q, br=<a href='./?b=%s'>%s</a>, err=%v\n", part.FileName(), part.FormName(), br, br, err)
|
||||
|
||||
|
|
|
@ -36,15 +36,8 @@
|
|||
<form method="POST" id='uploadform' enctype="multipart/form-data">
|
||||
<input type="file" id="fileinput" multiple="true" name="file" disabled="true" />
|
||||
<input type="submit" id="filesubmit" value="Upload" disabled="true" />
|
||||
<input type="checkbox" name="rollsum" id="chkrollsum" value="1" /> <label for="chkrollsum">Use rolling checksum for boundaries</label>
|
||||
</form>
|
||||
<script>
|
||||
if (disco && disco.uploadHelper) {
|
||||
document.getElementById("uploadform").action = disco.uploadHelper;
|
||||
document.getElementById("fileinput").disabled = false;
|
||||
document.getElementById("filesubmit").disabled = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -33,6 +33,26 @@ function indexOnLoad(e) {
|
|||
}
|
||||
btnNew.addEventListener("click", btnCreateNewPermanode);
|
||||
camliGetRecentlyUpdatedPermanodes({ success: indexBuildRecentlyUpdatedPermanodes });
|
||||
|
||||
if (disco && disco.uploadHelper) {
|
||||
var uploadForm = document.getElementById("uploadform");
|
||||
uploadform.action = disco.uploadHelper;
|
||||
document.getElementById("fileinput").disabled = false;
|
||||
document.getElementById("filesubmit").disabled = false;
|
||||
var chkRollSum = document.getElementById("chkrollsum");
|
||||
chkRollSum.addEventListener("change", function (e) {
|
||||
if (chkRollSum.checked) {
|
||||
if (disco.uploadHelper.indexOf("?") == -1) {
|
||||
uploadform.action = disco.uploadHelper + "?rollsum=1";
|
||||
} else {
|
||||
uploadform.action = disco.uploadHelper + "&rollsum=1";
|
||||
}
|
||||
} else {
|
||||
uploadform.action = disco.uploadHelper;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function indexBuildRecentlyUpdatedPermanodes(searchRes) {
|
||||
|
|
Loading…
Reference in New Issue