embeds work:
- ability to specify an explicit collection and pass extra config - reauth: don't show message if reauth pending - add fullscreen toggle
This commit is contained in:
Vendored
+41
-35
File diff suppressed because one or more lines are too long
@@ -10,6 +10,8 @@ class EmbedRWP extends LitElement
|
|||||||
this.view = "replay";
|
this.view = "replay";
|
||||||
this.ts = "";
|
this.ts = "";
|
||||||
this.url = "";
|
this.url = "";
|
||||||
|
this.config = "";
|
||||||
|
this.coll = "";
|
||||||
this.paramString = null;
|
this.paramString = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,6 +24,9 @@ class EmbedRWP extends LitElement
|
|||||||
|
|
||||||
title: { type: String },
|
title: { type: String },
|
||||||
|
|
||||||
|
coll: { type: String },
|
||||||
|
config: { type: String },
|
||||||
|
|
||||||
paramString: { type: String },
|
paramString: { type: String },
|
||||||
hashString: { type: String }
|
hashString: { type: String }
|
||||||
}
|
}
|
||||||
@@ -46,6 +51,8 @@ class EmbedRWP extends LitElement
|
|||||||
|
|
||||||
this.paramString = new URLSearchParams({
|
this.paramString = new URLSearchParams({
|
||||||
source: this.source,
|
source: this.source,
|
||||||
|
customColl: this.coll,
|
||||||
|
config: this.config,
|
||||||
embed: "true"
|
embed: "true"
|
||||||
}).toString();
|
}).toString();
|
||||||
|
|
||||||
|
|||||||
+66
-9
@@ -17,6 +17,8 @@ import allCssRaw from '../scss/main.scss';
|
|||||||
//import fasInfo from '@fortawesome/fontawesome-free/svgs/solid/info-circle.svg';
|
//import fasInfo from '@fortawesome/fontawesome-free/svgs/solid/info-circle.svg';
|
||||||
import fasArchiveIcon from '@fortawesome/fontawesome-free/svgs/solid/info-circle.svg';
|
import fasArchiveIcon from '@fortawesome/fontawesome-free/svgs/solid/info-circle.svg';
|
||||||
import fasRefresh from '@fortawesome/fontawesome-free/svgs/solid/redo-alt.svg';
|
import fasRefresh from '@fortawesome/fontawesome-free/svgs/solid/redo-alt.svg';
|
||||||
|
import fasFullscreen from '@fortawesome/fontawesome-free/svgs/solid/desktop.svg';
|
||||||
|
import fasUnfullscreen from '@fortawesome/fontawesome-free/svgs/solid/compress-arrows-alt.svg';
|
||||||
import fasHelp from '@fortawesome/fontawesome-free/svgs/solid/question-circle.svg';
|
import fasHelp from '@fortawesome/fontawesome-free/svgs/solid/question-circle.svg';
|
||||||
import farListAlt from '@fortawesome/fontawesome-free/svgs/solid/list-alt.svg';
|
import farListAlt from '@fortawesome/fontawesome-free/svgs/solid/list-alt.svg';
|
||||||
import fasSearch from '@fortawesome/fontawesome-free/svgs/solid/search.svg';
|
import fasSearch from '@fortawesome/fontawesome-free/svgs/solid/search.svg';
|
||||||
@@ -57,6 +59,7 @@ class AppMain extends LitElement
|
|||||||
navMenuShown: { type: Boolean },
|
navMenuShown: { type: Boolean },
|
||||||
showTerms: { type: Boolean },
|
showTerms: { type: Boolean },
|
||||||
collInfo: { type: Object },
|
collInfo: { type: Object },
|
||||||
|
loadInfo: { type: Object },
|
||||||
embed: { type: String },
|
embed: { type: String },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -241,6 +244,24 @@ class AppMain extends LitElement
|
|||||||
if (this.pageParams.has("terms")) {
|
if (this.pageParams.has("terms")) {
|
||||||
this.showTerms = true;
|
this.showTerms = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.pageParams.has("config")) {
|
||||||
|
if (!this.loadInfo) {
|
||||||
|
this.loadInfo = {}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
this.loadInfo.extraConfig = JSON.parse(this.pageParams.get("config"));
|
||||||
|
} catch (e) {
|
||||||
|
console.log("invalid config: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.pageParams.has("customColl")) {
|
||||||
|
if (!this.loadInfo) {
|
||||||
|
this.loadInfo = {}
|
||||||
|
}
|
||||||
|
this.loadInfo.customColl = this.pageParams.get("customColl");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onStartLoad(event) {
|
onStartLoad(event) {
|
||||||
@@ -381,6 +402,10 @@ You can select a file to upload from the main page by clicking the \'Choose File
|
|||||||
|
|
||||||
const msg = {"msg_type": "addColl", "name": this.coll, skipExisting: true, file: source};
|
const msg = {"msg_type": "addColl", "name": this.coll, skipExisting: true, file: source};
|
||||||
|
|
||||||
|
if (this.loadInfo && this.loadInfo.extraConfig) {
|
||||||
|
msg.extraConfig = this.loadInfo.extraConfig;
|
||||||
|
}
|
||||||
|
|
||||||
dbworker.postMessage(msg);
|
dbworker.postMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -729,8 +754,6 @@ class WrColl extends LitElement
|
|||||||
replayTS: { type: String },
|
replayTS: { type: String },
|
||||||
|
|
||||||
embed: { type: String },
|
embed: { type: String },
|
||||||
|
|
||||||
//_locationHash: { type: String }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -773,7 +796,12 @@ class WrColl extends LitElement
|
|||||||
}
|
}
|
||||||
|
|
||||||
async doUpdateInfo() {
|
async doUpdateInfo() {
|
||||||
const {url, coll} = await sourceToId(this.sourceUrl);
|
let coll = this.loadInfo && this.loadInfo.customColl;
|
||||||
|
|
||||||
|
if (!coll) {
|
||||||
|
const res = await sourceToId(this.sourceUrl);
|
||||||
|
coll = res.coll;
|
||||||
|
}
|
||||||
|
|
||||||
this.coll = coll;
|
this.coll = coll;
|
||||||
|
|
||||||
@@ -1518,6 +1546,7 @@ class WrReplayPage extends LitElement
|
|||||||
this.title = "";
|
this.title = "";
|
||||||
|
|
||||||
this.showAuth = false;
|
this.showAuth = false;
|
||||||
|
this.reauthWait = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get properties() {
|
static get properties() {
|
||||||
@@ -1538,17 +1567,35 @@ class WrReplayPage extends LitElement
|
|||||||
isLoading: { type: Boolean },
|
isLoading: { type: Boolean },
|
||||||
|
|
||||||
showAuth: { type: Boolean },
|
showAuth: { type: Boolean },
|
||||||
embed: { type: String }
|
|
||||||
|
embed: { type: String },
|
||||||
|
isFullscreen: { type: Boolean }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
firstUpdated() {
|
firstUpdated() {
|
||||||
window.addEventListener("message", (event) => this.onReplayMessage(event));
|
window.addEventListener("message", (event) => this.onReplayMessage(event));
|
||||||
navigator.serviceWorker.addEventListener("message", (event) => {
|
navigator.serviceWorker.addEventListener("message", async (event) => {
|
||||||
if (event.data.type === "authneeded" && this.collInfo && event.data.coll === this.collInfo.coll) {
|
if (event.data.type === "authneeded" && this.collInfo && event.data.coll === this.collInfo.coll) {
|
||||||
|
if (this.reauthWait) {
|
||||||
|
await this.reauthWait;
|
||||||
|
} else {
|
||||||
this.showAuth = true;
|
this.showAuth = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.addEventListener("fullscreenchange", (event) => {
|
||||||
|
this.isFullscreen = !!document.fullscreenElement;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onFullscreenToggle() {
|
||||||
|
if (!this.isFullscreen) {
|
||||||
|
this.requestFullscreen();
|
||||||
|
} else {
|
||||||
|
document.exitFullscreen();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doSetIframeUrl() {
|
doSetIframeUrl() {
|
||||||
@@ -1559,6 +1606,8 @@ class WrReplayPage extends LitElement
|
|||||||
if (changedProperties.has("sourceUrl") || changedProperties.has("collInfo")) {
|
if (changedProperties.has("sourceUrl") || changedProperties.has("collInfo")) {
|
||||||
this.isAuthable = (this.sourceUrl.startsWith("googledrive://") &&
|
this.isAuthable = (this.sourceUrl.startsWith("googledrive://") &&
|
||||||
this.collInfo && this.collInfo.onDemand);
|
this.collInfo && this.collInfo.onDemand);
|
||||||
|
|
||||||
|
this.reauthWait = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.url &&
|
if (this.url &&
|
||||||
@@ -1655,6 +1704,7 @@ class WrReplayPage extends LitElement
|
|||||||
max-width: none;
|
max-width: none;
|
||||||
border-bottom: solid .1rem #97989A;
|
border-bottom: solid .1rem #97989A;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
background-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.embed-bar {
|
.embed-bar {
|
||||||
@@ -1678,7 +1728,7 @@ class WrReplayPage extends LitElement
|
|||||||
line-height: 2;
|
line-height: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#refresh {
|
.is-borderless {
|
||||||
border: 0px;
|
border: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1695,7 +1745,12 @@ class WrReplayPage extends LitElement
|
|||||||
<div class="container replay-bar">
|
<div class="container replay-bar">
|
||||||
<form @submit="${this.onSubmit}">
|
<form @submit="${this.onSubmit}">
|
||||||
<div class="field has-addons">
|
<div class="field has-addons">
|
||||||
<a id="refresh" class="button ${this.isLoading ? 'is-loading' : ''}" @click="${this.onRefresh}">
|
<a id="fullscreen" class="button is-borderless" @click="${this.onFullscreenToggle}">
|
||||||
|
<span class="icon is-small">
|
||||||
|
<fa-icon size="1.0em" class="has-text-grey" .svg="${this.isFullscreen ? fasUnfullscreen : fasFullscreen}"></fa-icon>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
<a id="refresh" class="button is-borderless ${this.isLoading ? 'is-loading' : ''}" @click="${this.onRefresh}">
|
||||||
<span class="icon is-small">
|
<span class="icon is-small">
|
||||||
${!this.isLoading ? html`
|
${!this.isLoading ? html`
|
||||||
<fa-icon size="1.0em" class="has-text-grey" .svg="${fasRefresh}"></fa-icon>
|
<fa-icon size="1.0em" class="has-text-grey" .svg="${fasRefresh}"></fa-icon>
|
||||||
@@ -1722,7 +1777,7 @@ class WrReplayPage extends LitElement
|
|||||||
<div class="modal-card">
|
<div class="modal-card">
|
||||||
<header class="modal-card-head">
|
<header class="modal-card-head">
|
||||||
<p class="modal-card-title">Auth Needed</p>
|
<p class="modal-card-title">Auth Needed</p>
|
||||||
<button class="delete" aria-label="close" @click="${(e) => this.authNeeded = null}"></button>
|
<button class="delete" aria-label="close" @click="${(e) => this.showAuth = false}"></button>
|
||||||
</header>
|
</header>
|
||||||
<section class="modal-card-body">
|
<section class="modal-card-body">
|
||||||
<div class="container has-text-centered">
|
<div class="container has-text-centered">
|
||||||
@@ -1736,7 +1791,8 @@ class WrReplayPage extends LitElement
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async onReAuthed(event) {
|
onReAuthed(event) {
|
||||||
|
this.reauthWait = (async () => {
|
||||||
const headers = event.detail.headers;
|
const headers = event.detail.headers;
|
||||||
|
|
||||||
const resp = await fetch(`/wabac/api/${this.collInfo.coll}/updateAuth`, {
|
const resp = await fetch(`/wabac/api/${this.collInfo.coll}/updateAuth`, {
|
||||||
@@ -1748,6 +1804,7 @@ class WrReplayPage extends LitElement
|
|||||||
this.onRefresh(null, true);
|
this.onRefresh(null, true);
|
||||||
this.showAuth = false;
|
this.showAuth = false;
|
||||||
}
|
}
|
||||||
|
})();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user