diff --git a/frontend/src/components/ProgressModal.vue b/frontend/src/components/ProgressModal.vue index 85590fb..7bdb5dd 100644 --- a/frontend/src/components/ProgressModal.vue +++ b/frontend/src/components/ProgressModal.vue @@ -8,7 +8,7 @@ import { useI18n } from 'vue-i18n' const isOpen = ref(false) -const mode = ref<'export' | 'import' | 'download'>('export') +const mode = ref<'export' | 'import' | 'download' | 'validate'>('export') const snapshot = ref(null) @@ -17,7 +17,9 @@ const steps = computed(() => { case 'export': return ['initialisation', 'compression', 'complete'] case 'download': - return ['initialisation', 'download', 'complete'] + return ['initialisation', 'download', 'compare', 'complete'] + case 'validate': + return ['initialisation', 'compare', 'complete'] case 'import': return ['initialisation', 'backup', 'extract', 'cleanup', 'complete'] default: @@ -53,6 +55,37 @@ function startPolling() { interval = setInterval(updateProgress, 300) } +// runPreviewJob drives the modal for promise-returning preview flows (download, +// validate): opens the modal, polls, resolves with the preview or toasts+rejects. +function runPreviewJob( + modeName: 'download' | 'validate', + titleText: string, + op: Promise +): Promise { + return new Promise((resolve, reject) => { + isOpen.value = true + mode.value = modeName + title.value = titleText + snapshot.value = null + messages.value = [] + + op.then((preview: porter.ImportPreview) => { + resolve(preview) + isOpen.value = false + }) + .catch(err => { + toast.add({ title: decodeError(err, t), color: 'error' }) + reject(err) + }) + .finally(() => { + resetInterval() + updateProgress() + }) + + startPolling() + }) +} + defineExpose({ export: (destination: string) => { isOpen.value = true @@ -71,32 +104,10 @@ defineExpose({ startPolling() }, - download: (url: string): Promise => { - return new Promise((resolve, reject) => { - isOpen.value = true - mode.value = 'download' - title.value = t('labelUpdate') - snapshot.value = null - messages.value = [] - - programPorter - .DownloadAndValidate(url) - .then((preview: porter.ImportPreview) => { - resolve(preview) - isOpen.value = false - }) - .catch(err => { - toast.add({ title: decodeError(err, t), color: 'error' }) - reject(err) - }) - .finally(() => { - resetInterval() - updateProgress() - }) - - startPolling() - }) - }, + download: (url: string): Promise => + runPreviewJob('download', t('labelUpdate'), programPorter.DownloadAndValidate(url)), + validate: (path: string): Promise => + runPreviewJob('validate', t('labelValidate'), programPorter.ValidateZip(path)), import: (from: 'url' | 'file', source: string, opts: porter.ImportOptions) => { isOpen.value = true mode.value = 'import' diff --git a/frontend/src/components/ProgressStepper.vue b/frontend/src/components/ProgressStepper.vue index d732b72..c06cb5f 100644 --- a/frontend/src/components/ProgressStepper.vue +++ b/frontend/src/components/ProgressStepper.vue @@ -14,6 +14,7 @@ function stepKey(name: string): string { compression: 'stepCompression', complete: 'complete', download: 'stepDownload', + compare: 'stepCompare', backup: 'stepBackup', extract: 'stepExtract', cleanup: 'stepCleanup' diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json index 830639f..917d250 100644 --- a/frontend/src/i18n/en.json +++ b/frontend/src/i18n/en.json @@ -83,6 +83,12 @@ "labelBuildType": "Build Type", "labelCaseSensitive": "Case Sensitive", "labelCreated": "Created", + "labelDiffChanged": "Changed", + "labelDiffFileCount": "{count} file | {count} files", + "labelDiffIdentical": "Identical", + "labelDiffIncoming": "Backup", + "labelDiffLocal": "This PC", + "labelDiffNew": "New on this machine", "labelCurrentVersion": "Latest Version", "labelData": "Data", "labelDatabase": "Database", @@ -203,6 +209,7 @@ "stepBackupLabel": "Backup", "stepCleanup": "Cleaning up", "stepCleanupLabel": "Cleanup", + "stepCompare": "Compare", "stepCompression": "Compressing", "stepCompressionLabel": "Compression", "stepDecompressionLabel": "Decompression", diff --git a/frontend/src/i18n/zh_Hant_HK.json b/frontend/src/i18n/zh_Hant_HK.json index 11e2d4d..9468340 100644 --- a/frontend/src/i18n/zh_Hant_HK.json +++ b/frontend/src/i18n/zh_Hant_HK.json @@ -83,6 +83,12 @@ "labelBuildType": "組建類型", "labelCaseSensitive": "區分大小寫", "labelCreated": "建立日期", + "labelDiffChanged": "有變更", + "labelDiffFileCount": "{count} 個檔案", + "labelDiffIdentical": "相同", + "labelDiffIncoming": "備份", + "labelDiffLocal": "本機", + "labelDiffNew": "本機未有", "labelCurrentVersion": "現有版本", "labelData": "資料", "labelDatabase": "資料庫", @@ -203,6 +209,7 @@ "stepBackupLabel": "備份", "stepCleanup": "清理中", "stepCleanupLabel": "清理檔案", + "stepCompare": "比對", "stepCompression": "壓縮中", "stepCompressionLabel": "壓縮檔案", "stepDecompressionLabel": "解壓縮檔案", diff --git a/frontend/src/pages/porter.vue b/frontend/src/pages/porter.vue index ec3767d..caca37a 100644 --- a/frontend/src/pages/porter.vue +++ b/frontend/src/pages/porter.vue @@ -1,10 +1,9 @@