1 {% extends
"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 {% if user.is_admin %}
19 <li><a href=
"{% url 'projects:projects_list' %}">Projects
</a></li>
21 <li><a href=
"#">Projects
</a></li>
23 <li><a href=
"{% url 'projects:open_project' %}">{{project_name}}
</a></li>
24 <li><a>{{descriptor_id}}
</a></li>
27 {% block tab_pane_button_list %}
29 <li class=
"active" id=
"yaml_li"><a href=
"#yaml" data-toggle=
"tab"><i class=
"fa fa-file-code-o"></i> YAML
</a></li>
30 <li id=
"json_li"><a href=
"#json" data-toggle=
"tab"><i class=
"fa fa-file-code-o"></i> JSON
</a></li>
33 {% block nav_buttons_list %}
35 <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>
36 <li class=
"pull-right"><button id=
"save_show_graph" type=
"button" class=
"btn btn-block btn-primary btn-sm" onclick=
"update(this.id, 'true')"><i class=
"fa fa-save"></i> Update and Show Graph
</button></li>
37 <li class=
"pull-right"><button type=
"button" class=
"btn btn-block btn-primary btn-sm" onclick=
"goToGraph()"><i class=
"fa fa-sitemap"></i> Show Graph
</button></li>
41 {% block tab_pane_list %}
45 <div class=
"active tab-pane" id=
"yaml">
46 <textarea id=
"code_editor_yaml">
51 <div class=
"tab-pane" id=
"json">
52 <textarea id=
"code_editor_json">
58 {% block resource_block %}
66 $(document).ready(function () {
67 //var cmjsoneditor = CodeMirror.fromTextArea(document.getElementById(
"code_editor"), json_editor_settings);
68 var myJsonTextArea = document.getElementById(
"code_editor_json");
69 editorJSON = CodeMirror(function (elt) {
70 myJsonTextArea.parentNode.replaceChild(elt, myJsonTextArea);
71 }, json_editor_settings);
72 editorJSON.setValue(JSON.stringify({{descriptor_strings.descriptor_string_json | safe}}, null,
"\t"));
73 editorJSON.setOption(
"autoRefresh", true);
74 editorJSON.setSize(
"auto",
"auto");
76 var myYamlTextArea = document.getElementById(
"code_editor_yaml");
77 editorYaml = CodeMirror(function (elt) {
78 myYamlTextArea.parentNode.replaceChild(elt, myYamlTextArea);
79 }, yaml_editor_settings);
80 var des_strings = {{descriptor_strings | safe}};
81 editorYaml.setValue(des_strings.descriptor_string_yaml);
82 editorYaml.setSize(
"auto",
"auto");
86 function update(e, show_graph) {
87 var dialog = bootbox.dialog({
88 message: '
<div class=
"text-center"><i class=
"fa fa-spin fa-spinner"></i> Loading...
</div>',
92 var id = $('.nav-tabs .active').attr('id');
97 text = editorYaml.getValue();
101 text = editorJSON.getValue();
105 url:
"/projects/descriptors/{{descriptor_type}}/{{descriptor_id}}/",
109 'csrfmiddlewaretoken': '{{csrf_token}}',
113 success: function (result) {
117 dialog.modal('hide');
118 $(
"#success-alert").fadeTo(
2000,
500).slideDown(
500, function(){
119 setTimeout(function () {
120 $(
"#success-alert").slideUp(
500);
125 error: function (result) {
126 dialog.modal('hide');
127 var data = result.responseJSON;
128 var title =
"Error " + (data && data.code ? data.code : 'unknown');
129 var message = data && data.detail ? data.detail : 'No detail available.';
143 {% include
"footer.html" %}