use consistent naming for actions and views w/ burnettk
This commit is contained in:
parent
8476c4b004
commit
d5a2323dbe
|
@ -14,24 +14,9 @@ from spiff_workflow_webapp.services.process_model_service import ProcessModelSer
|
|||
admin_blueprint = Blueprint("admin", __name__, template_folder='templates', static_folder='static')
|
||||
|
||||
|
||||
@admin_blueprint.route("/index", methods=["GET"])
|
||||
def hello_world():
|
||||
"""Hello_world."""
|
||||
return render_template('index.html')
|
||||
|
||||
|
||||
@admin_blueprint.route("/view/<process_model_id>/<file_id>", methods=["GET"])
|
||||
def view_bpmn(process_model_id, file_id):
|
||||
"""View_bpmn."""
|
||||
process_model = ProcessModelService().get_spec(process_model_id)
|
||||
SpecFileService.get_files(process_model)
|
||||
bpmn_xml = SpecFileService.get_data(process_model, process_model.primary_file_name)
|
||||
return render_template('view.html', bpmn_xml=bpmn_xml.decode("utf-8"))
|
||||
|
||||
|
||||
@admin_blueprint.route("/run/<process_model_id>", methods=["GET"])
|
||||
def run_bpmn(process_model_id):
|
||||
"""Run_bpmn."""
|
||||
@admin_blueprint.route("/process-models/<process_model_id>/run", methods=["GET"])
|
||||
def process_model_run(process_model_id):
|
||||
"""Process_model_run."""
|
||||
user = find_or_create_user('Mr. Test') # Fixme - sheesh!
|
||||
process_instance = ProcessInstanceService.create_process_instance(process_model_id, user)
|
||||
processor = ProcessInstanceProcessor(process_instance)
|
||||
|
@ -45,26 +30,35 @@ def run_bpmn(process_model_id):
|
|||
return render_template('process_model_show.html', process_model=process_model, bpmn_xml=bpmn_xml, result=result)
|
||||
|
||||
|
||||
@admin_blueprint.route("/edit/<process_model_id>", methods=["GET"])
|
||||
def edit_bpmn(process_model_id):
|
||||
@admin_blueprint.route("/process_models/<process_model_id>/edit", methods=["GET"])
|
||||
def process_model_edit(process_model_id):
|
||||
"""Edit_bpmn."""
|
||||
process_model = ProcessModelService().get_spec(process_model_id)
|
||||
SpecFileService.get_files(process_model)
|
||||
bpmn_xml = SpecFileService.get_data(process_model, process_model.primary_file_name)
|
||||
|
||||
return render_template('edit.html', bpmn_xml=bpmn_xml.decode("utf-8"),
|
||||
return render_template('process_model_edit.html', bpmn_xml=bpmn_xml.decode("utf-8"),
|
||||
process_model=process_model)
|
||||
|
||||
|
||||
@admin_blueprint.route("/save/<process_model_id>", methods=["POST"])
|
||||
def save_bpmn(process_model_id):
|
||||
"""Save_bpmn."""
|
||||
@admin_blueprint.route("/process-models/<process_model_id>/save", methods=["POST"])
|
||||
def process_model_save(process_model_id):
|
||||
"""Process_model_save."""
|
||||
process_model = ProcessModelService().get_spec(process_model_id)
|
||||
SpecFileService.get_files(process_model, process_model.primary_file_name)
|
||||
SpecFileService.update_file(process_model, process_model.primary_file_name, request.get_data())
|
||||
bpmn_xml = SpecFileService.get_data(process_model, process_model.primary_file_name)
|
||||
return render_template('edit.html', bpmn_xml=bpmn_xml.decode("utf-8"),
|
||||
process_model_id=process_model_id)
|
||||
return render_template('process_model_edit.html', bpmn_xml=bpmn_xml.decode("utf-8"),
|
||||
process_model=process_model)
|
||||
|
||||
|
||||
@admin_blueprint.route("/process-models/<process_model_id>/<file_id>", methods=["GET"])
|
||||
def process_model_show_file(process_model_id, file_id):
|
||||
"""Process_model_show_file."""
|
||||
process_model = ProcessModelService().get_spec(process_model_id)
|
||||
SpecFileService.get_files(process_model)
|
||||
bpmn_xml = SpecFileService.get_data(process_model, file_id)
|
||||
return render_template('process_model_show.html', process_model=process_model, bpmn_xml=bpmn_xml)
|
||||
|
||||
|
||||
@admin_blueprint.route("/process-groups/<process_group_id>", methods=["GET"])
|
||||
|
@ -75,10 +69,10 @@ def process_group_show(process_group_id):
|
|||
|
||||
|
||||
@admin_blueprint.route("/process-groups", methods=["GET"])
|
||||
def list_process_groups():
|
||||
"""List_process_groups."""
|
||||
def process_groups_list():
|
||||
"""Process_groups_list."""
|
||||
process_groups = ProcessModelService().get_process_groups()
|
||||
return render_template('process_groups.html', process_groups=process_groups)
|
||||
return render_template('process_groups_list.html', process_groups=process_groups)
|
||||
|
||||
|
||||
@admin_blueprint.route("/process-models/<process_model_id>", methods=["GET"])
|
||||
|
@ -89,13 +83,6 @@ def process_model_show(process_model_id):
|
|||
return render_template('process_model_show.html', process_model=process_model, bpmn_xml=bpmn_xml)
|
||||
|
||||
|
||||
@admin_blueprint.route("/process-models", methods=["GET"])
|
||||
def list_process_models():
|
||||
"""List_process_models."""
|
||||
models = ProcessModelService().get_specs()
|
||||
return render_template('process_models.html', models=models)
|
||||
|
||||
|
||||
def find_or_create_user(username: str = "test_user1") -> Any:
|
||||
"""Find_or_create_user."""
|
||||
user = UserModel.query.filter_by(username=username).first()
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Hello World</title>
|
||||
|
||||
<script src="{{ url_for('admin.static', filename='node_modules/bpmn-js/dist/bpmn-viewer.development.js') }}"></script>
|
||||
|
||||
<!-- viewer distro (without pan and zoom) -->
|
||||
<!--
|
||||
<script src="https://unpkg.com/bpmn-js@9.1.0/dist/bpmn-viewer.development.js"></script>
|
||||
-->
|
||||
|
||||
<!-- required viewer styles -->
|
||||
<link rel="stylesheet" href="https://unpkg.com/bpmn-js@9.1.0/dist/assets/bpmn-js.css">
|
||||
|
||||
<!-- viewer distro (with pan and zoom) -->
|
||||
<script src="https://unpkg.com/bpmn-js@9.1.0/dist/bpmn-navigated-viewer.development.js"></script>
|
||||
|
||||
<!-- needed for this example only -->
|
||||
<script src="https://unpkg.com/jquery@3.3.1/dist/jquery.js"></script>
|
||||
|
||||
<!-- example styles -->
|
||||
<style>
|
||||
html, body, #canvas {
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.diagram-note {
|
||||
background-color: rgba(66, 180, 21, 0.7);
|
||||
color: White;
|
||||
border-radius: 5px;
|
||||
font-family: Arial;
|
||||
font-size: 12px;
|
||||
padding: 5px;
|
||||
min-height: 16px;
|
||||
width: 50px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.needs-discussion:not(.djs-connection) .djs-visual > :nth-child(1) {
|
||||
stroke: rgba(66, 180, 21, 0.7) !important; /* color elements as red */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="canvas"></div>
|
||||
|
||||
<script>
|
||||
|
||||
var diagramUrl = 'https://cdn.staticaly.com/gh/bpmn-io/bpmn-js-examples/dfceecba/starter/diagram.bpmn';
|
||||
|
||||
// viewer instance
|
||||
var bpmnViewer = new BpmnJS({
|
||||
container: '#canvas'
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Open diagram in our viewer instance.
|
||||
*
|
||||
* @param {String} bpmnXML diagram to display
|
||||
*/
|
||||
async function openDiagram(bpmnXML) {
|
||||
|
||||
// import diagram
|
||||
try {
|
||||
|
||||
await bpmnViewer.importXML(bpmnXML);
|
||||
|
||||
// access viewer components
|
||||
var canvas = bpmnViewer.get('canvas');
|
||||
var overlays = bpmnViewer.get('overlays');
|
||||
|
||||
|
||||
// zoom to fit full viewport
|
||||
canvas.zoom('fit-viewport');
|
||||
|
||||
// attach an overlay to a node
|
||||
overlays.add('SCAN_OK', 'note', {
|
||||
position: {
|
||||
bottom: 0,
|
||||
right: 0
|
||||
},
|
||||
html: '<div class="diagram-note">Mixed up the labels?</div>'
|
||||
});
|
||||
|
||||
// add marker
|
||||
canvas.addMarker('SCAN_OK', 'needs-discussion');
|
||||
} catch (err) {
|
||||
|
||||
console.error('could not import BPMN 2.0 diagram', err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// load external diagram file via AJAX and open it
|
||||
$.get(diagramUrl, openDiagram, 'text');
|
||||
</script>
|
||||
<!--
|
||||
Thanks for trying out our BPMN toolkit!
|
||||
If you'd like to learn more about what our library,
|
||||
continue with some more basic examples:
|
||||
* https://github.com/bpmn-io/bpmn-js-examples/overlays
|
||||
* https://github.com/bpmn-io/bpmn-js-examples/interaction
|
||||
* https://github.com/bpmn-io/bpmn-js-examples/colors
|
||||
* https://github.com/bpmn-io/bpmn-js-examples/commenting
|
||||
To get a bit broader overview over how bpmn-js works,
|
||||
follow our walkthrough:
|
||||
* https://bpmn.io/toolkit/bpmn-js/walkthrough/
|
||||
Related starters:
|
||||
* https://raw.githubusercontent.com/bpmn-io/bpmn-js-examples/starter/modeler.html
|
||||
-->
|
||||
</body>
|
||||
</html>
|
|
@ -1,7 +1,7 @@
|
|||
{% extends "layout.html" %}
|
||||
{% block title %}Process Group: {{ process_group.id }}{% endblock %}
|
||||
{% block content %}
|
||||
<button type="button" onclick="window.location.href='{{ url_for( 'admin.list_process_groups') }}';">Back</button>
|
||||
<button type="button" onclick="window.location.href='{{ url_for( 'admin.process_groups_list') }}';">Back</button>
|
||||
<table>
|
||||
<tbody>
|
||||
{# here we iterate over every item in our list#}
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
<div id="canvas"></div>
|
||||
|
||||
<meta id="bpmn_xml" data-name="{{bpmn_xml}}">
|
||||
<meta id="process_model_id" data-name="{{process_model_id}}">
|
||||
<meta id="process_model_id" data-name="{{process_model.id}}">
|
||||
<script>
|
||||
|
||||
// modeler instance
|
||||
|
@ -75,7 +75,7 @@
|
|||
var process_model_id = $('#process_model_id').data().name;
|
||||
console.log("The data is", data)
|
||||
//POST request with body equal on data in JSON format
|
||||
fetch('../save/' + process_model_id, {
|
||||
fetch('/admin/process-models/' + process_model_id + '/save' , {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'text/xml',
|
|
@ -48,8 +48,8 @@ html, body, #canvas {
|
|||
{% block content %}
|
||||
<div id="result">{{ result }}</div>
|
||||
<button type="button" onclick="window.location.href='{{ url_for( 'admin.process_group_show', process_group_id=process_model.process_group_id ) }}';">Back</button>
|
||||
<button type="button" onclick="window.location.href='{{ url_for( 'admin.run_bpmn' , process_model_id=process_model.id ) }}';">Run</button>
|
||||
<button type="button" onclick="window.location.href='{{ url_for( 'admin.edit_bpmn' , process_model_id=process_model.id ) }}';">Edit</button>
|
||||
<button type="button" onclick="window.location.href='{{ url_for( 'admin.process_model_run' , process_model_id=process_model.id ) }}';">Run</button>
|
||||
<button type="button" onclick="window.location.href='{{ url_for( 'admin.process_model_edit' , process_model_id=process_model.id ) }}';">Edit</button>
|
||||
<div id="canvas"></div>
|
||||
|
||||
<meta id="bpmn_xml" data-name="{{bpmn_xml}}">
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
{% extends "layout.html" %}
|
||||
{% block title %}Process Models{% endblock %}
|
||||
{% block content %}
|
||||
<table>
|
||||
<tbody>
|
||||
{# here we iterate over every item in our list#}
|
||||
{% for pm in models %}
|
||||
<tr><td><a href="{{ url_for('admin.run_bpmn', process_model_id=pm.id) }}">{{ pm.display_name }}</a></td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
|
@ -1,123 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Hello World</title>
|
||||
|
||||
<script src="{{ url_for('admin.static', filename='node_modules/bpmn-js/dist/bpmn-viewer.development.js') }}"></script>
|
||||
|
||||
<!-- viewer distro (without pan and zoom) -->
|
||||
<!--
|
||||
<script src="https://unpkg.com/bpmn-js@9.1.0/dist/bpmn-viewer.development.js"></script>
|
||||
-->
|
||||
|
||||
<!-- required viewer styles -->
|
||||
<link rel="stylesheet" href="https://unpkg.com/bpmn-js@9.1.0/dist/assets/bpmn-js.css">
|
||||
|
||||
<!-- viewer distro (with pan and zoom) -->
|
||||
<script src="https://unpkg.com/bpmn-js@9.1.0/dist/bpmn-navigated-viewer.development.js"></script>
|
||||
|
||||
<!-- needed for this example only -->
|
||||
<script src="https://unpkg.com/jquery@3.3.1/dist/jquery.js"></script>
|
||||
|
||||
<!-- example styles -->
|
||||
<style>
|
||||
html, body, #canvas {
|
||||
height: 90%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.diagram-note {
|
||||
background-color: rgba(66, 180, 21, 0.7);
|
||||
color: White;
|
||||
border-radius: 5px;
|
||||
font-family: Arial;
|
||||
font-size: 12px;
|
||||
padding: 5px;
|
||||
min-height: 16px;
|
||||
width: 50px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.needs-discussion:not(.djs-connection) .djs-visual > :nth-child(1) {
|
||||
stroke: rgba(66, 180, 21, 0.7) !important; /* color elements as red */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="result">{{ result }}</div>
|
||||
<button type="button" onclick="window.location.href='{{ url_for( 'admin.list_process_models' ) }}';">List</button>
|
||||
<button type="button" onclick="window.location.href='{{ url_for( 'admin.run_bpmn' , process_model_id=process_model_id ) }}';">Run</button>
|
||||
<button type="button" onclick="window.location.href='{{ url_for( 'admin.edit_bpmn' , process_model_id=process_model_id ) }}';">Edit</button>
|
||||
<div id="canvas"></div>
|
||||
|
||||
<meta id="bpmn_xml" data-name="{{bpmn_xml}}">
|
||||
<script>
|
||||
|
||||
var diagramUrl = 'https://cdn.staticaly.com/gh/bpmn-io/bpmn-js-examples/dfceecba/starter/diagram.bpmn';
|
||||
|
||||
// viewer instance
|
||||
var bpmnViewer = new BpmnJS({
|
||||
container: '#canvas'
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Open diagram in our viewer instance.
|
||||
*
|
||||
* @param {String} bpmnXML diagram to display
|
||||
*/
|
||||
async function openDiagram(bpmnXML) {
|
||||
|
||||
// import diagram
|
||||
try {
|
||||
|
||||
await bpmnViewer.importXML(bpmnXML);
|
||||
|
||||
// access viewer components
|
||||
var canvas = bpmnViewer.get('canvas');
|
||||
var overlays = bpmnViewer.get('overlays');
|
||||
|
||||
|
||||
// zoom to fit full viewport
|
||||
canvas.zoom('fit-viewport');
|
||||
|
||||
// attach an overlay to a node
|
||||
overlays.add('SCAN_OK', 'note', {
|
||||
position: {
|
||||
bottom: 0,
|
||||
right: 0
|
||||
},
|
||||
html: '<div class="diagram-note">Mixed up the labels?</div>'
|
||||
});
|
||||
|
||||
// add marker
|
||||
canvas.addMarker('SCAN_OK', 'needs-discussion');
|
||||
} catch (err) {
|
||||
|
||||
console.error('could not import BPMN 2.0 diagram', err);
|
||||
}
|
||||
}
|
||||
var bpmn_xml = $('#bpmn_xml').data();
|
||||
openDiagram(bpmn_xml.name)
|
||||
|
||||
// load external diagram file via AJAX and open it
|
||||
//$.get(diagramUrl, openDiagram, 'text');
|
||||
</script>
|
||||
<!--
|
||||
Thanks for trying out our BPMN toolkit!
|
||||
If you'd like to learn more about what our library,
|
||||
continue with some more basic examples:
|
||||
* https://github.com/bpmn-io/bpmn-js-examples/overlays
|
||||
* https://github.com/bpmn-io/bpmn-js-examples/interaction
|
||||
* https://github.com/bpmn-io/bpmn-js-examples/colors
|
||||
* https://github.com/bpmn-io/bpmn-js-examples/commenting
|
||||
To get a bit broader overview over how bpmn-js works,
|
||||
follow our walkthrough:
|
||||
* https://bpmn.io/toolkit/bpmn-js/walkthrough/
|
||||
Related starters:
|
||||
* https://raw.githubusercontent.com/bpmn-io/bpmn-js-examples/starter/modeler.html
|
||||
-->
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue