ui: improve resource view, add loader, ensure urls for ziparchive are loaded on-demand for prefix / exact match
add logo to loading screen
This commit is contained in:
+40
-18
@@ -10,8 +10,6 @@ import marked from 'marked';
|
|||||||
|
|
||||||
import '../scss/main.scss';
|
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 fasArrowLeft from '@fortawesome/fontawesome-free/svgs/solid/arrow-left.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';
|
||||||
@@ -265,10 +263,23 @@ class WrLoader extends LitElement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get styles() {
|
||||||
|
return css`
|
||||||
|
.logo {
|
||||||
|
width: 96px;
|
||||||
|
height: 96px;
|
||||||
|
margin: 1em;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return html`
|
return html`
|
||||||
<link href="./dist/frontend.css" rel="stylesheet"/>
|
<link href="./dist/frontend.css" rel="stylesheet"/>
|
||||||
<section class="container">
|
<section class="container">
|
||||||
|
<div class="level">
|
||||||
|
<img class="level-item logo" src="/static/logo.svg"/>
|
||||||
|
</div>
|
||||||
<div class="level">
|
<div class="level">
|
||||||
<p class="level-item">Loading <b>${this.sourceUrl}</b>...</p>
|
<p class="level-item">Loading <b>${this.sourceUrl}</b>...</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -288,7 +299,9 @@ class WrLoader extends LitElement
|
|||||||
|
|
||||||
case "started":
|
case "started":
|
||||||
return html`
|
return html`
|
||||||
<progress class="progress is-primary is-large" data-percent="${this.percent}" value="${this.percent}" max="100" style="max-width: 400px"/>`;
|
<progress class="progress is-primary is-large"
|
||||||
|
data-percent="${this.percent}" value="${this.percent}" max="100"
|
||||||
|
style="max-width: 400px"/>`;
|
||||||
|
|
||||||
case "errored":
|
case "errored":
|
||||||
return html`<div class="has-text-danger">${this.error}</div>`;
|
return html`<div class="has-text-danger">${this.error}</div>`;
|
||||||
@@ -517,8 +530,6 @@ class WrColl extends LitElement
|
|||||||
this.doUpdateInfo();
|
this.doUpdateInfo();
|
||||||
}
|
}
|
||||||
if (changedProperties.get("tabData")) {
|
if (changedProperties.get("tabData")) {
|
||||||
this._manualHash = true;
|
|
||||||
|
|
||||||
if (this.collInfo && !this.collInfo.coll) {
|
if (this.collInfo && !this.collInfo.coll) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -573,13 +584,10 @@ class WrColl extends LitElement
|
|||||||
}
|
}
|
||||||
|
|
||||||
onHashChange(event) {
|
onHashChange(event) {
|
||||||
if (this._manualHash) {
|
|
||||||
this._manualHash = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const hash = window.location.hash;
|
const hash = window.location.hash;
|
||||||
if (hash) {
|
if (hash && hash !== this._lastHash) {
|
||||||
this.tabData = Object.fromEntries(new URLSearchParams(hash.slice(1)).entries());
|
this.tabData = Object.fromEntries(new URLSearchParams(hash.slice(1)).entries());
|
||||||
|
this._lastHash = hash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -722,13 +730,13 @@ class WrCuratedPages extends LitElement
|
|||||||
}
|
}
|
||||||
|
|
||||||
async doLoadCurated() {
|
async doLoadCurated() {
|
||||||
this.curatedPages = {};
|
|
||||||
|
|
||||||
const resp = await fetch(`${this.collInfo.apiPrefix}/curatedPages?offset=${this.offset}`);
|
const resp = await fetch(`${this.collInfo.apiPrefix}/curatedPages?offset=${this.offset}`);
|
||||||
const json = await resp.json();
|
const json = await resp.json();
|
||||||
|
|
||||||
this.total = json.total;
|
this.total = json.total;
|
||||||
|
|
||||||
|
this.curatedPages = {};
|
||||||
|
|
||||||
for (const curated of json.curatedPages) {
|
for (const curated of json.curatedPages) {
|
||||||
if (!this.curatedPages[curated.list]) {
|
if (!this.curatedPages[curated.list]) {
|
||||||
this.curatedPages[curated.list] = [];
|
this.curatedPages[curated.list] = [];
|
||||||
@@ -913,6 +921,7 @@ class WrResources extends LitElement
|
|||||||
urlSearch: { type: String },
|
urlSearch: { type: String },
|
||||||
urlSearchType: { type: String },
|
urlSearchType: { type: String },
|
||||||
filteredResults: { type: Array },
|
filteredResults: { type: Array },
|
||||||
|
loading: { type: Boolean }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -922,6 +931,7 @@ class WrResources extends LitElement
|
|||||||
|
|
||||||
async doLoadResources() {
|
async doLoadResources() {
|
||||||
const count = 100;
|
const count = 100;
|
||||||
|
this.loading = true;
|
||||||
let url = (this.urlSearchType !== "contains" ? this.urlSearch : "");
|
let url = (this.urlSearchType !== "contains" ? this.urlSearch : "");
|
||||||
const prefix = url && this.urlSearchType === "prefix" ? 1 : 0;
|
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://
|
// 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,
|
currMime: this.currMime,
|
||||||
urlSearchType: this.urlSearchType};
|
urlSearchType: this.urlSearchType};
|
||||||
|
|
||||||
this.dispatchEvent(new CustomEvent("coll-tab-nav", {detail}));
|
|
||||||
|
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
mime: this.currMime,
|
mime: this.currMime,
|
||||||
url,
|
url,
|
||||||
@@ -948,6 +956,9 @@ class WrResources extends LitElement
|
|||||||
this.results = resp.urls;
|
this.results = resp.urls;
|
||||||
this.tryMore = (resp.urls.length === count);
|
this.tryMore = (resp.urls.length === count);
|
||||||
this.filter();
|
this.filter();
|
||||||
|
|
||||||
|
this.dispatchEvent(new CustomEvent("coll-tab-nav", {detail}));
|
||||||
|
this.loading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async doLoadMore() {
|
async doLoadMore() {
|
||||||
@@ -1062,6 +1073,15 @@ class WrResources extends LitElement
|
|||||||
width: 100vw;
|
width: 100vw;
|
||||||
display: flex;
|
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`
|
return html`
|
||||||
<link href="./dist/frontend.css" rel="stylesheet"/>
|
<link href="./dist/frontend.css" rel="stylesheet"/>
|
||||||
<div class="notification level is-marginless">
|
<div class="notification level is-marginless">
|
||||||
<div class="control level-left">
|
<div class="level-left flex-auto">
|
||||||
<div>
|
<div class="field flex-column">
|
||||||
<input type="text" style="width: 400px" class="input level-item" @input="${this.onChangeUrlSearch}" value="${this.urlSearch}" type="text" placeholder="Search URL">
|
<div class="control ${this.loading ? 'is-loading' : ''}">
|
||||||
|
<input type="text" class="input" @input="${this.onChangeUrlSearch}" value="${this.urlSearch}" type="text" placeholder="Search URL">
|
||||||
|
</div>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<label class="radio has-text-left"><input type="radio" name="urltype" value="exact" ?checked="${this.urlSearchType === ''}" @click="${this.onClickUrlType}"> Exact</label>
|
<label class="radio has-text-left"><input type="radio" name="urltype" value="exact" ?checked="${this.urlSearchType === ''}" @click="${this.onClickUrlType}"> Exact</label>
|
||||||
<label class="radio has-text-left"><input type="radio" name="urltype" value="prefix" ?checked="${this.urlSearchType === 'prefix'}" @click="${this.onClickUrlType}"> Prefix</label>
|
<label class="radio has-text-left"><input type="radio" name="urltype" value="prefix" ?checked="${this.urlSearchType === 'prefix'}" @click="${this.onClickUrlType}"> Prefix</label>
|
||||||
<label class="radio has-text-left"><input type="radio" name="urltype" value="contains" ?checked="${this.urlSearchType === 'contains'}" @click="${this.onClickUrlType}"> Contains</label>
|
<label class="radio has-text-left"><input type="radio" name="urltype" value="contains" ?checked="${this.urlSearchType === 'contains'}" @click="${this.onClickUrlType}"> Contains</label>
|
||||||
|
<span class="is-pulled-right" style="margin-left: 1em">Showing ${this.filteredResults.length} Results</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="level-item">Showing ${this.filteredResults.length} Results</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="control level-right">
|
<div class="control level-right">
|
||||||
<span>Resource Type: </span>
|
<span>Resource Type: </span>
|
||||||
|
|||||||
Reference in New Issue
Block a user