| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  | {{define "qrcodeModal"}} | 
					
						
							|  |  |  | <a-modal id="qrcode-modal" v-model="qrModal.visible" :title="qrModal.title" | 
					
						
							| 
									
										
										
										
											2023-03-24 13:17:14 +00:00
										 |  |  |          :closable="true" | 
					
						
							| 
									
										
										
										
											2023-05-08 14:44:22 +00:00
										 |  |  |          :class="themeSwitcher.darkCardClass" | 
					
						
							| 
									
										
										
										
											2023-03-24 13:17:14 +00:00
										 |  |  |          :footer="null" | 
					
						
							|  |  |  |          width="300px"> | 
					
						
							| 
									
										
										
										
											2023-05-08 14:44:22 +00:00
										 |  |  |     <a-tag color="green" style="margin-bottom: 10px;display: block;text-align: center;"> | 
					
						
							|  |  |  |         {{ i18n "pages.inbounds.clickOnQRcode" }} | 
					
						
							|  |  |  |     </a-tag> | 
					
						
							| 
									
										
										
										
											2023-05-22 14:01:41 +00:00
										 |  |  |     <template v-if="app.subSettings.enable && qrModal.subId"> | 
					
						
							|  |  |  |         <a-divider>Subscription</a-divider> | 
					
						
							|  |  |  |         <canvas @click="copyToClipboard('qrCode-sub',genSubLink(qrModal.client.subId))" id="qrCode-sub" style="width: 100%; height: 100%;"></canvas> | 
					
						
							|  |  |  |     </template> | 
					
						
							|  |  |  |     <a-divider>{{ i18n "pages.inbounds.client" }}</a-divider> | 
					
						
							|  |  |  |     <template v-for="(row, index) in qrModal.qrcodes"> | 
					
						
							|  |  |  |         <a-tag color="orange" style="margin-top: 10px;display: block;text-align: center;">[[ row.remark ]]</a-tag> | 
					
						
							|  |  |  |         <canvas @click="copyToClipboard('qrCode-'+index, row.link)" :id="'qrCode-'+index" style="width: 100%; height: 100%;"></canvas> | 
					
						
							|  |  |  |     </template> | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  | </a-modal> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <script> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const qrModal = { | 
					
						
							|  |  |  |         title: '', | 
					
						
							| 
									
										
										
										
											2023-05-22 14:01:41 +00:00
										 |  |  |         clientIndex: 0, | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |         inbound: new Inbound(), | 
					
						
							|  |  |  |         dbInbound: new DBInbound(), | 
					
						
							| 
									
										
										
										
											2023-05-22 14:01:41 +00:00
										 |  |  |         client: null, | 
					
						
							|  |  |  |         qrcodes: [], | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |         clipboard: null, | 
					
						
							|  |  |  |         visible: false, | 
					
						
							| 
									
										
										
										
											2023-05-22 14:01:41 +00:00
										 |  |  |         subId: '', | 
					
						
							|  |  |  |         show: function (title = '', dbInbound = new DBInbound(), clientIndex = 0) { | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |             this.title = title; | 
					
						
							| 
									
										
										
										
											2023-05-22 14:01:41 +00:00
										 |  |  |             this.clientIndex = clientIndex; | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |             this.dbInbound = dbInbound; | 
					
						
							|  |  |  |             this.inbound = dbInbound.toInbound(); | 
					
						
							| 
									
										
										
										
											2023-05-22 14:01:41 +00:00
										 |  |  |             settings = JSON.parse(this.inbound.settings); | 
					
						
							|  |  |  |             this.client = settings.clients[clientIndex]; | 
					
						
							|  |  |  |             remark = this.dbInbound.remark + "-" + this.client.email; | 
					
						
							|  |  |  |             address = this.dbInbound.address; | 
					
						
							| 
									
										
										
										
											2023-05-22 23:45:34 +00:00
										 |  |  |             this.subId = ''; | 
					
						
							| 
									
										
										
										
											2023-05-22 14:01:41 +00:00
										 |  |  |             this.qrcodes = []; | 
					
						
							|  |  |  |             if (this.inbound.tls && !ObjectUtil.isArrEmpty(this.inbound.stream.tls.settings.domains)) { | 
					
						
							|  |  |  |                 this.inbound.stream.tls.settings.domains.forEach((domain) => { | 
					
						
							|  |  |  |                     this.qrcodes.push({ | 
					
						
							|  |  |  |                         remark: remark + "-" + domain.remark, | 
					
						
							|  |  |  |                         link: this.inbound.genLink(domain.domain, remark + "-" + domain.remark, clientIndex) | 
					
						
							|  |  |  |                     }); | 
					
						
							|  |  |  |                 }); | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2023-05-22 14:01:41 +00:00
										 |  |  |                 this.qrcodes.push({ | 
					
						
							|  |  |  |                     remark: remark, | 
					
						
							|  |  |  |                     link: this.inbound.genLink(address, remark, clientIndex) | 
					
						
							|  |  |  |                 }); | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |             this.visible = true; | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         close: function () { | 
					
						
							|  |  |  |             this.visible = false; | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const qrModalApp = new Vue({ | 
					
						
							| 
									
										
										
										
											2023-05-12 17:23:05 +00:00
										 |  |  |         delimiters: ['[[', ']]'], | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |         el: '#qrcode-modal', | 
					
						
							|  |  |  |         data: { | 
					
						
							|  |  |  |             qrModal: qrModal, | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2023-03-17 16:07:49 +00:00
										 |  |  |         methods: { | 
					
						
							| 
									
										
										
										
											2023-05-22 14:01:41 +00:00
										 |  |  |             copyToClipboard(elmentId,content) { | 
					
						
							|  |  |  |                 this.qrModal.clipboard = new ClipboardJS('#'+elmentId, { | 
					
						
							|  |  |  |                     text: () => content, | 
					
						
							| 
									
										
										
										
											2023-03-17 16:07:49 +00:00
										 |  |  |                 }); | 
					
						
							|  |  |  |                 this.qrModal.clipboard.on('success', () => { | 
					
						
							|  |  |  |                     app.$message.success('{{ i18n "copied" }}') | 
					
						
							|  |  |  |                     this.qrModal.clipboard.destroy(); | 
					
						
							|  |  |  |                 }); | 
					
						
							| 
									
										
										
										
											2023-05-22 14:01:41 +00:00
										 |  |  |             }, | 
					
						
							|  |  |  |             setQrCode(elmentId,content) { | 
					
						
							|  |  |  |                 new QRious({ | 
					
						
							|  |  |  |                         element: document.querySelector('#'+elmentId), | 
					
						
							|  |  |  |                         size: 260, | 
					
						
							|  |  |  |                         value: content, | 
					
						
							|  |  |  |                     }); | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             genSubLink(subID) { | 
					
						
							|  |  |  |                 protocol = app.subSettings.tls ? "https://" : "http://"; | 
					
						
							|  |  |  |                 hostName = app.subSettings.domain === "" ? window.location.hostname : app.subSettings.domain; | 
					
						
							|  |  |  |                 subPort = app.subSettings.port; | 
					
						
							|  |  |  |                 port = (subPort === 443 && app.subSettings.tls) || (subPort === 80 && !app.subSettings.tls) ? "" : ":" + String(subPort); | 
					
						
							|  |  |  |                 subPath = app.subSettings.path; | 
					
						
							|  |  |  |                 return protocol + hostName + port + subPath + subID; | 
					
						
							| 
									
										
										
										
											2023-03-17 16:07:49 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2023-05-22 14:01:41 +00:00
										 |  |  |         updated() { | 
					
						
							|  |  |  |             if (qrModal.client.subId){ | 
					
						
							|  |  |  |                 qrModal.subId = qrModal.client.subId; | 
					
						
							| 
									
										
										
										
											2023-05-23 14:25:42 +00:00
										 |  |  |                 this.setQrCode("qrCode-sub",this.genSubLink(qrModal.subId)); | 
					
						
							| 
									
										
										
										
											2023-05-22 14:01:41 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |             qrModal.qrcodes.forEach((element,index) => { | 
					
						
							|  |  |  |                 this.setQrCode("qrCode-"+index, element.link);      | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | </script> | 
					
						
							|  |  |  | {{end}} |