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

Merge pull request #184 from Qortal/qortal-ui-dev

Qortal UI dev
This commit is contained in:
AlphaX-Projects 2023-08-02 10:44:51 +02:00 committed by GitHub
commit fc6a9f2d69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 181 additions and 38 deletions

View File

@ -79,7 +79,11 @@
"tm34": "Export Tab Menu", "tm34": "Export Tab Menu",
"tm35": "Your existing tab menu will be deleted and set to uploaded tab menu.", "tm35": "Your existing tab menu will be deleted and set to uploaded tab menu.",
"tm36": "Tab Menu Successfully Restored", "tm36": "Tab Menu Successfully Restored",
"tm37": "Tab Menu Successfully Saved As" "tm37": "Tab Menu Successfully Saved As",
"tm38": "DEV MODE",
"tm39": "Add Custom Framework",
"tm40": "Add And Open",
"tm41": "Error: Invalid data please try again !"
}, },
"login": { "login": {
"login": "Log In", "login": "Log In",

View File

@ -45,7 +45,8 @@ class ShowPlugin extends connect(store)(LitElement) {
theme: { type: String, reflect: true }, theme: { type: String, reflect: true },
tabInfo: { type: Object }, tabInfo: { type: Object },
chatLastSeen: { type: Array }, chatLastSeen: { type: Array },
chatHeads: { type: Array } chatHeads: { type: Array },
proxyPort: { type: Number }
} }
} }
@ -63,6 +64,23 @@ class ShowPlugin extends connect(store)(LitElement) {
* { * {
scrollbar-width: thin; scrollbar-width: thin;
scrollbar-color: var(--thumbBG) var(--scrollbarBG); scrollbar-color: var(--thumbBG) var(--scrollbarBG);
--mdc-theme-primary: rgb(3, 169, 244);
--mdc-theme-surface: var(--white);
--mdc-text-field-outlined-idle-border-color: var(--txtfieldborder);
--mdc-text-field-outlined-hover-border-color: var(--txtfieldhoverborder);
--mdc-text-field-label-ink-color: var(--black);
--mdc-text-field-ink-color: var(--black);
--mdc-select-ink-color: var(--black);
--mdc-select-fill-color: var(--black);
--mdc-select-label-ink-color: var(--black);
--mdc-select-idle-line-color: var(--black);
--mdc-select-hover-line-color: var(--black);
--mdc-select-outlined-idle-border-color: var(--txtfieldborder);
--mdc-select-outlined-hover-border-color: var(--txtfieldhoverborder);
--mdc-dialog-content-ink-color: var(--black);
--mdc-dialog-shape-radius: 25px;
--mdc-dialog-min-width: 400px;
--mdc-dialog-max-width: 700px;
} }
*::-webkit-scrollbar-track { *::-webkit-scrollbar-track {
@ -206,6 +224,30 @@ class ShowPlugin extends connect(store)(LitElement) {
color: var(--black); color: var(--black);
} }
.add-dev-button {
position: fixed;
right: 20px;
margin-left: 10px;
margin-top: 4px;
max-height: 28px;
padding: 5px 5px;
font-size: 14px;
background-color: #03a9f4;
color: white;
border: 1px solid transparent;
border-radius: 3px;
cursor: pointer;
}
.add-dev-button:hover {
opacity: 0.8;
cursor: pointer;
}
.red {
--mdc-theme-primary: #F44336;
}
.iconActive { .iconActive {
position: absolute; position: absolute;
top: 5px; top: 5px;
@ -291,6 +333,7 @@ class ShowPlugin extends connect(store)(LitElement) {
this.tabInfo = {} this.tabInfo = {}
this.chatLastSeen = [] this.chatLastSeen = []
this.chatHeads = [] this.chatHeads = []
this.proxyPort = 0
} }
render() { render() {
@ -341,6 +384,8 @@ class ShowPlugin extends connect(store)(LitElement) {
title = html`${translate('tabmenu.tm16')}` title = html`${translate('tabmenu.tm16')}`
} else if (tab.myPlugObj && tab.myPlugObj.url === "myapp") { } else if (tab.myPlugObj && tab.myPlugObj.url === "myapp") {
title = tab.myPlugObj && tab.myPlugObj.title title = tab.myPlugObj && tab.myPlugObj.title
} else if (tab.myPlugObj && tab.myPlugObj.url === "devmode") {
title = html`${translate('tabmenu.tm38')}`
} else { } else {
title = html`${translate('tabmenu.tm17')}` title = html`${translate('tabmenu.tm17')}`
} }
@ -413,6 +458,11 @@ class ShowPlugin extends connect(store)(LitElement) {
this.currentTab = lengthOfTabs this.currentTab = lengthOfTabs
}} }}
>+</button> >+</button>
<button
class="add-dev-button"
title="${translate('tabmenu.tm18')}"
@click=${this.openDevDialog}
>${translate('tabmenu.tm38')}</button>
</div> </div>
${repeat(this.tabs, (tab) => tab.id, (tab, index) => html` ${repeat(this.tabs, (tab) => tab.id, (tab, index) => html`
@ -433,7 +483,32 @@ class ShowPlugin extends connect(store)(LitElement) {
> >
</nav-bar> </nav-bar>
</div> </div>
`)} `)}
<mwc-dialog id="addDevDialog">
<div style="text-align: center;">
<h2>${translate('tabmenu.tm39')}</h2>
<hr>
</div>
<p>
<mwc-textfield id="domainInput" style="width:100%; color: var(--black);" required outlined label="${translate("settings.domain")}"></mwc-textfield>
</p>
<p>
<mwc-textfield id="portInput" style="width:100%; color: var(--black);" required outlined label="${translate("settings.port")}"></mwc-textfield>
</p>
<mwc-button
slot="secondaryAction"
dialogAction="close"
class="red"
>
${translate("general.close")}
</mwc-button>
<mwc-button
slot="primaryAction"
@click="${this.getProxyPort}"
>
${translate('tabmenu.tm40')}
</mwc-button>
</mwc-dialog>
` `
} }
@ -476,6 +551,58 @@ class ShowPlugin extends connect(store)(LitElement) {
return true return true
} }
openDevDialog() {
this.shadowRoot.getElementById('domainInput').value = ''
this.shadowRoot.getElementById('portInput').value = ''
this.shadowRoot.querySelector("#addDevDialog").show()
}
async getProxyPort() {
this.proxyPort = 0
let framework = ''
const domain = this.shadowRoot.getElementById('domainInput').value
const port = this.shadowRoot.getElementById('portInput').value
if (domain.length >= 3 && port.length >= 2) {
framework = domain + ':' + port
} else {
let errorString = get("tabmenu.tm41")
parentEpml.request('showSnackBar', `${errorString}`)
return
}
let framePort = await parentEpml.request('apiCall', {
url: `/developer/proxy/start`,
method: 'POST',
headers: {
'Content-Type': 'text/plain'
},
body: `${framework}`
})
this.createUrl(framePort)
}
createUrl(framePort) {
this.proxyPort = framePort
const myFrameNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
const myFrameNodeUrl = myFrameNode.protocol + '://' + myFrameNode.domain + ':' + this.proxyPort
this.changePage({
"url": "devmode",
"domain": "core",
"page": `qdn/browser/index.html?link=${myFrameNodeUrl}&dev=FRAMEWORK`,
"title": "Dev Server",
"icon": "vaadin:desktop",
"mwcicon": "api",
"menus": [],
"parent": false
})
this.shadowRoot.querySelector("#addDevDialog").close()
}
async addTab(tab) { async addTab(tab) {
if (this.tabs == []) { if (this.tabs == []) {
// ...Nothing to do // ...Nothing to do

View File

@ -34,6 +34,8 @@ class WebBrowser extends LitElement {
identifier: { type: String }, identifier: { type: String },
path: { type: String }, path: { type: String },
preview: { type: String }, preview: { type: String },
dev: { type: String },
link: { type: String },
displayUrl: { type: String }, displayUrl: { type: String },
followedNames: { type: Array }, followedNames: { type: Array },
blockedNames: { type: Array }, blockedNames: { type: Array },
@ -129,11 +131,11 @@ class WebBrowser extends LitElement {
constructor() { constructor() {
super(); super();
this.url = 'about:blank'; this.url = 'about:blank';
this.myAddress = window.parent.reduxStore.getState().app.selectedAddress; this.myAddress = window.parent.reduxStore.getState().app.selectedAddress
this._publicKey = { key: '', hasPubKey: false }; this._publicKey = { key: '', hasPubKey: false }
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search)
this.name = urlParams.get('name'); this.name = urlParams.get('name')
this.service = urlParams.get('service'); this.service = urlParams.get('service')
this.identifier = this.identifier =
urlParams.get('identifier') != null urlParams.get('identifier') != null
? urlParams.get('identifier') ? urlParams.get('identifier')
@ -144,44 +146,53 @@ class WebBrowser extends LitElement {
urlParams.get('path') urlParams.get('path')
: ''; : '';
this.preview = urlParams.get('preview'); this.preview = urlParams.get('preview');
this.followedNames = []; this.link = urlParams.get('link')
this.blockedNames = []; this.dev = urlParams.get('dev')
this.followedNames = []
this.blockedNames = []
this.theme = localStorage.getItem('qortalTheme') ? localStorage.getItem('qortalTheme') : 'light' this.theme = localStorage.getItem('qortalTheme') ? localStorage.getItem('qortalTheme') : 'light'
this.loader = new Loader(); this.loader = new Loader()
// Build initial display URL // Build initial display URL
let displayUrl = 'qortal://' + this.service + '/' + this.name; let displayUrl = ''
if (
this.identifier && this.identifier != 'null' && if (this.dev === 'FRAMEWORK') {
this.identifier != 'default' displayUrl = 'qortal://app/development'
) { } else {
displayUrl = displayUrl.concat('/' + this.identifier); displayUrl = 'qortal://' + this.service + '/' + this.name
if (this.identifier && this.identifier != 'null' && this.identifier != 'default') {
displayUrl = displayUrl.concat('/' + this.identifier)
}
if (this.path != null && this.path != '/') {
displayUrl = displayUrl.concat(this.path)
}
} }
if (this.path != null && this.path != '/')
displayUrl = displayUrl.concat(this.path); this.displayUrl = displayUrl
this.displayUrl = displayUrl;
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()}`,
}); })
this.followedNames = followedNames; this.followedNames = followedNames
setTimeout( setTimeout(
getFollowedNames, getFollowedNames,
this.config.user.nodeSettings.pingInterval this.config.user.nodeSettings.pingInterval
); )
}; }
const getBlockedNames = async () => { const getBlockedNames = async () => {
let blockedNames = await parentEpml.request('apiCall', { let blockedNames = await parentEpml.request('apiCall', {
url: `/lists/blockedNames?apiKey=${this.getApiKey()}`, url: `/lists/blockedNames?apiKey=${this.getApiKey()}`,
}); })
this.blockedNames = blockedNames; this.blockedNames = blockedNames;
setTimeout( setTimeout(
getBlockedNames, getBlockedNames,
this.config.user.nodeSettings.pingInterval this.config.user.nodeSettings.pingInterval
); )
}; }
const render = () => { const render = () => {
const myNode = const myNode =
@ -194,8 +205,9 @@ class WebBrowser extends LitElement {
if (this.preview != null && this.preview.length > 0) { if (this.preview != null && this.preview.length > 0) {
// In preview mode we access the preview URL path directly // In preview mode we access the preview URL path directly
this.url = `${nodeUrl}${this.preview}&theme=${this.theme}` this.url = `${nodeUrl}${this.preview}&theme=${this.theme}`
} } else if (this.dev === 'FRAMEWORK') {
else { this.url = `${this.link}`
} else {
// Normal mode // Normal mode
this.url = `${nodeUrl}/render/${this.service}/${this.name}${this.path != null ? this.path : '' this.url = `${nodeUrl}/render/${this.service}/${this.name}${this.path != null ? this.path : ''
@ -2757,15 +2769,15 @@ class WebBrowser extends LitElement {
} }
refresh() { refresh() {
const myNode = const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
window.parent.reduxStore.getState().app.nodeConfig.knownNodes[ const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port
window.parent.reduxStore.getState().app.nodeConfig.node if (this.dev === 'FRAMEWORK') {
]; this.url = `${this.link}?time=${new Date().getMilliseconds()}`
const nodeUrl = } else {
myNode.protocol + '://' + myNode.domain + ':' + myNode.port; this.url = `${nodeUrl}/render/${this.service}/${this.name}${this.path != null ? this.path : ''
this.url = `${nodeUrl}/render/${this.service}/${this.name}${this.path != null ? this.path : '' }?theme=${this.theme}&identifier=${this.identifier != null ? this.identifier : ''
}?theme=${this.theme}&identifier=${this.identifier != null ? this.identifier : '' }&time=${new Date().getMilliseconds()}`
}&time=${new Date().getMilliseconds()}`; }
} }
goBackToList() { goBackToList() {