From ee78b3cdac84e43500e75fc587f3aa1879b7bd15 Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Wed, 29 Apr 2020 20:15:19 -0700 Subject: [PATCH] update ui pass, add logo, branding colors! --- src/frontend.js | 294 +++++++++++++++++++++++++++++++----------------- 1 file changed, 188 insertions(+), 106 deletions(-) diff --git a/src/frontend.js b/src/frontend.js index 9228854..be82bf5 100644 --- a/src/frontend.js +++ b/src/frontend.js @@ -4,6 +4,7 @@ import { styleMap } from 'lit-html/directives/style-map'; import { initSW, digestMessage, getTS } from './pageutils'; +import prettyBytes from 'pretty-bytes'; import marked from 'marked'; import '../scss/main.scss'; @@ -28,6 +29,41 @@ class AppMain extends LitElement } } + static get styles() { + return css` + .logo { + max-height: 2.0rem; + margin-right: 8px; + } + .has-allcaps { + font-variant-caps: all-small-caps; + } + `; + } + + render() { + return html` + +
+ +
+ ${this.sourceUrl ? html` + + ` : this.sourceUrl === "" ? html`` : html``} + `; + } + firstUpdated() { this.initRoute(); } @@ -53,20 +89,6 @@ class AppMain extends LitElement this.sourceUrl = this.pageParams.get("source") || ""; } - - render() { - return html` - -
-
-

Webrecorder Viewer

-
-
- ${this.sourceUrl ? html` - - ` : this.sourceUrl === "" ? html`` : html``} - `; - } } // =========================================================================== @@ -126,14 +148,36 @@ class WrLoader extends LitElement } async doLoad() { - const sourceUrl = this.sourceUrl; + let sourceUrl = this.sourceUrl; let source = null; - if (sourceUrl.startsWith("googledrive://")) { - this.state = "googledrive"; - this.fileId = sourceUrl.slice("googledrive://".length); - source = await this.googledriveInit(); - } else { + // custom protocol handlers here... + try { + const sup = new URL(this.sourceUrl); + let firstSlash = null; + + if (!sup.host) { + firstSlash = sup.pathname.indexOf("/", 2); + } + + switch (sup.protocol) { + case "googledrive:": + this.state = "googledrive"; + if (firstSlash < 0) { + firstSlash = undefined; + } + this.fileId = sup.pathname.slice(2, firstSlash); + source = await this.googledriveInit(); + break; + + case "s3:": + sourceUrl = `https://${sup.pathname.slice(2, firstSlash)}.s3.amazonaws.com${sup.pathname.slice(firstSlash)}`; + break; + + } + } catch (e) {} + + if (!source) { source = {sourceUrl}; } @@ -211,10 +255,6 @@ class WrIndex extends LitElement } } - static get styles() { - return css``; - } - firstUpdated() { this.loadColls(); } @@ -243,6 +283,14 @@ class WrIndex extends LitElement return false; } + static get styles() { + return css` + .size { + margin-right: 20px; + } + `; + } + render() { return html` @@ -259,8 +307,8 @@ class WrIndex extends LitElement
+ Size: ${prettyBytes(coll.size)} -
`)} @@ -390,6 +438,27 @@ class WrColl extends LitElement this.tabData = {...this.tabData, ...event.detail}; } + static get styles() { + return css` + .icon { + vertical-align: text-top; + } + .back fa-icon { + width: 2em; + vertical-align: bottom; + line-height: 0.5em; + } + .is-active { + font-weight: bold; + } + .header-info { + font-size: initial; + font-weight: initial; + margin-right: 20px; + } + `; + } + render() { return html` @@ -402,20 +471,33 @@ class WrColl extends LitElement return html``; } else if (this.collInfo) { return html` -