1.4.0 Release (#45)
* customizations for chooser, coll-index and appmain to support usage in archiveweb.page - chooser: support panel/message view - move apiPrefix to misc - make coll-index extensible, overridable styles, filtering * api changes: make configurable in coll-index, now using '/w/' instead of '/wabac/', '/c/' prefix for coll apis * lint pass! * bulma: update to 0.9.2, fix delete spinner with latest bulma * ui fixes: - show 'Loading Archives...' on initial load until first api response succeeds - fix typo in oncontrollerchange not actually resolving the promise! * embed sandbox: add other allow options, except top-nav - first api load: keep loading message until first successful api load - don't reset hash on purge to keep current page - sw config: fix typo with latest wabac.js - embed: add 'noSandbox' option to avoid adding sandbox to iframe, needed to show PDFs, add more allow rules (all except top-navigation) * ui improvements: - refresh: ensure location refresh from hitting enter in location bar always resets url - pageentry doubleclick: ensure double-clicking on page in sidebar always triggers reload, even if current page - pageentry typo fix: fix missing var causing selection error (fixes webrecorder/archivewebpage#25) - lint: don't include 'event' as global - use latest wabac.js 2.7.0-beta.1 * add CHANGES for 1.4.0, add 'noSandbox' to embedding options - electron app: fix path to 'w/' - bump electron to 11.4.3 * docs: autoload current version from package.json - chooser: support .json files for multiwacz (experimental) - update CHANGES.md - add missing .eslintrc.js file * bump version to 1.4.0
This commit is contained in:
+83
-80
@@ -1,9 +1,9 @@
|
||||
import { LitElement, html, css } from 'lit-element';
|
||||
import { wrapCss, IS_APP } from './misc';
|
||||
import { LitElement, html, css } from "lit-element";
|
||||
import { wrapCss, IS_APP } from "./misc";
|
||||
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
import prettyBytes from "pretty-bytes";
|
||||
|
||||
import { parseURLSchemeHostPath } from './pageutils';
|
||||
import { parseURLSchemeHostPath } from "./pageutils";
|
||||
|
||||
|
||||
// ===========================================================================
|
||||
@@ -46,10 +46,10 @@ class Loader extends LitElement
|
||||
embed: { type: String },
|
||||
tryFileHandle: { type: Boolean },
|
||||
errorAllowRetry: { type: Boolean }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
firstUpdated(props) {
|
||||
firstUpdated() {
|
||||
this.initMessages();
|
||||
//this.doLoad();
|
||||
}
|
||||
@@ -61,41 +61,41 @@ class Loader extends LitElement
|
||||
|
||||
navigator.serviceWorker.addEventListener("message", (event) => {
|
||||
switch (event.data.msg_type) {
|
||||
case "collProgress":
|
||||
if (event.data.name === this.coll) {
|
||||
this.percent = event.data.percent;
|
||||
if (event.data.error) {
|
||||
this.error = event.data.error;
|
||||
this.state = "errored";
|
||||
this.errorAllowRetry = true;
|
||||
this.fileHandle = event.data.fileHandle;
|
||||
if (this.error === "missing_local_file") {
|
||||
this.tryFileHandle = false;
|
||||
} else if (this.error === "permission_needed" && event.data.fileHandle) {
|
||||
this.state = "permission_needed";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (event.data.currentSize && event.data.totalSize) {
|
||||
this.currentSize = event.data.currentSize;
|
||||
this.totalSize = event.data.totalSize;
|
||||
case "collProgress":
|
||||
if (event.data.name === this.coll) {
|
||||
this.percent = event.data.percent;
|
||||
if (event.data.error) {
|
||||
this.error = event.data.error;
|
||||
this.state = "errored";
|
||||
this.errorAllowRetry = true;
|
||||
this.fileHandle = event.data.fileHandle;
|
||||
if (this.error === "missing_local_file") {
|
||||
this.tryFileHandle = false;
|
||||
} else if (this.error === "permission_needed" && event.data.fileHandle) {
|
||||
this.state = "permission_needed";
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
if (event.data.currentSize && event.data.totalSize) {
|
||||
this.currentSize = event.data.currentSize;
|
||||
this.totalSize = event.data.totalSize;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "collAdded":
|
||||
if (event.data.name === this.coll) {
|
||||
if (!this.total) {
|
||||
this.total = 100;
|
||||
}
|
||||
this.progress = this.total;
|
||||
this.percent = 100;
|
||||
if (this.pingInterval) {
|
||||
clearInterval(this.pingInterval);
|
||||
}
|
||||
this.dispatchEvent(new CustomEvent("coll-loaded", {detail: event.data}));
|
||||
case "collAdded":
|
||||
if (event.data.name === this.coll) {
|
||||
if (!this.total) {
|
||||
this.total = 100;
|
||||
}
|
||||
break;
|
||||
this.progress = this.total;
|
||||
this.percent = 100;
|
||||
if (this.pingInterval) {
|
||||
clearInterval(this.pingInterval);
|
||||
}
|
||||
this.dispatchEvent(new CustomEvent("coll-loaded", {detail: event.data}));
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -124,38 +124,39 @@ Please try loading this page from an HTTPS URL`;
|
||||
const {scheme, host, path} = parseURLSchemeHostPath(sourceUrl);
|
||||
|
||||
switch (scheme) {
|
||||
case "googledrive":
|
||||
this.state = "googledrive";
|
||||
source = await this.googledriveInit();
|
||||
break;
|
||||
case "googledrive":
|
||||
this.state = "googledrive";
|
||||
source = await this.googledriveInit();
|
||||
break;
|
||||
|
||||
case "s3":
|
||||
source = {sourceUrl,
|
||||
loadUrl: `https://${host}.s3.amazonaws.com${path}`,
|
||||
name: this.sourceUrl};
|
||||
break;
|
||||
case "s3":
|
||||
source = {sourceUrl,
|
||||
loadUrl: `https://${host}.s3.amazonaws.com${path}`,
|
||||
name: this.sourceUrl};
|
||||
break;
|
||||
|
||||
case "file":
|
||||
if (!this.loadInfo && !this.tryFileHandle) {
|
||||
this.state = "errored";
|
||||
this.error = `\
|
||||
case "file":
|
||||
if (!this.loadInfo && !this.tryFileHandle) {
|
||||
this.state = "errored";
|
||||
this.error = `\
|
||||
File URLs can not be entered directly or shared.
|
||||
You can select a file to upload from the main page by clicking the \'Choose File...\' button.`;
|
||||
this.errorAllowRetry = false;
|
||||
return;
|
||||
}
|
||||
You can select a file to upload from the main page by clicking the 'Choose File...' button.`;
|
||||
this.errorAllowRetry = false;
|
||||
return;
|
||||
}
|
||||
|
||||
source = this.loadInfo;
|
||||
break;
|
||||
source = this.loadInfo;
|
||||
break;
|
||||
|
||||
case "ipfs":
|
||||
if (IS_APP) {
|
||||
const url = new URL(__APP_FILE_SERVE_PREFIX__);
|
||||
const hash = sourceUrl.split("#", 1)[0];
|
||||
url.searchParams.set("ipfs", hash.slice("ipfs://".length));
|
||||
source = {sourceUrl, loadUrl: url.href};
|
||||
}
|
||||
break;
|
||||
case "ipfs":
|
||||
if (IS_APP) {
|
||||
// eslint-disable-next-line no-undef
|
||||
const url = new URL(__APP_FILE_SERVE_PREFIX__);
|
||||
const hash = sourceUrl.split("#", 1)[0];
|
||||
url.searchParams.set("ipfs", hash.slice("ipfs://".length));
|
||||
source = {sourceUrl, loadUrl: url.href};
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
@@ -165,6 +166,8 @@ You can select a file to upload from the main page by clicking the \'Choose File
|
||||
source = {sourceUrl};
|
||||
}
|
||||
|
||||
source.newFullImport = (this.loadInfo && this.loadInfo.newFullImport);
|
||||
|
||||
this.state = "started";
|
||||
|
||||
const msg = {"msg_type": "addColl", "name": this.coll, skipExisting: true, file: source};
|
||||
@@ -175,7 +178,7 @@ You can select a file to upload from the main page by clicking the \'Choose File
|
||||
|
||||
if (!navigator.serviceWorker.controller) {
|
||||
await new Promise((resolve) => {
|
||||
navigator.serviceWorker.addEventListener("controllerchange", () => resolve);
|
||||
navigator.serviceWorker.addEventListener("controllerchange", () => resolve());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -269,7 +272,7 @@ You can select a file to upload from the main page by clicking the \'Choose File
|
||||
${!this.embed ? html`
|
||||
<div class="level">
|
||||
<p class="level-item">Loading <b>${this.sourceUrl}</b>...</p>
|
||||
</div>` : ``}
|
||||
</div>` : ""}
|
||||
<div class="level">
|
||||
<div class="level-item has-text-centered">
|
||||
${this.renderContent()}
|
||||
@@ -281,11 +284,11 @@ You can select a file to upload from the main page by clicking the \'Choose File
|
||||
|
||||
renderContent() {
|
||||
switch (this.state) {
|
||||
case "googledrive":
|
||||
return html`<wr-gdrive .sourceUrl=${this.sourceUrl} @load-ready=${this.onLoadReady}/>`
|
||||
case "googledrive":
|
||||
return html`<wr-gdrive .sourceUrl=${this.sourceUrl} @load-ready=${this.onLoadReady}/>`;
|
||||
|
||||
case "started":
|
||||
return html`
|
||||
case "started":
|
||||
return html`
|
||||
<div class="progress-div">
|
||||
<progress id="progress" class="progress is-primary is-large"
|
||||
value="${this.percent}" max="100"></progress>
|
||||
@@ -294,31 +297,31 @@ You can select a file to upload from the main page by clicking the \'Choose File
|
||||
<p class="loaded-prog">Loaded <b>${prettyBytes(this.currentSize)}</b> of <b>${prettyBytes(this.totalSize)}</b></p>` : html``}
|
||||
|
||||
${!this.embed ? html`
|
||||
<button @click="${this.onCancel}" class="button is-danger">Cancel</button>` : ``}
|
||||
<button @click="${this.onCancel}" class="button is-danger">Cancel</button>` : ""}
|
||||
</div>`;
|
||||
|
||||
case "errored":
|
||||
return html`
|
||||
case "errored":
|
||||
return html`
|
||||
<div class="has-text-left">
|
||||
<div class="error has-text-danger">${this.error}</div>
|
||||
<div>
|
||||
${this.errorAllowRetry ? html`
|
||||
<a class="button is-warning" @click=${(e) => window.parent.location.reload()}>Try Again</a>` : ``}
|
||||
<a class="button is-warning" @click=${() => window.parent.location.reload()}>Try Again</a>` : ""}
|
||||
${this.embed ? html`` : html`
|
||||
<a href="/" class="button is-warning">Back</a>`}
|
||||
</div>`;
|
||||
|
||||
case "permission_needed":
|
||||
return html`
|
||||
case "permission_needed":
|
||||
return html`
|
||||
<div class="has-text-left">
|
||||
<div class="">Permission is needed to reload the archive file. (Click <i>Cancel</i> to cancel loading this archive.)</div>
|
||||
<button @click="${this.onAskPermission}" class="button is-primary">Show Permission</button>
|
||||
<a href="/" class="button is-danger">Cancel</a>
|
||||
</div>`;
|
||||
|
||||
case "waiting":
|
||||
default:
|
||||
return html`<progress class="progress is-primary is-large" style="max-width: 400px"/>`;
|
||||
case "waiting":
|
||||
default:
|
||||
return html`<progress class="progress is-primary is-large" style="max-width: 400px"/>`;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -333,4 +336,4 @@ You can select a file to upload from the main page by clicking the \'Choose File
|
||||
|
||||
customElements.define("wr-loader", Loader);
|
||||
|
||||
export { Loader };
|
||||
export { Loader };
|
||||
|
||||
Reference in New Issue
Block a user