k8sClusters; k8sRepos
[osm/LW-UI.git] / k8srepohandler / template / k8srepo_list.html
1 <!--
2 Copyright 2019 EveryUP srl
3
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
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
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.
15 -->
16
17 {% extends "base.html" %}
18 {% load get %}
19 {% load staticfiles %}
20
21
22 {% block head_block %}
23 {{ block.super }}
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/css/lwuitable.css">
31 <link rel="stylesheet" href="/static/node_modules/datatables.net-bs/css/dataTables.bootstrap.min.css">
32
33 {% endblock %}
34 {% block title_header_big %}
35 {{ block.super }}
36 {% endblock %}
37 {% block left_sidebar %}
38 {% include 'osm/osm_project_left_sidebar.html' %}
39 {% endblock %}
40
41
42 {% block breadcrumb_body %}
43 {{ block.super }}
44 <li><a href="{% url 'k8sr:list' %}">K8s repository</a></li>
45 {% endblock %}
46
47 {% block content_body %}
48 {{ block.super }}
49 {% include 'modal/k8srepo_details.html' %}
50 {% include 'modal/k8srepo_register.html' %}
51 {% csrf_token %}
52 <div class="row">
53 <div class="col-md-12">
54
55 <div class="box">
56 <div class="box-header with-border">
57 <h3 class="box-title">Registered K8s repository</h3>
58 <div class="box-tools">
59 <button type="button" class="btn btn-default" data-container="body"
60 data-toggle="tooltip" data-placement="top" title="New K8s Repository"
61 onclick="javascript:openModalRegisterK8sr({ 'project_id':'{{ project_id }}'})">
62 <i class="fa fa-plus"></i> <span> Add K8s Repository</span>
63 </button>
64 </div>
65 </div>
66 <div class="box-body">
67 <table id="k8sr_table" class="table table-bordered table-striped">
68 <thead>
69 <tr>
70 <th>Name</th>
71 <th>Identifier</th>
72 <th>Url</th>
73 <th>Type</th>
74 <th>Created</th>
75 <th>Modified</th>
76 <th>Actions</th>
77
78 </tr>
79 </thead>
80 <tbody>
81
82 </tbody>
83 </table>
84 </div>
85 </div>
86 </div>
87
88 </div>
89 {% endblock %}
90
91 {% block resource_block %}
92 {{ block.super }}
93 <script src="/static/node_modules/select2/dist/js/select2.js"></script>
94 <script src="/static/node_modules/codemirror/lib/codemirror.js"></script>
95 <script src="/static/node_modules/codemirror/addon/fold/foldcode.js"></script>
96 <script src="/static/node_modules/codemirror/addon/fold/foldgutter.js"></script>
97 <script src="/static/node_modules/codemirror/addon/fold/brace-fold.js"></script>
98 <script src="/static/node_modules/codemirror/mode/javascript/javascript.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>
107 <script src="/static/node_modules/moment/moment.js"></script>
108 <script src="/static/node_modules/datatables.net/js/jquery.dataTables.min.js"></script>
109 <script src="/static/node_modules/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
110 <script src="/static/src/k8srepohandler/k8srepos_list.js"></script>
111
112 <script>
113 var table;
114 $(document).ready( function () {
115 table = $('#k8sr_table').DataTable({
116 responsive: true,
117 "ajax": {
118 "url": "/k8srepo/list",
119 "dataSrc": function (json) {
120 return json['k8sr'];
121 },
122 statusCode: {
123 401: function () {
124 console.log("no auth");
125 moveToLogin(window.location.pathname);
126 }
127 },
128 "error": function (hxr, error, thrown) {
129 console.log(hxr)
130 console.log(thrown)
131 console.log(error);
132 }
133
134 },
135 "columns": [
136 {
137 "render": function (data, type, row) {
138 return row["name"];
139 },
140 "targets": 0
141 },
142 {
143 "render": function (data, type, row) {
144 return row['_id'];
145 },
146 "targets": 1
147 },
148 {
149 "render": function (data, type, row) {
150 return row["url"];
151 },
152 "targets": 2
153 },
154 {
155 "render": function (data, type, row) {
156 return row["type"];
157 },
158 "targets": 3
159 },
160 {
161 "render": function (data, type, row) {
162 return moment.unix(row['_admin']['created']).format('YYYY-MM-DD hh:mm:ss a');
163 },
164 "targets": 4
165 },
166 {
167 "render": function (data, type, row) {
168 return moment.unix(row['_admin']['modified']).format('YYYY-MM-DD hh:mm:ss a');
169 },
170 "targets": 5
171 },
172 {
173 "render": function (data, type, row) {
174 return '<div class="btn-group">' +
175 '<button type="button" class="btn btn-default" ' +
176 'onclick="javascript:showK8sr( \''+row['_id'] + '\', \''+row['name'] +'\')" data-toggle="tooltip" data-placement="top" data-container="body" title="Show Info"><i class="fa fa-info"></i>' +
177 '</button>' +
178 '<button type="button" class="btn btn-default"' +
179 'onclick="javascript:deleteK8sc(\''+row['_id']+'\', \''+ row["name"] +'\')" data-toggle="tooltip" data-placement="top" data-container="body" title="Delete">' +
180 '<i class="far fa-trash-alt" ></i></button></div>';
181 },
182 "targets": 6,
183 "orderable": false
184 }
185 ]
186 });
187
188 setInterval(function () {
189 table.ajax.reload();
190 }, 10000);
191 });
192
193 </script>
194 {% endblock %}
195
196 {% block footer %}
197 {% include "footer.html" %}
198 {% endblock %}