mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-03-30 17:25:54 +00:00
file picker logic
This commit is contained in:
parent
2443071e8e
commit
e6dfa5dc35
@ -486,7 +486,8 @@
|
|||||||
"cchange24": "Maximum Characters per message is 255",
|
"cchange24": "Maximum Characters per message is 255",
|
||||||
"cchange25": "Edit Message",
|
"cchange25": "Edit Message",
|
||||||
"cchange26": "File size exceeds 5 MB",
|
"cchange26": "File size exceeds 5 MB",
|
||||||
"cchange27": "A registered name is required to send images"
|
"cchange27": "A registered name is required to send images",
|
||||||
|
"cchange28": "This file is not an image"
|
||||||
},
|
},
|
||||||
"welcomepage": {
|
"welcomepage": {
|
||||||
"wcchange1": "Welcome to Q-Chat",
|
"wcchange1": "Welcome to Q-Chat",
|
||||||
|
@ -210,9 +210,27 @@ class ChatPage extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.send-icon:hover {
|
.send-icon:hover {
|
||||||
cursor: pointer;
|
|
||||||
filter: brightness(1.1);
|
filter: brightness(1.1);
|
||||||
}
|
}
|
||||||
|
.file-picker-container {
|
||||||
|
position: relative;
|
||||||
|
height: 25px;
|
||||||
|
width: 25px;
|
||||||
|
}
|
||||||
|
.file-picker-input-container {
|
||||||
|
position: absolute;
|
||||||
|
top: 0px;
|
||||||
|
bottom: 0px;
|
||||||
|
left: 0px;
|
||||||
|
right: 0px;
|
||||||
|
z-index: 10;
|
||||||
|
opacity: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=file]::-webkit-file-upload-button {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
@ -256,11 +274,12 @@ class ChatPage extends LitElement {
|
|||||||
<div class="chat-container">
|
<div class="chat-container">
|
||||||
<div>
|
<div>
|
||||||
${this.isLoadingMessages ? html`<h1>${translate("chatpage.cchange22")}</h1>` : this.renderChatScroller(this._initialMessages)}
|
${this.isLoadingMessages ? html`<h1>${translate("chatpage.cchange22")}</h1>` : this.renderChatScroller(this._initialMessages)}
|
||||||
<mwc-dialog id="showDialogPublicKey" ?open=${this.imageFile}>
|
<mwc-dialog id="showDialogPublicKey" ?open=${this.imageFile} @closed=${()=> {
|
||||||
|
this.imageFile = null
|
||||||
|
}}>
|
||||||
<div class="dialog-header">
|
<div class="dialog-header">
|
||||||
</div>
|
</div>
|
||||||
<div class="dialog-container">
|
<div class="dialog-container">
|
||||||
hello
|
|
||||||
${this.imageFile && html`
|
${this.imageFile && html`
|
||||||
<img src=${URL.createObjectURL(this.imageFile)} />
|
<img src=${URL.createObjectURL(this.imageFile)} />
|
||||||
`}
|
`}
|
||||||
@ -330,12 +349,23 @@ class ChatPage extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
`}
|
`}
|
||||||
<div class="chatbar">
|
<div class="chatbar">
|
||||||
|
<div class="file-picker-container">
|
||||||
<vaadin-icon
|
<vaadin-icon
|
||||||
class="paperclip-icon"
|
class="paperclip-icon"
|
||||||
icon="vaadin:paperclip"
|
icon="vaadin:paperclip"
|
||||||
slot="icon"
|
slot="icon"
|
||||||
@click=${() => this.closeEditMessageContainer()}
|
@click=${() => this.closeEditMessageContainer()}
|
||||||
></vaadin-icon>
|
>
|
||||||
|
</vaadin-icon>
|
||||||
|
<div class="file-picker-input-container">
|
||||||
|
<input
|
||||||
|
.value="${this.imageFile}"
|
||||||
|
@change="${e => this.insertImage(e.target.files[0])}"
|
||||||
|
class="file-picker-input" type="file" name="myImage" accept="image/*" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<textarea style="color: var(--black);" tabindex='1' ?autofocus=${true} ?disabled=${this.isLoading || this.isLoadingMessages} id="messageBox" rows="1"></textarea>
|
<textarea style="color: var(--black);" tabindex='1' ?autofocus=${true} ?disabled=${this.isLoading || this.isLoadingMessages} id="messageBox" rows="1"></textarea>
|
||||||
<iframe style="${`height: ${this.iframeHeight}px`}" class="chat-editor" id="_chatEditorDOM" tabindex="-1" height=${this.iframeHeight}>
|
<iframe style="${`height: ${this.iframeHeight}px`}" class="chat-editor" id="_chatEditorDOM" tabindex="-1" height=${this.iframeHeight}>
|
||||||
</iframe>
|
</iframe>
|
||||||
@ -376,8 +406,14 @@ class ChatPage extends LitElement {
|
|||||||
|
|
||||||
|
|
||||||
insertImage(file){
|
insertImage(file){
|
||||||
|
|
||||||
|
if(file.type.includes('image')){
|
||||||
this.imageFile = file
|
this.imageFile = file
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
parentEpml.request('showSnackBar', get("chatpage.cchange28"))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,5 +371,6 @@ export const chatStyles = css`
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
height: 80vh;
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
@ -256,7 +256,6 @@ class MessageTemplate extends LitElement {
|
|||||||
imageHTMLRes.onclick= ()=> {
|
imageHTMLRes.onclick= ()=> {
|
||||||
this.openDialogImage = true
|
this.openDialogImage = true
|
||||||
}
|
}
|
||||||
let p = 0
|
|
||||||
imageHTMLRes.onerror = ()=> {
|
imageHTMLRes.onerror = ()=> {
|
||||||
|
|
||||||
console.log('inputRef', this.imageFetches)
|
console.log('inputRef', this.imageFetches)
|
||||||
@ -270,8 +269,10 @@ class MessageTemplate extends LitElement {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
imageHTMLRes.src = '/img/chain.png'
|
imageHTMLRes.src = '/img/chain.png'
|
||||||
imageHTMLRes.style= "max-width:45vh; max-height:40vh; border-radius: 5px; filter: opacity(0.5)"
|
imageHTMLRes.style= "max-width:45vh; max-height:20vh; border-radius: 5px; filter: opacity(0.5)";
|
||||||
;
|
imageHTMLRes.onclick= ()=> {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -287,10 +288,11 @@ class MessageTemplate extends LitElement {
|
|||||||
imageUrl = `${nodeUrl}/arbitrary/${image.service}/${image.name}/${image.identifier}?async=true&apiKey=${myNode.apiKey}`
|
imageUrl = `${nodeUrl}/arbitrary/${image.service}/${image.name}/${image.identifier}?async=true&apiKey=${myNode.apiKey}`
|
||||||
imageHTML = createImage(imageUrl)
|
imageHTML = createImage(imageUrl)
|
||||||
imageHTMLDialog = createImage(imageUrl)
|
imageHTMLDialog = createImage(imageUrl)
|
||||||
imageHTMLDialog.style= "height: 80vh ; width: auto; max-width: 80vw; object-fit: contain; border-radius: 5px"
|
imageHTMLDialog.style= "height: auto; max-height: 80vh; width: auto; max-width: 80vw; object-fit: contain; border-radius: 5px"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (this.messageObj.sender === this.myAddress) {
|
if (this.messageObj.sender === this.myAddress) {
|
||||||
nameMenu = html`<span style="color: #03a9f4;">${this.messageObj.senderName ? this.messageObj.senderName : this.messageObj.sender}</span>`
|
nameMenu = html`<span style="color: #03a9f4;">${this.messageObj.senderName ? this.messageObj.senderName : this.messageObj.sender}</span>`
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user