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">
29 <link rel=
"stylesheet" href=
"/static/node_modules/select2/dist/css/select2.min.css">
30 <link rel=
"stylesheet" href=
"/static/node_modules/datatables.net-bs/css/dataTables.bootstrap.min.css">
32 {% block title_header_big %}
34 Network Slices Templates
36 {% block left_sidebar %}
38 {% include 'osm/osm_project_left_sidebar.html' %}
43 {% block breadcrumb_body %}
45 <li><a href=
"{% url "netslices:list_templates
" %}">NetSlice Templates
</a></li>
48 {% block content_body %}
50 {% include 'modal/nst_details.html' %}
51 {% include 'modal/instance_create_nsi.html' %}
54 <div class=
"col-md-12">
57 <div class=
"box-header with-border">
58 <h3 class=
"box-title"></h3>
59 <div class=
"box-tools"></div>
61 <div class=
"box-body">
62 <table id=
"templates_table" class=
"table table-bordered table-striped dataTable" role=
"grid">
81 <div class=
"col-sm-12">
82 <div class=
"box box-solid">
83 <div class=
"box-body">
85 <div class=
"upload-drop-zone" id=
"drop-zone">
86 <i class=
"fa fa-upload"></i> Just drag and drop files here
95 {% block resource_block %}
97 <script src=
"/static/node_modules/select2/dist/js/select2.js"></script>
98 <script src=
"/static/node_modules/codemirror/lib/codemirror.js"></script>
99 <script src=
"/static/node_modules/codemirror/addon/fold/foldcode.js"></script>
100 <script src=
"/static/node_modules/codemirror/addon/fold/foldgutter.js"></script>
101 <script src=
"/static/node_modules/codemirror/addon/fold/brace-fold.js"></script>
102 <script src=
"/static/node_modules/codemirror/mode/javascript/javascript.js"></script>
103 <script src=
"/static/node_modules/codemirror/addon/search/searchcursor.js"></script>
104 <script src=
"/static/node_modules/codemirror/addon/search/search.js"></script>
105 <script src=
"/static/node_modules/codemirror/addon/dialog/dialog.js"></script>
106 <script src=
"/static/node_modules/codemirror/addon/display/autorefresh.js"></script>
107 <script src=
"/static/node_modules/codemirror/addon/edit/matchbrackets.js"></script>
108 <script src=
"/static/node_modules/codemirror/addon/edit/closebrackets.js"></script>
109 <script src=
"/static/node_modules/codemirror/addon/display/fullscreen.js"></script>
110 <script src=
"/static/node_modules/codemirror/keymap/sublime.js"></script>
111 <script src=
"/static/node_modules/datatables.net/js/jquery.dataTables.min.js"></script>
112 <script src=
"/static/node_modules/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
113 <script src=
"/static/src/drop_zone.js"></script>
114 <script src=
"/static/src/netslicehandler/onboard_template.js"></script>
115 <script src=
"/static/src/netslicehandler/templates_list.js"></script>
116 <script src=
"/static/src/instancehandler/instance_create.js"></script>
118 var csrf_token = '{{csrf_token}}';
125 $(document).ready(function () {
126 table = $('#templates_table').DataTable({
129 "url":
"netslices/templates/list",
130 "dataSrc": function (json) {
131 return json['templates'];
135 console.log(
"no auth");
136 moveToLogin(window.location.pathname);
139 "error": function (hxr, error, thrown) {
148 "render": function (data, type, row) {
149 return row['name'] || '';
154 "render": function (data, type, row) {
160 "render": function (data, type, row) {
161 return row['_admin']['usageState'];
166 "render": function (data, type, row) {
167 return '
<div class=
"btn-group">' +
168 '
<button type=
"button" class=
"btn btn-default" data-container=
"body"\n' +
169 '
data-toggle=
"tooltip" data-placement=
"top" title=
"Instantiate NS"\n' +
170 '
onclick=
"javascript:openModalCreateNSI({\'template_name\':\''+row["name
"]+'\', \'template_id\':\''+row["_id
"]+'\', \'project_id\':\'{{ project_id }}\',\'vim_list_url\': \'{% url "vims:list
" %}\', \'nst_list_url\': \'{% url "netslices:list_templates
" %}\'})">\n' +
171 '
<i class=
"fa fa-paper-plane"></i></button>\n'+
172 '
<button type=
"button" class=
"btn btn-default"' +
173 '
onclick=
"javascript:showNstDetails(\'' + row["_id
"] + '\')"' +
174 '
data-toggle=
"tooltip" data-placement=
"top" data-container=
"body" title=
"Open">' +
175 '
<i class=
"fa fa-info"></i>' +
177 '
<button type=
"button" class=
"btn btn-default"' +
178 '
onclick=
"window.location.href=\'/netslices/templates/'+row["_id
"]+'/edit\'"' +
179 '
data-toggle=
"tooltip" data-placement=
"top" data-container=
"body" title=
"Edit">' +
180 '
<i class=
"fa fa-edit"></i>' +
182 '
<button type=
"button" class=
"btn btn-default"' +
183 '
onclick=
"javascript:deleteTemplate(\'' + row["name
"] + '\', \'' + row["_id
"] + '\')"' +
184 '
data-toggle=
"tooltip" data-placement=
"top" data-container=
"body" title=
"Delete"><i' +
185 '
class=
"far fa-trash-alt"></i></button>' +
194 setInterval(function () {
198 var json_editor_settings = {
200 showCursorWhenSelecting: true,
205 gutters: [
"CodeMirror-linenumbers",
"CodeMirror-foldgutter"],
206 autoCloseBrackets: true,
209 "F11": function (cm) {
210 cm.setOption(
"fullScreen", !cm.getOption(
"fullScreen"));
212 "Esc": function (cm) {
213 if (cm.getOption(
"fullScreen")) cm.setOption(
"fullScreen", false);
215 "Ctrl-Q": function (cm) {
216 cm.foldCode(cm.getCursor());
222 var myJsonTextArea = document.getElementById(
"nst_view_json");
223 editorJSON = CodeMirror(function (elt) {
224 myJsonTextArea.parentNode.replaceChild(elt, myJsonTextArea);
225 }, json_editor_settings);
228 function refreshTable() {