tum 2 gadi atpakaļ
vecāks
revīzija
de7866bddb

BIN
app/Output/excel_out_test_excel_formatter_update.xlsx


+ 1 - 1
app/backend/templates/backend/index.html

@@ -4,7 +4,7 @@
4 4
 <h2>APIs</h2>
5 5
       <div class='row row-cols-md-5 row-cols-2'>
6 6
       {% for r in output.results %}
7
-        <div class='p-3 border text-center'>{{ r.display_name }}</div>
7
+      <div class='p-3 border text-center'><a href="/backend/service_status?cmd={{r.URI}}/v1&section=index">{{ r.display_name }}</a></div>
8 8
       {% endfor %}
9 9
       </div>
10 10
       <pre>

+ 11 - 2
app/backend/templates/backend/remote_render.html

@@ -2,12 +2,21 @@
2 2
 {% load backend_tags %}
3 3
 {% block content %}
4 4
 {% with output=res.json %}
5
-<h2>Services</h2>
5
+<h2>{{ output.result.ids.sla_name }}  Services</h2>
6 6
 <ul>
7 7
   {% for si in  output.result.service_instances %}
8
-  <li>{{ si.service_name }} <a href="" class='text-decoration-none badge bg-primary'>status</a></li>
8
+  <li>{{ si.service_name }} 
9
+    <a href="{% url "backend:service_status" %}?cmd={{ si.service_status_uri }}&section=status" class='text-decoration-none badge bg-primary'>status</a>
10
+    <a href="{% url "backend:service_status" %}?cmd={{ si.service_uri }}&section=detail" class='text-decoration-none badge bg-primary'>detail</a>
11
+  </li>
9 12
   {% endfor %}
10 13
 </ul>
14
+<h2>Verifiers</h2>
15
+<ul>
16
+{% for v in output.result.verifiers %}
17
+<li><a href="{% url "backend:service_status" %}?cmd={{ v.verifier_uri }}" class="text-decoration">{{ v.verifier_name }}</a></li>
18
+{% endfor %}
19
+</ul>
11 20
 {% endwith %}
12 21
   <p>
13 22
     <a class="btn btn-primary" data-bs-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">

+ 124 - 0
app/backend/templates/backend/service_status.html

@@ -0,0 +1,124 @@
1
+{% extends "base.html" %}
2
+{% load backend_tags %}
3
+{% load humanize %}
4
+{% block content %}
5
+{% with output=res.json %}
6
+<h1>{{ section }}</h1>
7
+
8
+{% if section == 'index' %}
9
+<ul>
10
+  {% for r in output.result.resources %}
11
+  <li><a href="{% url "backend:service_status" %}?cmd={{ r.URI }}&section={{ r.name }}">{{ r.display_name }}</li>
12
+  {% endfor %}
13
+</ul>
14
+{% endif %}
15
+{% if section == 'test_status' %}
16
+  {% for r in output.result %}
17
+    {% if forloop.first %}
18
+    <h2>{{ r.sla_name }} / {{ r.service_name }}</h2>
19
+    {% endif %}
20
+    {% if forloop.first %}
21
+    <table class='table table-striped table-bordered'>
22
+
23
+    <thead>
24
+      <tr>
25
+      <th>Timestamp</th>
26
+      {% for r0 in r.results_scores %}
27
+      <th class='text-end'>{{ r0.name }} / Score</th>
28
+      {% endfor %}
29
+      </tr>
30
+    </thead>
31
+    {% endif %}
32
+      <tr>
33
+        <td>{{ r.time_stamp_display }}</td>
34
+        {% for r0 in r.results_scores %}
35
+        <td class='text-end'>{{ r0.raw_value|intcomma }} / {{ r0.score }}</td>
36
+        {% endfor %}
37
+      </tr>
38
+    {% if forloop.last %}
39
+    </table>
40
+    {% endif %}
41
+  {% endfor %}
42
+{% endif %}
43
+{% if section == 'ConfigCur' %}
44
+<ul>
45
+  {% for r in output.result %}
46
+  <li><a class='text-decoration-none' href="{% url "backend:service_status" %}?cmd={{ r.ids.test_instance_uri }}&section=test_instance">{{ r.ids.test_display_name }} / {{ r.ids.test_type_name }}</a> <a href="{% url "backend:service_status" %}?cmd=/API/REST/Status/v1/TestStatus/{{ r.ids.test_instance_id }}&section=test_status" class='ms-3 text-decoration-none badge bg-primary'>Status</a></li>
47
+  {% endfor %}
48
+</ul>
49
+{% endif %}
50
+{% if section == 'test_type' %}
51
+    {% with ids=output.result.ids %}
52
+      {{ ids.test_display_name }}
53
+      {{ ids.test_type_name }}
54
+      <a href="{% url "backend:service_status" %}?cmd={{ ids.mdf_uri }}&section=mdf" class='text-decoration-none badge bg-primary'>MDF URI</a>
55
+      <a href="{% url "backend:service_status" %}?cmd={{ ids.test_type_uri }}&section=test_type" class='text-decoration-none badge bg-primary'>Test Type</a>
56
+    {% endwith %}
57
+{% endif %}
58
+{% if section == 'test_define' %}
59
+{% endif %}
60
+{% if section == "detail" %}
61
+<h1>{{ output.result.ids.service_name }}</h1>
62
+<a href="{% url "backend:service_status" %}?cmd={{ output.result.ids.overall_service_status_uri }}&section=overall">Overall</a>
63
+<table class='table table-bordered table-striped'>
64
+  <thead>
65
+    <tr><th>Status</th><th>Result</th></tr>
66
+  </thead>
67
+  <tbody>
68
+  {% for k,v in output.result.service_status.items %}
69
+  <tr>
70
+  <td>{{ k }}</td><td>{{ v }}</td>
71
+  </tr>
72
+  {% endfor %}
73
+  </tbody>
74
+</table>
75
+
76
+<h3>Test Templates</h3>
77
+<ul>
78
+  {% for si in  output.result.test_templates %}
79
+  <li>{{ si.test_name }} 
80
+    <a href="{% url "backend:service_status" %}?cmd={{ si.test_defn_uri }}&section=test_define" class='text-decoration-none badge bg-primary'>Test Define</a>
81
+    <a href="{% url "backend:service_status" %}?cmd={{ si.test_type_uri }}&section=test_type" class='text-decoration-none badge bg-primary'>Test Type</a>
82
+  </li>
83
+  {% endfor %}
84
+</ul>
85
+{% endif %}
86
+{% if section == "overall" %}
87
+<h1>Overall</h1>
88
+<div class='table-responsive'>
89
+<table class='table table-striped table-bordered'>
90
+  <thead>
91
+    <tr>
92
+  {% for k in output.result.0.keys %}
93
+  <th>{{ k }}</th>
94
+  {% endfor %}
95
+    </tr>
96
+  </thead>
97
+  <tbody>
98
+  {% for o in output.result %}
99
+    <tr>
100
+      {% for k1,v1 in o.items %}
101
+      <td>{{ v1 }}</td>
102
+      {% endfor %}
103
+    </tr>
104
+  {% endfor %}
105
+  </tbody>
106
+</table>
107
+</div>
108
+{% endif %}
109
+{% endwith %}
110
+  <p>
111
+    <a class="btn btn-primary" data-bs-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
112
+      Raw JSON
113
+    </a>
114
+  </p>
115
+  <div class="collapse" id="collapseExample">
116
+    <div class="card card-body">
117
+      <pre>
118
+        {{ res.json | pprint }}
119
+      </pre>
120
+    </div>
121
+  </div>
122
+
123
+
124
+{% endblock %}

+ 1 - 0
app/backend/urls.py

@@ -7,4 +7,5 @@ app_name = 'backend'
7 7
 urlpatterns = [
8 8
     path('', views.index, name='index'),
9 9
     path('remote/', views.remote, name='remote'),
10
+    path('service_status/', views.service_status, name='service_status'),
10 11
 ]

+ 10 - 0
app/backend/views.py

@@ -109,4 +109,14 @@ def remote(request):
109 109
     pprint(r.json())
110 110
     # return JsonResponse(r.json())
111 111
     return render(request, 'backend/remote_render.html', {'res': r})
112
+
113
+def service_status(request):
114
+    cmd = request.GET.get('cmd', None)
115
+    section = request.GET.get('section', 'all')
116
+    # exfo = Exfo("administrator", "exf0w0rxC@t4dm!n")
117
+    # exfo.login()
118
+    r = exfo.call_remote_api(cmd+"?sections=all&size=0")
119
+    pprint(r.json())
120
+    # return JsonResponse(r.json())
121
+    return render(request, 'backend/service_status.html', {'res': r, 'section': section})
112 122