Skip to content

Commit

Permalink
allow exporting and importing all data (#740)
Browse files Browse the repository at this point in the history
  • Loading branch information
josStorer committed Aug 5, 2024
1 parent 58090d4 commit c496f87
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 12 deletions.
4 changes: 3 additions & 1 deletion src/_locales/de/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,7 @@
"Explain this: {{selection}}": "Erkläre das: {{selection}}",
"New": "Neu",
"Always display floating window, disable sidebar for all site adapters": "Immer das schwebende Fenster anzeigen, die Seitenleiste für alle Website-Adapter deaktivieren",
"Allow ESC to close all floating windows": "ESC-Taste zum Schließen aller schwebenden Fenster zulassen"
"Allow ESC to close all floating windows": "ESC-Taste zum Schließen aller schwebenden Fenster zulassen",
"Export All Data": "Alle Daten exportieren",
"Import All Data": "Alle Daten importieren"
}
4 changes: 3 additions & 1 deletion src/_locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,7 @@
"Explain this: {{selection}}": "Explain this: {{selection}}",
"New": "New",
"Always display floating window, disable sidebar for all site adapters": "Always display floating window, disable sidebar for all site adapters",
"Allow ESC to close all floating windows": "Allow ESC to close all floating windows"
"Allow ESC to close all floating windows": "Allow ESC to close all floating windows",
"Export All Data": "Export All Data",
"Import All Data": "Import All Data"
}
4 changes: 3 additions & 1 deletion src/_locales/es/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,7 @@
"Explain this: {{selection}}": "Explicar esto: {{selection}}",
"New": "Nuevo",
"Always display floating window, disable sidebar for all site adapters": "Mostrar siempre la ventana flotante, desactivar la barra lateral para todos los adaptadores de sitios",
"Allow ESC to close all floating windows": "Permitir que ESC cierre todas las ventanas flotantes"
"Allow ESC to close all floating windows": "Permitir que ESC cierre todas las ventanas flotantes",
"Export All Data": "Exportar todos los datos",
"Import All Data": "Importar todos los datos"
}
4 changes: 3 additions & 1 deletion src/_locales/fr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,7 @@
"Explain this: {{selection}}": "Expliquer ceci : {{selection}}",
"New": "Nouveau",
"Always display floating window, disable sidebar for all site adapters": "Toujours afficher la fenêtre flottante, désactiver la barre latérale pour tous les adaptateurs de site",
"Allow ESC to close all floating windows": "Autoriser la touche ESC pour fermer toutes les fenêtres flottantes"
"Allow ESC to close all floating windows": "Autoriser la touche ESC pour fermer toutes les fenêtres flottantes",
"Export All Data": "Exporter toutes les données",
"Import All Data": "Importer toutes les données"
}
4 changes: 3 additions & 1 deletion src/_locales/in/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,7 @@
"Explain this: {{selection}}": "Jelaskan ini: {{selection}}",
"New": "Baru",
"Always display floating window, disable sidebar for all site adapters": "Selalu tampilkan jendela mengambang, nonaktifkan sidebar untuk semua adapter situs",
"Allow ESC to close all floating windows": "Izinkan ESC untuk menutup semua jendela mengambang"
"Allow ESC to close all floating windows": "Izinkan ESC untuk menutup semua jendela mengambang",
"Export All Data": "Ekspor Semua Data",
"Import All Data": "Impor Semua Data"
}
4 changes: 3 additions & 1 deletion src/_locales/it/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,7 @@
"Explain this: {{selection}}": "Spiega questo: {{selection}}",
"New": "Nuovo",
"Always display floating window, disable sidebar for all site adapters": "Mostra sempre la finestra flottante, disabilita la barra laterale per tutti gli adattatori del sito",
"Allow ESC to close all floating windows": "Consenti ESC per chiudere tutte le finestre flottanti"
"Allow ESC to close all floating windows": "Consenti ESC per chiudere tutte le finestre flottanti",
"Export All Data": "Esporta tutti i dati",
"Import All Data": "Importa tutti i dati"
}
4 changes: 3 additions & 1 deletion src/_locales/ja/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,7 @@
"Explain this: {{selection}}": "これを説明する: {{selection}}",
"New": "新規",
"Always display floating window, disable sidebar for all site adapters": "常にフローティングウィンドウを表示し、すべてのサイトアダプターでサイドバーを無効にします",
"Allow ESC to close all floating windows": "ESCキーですべてのフローティングウィンドウを閉じる"
"Allow ESC to close all floating windows": "ESCキーですべてのフローティングウィンドウを閉じる",
"Export All Data": "すべてのデータをエクスポート",
"Import All Data": "すべてのデータをインポート"
}
4 changes: 3 additions & 1 deletion src/_locales/ko/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,7 @@
"Explain this: {{selection}}": "이것을 설명하세요: {{selection}}",
"New": "새로 만들기",
"Always display floating window, disable sidebar for all site adapters": "항상 떠다니는 창을 표시하고 모든 사이트 어댑터의 사이드바를 비활성화합니다",
"Allow ESC to close all floating windows": "ESC를 눌러 모든 떠다니는 창을 닫도록 허용"
"Allow ESC to close all floating windows": "ESC를 눌러 모든 떠다니는 창을 닫도록 허용",
"Export All Data": "모든 데이터 내보내기",
"Import All Data": "모든 데이터 가져오기"
}
4 changes: 3 additions & 1 deletion src/_locales/pt/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,7 @@
"Explain this: {{selection}}": "Explique isso: {{selection}}",
"New": "Novo",
"Always display floating window, disable sidebar for all site adapters": "Sempre exibir janela flutuante, desativar barra lateral para todos os adaptadores de site",
"Allow ESC to close all floating windows": "Permitir ESC para fechar todas as janelas flutuantes"
"Allow ESC to close all floating windows": "Permitir ESC para fechar todas as janelas flutuantes",
"Export All Data": "Exportar Todos os Dados",
"Import All Data": "Importar Todos os Dados"
}
4 changes: 3 additions & 1 deletion src/_locales/ru/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,7 @@
"Explain this: {{selection}}": "Объяснить это: {{selection}}",
"New": "Новый",
"Always display floating window, disable sidebar for all site adapters": "Всегда отображать плавающее окно, отключить боковую панель для всех адаптеров сайтов",
"Allow ESC to close all floating windows": "Разрешить ESC для закрытия всех плавающих окон"
"Allow ESC to close all floating windows": "Разрешить ESC для закрытия всех плавающих окон",
"Export All Data": "Экспорт всех данных",
"Import All Data": "Импорт всех данных"
}
4 changes: 3 additions & 1 deletion src/_locales/tr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,7 @@
"Explain this: {{selection}}": "Bunu açıkla: {{selection}}",
"New": "Yeni",
"Always display floating window, disable sidebar for all site adapters": "Her zaman kayan pencereyi görüntüle, tüm site adaptörleri için kenar çubuğunu devre dışı bırak",
"Allow ESC to close all floating windows": "ESC tuşuyla tüm kayan pencereleri kapatmaya izin ver"
"Allow ESC to close all floating windows": "ESC tuşuyla tüm kayan pencereleri kapatmaya izin ver",
"Export All Data": "Tüm Verileri Dışa Aktar",
"Import All Data": "Tüm Verileri İçe Aktar"
}
2 changes: 2 additions & 0 deletions src/_locales/zh-hans/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@
"New": "新建",
"Always display floating window, disable sidebar for all site adapters": "总是显示浮动窗口, 禁用所有站点适配器的侧边栏",
"Allow ESC to close all floating windows": "允许按ESC关闭所有浮动窗口",
"Export All Data": "导出所有数据",
"Import All Data": "导入所有数据",
"Temperature": "温度",
"keep-alive Time": "保活时间",
"5m": "5分钟",
Expand Down
4 changes: 3 additions & 1 deletion src/_locales/zh-hant/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,7 @@
"Explain this: {{selection}}": "解釋這個: {{selection}}",
"New": "新增",
"Always display floating window, disable sidebar for all site adapters": "總是顯示浮動視窗,停用所有網站適配器的側邊欄",
"Allow ESC to close all floating windows": "允許按 ESC 關閉所有浮動視窗"
"Allow ESC to close all floating windows": "允許按 ESC 關閉所有浮動視窗",
"Export All Data": "匯出所有資料",
"Import All Data": "匯入所有資料"
}
39 changes: 39 additions & 0 deletions src/popup/sections/GeneralPart.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useTranslation } from 'react-i18next'
import { useState } from 'react'
import FileSaver from 'file-saver'
import { openUrl } from '../../utils/index.mjs'
import {
isUsingOpenAiApiKey,
Expand Down Expand Up @@ -551,6 +552,44 @@ export function GeneralPart({ config, updateConfig }) {
{t('Focus to input box after answering')}
</label>
<br />
<div style={{ display: 'flex', gap: '10px' }}>
<button
className="secondary"
onClick={async (e) => {
e.preventDefault()
const file = await new Promise((resolve) => {
const input = document.createElement('input')
input.type = 'file'
input.accept = '.json'
input.onchange = (e) => resolve(e.target.files[0])
input.click()
})
if (!file) return
const data = await new Promise((resolve) => {
const reader = new FileReader()
reader.onload = (e) => resolve(JSON.parse(e.target.result))
reader.readAsText(file)
})
await Browser.storage.local.set(data)
window.location.reload()
}}
>
{t('Import All Data')}
</button>
<button
className="secondary"
onClick={async (e) => {
e.preventDefault()
const blob = new Blob(
[JSON.stringify(await Browser.storage.local.get(null), null, 2)],
{ type: 'text/json;charset=utf-8' },
)
FileSaver.saveAs(blob, 'chatgptbox-data.json')
}}
>
{t('Export All Data')}
</button>
</div>
</>
)
}

0 comments on commit c496f87

Please sign in to comment.