fix: fix more settings persistence bug(s) for datasync/configure

esp. for the profile consumers info
This commit is contained in:
Lance Edgar 2024-07-18 17:58:59 -05:00
parent f4f79f170a
commit 1bba6d9947

View file

@ -734,16 +734,9 @@
this.editingProfilePendingConsumers = [] this.editingProfilePendingConsumers = []
for (let consumer of row.consumers_data) { for (let consumer of row.consumers_data) {
let pending = { const pending = {
...consumer,
original_key: consumer.key, original_key: consumer.key,
key: consumer.key,
consumer_spec: consumer.consumer_spec,
consumer_dbkey: consumer.consumer_dbkey,
consumer_delay: consumer.consumer_delay,
consumer_retry_attempts: consumer.consumer_retry_attempts,
consumer_retry_delay: consumer.consumer_retry_delay,
consumer_runas: consumer.consumer_runas,
enabled: consumer.enabled,
} }
this.editingProfilePendingConsumers.push(pending) this.editingProfilePendingConsumers.push(pending)
} }
@ -791,8 +784,8 @@
this.editingProfilePendingWatcherKwargs.splice(i, 1) this.editingProfilePendingWatcherKwargs.splice(i, 1)
} }
ThisPage.methods.findOriginalConsumer = function(key) { ThisPage.methods.findConsumer = function(profileConsumers, key) {
for (let consumer of this.editingProfile.consumers_data) { for (const consumer of profileConsumers) {
if (consumer.key == key) { if (consumer.key == key) {
return consumer return consumer
} }
@ -803,9 +796,12 @@
const row = this.editingProfile const row = this.editingProfile
const newRow = !row.key const newRow = !row.key
let originalProfile = null
if (newRow) { if (newRow) {
row.consumers_data = [] row.consumers_data = []
this.profilesData.push(row) this.profilesData.push(row)
} else {
originalProfile = this.findProfile(row)
} }
row.key = this.editingProfileKey row.key = this.editingProfileKey
@ -853,7 +849,8 @@
for (let pending of this.editingProfilePendingConsumers) { for (let pending of this.editingProfilePendingConsumers) {
persistentConsumers.push(pending.key) persistentConsumers.push(pending.key)
if (pending.original_key) { if (pending.original_key) {
let consumer = this.findOriginalConsumer(pending.original_key) const consumer = this.findConsumer(originalProfile.consumers_data,
pending.original_key)
consumer.key = pending.key consumer.key = pending.key
consumer.consumer_spec = pending.consumer_spec consumer.consumer_spec = pending.consumer_spec
consumer.consumer_dbkey = pending.consumer_dbkey consumer.consumer_dbkey = pending.consumer_dbkey
@ -941,8 +938,10 @@
} }
ThisPage.methods.updateConsumer = function() { ThisPage.methods.updateConsumer = function() {
let pending = this.editingConsumer const pending = this.findConsumer(
let isNew = !pending.key this.editingProfilePendingConsumers,
this.editingConsumer.key)
const isNew = !pending.key
pending.key = this.editingConsumerKey pending.key = this.editingConsumerKey
pending.consumer_spec = this.editingConsumerSpec pending.consumer_spec = this.editingConsumerSpec