fix: show sync warnings in settings
This commit is contained in:
parent
7641a311cc
commit
c40d8c9dd3
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -16,8 +16,8 @@
|
||||||
background: #13131f;
|
background: #13131f;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script type="module" crossorigin src="/assets/main-DnJYoBUl.js"></script>
|
<script type="module" crossorigin src="/assets/main-gfkCdjpq.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/main-DUL0iWPC.css">
|
<link rel="stylesheet" crossorigin href="/assets/main-ANUqg_zC.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
let loading = false
|
let loading = false
|
||||||
let errorMsg = ''
|
let errorMsg = ''
|
||||||
let resultMsg = ''
|
let resultMsg = ''
|
||||||
|
let resultKind = ''
|
||||||
|
|
||||||
let serverUrl = ''
|
let serverUrl = ''
|
||||||
let username = ''
|
let username = ''
|
||||||
|
|
@ -41,6 +42,7 @@
|
||||||
async function testConnection() {
|
async function testConnection() {
|
||||||
loading = true
|
loading = true
|
||||||
errorMsg = ''
|
errorMsg = ''
|
||||||
|
resultKind = ''
|
||||||
connectionOk = null
|
connectionOk = null
|
||||||
try {
|
try {
|
||||||
await wailsCall('SyncTestConnection', serverUrl, username, password)
|
await wailsCall('SyncTestConnection', serverUrl, username, password)
|
||||||
|
|
@ -56,6 +58,7 @@
|
||||||
async function configureSync() {
|
async function configureSync() {
|
||||||
loading = true
|
loading = true
|
||||||
errorMsg = ''
|
errorMsg = ''
|
||||||
|
resultKind = ''
|
||||||
try {
|
try {
|
||||||
await wailsCall('SyncConfigure', serverUrl, username, password)
|
await wailsCall('SyncConfigure', serverUrl, username, password)
|
||||||
resultMsg = 'configured'
|
resultMsg = 'configured'
|
||||||
|
|
@ -69,12 +72,29 @@
|
||||||
loading = false
|
loading = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function syncResultWarning(result) {
|
||||||
|
const conflicts = Array.isArray(result?.conflicts) ? result.conflicts : []
|
||||||
|
const applyErrors = Array.isArray(result?.applyErrors) ? result.applyErrors : []
|
||||||
|
const parts = []
|
||||||
|
if (conflicts.length > 0) {
|
||||||
|
parts.push(t('sync.conflictsCount', { count: conflicts.length }))
|
||||||
|
}
|
||||||
|
if (applyErrors.length > 0) {
|
||||||
|
parts.push(t('sync.applyErrorsCount', { count: applyErrors.length }))
|
||||||
|
}
|
||||||
|
return parts.join(' · ')
|
||||||
|
}
|
||||||
|
|
||||||
async function runSyncNow() {
|
async function runSyncNow() {
|
||||||
loading = true
|
loading = true
|
||||||
errorMsg = ''
|
errorMsg = ''
|
||||||
|
resultKind = ''
|
||||||
try {
|
try {
|
||||||
const r = await wailsCall('SyncNow')
|
const r = await wailsCall('SyncNow')
|
||||||
resultMsg = 'pushed ' + r.pushed + ', pulled ' + r.pulled
|
const summary = t('sync.pushedPulled', { pushed: r?.pushed || 0, pulled: r?.pulled || 0 })
|
||||||
|
const warning = syncResultWarning(r)
|
||||||
|
resultMsg = warning ? summary + ' · ' + warning : summary
|
||||||
|
resultKind = warning ? 'warning' : ''
|
||||||
await load()
|
await load()
|
||||||
if (onRefresh) onRefresh()
|
if (onRefresh) onRefresh()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
@ -87,6 +107,7 @@
|
||||||
try {
|
try {
|
||||||
await wailsCall('SyncSetInterval', syncInterval)
|
await wailsCall('SyncSetInterval', syncInterval)
|
||||||
resultMsg = t('sync.settingsSaved')
|
resultMsg = t('sync.settingsSaved')
|
||||||
|
resultKind = ''
|
||||||
} catch (e) { errorMsg = String(e) }
|
} catch (e) { errorMsg = String(e) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,6 +118,7 @@
|
||||||
async function doDisconnect() {
|
async function doDisconnect() {
|
||||||
showDisconnectConfirm = false
|
showDisconnectConfirm = false
|
||||||
loading = true
|
loading = true
|
||||||
|
resultKind = ''
|
||||||
try {
|
try {
|
||||||
await wailsCall('SyncDisconnect')
|
await wailsCall('SyncDisconnect')
|
||||||
resultMsg = 'disconnected'
|
resultMsg = 'disconnected'
|
||||||
|
|
@ -113,6 +135,7 @@
|
||||||
async function doResetKey() {
|
async function doResetKey() {
|
||||||
showResetKeyConfirm = false
|
showResetKeyConfirm = false
|
||||||
loading = true
|
loading = true
|
||||||
|
resultKind = ''
|
||||||
try {
|
try {
|
||||||
await wailsCall('ResetSyncKey')
|
await wailsCall('ResetSyncKey')
|
||||||
resultMsg = 'key reset'
|
resultMsg = 'key reset'
|
||||||
|
|
@ -143,7 +166,7 @@
|
||||||
<div class="error-msg">{errorMsg}</div>
|
<div class="error-msg">{errorMsg}</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if resultMsg && !errorMsg}
|
{#if resultMsg && !errorMsg}
|
||||||
<div class="result-msg">{resultMsg}</div>
|
<div class="result-msg" class:warning={resultKind === 'warning'}>{resultMsg}</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if settings && settings.enabled}
|
{#if settings && settings.enabled}
|
||||||
|
|
@ -375,6 +398,11 @@
|
||||||
color: #34d399;
|
color: #34d399;
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
}
|
}
|
||||||
|
.result-msg.warning {
|
||||||
|
background: rgba(245, 158, 11, 0.1);
|
||||||
|
border-color: rgba(245, 158, 11, 0.3);
|
||||||
|
color: #f59e0b;
|
||||||
|
}
|
||||||
.modal-overlay {
|
.modal-overlay {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
|
|
|
||||||
|
|
@ -408,6 +408,7 @@ export default {
|
||||||
'sync.running': 'Syncing...',
|
'sync.running': 'Syncing...',
|
||||||
'sync.conflictsCount': 'Conflicts: {count}',
|
'sync.conflictsCount': 'Conflicts: {count}',
|
||||||
'sync.applyErrorsCount': 'Apply errors: {count}',
|
'sync.applyErrorsCount': 'Apply errors: {count}',
|
||||||
|
'sync.pushedPulled': 'Pushed: {pushed}, pulled: {pulled}',
|
||||||
'error.generic': 'An error occurred',
|
'error.generic': 'An error occurred',
|
||||||
'error.invalidCredentials': 'Invalid username or password',
|
'error.invalidCredentials': 'Invalid username or password',
|
||||||
'error.accountBlocked': 'Account blocked',
|
'error.accountBlocked': 'Account blocked',
|
||||||
|
|
|
||||||
|
|
@ -432,6 +432,7 @@ export default {
|
||||||
'sync.running': 'Синхронизация...',
|
'sync.running': 'Синхронизация...',
|
||||||
'sync.conflictsCount': 'Конфликты: {count}',
|
'sync.conflictsCount': 'Конфликты: {count}',
|
||||||
'sync.applyErrorsCount': 'Ошибки применения: {count}',
|
'sync.applyErrorsCount': 'Ошибки применения: {count}',
|
||||||
|
'sync.pushedPulled': 'Отправлено: {pushed}, получено: {pulled}',
|
||||||
|
|
||||||
'error.generic': 'Произошла ошибка',
|
'error.generic': 'Произошла ошибка',
|
||||||
'error.invalidCredentials': 'Неверный логин или пароль',
|
'error.invalidCredentials': 'Неверный логин или пароль',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue