diff --git a/tailbone/templates/themes/falafel/progress.mako b/tailbone/templates/themes/falafel/progress.mako index f1973e81..ad0a1371 100644 --- a/tailbone/templates/themes/falafel/progress.mako +++ b/tailbone/templates/themes/falafel/progress.mako @@ -8,6 +8,7 @@ ${initial_msg or "Working"}... ${core_javascript()} ${core_styles()} + ${self.extra_styles()} @@ -61,6 +62,8 @@
+ ${self.after_progress()} + @@ -72,23 +75,6 @@ let WholePage = { template: '#whole-page-template', - data() { - return { - progressURL: '${url('progress', key=progress.key, _query={'sessiontype': progress.session.type})}', - progressMessage: "${(initial_msg or "Working").replace('"', '\\"')} (please wait)", - progressMax: null, - progressMaxDisplay: null, - progressValue: null, - stillInProgress: true, - - % if can_cancel: - canCancel: true, - cancelURL: '${url('progress.cancel', key=progress.key, _query={'sessiontype': progress.session.type})}', - cancelingProgress: false, - % endif - } - }, - computed: { totalDisplay() { @@ -113,10 +99,15 @@ setTimeout(() => { this.updateProgress() }, 1000) + + // custom logic if applicable + this.mountedCustom() }, methods: { + mountedCustom() {}, + updateProgress() { this.$http.get(this.progressURL).then(response => { @@ -146,6 +137,9 @@ } } + // custom logic if applicable + this.updateProgressCustom(response) + if (this.stillInProgress) { // fetch progress data again, in one second from now @@ -157,6 +151,8 @@ }) }, + updateProgressCustom(response) {}, + % if can_cancel: cancelProgress() { @@ -178,13 +174,46 @@ } } - Vue.component('whole-page', WholePage) + let WholePageData = { - new Vue({ - el: '#whole-page-app' - }) + progressURL: '${url('progress', key=progress.key, _query={'sessiontype': progress.session.type})}', + progressMessage: "${(initial_msg or "Working").replace('"', '\\"')} (please wait)", + progressMax: null, + progressMaxDisplay: null, + progressValue: null, + stillInProgress: true, + + % if can_cancel: + canCancel: true, + cancelURL: '${url('progress.cancel', key=progress.key, _query={'sessiontype': progress.session.type})}', + cancelingProgress: false, + % endif + } + ${self.modify_whole_page_vars()} + ${self.make_whole_page_app()} + + +<%def name="extra_styles()"> + +<%def name="after_progress()"> + +<%def name="modify_whole_page_vars()"> + +<%def name="make_whole_page_app()"> + + diff --git a/tailbone/templates/themes/falafel/upgrade.mako b/tailbone/templates/themes/falafel/upgrade.mako new file mode 100644 index 00000000..7cc73941 --- /dev/null +++ b/tailbone/templates/themes/falafel/upgrade.mako @@ -0,0 +1,69 @@ +## -*- coding: utf-8; -*- +<%inherit file="/progress.mako" /> + +<%def name="extra_styles()"> + ${parent.extra_styles()} + + + +<%def name="after_progress()"> + + +
+ + + + ## nb. we auto-scroll down to "see" this element +
+
+ + + +<%def name="modify_whole_page_vars()"> + + + + +${parent.body()} diff --git a/tailbone/templates/upgrades/view.mako b/tailbone/templates/upgrades/view.mako index 530b8757..c5419574 100644 --- a/tailbone/templates/upgrades/view.mako +++ b/tailbone/templates/upgrades/view.mako @@ -78,13 +78,15 @@ <%def name="render_buefy_form()">
<${form.component} - % if expose_websockets and master.has_perm('execute'): + % if master.has_perm('execute'): + @declare-failure-click="declareFailureClick" + :declare-failure-submitting="declareFailureSubmitting" + % if expose_websockets: % if instance_executable: @execute-upgrade-click="executeUpgrade" % endif :upgrade-executing="upgradeExecuting" - @declare-failure-click="declareFailureClick" - :declare-failure-submitting="declareFailureSubmitting" + % endif % endif > diff --git a/tailbone/views/master.py b/tailbone/views/master.py index 2d6410e1..01a3405a 100644 --- a/tailbone/views/master.py +++ b/tailbone/views/master.py @@ -24,6 +24,7 @@ Model Master View """ +import io import os import csv import datetime @@ -33,7 +34,6 @@ import tempfile import logging import json -import six import sqlalchemy as sa from sqlalchemy import orm import sqlalchemy_continuum as continuum @@ -115,6 +115,7 @@ class MasterView(View): executable = False execute_progress_template = None execute_progress_initial_msg = None + execute_can_cancel = True supports_prev_next = False supports_import_batch_from_file = False has_input_file_templates = False @@ -1839,6 +1840,7 @@ class MasterView(View): return self.render_progress(progress, { 'instance': obj, 'initial_msg': self.execute_progress_initial_msg, + 'can_cancel': self.execute_can_cancel, 'cancel_url': self.get_action_url('view', obj), 'cancel_msg': "{} execution was canceled".format(model_title), }, template=self.execute_progress_template) @@ -3785,7 +3787,7 @@ class MasterView(View): """ obj = self.get_instance() fields = self.get_row_csv_fields() - data = six.StringIO() + data = io.StringIO() writer = UnicodeDictWriter(data, fields) writer.writeheader() for row in self.get_effective_row_data(sort=True): diff --git a/tailbone/views/upgrades.py b/tailbone/views/upgrades.py index 0b085ba7..f6df80d3 100644 --- a/tailbone/views/upgrades.py +++ b/tailbone/views/upgrades.py @@ -60,6 +60,7 @@ class UpgradeView(MasterView): executable = True execute_progress_template = '/upgrade.mako' execute_progress_initial_msg = "Upgrading" + execute_can_cancel = False labels = { 'executed_by': "Executed by",