Add button to remove all datasync settings from DB
seems useful for someone testing, as prep to make the switch
This commit is contained in:
parent
8aff5d519d
commit
4229798c7b
|
@ -50,8 +50,56 @@
|
||||||
</b-button>
|
</b-button>
|
||||||
${h.end_form()}
|
${h.end_form()}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="level-item">
|
||||||
|
<b-button type="is-danger"
|
||||||
|
@click="purgeSettingsInit()"
|
||||||
|
icon-pack="fas"
|
||||||
|
icon-left="trash">
|
||||||
|
Remove All Settings
|
||||||
|
</b-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<b-modal has-modal-card
|
||||||
|
:active.sync="purgeSettingsShowDialog">
|
||||||
|
<div class="modal-card">
|
||||||
|
|
||||||
|
<header class="modal-card-head">
|
||||||
|
<p class="modal-card-title">Remove All Settings</p>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<section class="modal-card-body">
|
||||||
|
<p class="block">
|
||||||
|
If you like we can remove all DataSync settings from the DB.
|
||||||
|
</p>
|
||||||
|
<p class="block">
|
||||||
|
Note that this tool normally removes all settings first,
|
||||||
|
every time you click "Save Settings". Here though you
|
||||||
|
can "just remove" and <span class="is-italic">not</span>
|
||||||
|
save the current settings.
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<footer class="modal-card-foot">
|
||||||
|
<b-button @click="purgeSettingsShowDialog = false">
|
||||||
|
Cancel
|
||||||
|
</b-button>
|
||||||
|
${h.form(request.current_route_url())}
|
||||||
|
${h.csrf_token(request)}
|
||||||
|
${h.hidden('purge_settings', 'true')}
|
||||||
|
<b-button type="is-danger"
|
||||||
|
native-type="submit"
|
||||||
|
:disabled="purgingSettings"
|
||||||
|
icon-pack="fas"
|
||||||
|
icon-left="trash"
|
||||||
|
@click="purgingSettings = true">
|
||||||
|
{{ purgingSettings ? "Working, please wait..." : "Remove All Settings" }}
|
||||||
|
</b-button>
|
||||||
|
${h.end_form()}
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</b-modal>
|
||||||
|
|
||||||
<b-notification type="is-warning"
|
<b-notification type="is-warning"
|
||||||
:active.sync="showConfigFilesNote">
|
:active.sync="showConfigFilesNote">
|
||||||
|
@ -448,6 +496,9 @@
|
||||||
|
|
||||||
ThisPageData.restartCommand = ${json.dumps(restart_command)|n}
|
ThisPageData.restartCommand = ${json.dumps(restart_command)|n}
|
||||||
|
|
||||||
|
ThisPageData.purgeSettingsShowDialog = false
|
||||||
|
ThisPageData.purgingSettings = false
|
||||||
|
|
||||||
ThisPageData.settingsNeedSaved = false
|
ThisPageData.settingsNeedSaved = false
|
||||||
ThisPageData.undoChanges = false
|
ThisPageData.undoChanges = false
|
||||||
ThisPageData.savingSettings = false
|
ThisPageData.savingSettings = false
|
||||||
|
@ -692,6 +743,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ThisPage.methods.purgeSettingsInit = function() {
|
||||||
|
this.purgeSettingsShowDialog = true
|
||||||
|
}
|
||||||
|
|
||||||
ThisPage.methods.saveSettings = function() {
|
ThisPage.methods.saveSettings = function() {
|
||||||
this.savingSettings = true
|
this.savingSettings = true
|
||||||
let url = ${json.dumps(request.current_route_url())|n}
|
let url = ${json.dumps(request.current_route_url())|n}
|
||||||
|
|
|
@ -30,11 +30,9 @@ import getpass
|
||||||
import subprocess
|
import subprocess
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import sqlalchemy as sa
|
|
||||||
|
|
||||||
from rattail.db import model
|
from rattail.db import model
|
||||||
from rattail.datasync.config import load_profiles
|
from rattail.datasync.config import load_profiles
|
||||||
from rattail.datasync.util import get_lastrun
|
from rattail.datasync.util import get_lastrun, purge_datasync_settings
|
||||||
|
|
||||||
from tailbone.views import MasterView
|
from tailbone.views import MasterView
|
||||||
from tailbone.util import csrf_token
|
from tailbone.util import csrf_token
|
||||||
|
@ -100,6 +98,12 @@ class DataSyncChangeView(MasterView):
|
||||||
View for configuring the DataSync daemon.
|
View for configuring the DataSync daemon.
|
||||||
"""
|
"""
|
||||||
if self.request.method == 'POST':
|
if self.request.method == 'POST':
|
||||||
|
# if self.request.is_xhr and not self.request.POST:
|
||||||
|
if self.request.POST.get('purge_settings'):
|
||||||
|
self.delete_settings()
|
||||||
|
self.request.session.flash("Settings have been removed.")
|
||||||
|
return self.redirect(self.request.current_route_url())
|
||||||
|
else:
|
||||||
data = self.request.json_body
|
data = self.request.json_body
|
||||||
self.save_settings(data)
|
self.save_settings(data)
|
||||||
self.request.session.flash("Settings have been saved. "
|
self.request.session.flash("Settings have been saved. "
|
||||||
|
@ -221,28 +225,7 @@ class DataSyncChangeView(MasterView):
|
||||||
value=setting['value']))
|
value=setting['value']))
|
||||||
|
|
||||||
def delete_settings(self):
|
def delete_settings(self):
|
||||||
model = self.model
|
purge_datasync_settings(self.rattail_config, self.Session())
|
||||||
|
|
||||||
to_delete = [
|
|
||||||
'rattail.datasync.watch',
|
|
||||||
'tailbone.datasync.restart',
|
|
||||||
]
|
|
||||||
for setting in to_delete:
|
|
||||||
setting = self.Session.query(model.Setting).get(setting)
|
|
||||||
if setting:
|
|
||||||
self.Session.delete(setting)
|
|
||||||
|
|
||||||
self.Session.query(model.Setting)\
|
|
||||||
.filter(sa.or_(
|
|
||||||
model.Setting.name.like('rattail.datasync.%.watcher'),
|
|
||||||
model.Setting.name.like('rattail.datasync.%.watcher.db'),
|
|
||||||
model.Setting.name.like('rattail.datasync.%.watcher.delay'),
|
|
||||||
model.Setting.name.like('rattail.datasync.%.watcher.retry_attempts'),
|
|
||||||
model.Setting.name.like('rattail.datasync.%.watcher.retry_delay'),
|
|
||||||
model.Setting.name.like('rattail.datasync.%.consumers'),
|
|
||||||
model.Setting.name.like('rattail.datasync.%.consumers.runas'),
|
|
||||||
model.Setting.name.like('rattail.datasync.%.consumer.%')))\
|
|
||||||
.delete(synchronize_session=False)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def defaults(cls, config):
|
def defaults(cls, config):
|
||||||
|
|
Loading…
Reference in a new issue