misc fixes:
- don't attempt to resolve sourceUrl (breaks file urls) - pass blob to loader - add exact size progress update, if available - google drive loader: switch to manual auth for any error
This commit is contained in:
+4
-2
@@ -39,7 +39,9 @@ class Chooser extends LitElement
|
||||
loadInfo.loadUrl = url.href;
|
||||
} else {
|
||||
loadInfo.loadUrl = URL.createObjectURL(this.file);
|
||||
loadInfo.blob = this.file;
|
||||
}
|
||||
loadInfo.size = this.file.size;
|
||||
loadInfo.noCache = this.file.path !== undefined;
|
||||
loadInfo.name = this.fileDisplayName;
|
||||
}
|
||||
@@ -125,11 +127,11 @@ class Chooser extends LitElement
|
||||
<p class="control is-expanded">
|
||||
<input class="file-name input" type="text"
|
||||
name="filename" id="filename"
|
||||
pattern="((file|http|https|s3):\/\/.*\.(warc|warc.gz|har|zip|wacz))|(googledrive:\/\/.+)"
|
||||
pattern="((file|http|https|s3):\/\/.*\.(warc|warc.gz|zip|wacz))|(googledrive:\/\/.+)"
|
||||
.value="${this.fileDisplayName}"
|
||||
@input="${this.onInput}"
|
||||
autocomplete="off"
|
||||
placeholder="Enter a URL or click 'Choose File' to select a (WARC, HAR, WBN, or WACZ) archive source">
|
||||
placeholder="Enter a URL or click 'Choose File' to select a WARC or WACZ archive source">
|
||||
</p>
|
||||
<div class="control">
|
||||
<button type="submit" class="button is-hidden-mobile is-primary">Load</button>
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@ class GDrive extends LitElement
|
||||
onLoad() {
|
||||
this.scriptLoaded = true;
|
||||
this.gauth('none', (response) => {
|
||||
if (response.error === "immediate_failed") {
|
||||
if (response.error) {
|
||||
if (this.state !== "implicitonly") {
|
||||
this.state = "trymanual";
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { LitElement, html, css } from 'lit-element';
|
||||
import { wrapCss } from './misc';
|
||||
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
|
||||
import { parseURLSchemeHostPath, initDBWorker } from './pageutils';
|
||||
|
||||
|
||||
@@ -16,6 +18,9 @@ class Loader extends LitElement
|
||||
this.state = "waiting";
|
||||
this.loadInfo = null;
|
||||
|
||||
this.currentSize = 0;
|
||||
this.totalSize = 0;
|
||||
|
||||
this.dbworker = initDBWorker();
|
||||
}
|
||||
|
||||
@@ -26,6 +31,8 @@ class Loader extends LitElement
|
||||
state: { type: String },
|
||||
progress: { type: Number },
|
||||
percent: { type: Number },
|
||||
currentSize: { type: Number },
|
||||
totalSize: { type: Number },
|
||||
error: { type: String},
|
||||
total: { type: Number },
|
||||
status: { type: String },
|
||||
@@ -48,6 +55,10 @@ class Loader extends LitElement
|
||||
this.error = event.data.error;
|
||||
this.state = "errored";
|
||||
}
|
||||
if (event.data.currentSize && event.data.totalSize) {
|
||||
this.currentSize = event.data.currentSize;
|
||||
this.totalSize = event.data.totalSize;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -69,6 +80,8 @@ class Loader extends LitElement
|
||||
let sourceUrl = this.sourceUrl;
|
||||
let source = null;
|
||||
|
||||
this.percent = this.currentSize = this.totalSize = 0;
|
||||
|
||||
// custom protocol handlers here...
|
||||
try {
|
||||
const {scheme, host, path} = parseURLSchemeHostPath(sourceUrl);
|
||||
@@ -161,6 +174,10 @@ You can select a file to upload from the main page by clicking the \'Choose File
|
||||
line-height: 1.5rem;
|
||||
}
|
||||
|
||||
.loaded-prog {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.error {
|
||||
white-space: pre-wrap;
|
||||
margin-bottom: 2em;
|
||||
@@ -197,6 +214,9 @@ You can select a file to upload from the main page by clicking the \'Choose File
|
||||
<progress id="progress" class="progress is-primary is-large"
|
||||
value="${this.percent}" max="100"></progress>
|
||||
<label class="progress-label" for="progress">${this.percent}%</label>
|
||||
${this.currentSize && this.totalSize ? html`
|
||||
<p class="loaded-prog">Loaded <b>${prettyBytes(this.currentSize)}</b> of <b>${prettyBytes(this.totalSize)}</b></p>` : html``}
|
||||
|
||||
<button @click="${this.onCancel}" class="button is-danger">Cancel</button>
|
||||
</div>`;
|
||||
|
||||
|
||||
@@ -76,10 +76,6 @@ function getTS(iso) {
|
||||
|
||||
// ===========================================================================
|
||||
async function sourceToId(url) {
|
||||
try {
|
||||
url = new URL(url, window.location.origin).href;
|
||||
} catch(e) {}
|
||||
|
||||
const digest = await digestMessage(url, 'SHA-256');
|
||||
const coll = "id-" + digest.slice(0, 12);
|
||||
return {url, coll};
|
||||
|
||||
Reference in New Issue
Block a user