4
1
mirror of https://github.com/Qortal/qortal-ui.git synced 2025-02-11 17:55:51 +00:00

Merge branch 'master' of github.com:Qortal/qortal-ui

This commit is contained in:
CalDescent 2022-02-26 22:39:48 +00:00
commit fc0f850680
3 changed files with 571 additions and 83 deletions

View File

@ -4,6 +4,7 @@ import { Epml } from '../../../epml.js'
import '@material/mwc-icon'
import '@material/mwc-button'
import '@material/mwc-tab-bar'
import '@material/mwc-textfield'
import '@vaadin/button'
import '@vaadin/grid'
@ -28,7 +29,13 @@ class Websites extends LitElement {
searchName: { type: String },
searchResources: { type: Array },
searchFollowedNames: { type: Array },
searchBlockedNames: { type: Array }
searchBlockedNames: { type: Array },
webResources: { type: Array },
webFollowedNames: { type: Array },
webBlockedNames: { type: Array },
blockResources: { type: Array },
blockFollowedNames: { type: Array },
blockBlockedNames: { type: Array }
}
}
@ -43,6 +50,15 @@ class Websites extends LitElement {
--lumo-primary-color: hsl(199, 100%, 48%);
}
#tabs-1 {
--mdc-tab-height: 50px;
}
#tabs-1-content {
height: 100%;
padding-bottom: 10px;
}
#pages {
display: flex;
flex-wrap: wrap;
@ -177,88 +193,181 @@ class Websites extends LitElement {
this.searchResources = []
this.searchFollowedNames = []
this.searchBlockedNames = []
this.webResources = []
this.webFollowedNames = []
this.webBlockedNames = []
this.blockResources = []
this.blockFollowedNames = []
this.blockBlockedNames = []
}
render() {
return html`
<div id="websites-list-page">
<div style="min-height:48px; display: flex; padding-bottom: 6px; margin: 2px;">
<h2 style="margin: 0; flex: 1; padding-top: .1em; display: inline;">Browse Websites</h2>
${this.renderPublishButton()}
</div>
<div class="divCard">
<h3 style="margin: 0; margin-bottom: 1em; text-align: left;">Search Websites</h3>
<div id="search">
<vaadin-text-field theme="medium" id="searchName" placeholder="Name to search" value="${this.searchName}" @keydown="${this.searchListener}" clear-button-visible>
<vaadin-icon slot="prefix" icon="vaadin:user"></vaadin-icon>
</vaadin-text-field>&nbsp;&nbsp;<br>
<vaadin-button theme="medium" @click="${(e) => this.doSearch(e)}">
<vaadin-icon icon="vaadin:search" slot="prefix"></vaadin-icon>
Search
</vaadin-button>
</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 width="5rem" flex-grow="0" header="Avatar" .renderer=${(root, column, data) => {
render(html`${this.renderSearchAvatar(data.item)}`, root)
}}>
</vaadin-grid-column>
<vaadin-grid-column header="Name" .renderer=${(root, column, data) => {
render(html`${this.renderSearchName(data.item)}`, root)
}}>
</vaadin-grid-column>
<vaadin-grid-column header="Status" .renderer=${(root, column, data) => {
render(html`${this.renderSearchStatus(data.item)}`, root)
}}>
</vaadin-grid-column>
<vaadin-grid-column header="Size" .renderer=${(root, column, data) => {
render(html`${this.renderSearchSize(data.item)}`, root)
}}>
</vaadin-grid-column>
<vaadin-grid-column width="10rem" flex-grow="0" header="Action" .renderer=${(root, column, data) => {
render(html`${this.renderSearchFollowUnfollowButton(data.item)}`, root);
}}>
</vaadin-grid-column>
<vaadin-grid-column width="10rem" flex-grow="0" header="" .renderer=${(root, column, data) => {
render(html`${this.renderSearchBlockUnblockButton(data.item)}`, root);
}}>
</vaadin-grid-column>
</vaadin-grid><br />
</div>
<div class="divCard">
<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 width="5rem" flex-grow="0" header="Avatar" .renderer=${(root, column, data) => {
render(html`${this.renderAvatar(data.item)}`, root)
}}>
</vaadin-grid-column>
<vaadin-grid-column header="Name" .renderer=${(root, column, data) => {
render(html`${this.renderName(data.item)}`, root)
}}>
</vaadin-grid-column>
<vaadin-grid-column header="Status" .renderer=${(root, column, data) => {
render(html`${this.renderStatus(data.item)}`, root)
}}>
</vaadin-grid-column>
<vaadin-grid-column header="Size" .renderer=${(root, column, data) => {
render(html`${this.renderSize(data.item)}`, root)
}}>
</vaadin-grid-column>
<vaadin-grid-column width="10rem" flex-grow="0" header="Action" .renderer=${(root, column, data) => {
render(html`${this.renderFollowUnfollowButton(data.item)}`, root);
}}>
</vaadin-grid-column>
<vaadin-grid-column width="10rem" flex-grow="0" header="" .renderer=${(root, column, data) => {
render(html`${this.renderBlockUnblockButton(data.item)}`, root);
}}>
</vaadin-grid-column>
</vaadin-grid>
<div id="pages"></div>
${this.isEmptyArray(this.resources) ? html`
No websites available
`: ''}
</div>
${this.renderRelayModeText()}
</div>
<mwc-tab-bar id="tabs-1" activeIndex="0">
<mwc-tab label="Browse Websites" icon="travel_explore" @click="${(e) => this.displayTabContent('browse')}"></mwc-tab>
<mwc-tab label="Followed Websites" icon="desktop_windows" @click="${(e) => this.displayTabContent('followed')}"></mwc-tab>
<mwc-tab label="Blocked Websites" icon="block" @click="${(e) => this.displayTabContent('blocked')}"></mwc-tab>
</mwc-tab-bar>
<z id="tabs-1-content">
<div id="tab-browse-content">
<div style="min-height:48px; display: flex; padding-bottom: 6px; margin: 2px;">
<h2 style="margin: 0; flex: 1; padding-top: .5em; display: inline;">Browse Websites</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: left;">Search Websites</h3>
<div id="search">
<vaadin-text-field theme="medium" id="searchName" placeholder="Name to search" value="${this.searchName}" @keydown="${this.searchListener}" clear-button-visible>
<vaadin-icon slot="prefix" icon="vaadin:user"></vaadin-icon>
</vaadin-text-field>&nbsp;&nbsp;<br>
<vaadin-button theme="medium" @click="${(e) => this.doSearch(e)}">
<vaadin-icon icon="vaadin:search" slot="prefix"></vaadin-icon>
Search
</vaadin-button>
</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 width="5rem" flex-grow="0" header="Avatar" .renderer=${(root, column, data) => {
render(html`${this.renderSearchAvatar(data.item)}`, root)
}}>
</vaadin-grid-column>
<vaadin-grid-column header="Name" .renderer=${(root, column, data) => {
render(html`${this.renderSearchName(data.item)}`, root)
}}>
</vaadin-grid-column>
<vaadin-grid-column header="Status" .renderer=${(root, column, data) => {
render(html`${this.renderSearchStatus(data.item)}`, root)
}}>
</vaadin-grid-column>
<vaadin-grid-column header="Size" .renderer=${(root, column, data) => {
render(html`${this.renderSearchSize(data.item)}`, root)
}}>
</vaadin-grid-column>
<vaadin-grid-column width="10rem" flex-grow="0" header="Action" .renderer=${(root, column, data) => {
render(html`${this.renderSearchFollowUnfollowButton(data.item)}`, root);
}}>
</vaadin-grid-column>
<vaadin-grid-column width="10rem" flex-grow="0" header="" .renderer=${(root, column, data) => {
render(html`${this.renderSearchBlockUnblockButton(data.item)}`, root);
}}>
</vaadin-grid-column>
</vaadin-grid><br />
</div>
<div class="divCard">
<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 width="5rem" flex-grow="0" header="Avatar" .renderer=${(root, column, data) => {
render(html`${this.renderAvatar(data.item)}`, root)
}}>
</vaadin-grid-column>
<vaadin-grid-column header="Name" .renderer=${(root, column, data) => {
render(html`${this.renderName(data.item)}`, root)
}}>
</vaadin-grid-column>
<vaadin-grid-column header="Status" .renderer=${(root, column, data) => {
render(html`${this.renderStatus(data.item)}`, root)
}}>
</vaadin-grid-column>
<vaadin-grid-column header="Size" .renderer=${(root, column, data) => {
render(html`${this.renderSize(data.item)}`, root)
}}>
</vaadin-grid-column>
<vaadin-grid-column width="10rem" flex-grow="0" header="Action" .renderer=${(root, column, data) => {
render(html`${this.renderFollowUnfollowButton(data.item)}`, root);
}}>
</vaadin-grid-column>
<vaadin-grid-column width="10rem" flex-grow="0" header="" .renderer=${(root, column, data) => {
render(html`${this.renderBlockUnblockButton(data.item)}`, root);
}}>
</vaadin-grid-column>
</vaadin-grid>
<div id="pages"></div>
${this.isEmptyArray(this.resources) ? html`
No websites available
`: ''}
</div>
${this.renderRelayModeText()}
</div>
<div id="tab-followed-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 followed 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;">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 width="5rem" flex-grow="0" header="Avatar" .renderer=${(root, column, data) => {
render(html`${this.renderWebAvatar(data.item)}`, root)
}}>
</vaadin-grid-column>
<vaadin-grid-column header="Name" .renderer=${(root, column, data) => {
render(html`${this.renderWebName(data.item)}`, root)
}}>
</vaadin-grid-column>
<vaadin-grid-column header="Status" .renderer=${(root, column, data) => {
render(html`${this.renderWebStatus(data.item)}`, root)
}}>
</vaadin-grid-column>
<vaadin-grid-column header="Size" .renderer=${(root, column, data) => {
render(html`${this.renderWebSize(data.item)}`, root)
}}>
</vaadin-grid-column>
<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>
`
}
@ -266,6 +375,10 @@ class Websites extends LitElement {
this.showWebsites()
setTimeout(() => {
this.displayTabContent('browse')
}, 0)
const getFollowedNames = async () => {
let followedNames = await parentEpml.request('apiCall', {
url: `/lists/followedNames?apiKey=${this.getApiKey()}`
@ -284,6 +397,42 @@ class Websites extends LitElement {
setTimeout(getBlockedNames, 60000)
}
const getWebFollowedNames = async () => {
let webFollowedNames = await parentEpml.request('apiCall', {
url: `/lists/followedNames?apiKey=${this.getApiKey()}`
})
this.webFollowedNames = webFollowedNames
setTimeout(getWebFollowedNames, 60000)
}
const getWebBlockedNames = async () => {
let webBlockedNames = await parentEpml.request('apiCall', {
url: `/lists/blockedNames?apiKey=${this.getApiKey()}`
})
this.webBlockedNames = webBlockedNames
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 () => {
let searchFollowedNames = await parentEpml.request('apiCall', {
url: `/lists/followedNames?apiKey=${this.getApiKey()}`
@ -338,12 +487,20 @@ class Websites extends LitElement {
parentEpml.subscribe('config', c => {
if (!configLoaded) {
setTimeout(this.getArbitraryResources, 1)
setTimeout(this.getFollowedWebsites, 1)
setTimeout(this.getBlockedWebsites, 1)
setTimeout(getFollowedNames, 1)
setTimeout(getBlockedNames, 1)
setTimeout(getWebFollowedNames, 1)
setTimeout(getWebBlockedNames, 1)
setTimeout(getBlockFollowedNames, 1)
setTimeout(getBlockBlockedNames, 1)
setTimeout(getSearchFollowedNames, 1)
setTimeout(getSearchBlockedNames, 1)
setTimeout(getRelayMode, 1)
setInterval(this.getArbitraryResources, 120000)
setInterval(this.getFollowedWebsites, 60000)
setInterval(this.getBlockedWebsites, 60000)
configLoaded = true
}
this.config = JSON.parse(c)
@ -357,6 +514,15 @@ class Websites extends LitElement {
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) {
if (e.key === 'Enter') {
this.doSearch(e);
@ -453,6 +619,330 @@ class Websites extends LitElement {
this.searchResult()
}
getFollowedWebsites = 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 namesUrl = `${nodeUrl}/lists/followedNames?apiKey=${this.getApiKey()}`;
const jsonUrl = `${nodeUrl}/arbitrary/resources?service=WEBSITE&default=true&limit=0&reverse=false&includestatus=true`;
const jsonRes = await fetch(jsonUrl);
const jsonData = await jsonRes.json();
const response = await fetch(namesUrl);
const names = await response.json();
let webres = jsonData.filter((elm) => names.includes(elm.name));
this.webResources = webres;
}
renderWebAvatar(webObj) {
let name = webObj.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';">`
}
renderWebName(webObj) {
let name = webObj.name
return html`<a class="visitSite" href="browser/index.html?name=${name}&service=${this.service}">${name}</a>`
}
renderWebStatus(webObj) {
return html`<span title="${webObj.status.description}">${webObj.status.title}</span>`
}
renderWebSize(webObj) {
if (webObj.size === null) {
return html``
}
let sizeWebReadable = this.bytesToSize(webObj.size);
return html`<span>${sizeWebReadable}</span>`
}
renderWebFollowUnfollowButton(webObj) {
let name = webObj.name
if (this.webFollowedNames == null || !Array.isArray(this.webFollowedNames)) {
return html``
}
if (this.webFollowedNames.indexOf(name) === -1) {
return html`<mwc-button @click=${() => this.webFollowName(webObj)}><mwc-icon>add_to_queue</mwc-icon>&nbsp;Follow</mwc-button>`
}
else {
return html`<mwc-button @click=${() => this.webUnfollowName(webObj)}><mwc-icon>remove_from_queue</mwc-icon>&nbsp;Unfollow</mwc-button>`
}
}
async webFollowName(webObj) {
let name = webObj.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.webFollowedNames = this.webFollowedNames.filter(item => item != name);
this.webFollowedNames.push(name)
}
else {
parentEpml.request('showSnackBar', 'Error occurred when trying to follow this registered name. Please try again')
}
return ret
}
async webUnfollowName(webObj) {
let name = webObj.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.webFollowedNames = this.webFollowedNames.filter(item => item != name);
}
else {
parentEpml.request('showSnackBar', 'Error occurred when trying to unfollow this registered name. Please try again')
}
return ret
}
renderWebBlockUnblockButton(webObj) {
let name = webObj.name
if (this.webBlockedNames == null || !Array.isArray(this.webBlockedNames)) {
return html``
}
if (this.webBlockedNames.indexOf(name) === -1) {
return html`<mwc-button @click=${() => this.webBlockName(webObj)}><mwc-icon>block</mwc-icon>&nbsp;Block</mwc-button>`
}
else {
return html`<mwc-button @click=${() => this.webUnblockName(webObj)}><mwc-icon>radio_button_unchecked</mwc-icon>&nbsp;Unblock</mwc-button>`
}
}
async webBlockName(webObj) {
let name = webObj.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.webBlockedNames = this.webBlockedNames.filter(item => item != name);
this.webBlockedNames.push(name)
}
else {
parentEpml.request('showSnackBar', 'Error occurred when trying to block this registered name. Please try again')
}
return ret
}
async webUnblockName(webObj) {
let name = webObj.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.webBlockedNames = this.webBlockedNames.filter(item => item != name);
}
else {
parentEpml.request('showSnackBar', 'Error occurred when trying to unblock this registered name. Please try again')
}
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>&nbsp;Follow</mwc-button>`
}
else {
return html`<mwc-button @click=${() => this.blockUnfollowName(blockObj)}><mwc-icon>remove_from_queue</mwc-icon>&nbsp;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>&nbsp;Block</mwc-button>`
}
else {
return html`<mwc-button @click=${() => this.blockUnblockName(blockObj)}><mwc-icon>radio_button_unchecked</mwc-icon>&nbsp;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() {
let searchName = this.shadowRoot.getElementById('searchName').value
if (searchName.length === 0) {

View File

@ -1,6 +1,6 @@
#!/bin/bash
# Make necessary config and add LOTW Softwares apt repo
# Make necessary config and add Qortal Softwares apt repo
# SCript to run UI without sandbox
echo \'/opt/${productFilename}/qortal-ui\' --no-sandbox > '/opt/${productFilename}/run-ui'
@ -21,7 +21,6 @@ if ! which curl; then sudo apt-get --yes install curl; fi
# Install apt repository source list if it does not exist
if ! grep ^ /etc/apt/sources.list /etc/apt/sources.list.d/* | grep qortal.list; then
curl -sS https://lotw.qortal.org/lotw_pub.gpg | sudo apt-key add -
echo "deb [arch=amd64] https://lotw.qortal.org/debian stable main" \
| sudo tee /etc/apt/sources.list.d/qortal.list
curl -sS https://update.qortal.online/repo/qortal.gpg | sudo apt-key add -
echo 'deb https://update.qortal.online/repo/ ./ ' > /etc/apt/sources.list.d/qortal.list
fi

View File

@ -4,7 +4,6 @@
# Remove apt repository source list when user uninstalls app
if grep ^ /etc/apt/sources.list /etc/apt/sources.list.d/* | grep qortal.list; then
sudo apt-key del 5025E50F;
sudo rm /etc/apt/sources.list.d/qortal.list;
fi