kopia lustrzana https://github.com/dgtlmoon/changedetection.io
UI - Edit - Live Preview - improve error handling
rodzic
48921c878d
commit
c070265668
|
@ -312,8 +312,27 @@ def construct_blueprint(datastore: ChangeDetectionStore, update_q, queuedWatchMe
|
|||
'''For when viewing the "preview" of the rendered text from inside of Edit'''
|
||||
from flask import jsonify
|
||||
from changedetectionio.processors.text_json_diff import prepare_filter_prevew
|
||||
result = prepare_filter_prevew(watch_uuid=uuid, form_data=request.form, datastore=datastore)
|
||||
return jsonify(result)
|
||||
|
||||
watch = datastore.data["watching"].get(uuid)
|
||||
|
||||
if not watch:
|
||||
return jsonify({
|
||||
"error": "Watch not found",
|
||||
"code": 400
|
||||
}), 400
|
||||
|
||||
if not watch.history_n:
|
||||
return jsonify({
|
||||
"error": "Watch has empty history, at least one fetch of the page is required.",
|
||||
"code": 400
|
||||
}), 400
|
||||
#
|
||||
try:
|
||||
result = prepare_filter_prevew(watch_uuid=uuid, form_data=request.form, datastore=datastore)
|
||||
return jsonify(result)
|
||||
except Exception as e:
|
||||
return abort(500, str(e))
|
||||
|
||||
|
||||
@edit_blueprint.route("/highlight_submit_ignore_url", methods=['POST'])
|
||||
@login_optionally_required
|
||||
|
|
|
@ -21,6 +21,7 @@ function request_textpreview_update() {
|
|||
namespace: 'watchEdit'
|
||||
}).done(function (data) {
|
||||
console.debug(data['duration'])
|
||||
$('#error-text').text('');
|
||||
$('#filters-and-triggers #text-preview-before-inner').text(data['before_filter']);
|
||||
$('#filters-and-triggers #text-preview-inner')
|
||||
.text(data['after_filter'])
|
||||
|
@ -37,9 +38,8 @@ function request_textpreview_update() {
|
|||
}).fail(function (error) {
|
||||
if (error.statusText === 'abort') {
|
||||
console.log('Request was aborted due to a new request being fired.');
|
||||
} else {
|
||||
$('#filters-and-triggers #text-preview-inner').text('There was an error communicating with the server.');
|
||||
}
|
||||
$('#error-text').text(error.responseJSON['error']);
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -363,6 +363,7 @@ Math: {{ 1 + 1 }}") }}
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p id="error-text"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Ładowanie…
Reference in New Issue