1 {% extends
"descriptor/descriptor_view_base.html" %}
6 {% block title_header_big %}
8 Edit {{ descriptor_type|upper }} Descriptor
12 {% block left_sidebar %}
13 {% include 'osm/osm_project_left_sidebar.html' %}
16 {% block breadcrumb_body %}
18 <li><a href=
"{% url 'projects:open_project' %}">{{project_id}}
</a></li>
19 <li><a href=
"{% url 'projects:list_descriptors' descriptor_type=descriptor_type %}">{{ descriptor_type }} Descriptors
</a></li>
20 <li><a>{{descriptor_id}}
</a></li>
23 {% block tab_pane_button_list %}
25 <li class=
"active" id=
"yaml_li"><a href=
"#yaml" data-toggle=
"tab"><i class=
"fa fa-file-code-o"></i> YAML
</a></li>
26 <li id=
"json_li"><a href=
"#json" data-toggle=
"tab"><i class=
"fa fa-file-code-o"></i> JSON
</a></li>
29 {% block nav_buttons_list %}
31 <li class=
"pull-right"><button id=
"save" type=
"button" class=
"btn btn-block btn-primary btn-sm" onclick=
"update(this.id)" ><i class=
"fa fa-save"></i> Update
</button></li>
32 <li class=
"pull-right"><button id=
"save_show_graph" type=
"button" class=
"btn btn-block btn-primary btn-sm" onclick=
"update(this.id)" disabled
><i class=
"fa fa-save"></i> Update and Show Graph
</button></li>
33 <li class=
"pull-right"><button type=
"button" class=
"btn btn-block btn-primary btn-sm" onclick=
"goToGraph()" disabled
><i class=
"fa fa-sitemap"></i> Show Graph
</button></li>
37 {% block tab_pane_list %}
41 <div class=
"active tab-pane" id=
"yaml">
42 <textarea id=
"code_editor_yaml">
47 <div class=
"tab-pane" id=
"json">
48 <textarea id=
"code_editor_json">
54 {% block resource_block %}
62 $(document).ready(function () {
63 //var cmjsoneditor = CodeMirror.fromTextArea(document.getElementById(
"code_editor"), json_editor_settings);
64 var myJsonTextArea = document.getElementById(
"code_editor_json");
65 editorJSON = CodeMirror(function (elt) {
66 myJsonTextArea.parentNode.replaceChild(elt, myJsonTextArea);
67 }, json_editor_settings);
68 editorJSON.setValue(JSON.stringify({{descriptor_strings.descriptor_string_json | safe}}, null,
"\t"));
69 editorJSON.setOption(
"autoRefresh", true);
70 editorJSON.setSize(
"auto",
"auto");
72 var myYamlTextArea = document.getElementById(
"code_editor_yaml");
73 editorYaml = CodeMirror(function (elt) {
74 myYamlTextArea.parentNode.replaceChild(elt, myYamlTextArea);
75 }, yaml_editor_settings);
76 var des_strings = {{descriptor_strings | safe}};
77 editorYaml.setValue(des_strings.descriptor_string_yaml);
78 editorYaml.setSize(
"auto",
"auto");
83 var dialog = bootbox.dialog({
84 message: '
<div class=
"text-center"><i class=
"fa fa-spin fa-spinner"></i> Loading...
</div>',
88 var id = $('.nav-tabs .active').attr('id');
93 text = editorYaml.getValue();
97 text = editorJSON.getValue();
101 url:
"/projects/descriptors/{{descriptor_type}}/{{descriptor_id}}/",
105 'csrfmiddlewaretoken': '{{csrf_token}}',
109 success: function (result) {
110 dialog.modal('hide');
111 $(
"#success-alert").fadeTo(
2000,
500).slideDown(
500, function(){
112 setTimeout(function () {
113 $(
"#success-alert").slideUp(
500);
118 error: function (result) {
120 dialog.modal('hide');
121 bootbox.alert(result);
131 {% include
"footer.html" %}