From 47108dc7d8609ad2cd088babdd681d48c229a11b Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Fri, 1 May 2020 23:59:33 -0700 Subject: [PATCH] ui: improve resource view, add loader, ensure urls for ziparchive are loaded on-demand for prefix / exact match add logo to loading screen --- src/frontend.js | 58 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/src/frontend.js b/src/frontend.js index abf71fb..6de32cc 100644 --- a/src/frontend.js +++ b/src/frontend.js @@ -10,8 +10,6 @@ import marked from 'marked'; import '../scss/main.scss'; -//import 'fa-icons'; -//import '@fortawesome/fontawesome-free/sprites/solid.svg'; import fasArrowLeft from '@fortawesome/fontawesome-free/svgs/solid/arrow-left.svg'; import farListAlt from '@fortawesome/fontawesome-free/svgs/solid/list-alt.svg'; import fasSearch from '@fortawesome/fontawesome-free/svgs/solid/search.svg'; @@ -265,10 +263,23 @@ class WrLoader extends LitElement } } + static get styles() { + return css` + .logo { + width: 96px; + height: 96px; + margin: 1em; + } + `; + } + render() { return html`
+
+ +

Loading ${this.sourceUrl}...

@@ -288,7 +299,9 @@ class WrLoader extends LitElement case "started": return html` - `; + `; case "errored": return html`
${this.error}
`; @@ -517,8 +530,6 @@ class WrColl extends LitElement this.doUpdateInfo(); } if (changedProperties.get("tabData")) { - this._manualHash = true; - if (this.collInfo && !this.collInfo.coll) { return } @@ -573,13 +584,10 @@ class WrColl extends LitElement } onHashChange(event) { - if (this._manualHash) { - this._manualHash = false; - return; - } const hash = window.location.hash; - if (hash) { + if (hash && hash !== this._lastHash) { this.tabData = Object.fromEntries(new URLSearchParams(hash.slice(1)).entries()); + this._lastHash = hash; } } @@ -722,13 +730,13 @@ class WrCuratedPages extends LitElement } async doLoadCurated() { - this.curatedPages = {}; - const resp = await fetch(`${this.collInfo.apiPrefix}/curatedPages?offset=${this.offset}`); const json = await resp.json(); this.total = json.total; + this.curatedPages = {}; + for (const curated of json.curatedPages) { if (!this.curatedPages[curated.list]) { this.curatedPages[curated.list] = []; @@ -913,6 +921,7 @@ class WrResources extends LitElement urlSearch: { type: String }, urlSearchType: { type: String }, filteredResults: { type: Array }, + loading: { type: Boolean } } } @@ -922,6 +931,7 @@ class WrResources extends LitElement async doLoadResources() { const count = 100; + this.loading = true; let url = (this.urlSearchType !== "contains" ? this.urlSearch : ""); const prefix = url && this.urlSearchType === "prefix" ? 1 : 0; // optimization: if not starting with http, likely won't have a match here, so just add https:// @@ -934,8 +944,6 @@ class WrResources extends LitElement currMime: this.currMime, urlSearchType: this.urlSearchType}; - this.dispatchEvent(new CustomEvent("coll-tab-nav", {detail})); - const params = new URLSearchParams({ mime: this.currMime, url, @@ -948,6 +956,9 @@ class WrResources extends LitElement this.results = resp.urls; this.tryMore = (resp.urls.length === count); this.filter(); + + this.dispatchEvent(new CustomEvent("coll-tab-nav", {detail})); + this.loading = false; } async doLoadMore() { @@ -1062,6 +1073,15 @@ class WrResources extends LitElement width: 100vw; display: flex; } + .flex-column { + display: flex; + flex: auto; + max-width: 80%; + flex-direction: column; + } + .flex-auto { + flex: auto; + } `; } @@ -1069,16 +1089,18 @@ class WrResources extends LitElement return html`
-
-
- +
+
+
+ +
+ Showing ${this.filteredResults.length} Results
-

Showing ${this.filteredResults.length} Results

Resource Type: