OMG a ridiculous commit to overhaul import handler config etc.

- add `MasterView.configurable` concept, `/configure.mako` template
- add new master view for DataSync Threads (needs content)
- tweak view config for DataSync Changes accordingly
- update the Configure DataSync page per `configurable` concept
- add new Configure Import/Export page, per `configurable`
- add basic views for Raw Permissions
This commit is contained in:
Lance Edgar 2021-12-06 20:04:34 -06:00
parent 282185c5af
commit cc4b2278e7
10 changed files with 735 additions and 238 deletions

View file

@ -1,13 +1,10 @@
## -*- coding: utf-8; -*-
<%inherit file="/page.mako" />
<%def name="title()">Configure DataSync</%def>
<%def name="page_content()">
<br />
<%inherit file="/configure.mako" />
<%def name="buttons_row()">
<div class="level">
<div class="level-left">
<div class="level-item">
<p class="block">
This tool lets you modify the DataSync configuration.&nbsp;
@ -19,24 +16,13 @@
</p>
</div>
<div class="level-item buttons"
v-if="settingsNeedSaved">
<b-button type="is-primary"
@click="saveSettings"
:disabled="savingSettings"
icon-pack="fas"
icon-left="save">
{{ saveSettingsButtonText }}
</b-button>
<once-button tag="a" href="${request.current_route_url()}"
@click="undoChanges = true"
icon-left="undo"
text="Undo All Changes">
</once-button>
<div class="level-item">
${self.save_undo_buttons()}
</div>
</div>
<div class="level-right">
<div class="level-item">
${h.form(url('datasync.restart'), **{'@submit': 'submitRestartDatasyncForm'})}
${h.csrf_token(request)}
@ -50,56 +36,16 @@
</b-button>
${h.end_form()}
</div>
<div class="level-item">
<b-button type="is-danger"
@click="purgeSettingsInit()"
icon-pack="fas"
icon-left="trash">
Remove All Settings
</b-button>
${self.purge_button()}
</div>
</div>
</div>
</%def>
<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".&nbsp; 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>
<%def name="page_content()">
${parent.page_content()}
<b-notification type="is-warning"
:active.sync="showConfigFilesNote">
@ -496,13 +442,6 @@
ThisPageData.restartCommand = ${json.dumps(restart_command)|n}
ThisPageData.purgeSettingsShowDialog = false
ThisPageData.purgingSettings = false
ThisPageData.settingsNeedSaved = false
ThisPageData.undoChanges = false
ThisPageData.savingSettings = false
ThisPage.computed.filteredProfilesData = function() {
if (this.showDisabledProfiles) {
return this.profilesData
@ -539,13 +478,6 @@
return false
}
ThisPage.computed.saveSettingsButtonText = function() {
if (this.savingSettings) {
return "Working, please wait..."
}
return "Save All Settings"
}
ThisPage.methods.toggleDisabledProfiles = function() {
this.showDisabledProfiles = !this.showDisabledProfiles
}
@ -743,53 +675,11 @@
}
}
ThisPage.methods.purgeSettingsInit = function() {
this.purgeSettingsShowDialog = true
}
ThisPage.methods.saveSettings = function() {
this.savingSettings = true
let url = ${json.dumps(request.current_route_url())|n}
let params = {
ThisPage.methods.settingsCollectParams = function() {
return {
profiles: this.profilesData,
restart_command: this.restartCommand,
}
let headers = {
'X-CSRF-TOKEN': this.csrftoken,
}
this.$http.post(url, params, {headers: headers}).then((response) => {
if (response.data.success) {
this.settingsNeedSaved = false
location.href = url // reload page
} else {
this.$buefy.toast.open({
message: "Save failed: " + (response.data.error || "(unknown error)"),
type: 'is-danger',
duration: 4000, // 4 seconds
})
}
}).catch((error) => {
this.$buefy.toast.open({
message: "Save failed: (unknown error)",
type: 'is-danger',
duration: 4000, // 4 seconds
})
})
}
// cf. https://stackoverflow.com/a/56551646
ThisPage.methods.beforeWindowUnload = function(e) {
if (this.settingsNeedSaved && !this.undoChanges) {
e.preventDefault()
e.returnValue = ''
}
}
ThisPage.created = function() {
window.addEventListener('beforeunload', this.beforeWindowUnload)
}
% if request.has_perm('datasync.restart'):