forked from Qortal/qortal-ui
Add tabs and blocked webaites
This commit is contained in:
parent
a935944beb
commit
aa80249155
@ -4,6 +4,7 @@ import { Epml } from '../../../epml.js'
|
|||||||
|
|
||||||
import '@material/mwc-icon'
|
import '@material/mwc-icon'
|
||||||
import '@material/mwc-button'
|
import '@material/mwc-button'
|
||||||
|
import '@material/mwc-tab-bar'
|
||||||
import '@material/mwc-textfield'
|
import '@material/mwc-textfield'
|
||||||
import '@vaadin/button'
|
import '@vaadin/button'
|
||||||
import '@vaadin/grid'
|
import '@vaadin/grid'
|
||||||
@ -31,7 +32,10 @@ class Websites extends LitElement {
|
|||||||
searchBlockedNames: { type: Array },
|
searchBlockedNames: { type: Array },
|
||||||
webResources: { type: Array },
|
webResources: { type: Array },
|
||||||
webFollowedNames: { type: Array },
|
webFollowedNames: { type: Array },
|
||||||
webBlockedNames: { type: Array }
|
webBlockedNames: { type: Array },
|
||||||
|
blockResources: { type: Array },
|
||||||
|
blockFollowedNames: { type: Array },
|
||||||
|
blockBlockedNames: { type: Array }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +50,15 @@ class Websites extends LitElement {
|
|||||||
--lumo-primary-color: hsl(199, 100%, 48%);
|
--lumo-primary-color: hsl(199, 100%, 48%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#tabs-1 {
|
||||||
|
--mdc-tab-height: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tabs-1-content {
|
||||||
|
height: 100%;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
#pages {
|
#pages {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
@ -183,120 +196,178 @@ class Websites extends LitElement {
|
|||||||
this.webResources = []
|
this.webResources = []
|
||||||
this.webFollowedNames = []
|
this.webFollowedNames = []
|
||||||
this.webBlockedNames = []
|
this.webBlockedNames = []
|
||||||
|
this.blockResources = []
|
||||||
|
this.blockFollowedNames = []
|
||||||
|
this.blockBlockedNames = []
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return html`
|
return html`
|
||||||
<div id="websites-list-page">
|
<div id="websites-list-page">
|
||||||
<div style="min-height:48px; display: flex; padding-bottom: 6px; margin: 2px;">
|
<mwc-tab-bar id="tabs-1" activeIndex="0">
|
||||||
<h2 style="margin: 0; flex: 1; padding-top: .1em; display: inline;">Browse Websites</h2>
|
<mwc-tab label="Browse Websites" icon="travel_explore" @click="${(e) => this.displayTabContent('browse')}"></mwc-tab>
|
||||||
${this.renderPublishButton()}
|
<mwc-tab label="Followed Websites" icon="desktop_windows" @click="${(e) => this.displayTabContent('followed')}"></mwc-tab>
|
||||||
</div>
|
<mwc-tab label="Blocked Websites" icon="block" @click="${(e) => this.displayTabContent('blocked')}"></mwc-tab>
|
||||||
<div class="divCard">
|
</mwc-tab-bar>
|
||||||
<h3 style="margin: 0; margin-bottom: 1em; text-align: left;">Search Websites</h3>
|
<z id="tabs-1-content">
|
||||||
<div id="search">
|
<div id="tab-browse-content">
|
||||||
<vaadin-text-field theme="medium" id="searchName" placeholder="Name to search" value="${this.searchName}" @keydown="${this.searchListener}" clear-button-visible>
|
<div style="min-height:48px; display: flex; padding-bottom: 6px; margin: 2px;">
|
||||||
<vaadin-icon slot="prefix" icon="vaadin:user"></vaadin-icon>
|
<h2 style="margin: 0; flex: 1; padding-top: .5em; display: inline;">Browse Websites</h2>
|
||||||
</vaadin-text-field> <br>
|
<h2 style="margin: 0; flex: 1; padding-top: .5em; display: inline;">${this.renderPublishButton()}</h2>
|
||||||
<vaadin-button theme="medium" @click="${(e) => this.doSearch(e)}">
|
</div>
|
||||||
<vaadin-icon icon="vaadin:search" slot="prefix"></vaadin-icon>
|
<div class="divCard">
|
||||||
Search
|
<h3 style="margin: 0; margin-bottom: 1em; text-align: left;">Search Websites</h3>
|
||||||
</vaadin-button>
|
<div id="search">
|
||||||
</div><br />
|
<vaadin-text-field theme="medium" id="searchName" placeholder="Name to search" value="${this.searchName}" @keydown="${this.searchListener}" clear-button-visible>
|
||||||
<vaadin-grid theme="large" id="searchResourcesGrid" ?hidden="${this.isEmptyArray(this.searchResources)}" .items="${this.searchResources}" aria-label="Search Websites" all-rows-visible>
|
<vaadin-icon slot="prefix" icon="vaadin:user"></vaadin-icon>
|
||||||
<vaadin-grid-column width="5rem" flex-grow="0" header="Avatar" .renderer=${(root, column, data) => {
|
</vaadin-text-field> <br>
|
||||||
render(html`${this.renderSearchAvatar(data.item)}`, root)
|
<vaadin-button theme="medium" @click="${(e) => this.doSearch(e)}">
|
||||||
}}>
|
<vaadin-icon icon="vaadin:search" slot="prefix"></vaadin-icon>
|
||||||
</vaadin-grid-column>
|
Search
|
||||||
<vaadin-grid-column header="Name" .renderer=${(root, column, data) => {
|
</vaadin-button>
|
||||||
render(html`${this.renderSearchName(data.item)}`, root)
|
</div><br />
|
||||||
}}>
|
<vaadin-grid theme="large" id="searchResourcesGrid" ?hidden="${this.isEmptyArray(this.searchResources)}" .items="${this.searchResources}" aria-label="Search Websites" all-rows-visible>
|
||||||
</vaadin-grid-column>
|
<vaadin-grid-column width="5rem" flex-grow="0" header="Avatar" .renderer=${(root, column, data) => {
|
||||||
<vaadin-grid-column header="Status" .renderer=${(root, column, data) => {
|
render(html`${this.renderSearchAvatar(data.item)}`, root)
|
||||||
render(html`${this.renderSearchStatus(data.item)}`, root)
|
}}>
|
||||||
}}>
|
</vaadin-grid-column>
|
||||||
</vaadin-grid-column>
|
<vaadin-grid-column header="Name" .renderer=${(root, column, data) => {
|
||||||
<vaadin-grid-column header="Size" .renderer=${(root, column, data) => {
|
render(html`${this.renderSearchName(data.item)}`, root)
|
||||||
render(html`${this.renderSearchSize(data.item)}`, root)
|
}}>
|
||||||
}}>
|
</vaadin-grid-column>
|
||||||
</vaadin-grid-column>
|
<vaadin-grid-column header="Status" .renderer=${(root, column, data) => {
|
||||||
<vaadin-grid-column width="10rem" flex-grow="0" header="Action" .renderer=${(root, column, data) => {
|
render(html`${this.renderSearchStatus(data.item)}`, root)
|
||||||
render(html`${this.renderSearchFollowUnfollowButton(data.item)}`, root);
|
}}>
|
||||||
}}>
|
</vaadin-grid-column>
|
||||||
</vaadin-grid-column>
|
<vaadin-grid-column header="Size" .renderer=${(root, column, data) => {
|
||||||
<vaadin-grid-column width="10rem" flex-grow="0" header="" .renderer=${(root, column, data) => {
|
render(html`${this.renderSearchSize(data.item)}`, root)
|
||||||
render(html`${this.renderSearchBlockUnblockButton(data.item)}`, root);
|
}}>
|
||||||
}}>
|
</vaadin-grid-column>
|
||||||
</vaadin-grid-column>
|
<vaadin-grid-column width="10rem" flex-grow="0" header="Action" .renderer=${(root, column, data) => {
|
||||||
</vaadin-grid><br />
|
render(html`${this.renderSearchFollowUnfollowButton(data.item)}`, root);
|
||||||
</div>
|
}}>
|
||||||
<div class="divCard">
|
</vaadin-grid-column>
|
||||||
<h3 style="margin: 0; margin-bottom: 1em; text-align: center;">Followed Websites</h3>
|
<vaadin-grid-column width="10rem" flex-grow="0" header="" .renderer=${(root, column, data) => {
|
||||||
<vaadin-grid theme="large" id="webResourcesGrid" ?hidden="${this.isEmptyArray(this.webResources)}" .items="${this.webResources}" aria-label="Followed Websites" all-rows-visible>
|
render(html`${this.renderSearchBlockUnblockButton(data.item)}`, root);
|
||||||
<vaadin-grid-column width="5rem" flex-grow="0" header="Avatar" .renderer=${(root, column, data) => {
|
}}>
|
||||||
render(html`${this.renderWebAvatar(data.item)}`, root)
|
</vaadin-grid-column>
|
||||||
}}>
|
</vaadin-grid><br />
|
||||||
</vaadin-grid-column>
|
</div>
|
||||||
<vaadin-grid-column header="Name" .renderer=${(root, column, data) => {
|
<div class="divCard">
|
||||||
render(html`${this.renderWebName(data.item)}`, root)
|
<h3 style="margin: 0; margin-bottom: 1em; text-align: center;">Websites</h3>
|
||||||
}}>
|
<vaadin-grid theme="large" id="resourcesGrid" ?hidden="${this.isEmptyArray(this.resources)}" aria-label="Websites" page-size="20" all-rows-visible>
|
||||||
</vaadin-grid-column>
|
<vaadin-grid-column width="5rem" flex-grow="0" header="Avatar" .renderer=${(root, column, data) => {
|
||||||
<vaadin-grid-column header="Status" .renderer=${(root, column, data) => {
|
render(html`${this.renderAvatar(data.item)}`, root)
|
||||||
render(html`${this.renderWebStatus(data.item)}`, root)
|
}}>
|
||||||
}}>
|
</vaadin-grid-column>
|
||||||
</vaadin-grid-column>
|
<vaadin-grid-column header="Name" .renderer=${(root, column, data) => {
|
||||||
<vaadin-grid-column header="Size" .renderer=${(root, column, data) => {
|
render(html`${this.renderName(data.item)}`, root)
|
||||||
render(html`${this.renderWebSize(data.item)}`, root)
|
}}>
|
||||||
}}>
|
</vaadin-grid-column>
|
||||||
</vaadin-grid-column>
|
<vaadin-grid-column header="Status" .renderer=${(root, column, data) => {
|
||||||
<vaadin-grid-column width="10rem" flex-grow="0" header="Action" .renderer=${(root, column, data) => {
|
render(html`${this.renderStatus(data.item)}`, root)
|
||||||
render(html`${this.renderWebFollowUnfollowButton(data.item)}`, root);
|
}}>
|
||||||
}}>
|
</vaadin-grid-column>
|
||||||
</vaadin-grid-column>
|
<vaadin-grid-column header="Size" .renderer=${(root, column, data) => {
|
||||||
<vaadin-grid-column width="10rem" flex-grow="0" header="" .renderer=${(root, column, data) => {
|
render(html`${this.renderSize(data.item)}`, root)
|
||||||
render(html`${this.renderWebBlockUnblockButton(data.item)}`, root);
|
}}>
|
||||||
}}>
|
</vaadin-grid-column>
|
||||||
</vaadin-grid-column>
|
<vaadin-grid-column width="10rem" flex-grow="0" header="Action" .renderer=${(root, column, data) => {
|
||||||
</vaadin-grid>
|
render(html`${this.renderFollowUnfollowButton(data.item)}`, root);
|
||||||
${this.isEmptyArray(this.webResources) ? html`
|
}}>
|
||||||
You not follow any website
|
</vaadin-grid-column>
|
||||||
`: ''}
|
<vaadin-grid-column width="10rem" flex-grow="0" header="" .renderer=${(root, column, data) => {
|
||||||
</div>
|
render(html`${this.renderBlockUnblockButton(data.item)}`, root);
|
||||||
<div class="divCard">
|
}}>
|
||||||
<h3 style="margin: 0; margin-bottom: 1em; text-align: center;">Websites</h3>
|
</vaadin-grid-column>
|
||||||
<vaadin-grid theme="large" id="resourcesGrid" ?hidden="${this.isEmptyArray(this.resources)}" aria-label="Websites" page-size="20" all-rows-visible>
|
</vaadin-grid>
|
||||||
<vaadin-grid-column width="5rem" flex-grow="0" header="Avatar" .renderer=${(root, column, data) => {
|
<div id="pages"></div>
|
||||||
render(html`${this.renderAvatar(data.item)}`, root)
|
${this.isEmptyArray(this.resources) ? html`
|
||||||
}}>
|
No websites available
|
||||||
</vaadin-grid-column>
|
`: ''}
|
||||||
<vaadin-grid-column header="Name" .renderer=${(root, column, data) => {
|
</div>
|
||||||
render(html`${this.renderName(data.item)}`, root)
|
${this.renderRelayModeText()}
|
||||||
}}>
|
</div>
|
||||||
</vaadin-grid-column>
|
<div id="tab-followed-content">
|
||||||
<vaadin-grid-column header="Status" .renderer=${(root, column, data) => {
|
<div style="min-height:48px; display: flex; padding-bottom: 6px; margin: 2px;">
|
||||||
render(html`${this.renderStatus(data.item)}`, root)
|
<h2 style="margin: 0; flex: 1; padding-top: .5em; display: inline;">Your followed Webistes</h2>
|
||||||
}}>
|
<h2 style="margin: 0; flex: 1; padding-top: .5em; display: inline;">${this.renderPublishButton()}</h2>
|
||||||
</vaadin-grid-column>
|
</div>
|
||||||
<vaadin-grid-column header="Size" .renderer=${(root, column, data) => {
|
<div class="divCard">
|
||||||
render(html`${this.renderSize(data.item)}`, root)
|
<h3 style="margin: 0; margin-bottom: 1em; text-align: center;">Followed Websites</h3>
|
||||||
}}>
|
<vaadin-grid theme="large" id="webResourcesGrid" ?hidden="${this.isEmptyArray(this.webResources)}" .items="${this.webResources}" aria-label="Followed Websites" all-rows-visible>
|
||||||
</vaadin-grid-column>
|
<vaadin-grid-column width="5rem" flex-grow="0" header="Avatar" .renderer=${(root, column, data) => {
|
||||||
<vaadin-grid-column width="10rem" flex-grow="0" header="Action" .renderer=${(root, column, data) => {
|
render(html`${this.renderWebAvatar(data.item)}`, root)
|
||||||
render(html`${this.renderFollowUnfollowButton(data.item)}`, root);
|
}}>
|
||||||
}}>
|
</vaadin-grid-column>
|
||||||
</vaadin-grid-column>
|
<vaadin-grid-column header="Name" .renderer=${(root, column, data) => {
|
||||||
<vaadin-grid-column width="10rem" flex-grow="0" header="" .renderer=${(root, column, data) => {
|
render(html`${this.renderWebName(data.item)}`, root)
|
||||||
render(html`${this.renderBlockUnblockButton(data.item)}`, root);
|
}}>
|
||||||
}}>
|
</vaadin-grid-column>
|
||||||
</vaadin-grid-column>
|
<vaadin-grid-column header="Status" .renderer=${(root, column, data) => {
|
||||||
</vaadin-grid>
|
render(html`${this.renderWebStatus(data.item)}`, root)
|
||||||
<div id="pages"></div>
|
}}>
|
||||||
${this.isEmptyArray(this.resources) ? html`
|
</vaadin-grid-column>
|
||||||
No websites available
|
<vaadin-grid-column header="Size" .renderer=${(root, column, data) => {
|
||||||
`: ''}
|
render(html`${this.renderWebSize(data.item)}`, root)
|
||||||
</div>
|
}}>
|
||||||
${this.renderRelayModeText()}
|
</vaadin-grid-column>
|
||||||
</div>
|
<vaadin-grid-column width="10rem" flex-grow="0" header="Action" .renderer=${(root, column, data) => {
|
||||||
|
render(html`${this.renderWebFollowUnfollowButton(data.item)}`, root);
|
||||||
|
}}>
|
||||||
|
</vaadin-grid-column>
|
||||||
|
<vaadin-grid-column width="10rem" flex-grow="0" header="" .renderer=${(root, column, data) => {
|
||||||
|
render(html`${this.renderWebBlockUnblockButton(data.item)}`, root);
|
||||||
|
}}>
|
||||||
|
</vaadin-grid-column>
|
||||||
|
</vaadin-grid>
|
||||||
|
${this.isEmptyArray(this.webResources) ? html`
|
||||||
|
You not follow any website
|
||||||
|
`: ''}
|
||||||
|
</div>
|
||||||
|
${this.renderRelayModeText()}
|
||||||
|
</div>
|
||||||
|
<div id="tab-blocked-content">
|
||||||
|
<div style="min-height:48px; display: flex; padding-bottom: 6px; margin: 2px;">
|
||||||
|
<h2 style="margin: 0; flex: 1; padding-top: .5em; display: inline;">Your blocked Webistes</h2>
|
||||||
|
<h2 style="margin: 0; flex: 1; padding-top: .5em; display: inline;">${this.renderPublishButton()}</h2>
|
||||||
|
</div>
|
||||||
|
<div class="divCard">
|
||||||
|
<h3 style="margin: 0; margin-bottom: 1em; text-align: center;">Blocked Websites</h3>
|
||||||
|
<vaadin-grid theme="large" id="blockResourcesGrid" ?hidden="${this.isEmptyArray(this.blockResources)}" .items="${this.blockResources}" aria-label="Followed Websites" all-rows-visible>
|
||||||
|
<vaadin-grid-column width="5rem" flex-grow="0" header="Avatar" .renderer=${(root, column, data) => {
|
||||||
|
render(html`${this.renderBlockAvatar(data.item)}`, root)
|
||||||
|
}}>
|
||||||
|
</vaadin-grid-column>
|
||||||
|
<vaadin-grid-column header="Name" .renderer=${(root, column, data) => {
|
||||||
|
render(html`${this.renderBlockName(data.item)}`, root)
|
||||||
|
}}>
|
||||||
|
</vaadin-grid-column>
|
||||||
|
<vaadin-grid-column header="Status" .renderer=${(root, column, data) => {
|
||||||
|
render(html`${this.renderBlockStatus(data.item)}`, root)
|
||||||
|
}}>
|
||||||
|
</vaadin-grid-column>
|
||||||
|
<vaadin-grid-column header="Size" .renderer=${(root, column, data) => {
|
||||||
|
render(html`${this.renderBlockSize(data.item)}`, root)
|
||||||
|
}}>
|
||||||
|
</vaadin-grid-column>
|
||||||
|
<vaadin-grid-column width="10rem" flex-grow="0" header="Action" .renderer=${(root, column, data) => {
|
||||||
|
render(html`${this.renderBlockFollowUnfollowButton(data.item)}`, root);
|
||||||
|
}}>
|
||||||
|
</vaadin-grid-column>
|
||||||
|
<vaadin-grid-column width="10rem" flex-grow="0" header="" .renderer=${(root, column, data) => {
|
||||||
|
render(html`${this.renderBlockBlockUnblockButton(data.item)}`, root);
|
||||||
|
}}>
|
||||||
|
</vaadin-grid-column>
|
||||||
|
</vaadin-grid>
|
||||||
|
${this.isEmptyArray(this.blockResources) ? html`
|
||||||
|
You have not blocked any website
|
||||||
|
`: ''}
|
||||||
|
</div>
|
||||||
|
${this.renderRelayModeText()}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,6 +375,10 @@ class Websites extends LitElement {
|
|||||||
|
|
||||||
this.showWebsites()
|
this.showWebsites()
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.displayTabContent('browse')
|
||||||
|
}, 0)
|
||||||
|
|
||||||
const getFollowedNames = async () => {
|
const getFollowedNames = async () => {
|
||||||
let followedNames = await parentEpml.request('apiCall', {
|
let followedNames = await parentEpml.request('apiCall', {
|
||||||
url: `/lists/followedNames?apiKey=${this.getApiKey()}`
|
url: `/lists/followedNames?apiKey=${this.getApiKey()}`
|
||||||
@ -340,6 +415,24 @@ class Websites extends LitElement {
|
|||||||
setTimeout(getWebBlockedNames, 60000)
|
setTimeout(getWebBlockedNames, 60000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getBlockFollowedNames = async () => {
|
||||||
|
let blockFollowedNames = await parentEpml.request('apiCall', {
|
||||||
|
url: `/lists/followedNames?apiKey=${this.getApiKey()}`
|
||||||
|
})
|
||||||
|
|
||||||
|
this.blockFollowedNames = blockFollowedNames
|
||||||
|
setTimeout(getBlockFollowedNames, 60000)
|
||||||
|
}
|
||||||
|
|
||||||
|
const getBlockBlockedNames = async () => {
|
||||||
|
let blockBlockedNames = await parentEpml.request('apiCall', {
|
||||||
|
url: `/lists/blockedNames?apiKey=${this.getApiKey()}`
|
||||||
|
})
|
||||||
|
|
||||||
|
this.blockBlockedNames = blockBlockedNames
|
||||||
|
setTimeout(getBlockBlockedNames, 60000)
|
||||||
|
}
|
||||||
|
|
||||||
const getSearchFollowedNames = async () => {
|
const getSearchFollowedNames = async () => {
|
||||||
let searchFollowedNames = await parentEpml.request('apiCall', {
|
let searchFollowedNames = await parentEpml.request('apiCall', {
|
||||||
url: `/lists/followedNames?apiKey=${this.getApiKey()}`
|
url: `/lists/followedNames?apiKey=${this.getApiKey()}`
|
||||||
@ -395,15 +488,19 @@ class Websites extends LitElement {
|
|||||||
if (!configLoaded) {
|
if (!configLoaded) {
|
||||||
setTimeout(this.getArbitraryResources, 1)
|
setTimeout(this.getArbitraryResources, 1)
|
||||||
setTimeout(this.getFollowedWebsites, 1)
|
setTimeout(this.getFollowedWebsites, 1)
|
||||||
|
setTimeout(this.getBlockedWebsites, 1)
|
||||||
setTimeout(getFollowedNames, 1)
|
setTimeout(getFollowedNames, 1)
|
||||||
setTimeout(getBlockedNames, 1)
|
setTimeout(getBlockedNames, 1)
|
||||||
setTimeout(getWebFollowedNames, 1)
|
setTimeout(getWebFollowedNames, 1)
|
||||||
setTimeout(getWebBlockedNames, 1)
|
setTimeout(getWebBlockedNames, 1)
|
||||||
|
setTimeout(getBlockFollowedNames, 1)
|
||||||
|
setTimeout(getBlockBlockedNames, 1)
|
||||||
setTimeout(getSearchFollowedNames, 1)
|
setTimeout(getSearchFollowedNames, 1)
|
||||||
setTimeout(getSearchBlockedNames, 1)
|
setTimeout(getSearchBlockedNames, 1)
|
||||||
setTimeout(getRelayMode, 1)
|
setTimeout(getRelayMode, 1)
|
||||||
setInterval(this.getArbitraryResources, 120000)
|
setInterval(this.getArbitraryResources, 120000)
|
||||||
setInterval(this.getFollowedWebsites, 60000)
|
setInterval(this.getFollowedWebsites, 60000)
|
||||||
|
setInterval(this.getBlockedWebsites, 60000)
|
||||||
configLoaded = true
|
configLoaded = true
|
||||||
}
|
}
|
||||||
this.config = JSON.parse(c)
|
this.config = JSON.parse(c)
|
||||||
@ -417,6 +514,15 @@ class Websites extends LitElement {
|
|||||||
parentEpml.imReady()
|
parentEpml.imReady()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
displayTabContent(tab) {
|
||||||
|
const tabBrowseContent = this.shadowRoot.getElementById('tab-browse-content')
|
||||||
|
const tabFollowedContent = this.shadowRoot.getElementById('tab-followed-content')
|
||||||
|
const tabBlockedContent = this.shadowRoot.getElementById('tab-blocked-content')
|
||||||
|
tabBrowseContent.style.display = (tab === 'browse') ? 'block' : 'none'
|
||||||
|
tabFollowedContent.style.display = (tab === 'followed') ? 'block' : 'none'
|
||||||
|
tabBlockedContent.style.display = (tab === 'blocked') ? 'block' : 'none'
|
||||||
|
}
|
||||||
|
|
||||||
searchListener(e) {
|
searchListener(e) {
|
||||||
if (e.key === 'Enter') {
|
if (e.key === 'Enter') {
|
||||||
this.doSearch(e);
|
this.doSearch(e);
|
||||||
@ -675,6 +781,168 @@ class Websites extends LitElement {
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getBlockedWebsites = async () => {
|
||||||
|
let data = [];
|
||||||
|
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node];
|
||||||
|
const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port;
|
||||||
|
const blockedNamesUrl = `${nodeUrl}/lists/blockedNames?apiKey=${this.getApiKey()}`;
|
||||||
|
const blockedJsonUrl = `${nodeUrl}/arbitrary/resources?service=WEBSITE&default=true&limit=0&reverse=false&includestatus=true`;
|
||||||
|
|
||||||
|
const blockedJsonRes = await fetch(blockedJsonUrl);
|
||||||
|
const blockedJsonData = await blockedJsonRes.json();
|
||||||
|
const blockedResponse = await fetch(blockedNamesUrl);
|
||||||
|
const blockednames = await blockedResponse.json();
|
||||||
|
|
||||||
|
let blockedres = blockedJsonData.filter((elm) => blockednames.includes(elm.name));
|
||||||
|
|
||||||
|
this.blockResources = blockedres;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderBlockAvatar(blockObj) {
|
||||||
|
let name = blockObj.name
|
||||||
|
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
||||||
|
const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port
|
||||||
|
const url = `${nodeUrl}/arbitrary/THUMBNAIL/${name}/qortal_avatar?async=true&apiKey=${this.getApiKey()}`;
|
||||||
|
return html`<img src="${url}" onerror="this.onerror=null; this.src='/img/incognito.png';">`
|
||||||
|
}
|
||||||
|
|
||||||
|
renderBlockName(blockObj) {
|
||||||
|
let name = blockObj.name
|
||||||
|
return html`<a class="visitSite" href="browser/index.html?name=${name}&service=${this.service}">${name}</a>`
|
||||||
|
}
|
||||||
|
|
||||||
|
renderBlockStatus(blockObj) {
|
||||||
|
return html`<span title="${blockObj.status.description}">${blockObj.status.title}</span>`
|
||||||
|
}
|
||||||
|
|
||||||
|
renderBlockSize(blockObj) {
|
||||||
|
if (blockObj.size === null) {
|
||||||
|
return html``
|
||||||
|
}
|
||||||
|
let sizeBlockReadable = this.bytesToSize(blockObj.size);
|
||||||
|
return html`<span>${sizeBlockReadable}</span>`
|
||||||
|
}
|
||||||
|
|
||||||
|
renderBlockFollowUnfollowButton(blockObj) {
|
||||||
|
let name = blockObj.name
|
||||||
|
if (this.blockFollowedNames == null || !Array.isArray(this.blockFollowedNames)) {
|
||||||
|
return html``
|
||||||
|
}
|
||||||
|
if (this.blockFollowedNames.indexOf(name) === -1) {
|
||||||
|
return html`<mwc-button @click=${() => this.blockFollowName(blockObj)}><mwc-icon>add_to_queue</mwc-icon> Follow</mwc-button>`
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return html`<mwc-button @click=${() => this.blockUnfollowName(blockObj)}><mwc-icon>remove_from_queue</mwc-icon> Unfollow</mwc-button>`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async blockFollowName(blockObj) {
|
||||||
|
let name = blockObj.name
|
||||||
|
let items = [
|
||||||
|
name
|
||||||
|
]
|
||||||
|
let namesJsonString = JSON.stringify({ "items": items })
|
||||||
|
let ret = await parentEpml.request('apiCall', {
|
||||||
|
url: `/lists/followedNames?apiKey=${this.getApiKey()}`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: `${namesJsonString}`
|
||||||
|
})
|
||||||
|
if (ret === true) {
|
||||||
|
this.blockFollowedNames = this.blockFollowedNames.filter(item => item != name);
|
||||||
|
this.blockFollowedNames.push(name)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
parentEpml.request('showSnackBar', 'Error occurred when trying to follow this registered name. Please try again')
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
async blockUnfollowName(blockObj) {
|
||||||
|
let name = blockObj.name
|
||||||
|
let items = [
|
||||||
|
name
|
||||||
|
]
|
||||||
|
let namesJsonString = JSON.stringify({ "items": items })
|
||||||
|
let ret = await parentEpml.request('apiCall', {
|
||||||
|
url: `/lists/followedNames?apiKey=${this.getApiKey()}`,
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: `${namesJsonString}`
|
||||||
|
})
|
||||||
|
if (ret === true) {
|
||||||
|
this.blockFollowedNames = this.blockFollowedNames.filter(item => item != name);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
parentEpml.request('showSnackBar', 'Error occurred when trying to unfollow this registered name. Please try again')
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
renderBlockBlockUnblockButton(blockObj) {
|
||||||
|
let name = blockObj.name
|
||||||
|
if (this.blockBlockedNames == null || !Array.isArray(this.blockBlockedNames)) {
|
||||||
|
return html``
|
||||||
|
}
|
||||||
|
if (this.blockBlockedNames.indexOf(name) === -1) {
|
||||||
|
return html`<mwc-button @click=${() => this.blockBlockName(blockObj)}><mwc-icon>block</mwc-icon> Block</mwc-button>`
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return html`<mwc-button @click=${() => this.blockUnblockName(blockObj)}><mwc-icon>radio_button_unchecked</mwc-icon> Unblock</mwc-button>`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async blockBlockName(blockObj) {
|
||||||
|
let name = blockObj.name
|
||||||
|
let items = [
|
||||||
|
name
|
||||||
|
]
|
||||||
|
let namesJsonString = JSON.stringify({ "items": items })
|
||||||
|
let ret = await parentEpml.request('apiCall', {
|
||||||
|
url: `/lists/blockedNames?apiKey=${this.getApiKey()}`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: `${namesJsonString}`
|
||||||
|
})
|
||||||
|
if (ret === true) {
|
||||||
|
this.blockBlockedNames = this.blockBlockedNames.filter(item => item != name);
|
||||||
|
this.blockBlockedNames.push(name)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
parentEpml.request('showSnackBar', 'Error occurred when trying to block this registered name. Please try again')
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
async blockUnblockName(blockObj) {
|
||||||
|
let name = blockObj.name
|
||||||
|
let items = [
|
||||||
|
name
|
||||||
|
]
|
||||||
|
let namesJsonString = JSON.stringify({ "items": items })
|
||||||
|
let ret = await parentEpml.request('apiCall', {
|
||||||
|
url: `/lists/blockedNames?apiKey=${this.getApiKey()}`,
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: `${namesJsonString}`
|
||||||
|
})
|
||||||
|
if (ret === true) {
|
||||||
|
this.blockBlockedNames = this.blockBlockedNames.filter(item => item != name);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
parentEpml.request('showSnackBar', 'Error occurred when trying to unblock this registered name. Please try again')
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
async searchResult() {
|
async searchResult() {
|
||||||
let searchName = this.shadowRoot.getElementById('searchName').value
|
let searchName = this.shadowRoot.getElementById('searchName').value
|
||||||
if (searchName.length === 0) {
|
if (searchName.length === 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user