Update backups config page to use backupPathEnvSet returned from endpoint, remove from ServerConfig

This commit is contained in:
advplyr 2024-07-05 16:10:07 -05:00
parent a1688488e5
commit 7c0b4e35d7
4 changed files with 9 additions and 11 deletions

View File

@ -171,7 +171,7 @@ export default {
this.$axios this.$axios
.$get('/api/backups') .$get('/api/backups')
.then((data) => { .then((data) => {
this.$emit('loaded', data.backupLocation) this.$emit('loaded', data)
this.setBackups(data.backups || []) this.setBackups(data.backups || [])
}) })
.catch((error) => { .catch((error) => {

View File

@ -92,6 +92,7 @@ export default {
newServerSettings: {}, newServerSettings: {},
showCronBuilder: false, showCronBuilder: false,
showEditBackupPath: false, showEditBackupPath: false,
backupPathEnvSet: false,
backupLocation: '', backupLocation: '',
newBackupLocation: '', newBackupLocation: '',
savingBackupPath: false savingBackupPath: false
@ -116,8 +117,8 @@ export default {
return this.serverSettings.timeFormat return this.serverSettings.timeFormat
}, },
canEditBackup() { canEditBackup() {
// Prevent editing of backup path if an environement variable is set // Prevent editing of backup path if an environment variable is set
return !this.serverSettings.backupPathEnvSet return !this.backupPathEnvSet
}, },
scheduleDescription() { scheduleDescription() {
if (!this.cronExpression) return '' if (!this.cronExpression) return ''
@ -131,9 +132,10 @@ export default {
} }
}, },
methods: { methods: {
backupsLoaded(backupLocation) { backupsLoaded(data) {
this.backupLocation = backupLocation this.backupLocation = data.backupLocation
this.newBackupLocation = backupLocation this.newBackupLocation = data.backupLocation
this.backupPathEnvSet = data.backupPathEnvSet
}, },
cancelEditBackupPath() { cancelEditBackupPath() {
this.newBackupLocation = this.backupLocation this.newBackupLocation = this.backupLocation

View File

@ -30,7 +30,7 @@ class BackupManager {
} }
get backupPathEnvSet() { get backupPathEnvSet() {
return global.ServerSettings.backupPathEnvSet return !!process.env.BACKUP_PATH
} }
get backupSchedule() { get backupSchedule() {

View File

@ -26,7 +26,6 @@ class ServerSettings {
this.rateLimitLoginWindow = 10 * 60 * 1000 // 10 Minutes this.rateLimitLoginWindow = 10 * 60 * 1000 // 10 Minutes
// Backups // Backups
this.backupPathEnvSet = false
this.backupPath = Path.join(global.MetadataPath, 'backups') this.backupPath = Path.join(global.MetadataPath, 'backups')
this.backupSchedule = false // If false then auto-backups are disabled this.backupSchedule = false // If false then auto-backups are disabled
this.backupsToKeep = 2 this.backupsToKeep = 2
@ -189,8 +188,6 @@ class ServerSettings {
Logger.info(`[ServerSettings] Using backup path from environment variable ${process.env.BACKUP_PATH}`) Logger.info(`[ServerSettings] Using backup path from environment variable ${process.env.BACKUP_PATH}`)
this.backupPath = process.env.BACKUP_PATH this.backupPath = process.env.BACKUP_PATH
} }
this.backupPathEnvSet = !!process.env.BACKUP_PATH || false
} }
toJSON() { toJSON() {
@ -209,7 +206,6 @@ class ServerSettings {
rateLimitLoginRequests: this.rateLimitLoginRequests, rateLimitLoginRequests: this.rateLimitLoginRequests,
rateLimitLoginWindow: this.rateLimitLoginWindow, rateLimitLoginWindow: this.rateLimitLoginWindow,
backupPath: this.backupPath, backupPath: this.backupPath,
backupPathEnvSet: this.backupPathEnvSet,
backupSchedule: this.backupSchedule, backupSchedule: this.backupSchedule,
backupsToKeep: this.backupsToKeep, backupsToKeep: this.backupsToKeep,
maxBackupSize: this.maxBackupSize, maxBackupSize: this.maxBackupSize,