From 35feef650f793ffbec2af51a18fd25d8b0beefb1 Mon Sep 17 00:00:00 2001 From: Alireza Ahmadi Date: Fri, 8 Dec 2023 20:08:44 +0100 Subject: import-export inbound #1300 --- web/html/common/prompt_modal.html | 1 - web/html/common/text_modal.html | 5 ++++- web/html/xui/inbounds.html | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) (limited to 'web/html') diff --git a/web/html/common/prompt_modal.html b/web/html/common/prompt_modal.html index a61b4454..edfad682 100644 --- a/web/html/common/prompt_modal.html +++ b/web/html/common/prompt_modal.html @@ -1,7 +1,6 @@ {{define "promptModal"}} this.content, }); - this.clipboard.on('success', () => app.$message.success('{{ i18n "copied" }}')); + this.clipboard.on('success', () => { + app.$message.success('{{ i18n "copied" }}') + this.close(); + }); } }); }, diff --git a/web/html/xui/inbounds.html b/web/html/xui/inbounds.html index 13808ac9..31595f00 100644 --- a/web/html/xui/inbounds.html +++ b/web/html/xui/inbounds.html @@ -121,6 +121,10 @@ + + + {{ i18n "pages.inbounds.importInbound" }} + {{ i18n "pages.inbounds.export" }} @@ -221,6 +225,10 @@ {{ i18n "info"}} + + + {{ i18n "pages.inbounds.copyToClipboard" }} + {{ i18n "pages.inbounds.resetTraffic" }} @@ -708,6 +716,9 @@ }, generalActions(action) { switch (action.key) { + case "import": + this.importInbound(); + break; case "export": this.exportAllLinks(); break; @@ -742,6 +753,9 @@ case "export": this.inboundLinks(dbInbound.id); break; + case "clipboard": + this.copyToClipboard(dbInbound.id); + break; case "resetTraffic": this.resetTraffic(dbInbound.id); break; @@ -1162,6 +1176,18 @@ newDbInbound = this.checkFallback(dbInbound); txtModal.show('{{ i18n "pages.inbounds.export"}}', newDbInbound.genInboundLinks, newDbInbound.remark); }, + importInbound() { + promptModal.open({ + title: '{{ i18n "pages.inbounds.importInbound" }}', + type: 'textarea', + value: '', + okText: '{{ i18n "pages.inbounds.import" }}', + confirm: async (dbInboundText) => { + await this.submit('/panel/inbound/import', {data: dbInboundText}, promptModal); + promptModal.close(); + }, + }); + }, exportAllLinks() { let copyText = []; for (const dbInbound of this.dbInbounds) { @@ -1169,6 +1195,10 @@ } txtModal.show('{{ i18n "pages.inbounds.export"}}', copyText.join('\r\n'), 'All-Inbounds'); }, + copyToClipboard(dbInboundId) { + dbInbound = this.dbInbounds.find(row => row.id === dbInboundId); + txtModal.show('{{ i18n "pages.inbounds.inboundData" }}', JSON.stringify(dbInbound, null, 2)); + }, async startDataRefreshLoop() { while (this.isRefreshEnabled) { try { -- cgit v1.2.3