2 Copyright 2019 EveryUP srl
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
17 {% extends
"base.html" %}
19 {% load staticfiles %}
22 {% block head_block %}
24 <link rel=
"stylesheet" href=
"/static/node_modules/codemirror/lib/codemirror.css">
25 <link rel=
"stylesheet" href=
"/static/node_modules/codemirror/addon/fold/foldgutter.css" />
26 <link rel=
"stylesheet" href=
"/static/node_modules/codemirror/theme/neat.css">
27 <link rel=
"stylesheet" href=
"/static/node_modules/codemirror/addon/dialog/dialog.css">
28 <link rel=
"stylesheet" href=
"/static/node_modules/codemirror/addon/display/fullscreen.css">
30 {% block title_header_big %}
32 Network Slices Templates
34 {% block left_sidebar %}
36 {% include 'osm/osm_project_left_sidebar.html' %}
41 {% block breadcrumb_body %}
43 <li><a href=
"{% url "netslices:list_templates
" %}">NetSlice Templates
</a></li>
46 {% block content_body %}
51 <div class=
"col-md-12">
52 <div class=
"nav-tabs-custom" style=
"position: relative;">
53 <ul class=
"nav nav-tabs" >
54 <li class=
"active" id=
"yaml_li"><a href=
"#yaml" data-toggle=
"tab"><i class=
"fa fa-file-code-o"></i> YAML
</a></li>
55 <li class=
"pull-right"><button id=
"save" type=
"button" class=
"btn btn-block btn-primary btn-sm" onclick=
"update()" ><i class=
"fa fa-save"></i> Update
</button></li>
58 <div class=
"alert alert-success" id=
"success-alert" style=
"position: absolute; z-index: 100; top: 44px; left: 0; width: 100%;
60 background-color: rgba(0, 166, 90, 0.8) !important;
62 border-color: rgba(0, 141, 76, 0.4);" hidden
>
63 <button type=
"button" class=
"close" onclick=
"$('#success-alert').toggle()">x
</button>
64 <strong>Success!
</strong>
67 <div class=
"tab-content">
68 <div class=
"active tab-pane" id=
"yaml">
69 <textarea id=
"code_editor_yaml">
75 <!-- <div class="box">
76 <div class="box-header with-border">
77 <h3 class="box-title"></h3>
78 <div class="box-tools"></div>
80 <div class="box-body">
81 <textarea id="code_editor_yaml">
90 {% block resource_block %}
92 <script src=
"/static/node_modules/codemirror/lib/codemirror.js" ></script>
93 <script src=
"/static/node_modules/codemirror/addon/fold/foldcode.js" ></script>
94 <script src=
"/static/node_modules/codemirror/addon/fold/foldgutter.js" ></script>
95 <script src=
"/static/node_modules/codemirror/addon/fold/brace-fold.js" ></script>
96 <script src=
"/static/node_modules/codemirror/mode/javascript/javascript.js" ></script>
97 <script src=
"/static/node_modules/codemirror/mode/yaml/yaml.js" ></script>
98 <script src=
"/static/node_modules/codemirror/mode/markdown/markdown.js" ></script>
99 <script src=
"/static/node_modules/codemirror/addon/search/searchcursor.js" ></script>
100 <script src=
"/static/node_modules/codemirror/addon/search/search.js" ></script>
101 <script src=
"/static/node_modules/codemirror/addon/dialog/dialog.js" ></script>
102 <script src=
"/static/node_modules/codemirror/addon/display/autorefresh.js" ></script>
103 <script src=
"/static/node_modules/codemirror/addon/edit/matchbrackets.js" ></script>
104 <script src=
"/static/node_modules/codemirror/addon/edit/closebrackets.js" ></script>
105 <script src=
"/static/node_modules/codemirror/addon/display/fullscreen.js" ></script>
106 <script src=
"/static/node_modules/codemirror/keymap/sublime.js" ></script>
108 var csrf_token = '{{csrf_token}}';
111 var yaml_editor_settings = {
113 showCursorWhenSelecting: true,
119 gutters: [
"CodeMirror-linenumbers",
"CodeMirror-foldgutter"],
120 autoCloseBrackets: true,
123 "F11": function (cm) {
124 cm.setOption(
"fullScreen", !cm.getOption(
"fullScreen"));
126 "Esc": function (cm) {
127 if (cm.getOption(
"fullScreen")) cm.setOption(
"fullScreen", false);
129 "Ctrl-Q": function (cm) {
130 cm.foldCode(cm.getCursor());
138 var myYamlTextArea = document.getElementById(
"code_editor_yaml");
139 var editorYaml = CodeMirror(function (elt) {
140 myYamlTextArea.parentNode.replaceChild(elt, myYamlTextArea);
141 }, yaml_editor_settings);
143 var template = {{ template | safe}};
145 $(document).ready(function () {
147 editorYaml.setValue(template.data);
148 editorYaml.setSize(
"auto",
"auto");
153 var dialog = bootbox.dialog({
154 message: '
<div class=
"text-center"><i class=
"fa fa-spin fa-spinner"></i> Loading...
</div>',
159 text = editorYaml.getValue();
162 url: window.location.href,
166 'csrfmiddlewaretoken': '{{csrf_token}}',
169 success: function (result) {
171 dialog.modal('hide');
172 $(
"#success-alert").fadeTo(
2000,
500).slideDown(
500, function(){
173 setTimeout(function () {
174 $(
"#success-alert").slideUp(
500);
179 error: function (result) {
180 dialog.modal('hide');
181 var data = result.responseJSON;
182 var title =
"Error " + (data && data.code ? data.code : 'unknown');
183 var message = data && data.detail ? data.detail : 'No detail available.';