url resources: fix load more not working for multiple mime types, styling fix for header and loading logo, update sw

This commit is contained in:
Ilya Kreymer
2020-05-18 19:47:53 -07:00
parent 6a85bd801e
commit 5014cff233
4 changed files with 51 additions and 69 deletions
+6 -6
View File
@@ -1,4 +1,4 @@
!function(t,e){for(var s in e)t[s]=e[s]}(self,function(t){var e={};function s(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,s),r.l=!0,r.exports}return s.m=t,s.c=e,s.d=function(t,e,n){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)s.d(n,r,function(e){return t[e]}.bind(null,r));return n},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="/dist/",s(s.s=109)}({0:function(t,e,s){"use strict";s.d(e,"c",(function(){return d.e})),s.d(e,"d",(function(){return N})),s.d(e,"b",(function(){return C})),s.d(e,"a",(function(){return O}));var n=s(5),r=s(1);function i(t,e){const{element:{content:s},parts:n}=t,r=document.createTreeWalker(s,133,null,!1);let i=a(n),o=n[i],c=-1,l=0;const u=[];let d=null;for(;r.nextNode();){c++;const t=r.currentNode;for(t.previousSibling===d&&(d=null),e.has(t)&&(u.push(t),null===d&&(d=t)),null!==d&&l++;void 0!==o&&o.index===c;)o.index=null!==d?-1:o.index-l,i=a(n,i),o=n[i]}u.forEach(t=>t.parentNode.removeChild(t))}const o=t=>{let e=11===t.nodeType?0:1;const s=document.createTreeWalker(t,133,null,!1);for(;s.nextNode();)e++;return e},a=(t,e=-1)=>{for(let s=e+1;s<t.length;s++){const e=t[s];if(Object(r.d)(e))return s}return-1};var c=s(9),l=s(8),u=s(14),d=s(6);
!function(t,e){for(var s in e)t[s]=e[s]}(self,function(t){var e={};function s(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,s),r.l=!0,r.exports}return s.m=t,s.c=e,s.d=function(t,e,n){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)s.d(n,r,function(e){return t[e]}.bind(null,r));return n},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="/dist/",s(s.s=107)}({0:function(t,e,s){"use strict";s.d(e,"c",(function(){return d.e})),s.d(e,"d",(function(){return N})),s.d(e,"b",(function(){return C})),s.d(e,"a",(function(){return O}));var n=s(5),r=s(1);function i(t,e){const{element:{content:s},parts:n}=t,r=document.createTreeWalker(s,133,null,!1);let i=a(n),o=n[i],c=-1,l=0;const u=[];let d=null;for(;r.nextNode();){c++;const t=r.currentNode;for(t.previousSibling===d&&(d=null),e.has(t)&&(u.push(t),null===d&&(d=t)),null!==d&&l++;void 0!==o&&o.index===c;)o.index=null!==d?-1:o.index-l,i=a(n,i),o=n[i]}u.forEach(t=>t.parentNode.removeChild(t))}const o=t=>{let e=11===t.nodeType?0:1;const s=document.createTreeWalker(t,133,null,!1);for(;s.nextNode();)e++;return e},a=(t,e=-1)=>{for(let s=e+1;s<t.length;s++){const e=t[s];if(Object(r.d)(e))return s}return-1};var c=s(9),l=s(8),u=s(13),d=s(6);
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
@@ -65,7 +65,7 @@ const n=`{{lit-${String(Math.random()).slice(2)}}}`,r=`\x3c!--${n}--\x3e`,i=new
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
const n=new WeakMap,r=t=>(...e)=>{const s=t(...e);return n.set(s,!0),s},i=t=>"function"==typeof t&&n.has(t)},109:function(t,e,s){"use strict";s.r(e);var n=s(0);class r extends n.a{constructor(){super(),this.replayBase="http://localhost:9990/",this.view="replay",this.ts="",this.url="",this.config="",this.coll="",this.paramString=null}static get properties(){return{url:{type:String},ts:{type:String},source:{type:String},replayBase:{type:String},title:{type:String},coll:{type:String},config:{type:String},paramString:{type:String},hashString:{type:String}}}firstUpdated(){window.addEventListener("message",t=>{const e=this.renderRoot.querySelector("iframe");e&&t.source===e.contentWindow&&t.data.title&&(this.title=t.data.title)})}updated(t){(t.has("url")||t.has("ts")||t.has("source"))&&(this.paramString=new URLSearchParams({source:this.source,customColl:this.coll,config:this.config,embed:"true"}).toString(),this.hashString=new URLSearchParams({url:this.url,ts:this.ts,view:this.view}).toString())}static get styles(){return n.b`
const n=new WeakMap,r=t=>(...e)=>{const s=t(...e);return n.set(s,!0),s},i=t=>"function"==typeof t&&n.has(t)},107:function(t,e,s){"use strict";s.r(e);var n=s(0);class r extends n.a{constructor(){super(),this.replayBase="http://localhost:9990/",this.view="replay",this.ts="",this.url="",this.config="",this.coll="",this.paramString=null}static get properties(){return{url:{type:String},ts:{type:String},source:{type:String},replayBase:{type:String},title:{type:String},coll:{type:String},config:{type:String},paramString:{type:String},hashString:{type:String}}}firstUpdated(){window.addEventListener("message",t=>{const e=this.renderRoot.querySelector("iframe");e&&t.source===e.contentWindow&&t.data.title&&(this.title=t.data.title)})}updated(t){(t.has("url")||t.has("ts")||t.has("source"))&&(this.paramString=new URLSearchParams({source:this.source,customColl:this.coll,config:this.config,embed:"true"}).toString(),this.hashString=new URLSearchParams({url:this.url,ts:this.ts,view:this.view}).toString())}static get styles(){return n.b`
iframe {
width: 100%;
height: 100%;
@@ -81,7 +81,7 @@ const n=new WeakMap,r=t=>(...e)=>{const s=t(...e);return n.set(s,!0),s},i=t=>"fu
${this.paramString&&this.hashString?n.c`
<iframe src="${this.replayBase}?${this.paramString}#${this.hashString}" allow="autoplay *; fullscreen"></iframe>
`:n.c``}
`}}!async function(){customElements.define("replay-web-page",r)}()},13:function(t,e,s){"use strict";s.d(e,"b",(function(){return o})),s.d(e,"a",(function(){return a}));var n=s(5),r=s(1);
`}}!async function(){customElements.define("replay-web-page",r)}()},12:function(t,e,s){"use strict";s.d(e,"b",(function(){return o})),s.d(e,"a",(function(){return a}));var n=s(5),r=s(1);
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
@@ -95,7 +95,7 @@ const n=new WeakMap,r=t=>(...e)=>{const s=t(...e);return n.set(s,!0),s},i=t=>"fu
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
const i=` ${r.f} `;class o{constructor(t,e,s,n){this.strings=t,this.values=e,this.type=s,this.processor=n}getHTML(){const t=this.strings.length-1;let e="",s=!1;for(let n=0;n<t;n++){const t=this.strings[n],o=t.lastIndexOf("\x3c!--");s=(o>-1||s)&&-1===t.indexOf("--\x3e",o+1);const a=r.e.exec(t);e+=null===a?t+(s?i:r.g):t.substr(0,a.index)+a[1]+a[2]+r.b+a[3]+r.f}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");return t.innerHTML=this.getHTML(),t}}class a extends o{getHTML(){return`<svg>${super.getHTML()}</svg>`}getTemplateElement(){const t=super.getTemplateElement(),e=t.content,s=e.firstChild;return e.removeChild(s),Object(n.c)(e,s.firstChild),t}}},14:function(t,e,s){"use strict";s.d(e,"a",(function(){return i}));var n=s(5),r=s(1);
const i=` ${r.f} `;class o{constructor(t,e,s,n){this.strings=t,this.values=e,this.type=s,this.processor=n}getHTML(){const t=this.strings.length-1;let e="",s=!1;for(let n=0;n<t;n++){const t=this.strings[n],o=t.lastIndexOf("\x3c!--");s=(o>-1||s)&&-1===t.indexOf("--\x3e",o+1);const a=r.e.exec(t);e+=null===a?t+(s?i:r.g):t.substr(0,a.index)+a[1]+a[2]+r.b+a[3]+r.f}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");return t.innerHTML=this.getHTML(),t}}class a extends o{getHTML(){return`<svg>${super.getHTML()}</svg>`}getTemplateElement(){const t=super.getTemplateElement(),e=t.content,s=e.firstChild;return e.removeChild(s),Object(n.c)(e,s.firstChild),t}}},13:function(t,e,s){"use strict";s.d(e,"a",(function(){return i}));var n=s(5),r=s(1);
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
@@ -109,7 +109,7 @@ const i=` ${r.f} `;class o{constructor(t,e,s,n){this.strings=t,this.values=e,thi
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
class i{constructor(t,e,s){this.__parts=[],this.template=t,this.processor=e,this.options=s}update(t){let e=0;for(const s of this.__parts)void 0!==s&&s.setValue(t[e]),e++;for(const t of this.__parts)void 0!==t&&t.commit()}_clone(){const t=n.a?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),e=[],s=this.template.parts,i=document.createTreeWalker(t,133,null,!1);let o,a=0,c=0,l=i.nextNode();for(;a<s.length;)if(o=s[a],Object(r.d)(o)){for(;c<o.index;)c++,"TEMPLATE"===l.nodeName&&(e.push(l),i.currentNode=l.content),null===(l=i.nextNode())&&(i.currentNode=e.pop(),l=i.nextNode());if("node"===o.type){const t=this.processor.handleTextExpression(this.options);t.insertAfterNode(l.previousSibling),this.__parts.push(t)}else this.__parts.push(...this.processor.handleAttributeExpressions(l,o.name,o.strings,this.options));a++}else this.__parts.push(void 0),a++;return n.a&&(document.adoptNode(t),customElements.upgrade(t)),t}}},2:function(t,e,s){"use strict";s.d(e,"h",(function(){return l})),s.d(e,"a",(function(){return d})),s.d(e,"b",(function(){return h})),s.d(e,"e",(function(){return p})),s.d(e,"c",(function(){return f})),s.d(e,"f",(function(){return m})),s.d(e,"g",(function(){return _})),s.d(e,"d",(function(){return y}));var n=s(10),r=s(5),i=s(4),o=s(14),a=s(13),c=s(1);
class i{constructor(t,e,s){this.__parts=[],this.template=t,this.processor=e,this.options=s}update(t){let e=0;for(const s of this.__parts)void 0!==s&&s.setValue(t[e]),e++;for(const t of this.__parts)void 0!==t&&t.commit()}_clone(){const t=n.a?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),e=[],s=this.template.parts,i=document.createTreeWalker(t,133,null,!1);let o,a=0,c=0,l=i.nextNode();for(;a<s.length;)if(o=s[a],Object(r.d)(o)){for(;c<o.index;)c++,"TEMPLATE"===l.nodeName&&(e.push(l),i.currentNode=l.content),null===(l=i.nextNode())&&(i.currentNode=e.pop(),l=i.nextNode());if("node"===o.type){const t=this.processor.handleTextExpression(this.options);t.insertAfterNode(l.previousSibling),this.__parts.push(t)}else this.__parts.push(...this.processor.handleAttributeExpressions(l,o.name,o.strings,this.options));a++}else this.__parts.push(void 0),a++;return n.a&&(document.adoptNode(t),customElements.upgrade(t)),t}}},2:function(t,e,s){"use strict";s.d(e,"h",(function(){return l})),s.d(e,"a",(function(){return d})),s.d(e,"b",(function(){return h})),s.d(e,"e",(function(){return p})),s.d(e,"c",(function(){return f})),s.d(e,"f",(function(){return m})),s.d(e,"g",(function(){return _})),s.d(e,"d",(function(){return y}));var n=s(10),r=s(5),i=s(4),o=s(13),a=s(12),c=s(1);
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
@@ -164,7 +164,7 @@ const n="undefined"!=typeof window&&null!=window.customElements&&void 0!==window
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/const r=new class{handleAttributeExpressions(t,e,s,r){const i=e[0];if("."===i){return new n.f(t,e.slice(1),s).parts}return"@"===i?[new n.d(t,e.slice(1),r.eventContext)]:"?"===i?[new n.c(t,e.slice(1),s)]:new n.a(t,e,s).parts}handleTextExpression(t){return new n.e(t)}};var i=s(13),o=s(10);s(5),s(4),s(9),s(8),s(14),s(1);
*/const r=new class{handleAttributeExpressions(t,e,s,r){const i=e[0];if("."===i){return new n.f(t,e.slice(1),s).parts}return"@"===i?[new n.d(t,e.slice(1),r.eventContext)]:"?"===i?[new n.c(t,e.slice(1),s)]:new n.a(t,e,s).parts}handleTextExpression(t){return new n.e(t)}};var i=s(12),o=s(10);s(5),s(4),s(9),s(8),s(13),s(1);
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
+16 -16
View File
File diff suppressed because one or more lines are too long
+25 -43
View File
@@ -440,6 +440,7 @@ You can select a file to upload from the main page by clicking the \'Choose File
width: 96px;
height: 96px;
margin: 1em;
flex-grow: 1;
}
.progress-div {
@@ -466,8 +467,8 @@ You can select a file to upload from the main page by clicking the \'Choose File
render() {
return html`
<section class="container">
<div class="level has-text-centered">
<fa-icon class="level-item logo" size="96px" .svg=${rwpLogo}></fa-icon>
<div class="has-text-centered is-flex">
<fa-icon class="logo" size="96px" .svg=${rwpLogo}></fa-icon>
</div>
<div class="level">
<p class="level-item">Loading&nbsp;<b>${this.sourceUrl}</b>...</p>
@@ -1323,13 +1324,22 @@ class WrResources extends LitElement
}
}
async doLoadResources() {
async doLoadResources(isMore = false) {
const count = 100;
if (isMore && (!this.tryMore || !this.results.length)) {
return;
}
if (this.loading) {
return;
}
this.loading = true;
let url = (this.urlSearchType !== "" ? 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://
// optimization: if not starting with http, likely won't have a match here, so just add https://
if (url && !url.startsWith("http")) {
url = "https://" + url;
}
@@ -1341,47 +1351,20 @@ class WrResources extends LitElement
url,
prefix,
count
}).toString();
});
let resp = await fetch(`${this.collInfo.apiPrefix}/urls?${params}`);
resp = await resp.json();
this.results = resp.urls;
this.tryMore = (resp.urls.length === count);
this.filter();
this.loading = false;
}
async doLoadMore() {
const count = 100;
if (!this.tryMore || !this.results.length) {
return;
if (isMore) {
const last = this.results[this.results.length - 1];
params.set("fromMime", last.mime);
params.set("fromUrl", last.url);
params.set("fromTs", new Date(last.date).getTime());
}
if (this.loading) {
return;
}
this.loading = true;
const url = (this.urlSearchType !== "" ? this.urlSearch : "");
const prefix = url && this.urlSearchType === "prefix" ? 1 : 0;
const mime = this.currMime === "all" ? "" : this.currMime;
const last = this.results[this.results.length - 1];
const params = new URLSearchParams({
mime,
url,
prefix,
fromMime: last.mime,
fromUrl: last.url,
fromTs: new Date(last.date).getTime(),
count
}).toString();
let resp = await fetch(`${this.collInfo.apiPrefix}/urls?${params}`);
let resp = await fetch(`${this.collInfo.apiPrefix}/urls?${params.toString()}`);
resp = await resp.json();
this.results = this.results.concat(resp.urls);
this.tryMore = (resp.urls.length === count);
this.results = isMore ? this.results.concat(resp.urls) : resp.urls;
// can be more than count if multiple mimes
this.tryMore = (resp.urls.length >= count);
this.filter();
this.loading = false;
@@ -1428,7 +1411,7 @@ class WrResources extends LitElement
const element = event.currentTarget;
const diff = (element.scrollHeight - element.scrollTop) - element.clientHeight;
if (this.tryMore && diff < 40) {
this.doLoadMore();
this.doLoadResources(true);
}
}
@@ -1440,7 +1423,6 @@ class WrResources extends LitElement
}
.notification {
width: 100%;
min-height: 80px;
}
.main-scroll {
height: calc(100vh - 180px);
+4 -4
View File
File diff suppressed because one or more lines are too long